# Voltecx: full text # Voltecx — power electronics simulation that designs, checks and automates URL: https://voltecx-web.nguyenvanqui291.workers.dev/ ## Design from a spec. Check every number. Automate every step. Voltecx is a power-electronics simulator for converters, inverters and motor drives. Write a specification and it draws a topology, sizes the parts and the magnetics, closes the loop, checks every corner by simulation and writes a report. Every result says where it came from, and every action is a command that your scripts and AI agents can run. [Download the beta](https://voltecx-web.nguyenvanqui291.workers.dev/download) · [See the features](https://voltecx-web.nguyenvanqui291.workers.dev/features) > **Beta.** Voltecx 0.9.0 is in beta. The macOS build comes first; Linux packages are built and their command-line tool has been tried; Windows packages are still being tested. Prices are not set yet. ## Three things Voltecx does differently ### Design from a spec Give Voltecx the input range, the output, the load and the limits you care about: ripple, load step, start-up, efficiency, junction temperature, phase margin. `design.auto` picks a topology, draws it, sizes the inductor, capacitors and magnetics, closes the voltage loop, runs every corner of the spec, chooses real parts from cited data sheets, estimates conducted EMI and writes the report, the bill of materials, firmware and a KiCad schematic. When a design does not pass, the report names the stage that stopped it and what to try next. [How automatic design works](https://voltecx-web.nguyenvanqui291.workers.dev/features/auto-design) ### Check every number Two solvers check each other: a fast one for everyday work and a deliberately simple reference solver. Both are compared with closed-form answers and with waveforms from ngspice, and the accuracy report lists every comparison with its tolerance. On 2026-10-17 all 22 comparisons were within tolerance. Vendor device data carries its data sheet, revision and figure. Each design report lists what it did not check. [How results are checked](https://voltecx-web.nguyenvanqui291.workers.dev/features/simulation) ### Automate every step Every action in Voltecx is a named command. The window, the command line, Python, a JSON server and the built-in assistant all call the same commands, so anything you can click, you can script. The assistant inside the app proposes changes as ghosts on the schematic. Nothing changes until you accept. [Scripting and automation](https://voltecx-web.nguyenvanqui291.workers.dev/features/automation) · [The AI assistant](https://voltecx-web.nguyenvanqui291.workers.dev/features/ai-assistant) ## The design flow, step by step A requirements interview fills in the spec, a feasibility check says whether it can be met, and a comparison table shows why one topology and control method beat the others. Automatic design then sizes and verifies the converter, the Test Bench runs each test case against its limits, the EMI estimate sizes the input filter, and the report, bill of materials and KiCad project go to layout. Some of these steps arrive in the next release; the page says which. [See the design tools](https://voltecx-web.nguyenvanqui291.workers.dev/features/design-tools) ## Bring the files you already have Voltecx supports many formats: SPICE netlists, LTspice `.asc` files and files from other simulators. It writes your edits back into the same file. Only the lines you touched change. Of 332 public LTspice files and 122 public files in another supported format, every one came back byte for byte when nothing was edited. SPICE netlists go both ways, and some imported formats open read-only. [File compatibility](https://voltecx-web.nguyenvanqui291.workers.dev/features/file-compatibility) · [Moving from LTspice](https://voltecx-web.nguyenvanqui291.workers.dev/guides/migrate-from-ltspice) ## What you can build today - **DC-DC:** buck, synchronous buck, boost, closed-loop flyback with TL431 feedback, battery charger, SiC double-pulse test. - **Isolated and resonant:** LLC half bridge, phase-shifted full bridge, dual active bridge. - **AC:** PFC boost and interleaved PFC, Vienna rectifier, active front end, grid-tie inverter with PLL, three-level NPC inverter, modular multilevel converter leg. - **Drives:** induction motor V/f, field-oriented and direct torque control, PMSM FOC with a sensorless observer, BLDC six-step, DC motor. - **Energy:** solar MPPT charger, wind turbines with doubly fed and permanent-magnet generators, fuel cell, batteries, supercapacitors. These are among the 55 built-in examples, each with a known answer. Open one, press F5 and change it. Automatic design also draws SEPIC, buck-boost, four-switch buck-boost and multiphase buck stages. ## Who it is for - [Power supply design](https://voltecx-web.nguyenvanqui291.workers.dev/use-cases/power-supply) - [EV chargers and on-board chargers](https://voltecx-web.nguyenvanqui291.workers.dev/use-cases/ev-charger) - [Solar and energy storage](https://voltecx-web.nguyenvanqui291.workers.dev/use-cases/solar-storage) - [Motor drives](https://voltecx-web.nguyenvanqui291.workers.dev/use-cases/motor-drive) - [Server power and 48 V racks](https://voltecx-web.nguyenvanqui291.workers.dev/use-cases/server-power) - [Teaching and research](https://voltecx-web.nguyenvanqui291.workers.dev/use-cases/education-research) ## Honest about what is not done Voltecx has not been compared with the waveforms of other simulators, and its speed has not been measured side by side with any commercial tool. EMI, layout and price figures are estimates, and no result has been checked against a built board yet. The [FAQ](https://voltecx-web.nguyenvanqui291.workers.dev/faq) lists the open items. [Download the beta](https://voltecx-web.nguyenvanqui291.workers.dev/download) · [Talk to us](https://voltecx-web.nguyenvanqui291.workers.dev/about) --- # Features URL: https://voltecx-web.nguyenvanqui291.workers.dev/features/ ## Models Switches, diodes, MOSFETs and IGBTs with loss tables, SiC and GaN gate dynamics, thyristors, saturating magnetics, control blocks and digital control, thermal networks, induction, synchronous, PM and DC machines with mechanical loads, batteries, solar modules, supercapacitors, fuel cells, wind turbines, the three-phase grid, EMI parts, behavioural ICs (TL431, optocouplers and high-speed logic optocouplers, digital isolators, fiber-optic transmitters and receivers with a link-budget check, photovoltaic MOSFET drivers, current sensors) whose isolation barrier checks its common-mode transient immunity against the simulated dv/dt, constant-power loads with load profiles, and your own blocks as sandboxed WebAssembly. --- # Pricing URL: https://voltecx-web.nguyenvanqui291.workers.dev/pricing/ --- # Download URL: https://voltecx-web.nguyenvanqui291.workers.dev/download/ Pick the package for your computer. Each one lists its SHA-256 checksum, so you can check the download before you open it. On a Mac, open the .dmg and drag Voltecx onto Applications. --- # Contact URL: https://voltecx-web.nguyenvanqui291.workers.dev/contact/ Tell us what you are working on. We answer by email. --- # Frequently asked questions URL: https://voltecx-web.nguyenvanqui291.workers.dev/faq/ Answers are being written. --- # Use cases URL: https://voltecx-web.nguyenvanqui291.workers.dev/use-cases/ Stories of real design work are on the way. --- # Migration guides URL: https://voltecx-web.nguyenvanqui291.workers.dev/guides/ Voltecx supports many formats: SPICE netlists, LTspice .asc files and files from other simulators. The import chapter of the manual lists what each importer covers. --- # Power electronics course URL: https://voltecx-web.nguyenvanqui291.workers.dev/course/ A course in power electronics that follows the order most universities teach it, from the diode rectifier to grid-tied inverters. Each lesson gives you: - **A circuit** that ships with Voltecx, so nothing has to be built before the first run. - **A guided lesson in the app** (click **Guided Lessons** in the activity bar). It tells you what to change and what to predict, and checks every exercise against your own run: you go on when the number is right. - **This page**, with the theory in short, the figures from the circuit, the exercises and their answers. - **A lab handout** with a table to fill in and questions for the report. Every number on these pages comes from a run of the lesson's circuit, and an automated test repeats those runs, so the pages always match the program. ## The path | # | Lesson | Level | |---|---|---| | 1 | [Diodes and rectifiers](https://voltecx-web.nguyenvanqui291.workers.dev/course/diodes-and-rectifiers) | Undergraduate | | 2 | [The buck converter](https://voltecx-web.nguyenvanqui291.workers.dev/course/buck-converter) | Undergraduate | | 3 | [Boost and buck-boost](https://voltecx-web.nguyenvanqui291.workers.dev/course/boost-and-buck-boost) | Undergraduate | | 4 | [The flyback converter](https://voltecx-web.nguyenvanqui291.workers.dev/course/flyback-converter) | Undergraduate | | 5 | Averaged models and small-signal transfer functions (planned) | Undergraduate | | 6 | Loop design: crossover, phase margin and compensators (planned) | Undergraduate | | 7 | [The single-phase inverter and sine PWM](https://voltecx-web.nguyenvanqui291.workers.dev/course/single-phase-inverter) | Undergraduate | | 8 | Three-phase inverters and space-vector PWM (planned) | Undergraduate | | 9 | Magnetics: inductors and transformers (planned) | Undergraduate | | 10 | Losses and thermal design (planned) | Undergraduate | | 11 | Conducted EMI and input filters (planned) | Undergraduate | | 12 | Resonant and soft-switching converters (planned) | Graduate | | 13 | Power factor correction (planned) | Graduate | | 14 | Motor drives and field-oriented control (planned) | Graduate | | 15 | Grid-tied inverters (planned) | Graduate | | 16 | Digital control (planned) | Graduate | Teaching a class with it? Read [for instructors](https://voltecx-web.nguyenvanqui291.workers.dev/course/for-instructors): how students install, an assignment template, and how to grade saved circuits from the command line. --- # Worked examples URL: https://voltecx-web.nguyenvanqui291.workers.dev/worked-examples/ Each worked example opens a circuit that ships with Voltecx, works the hand calculation and compares it with a real run. Every number on these pages comes from a simulation that a test repeats. --- # Blog URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/ Posts will appear here. --- # Academic program URL: https://voltecx-web.nguyenvanqui291.workers.dev/academic/ Power electronics is learned by changing a circuit and seeing what happens. Voltecx is built for that: every example opens with its main signals on the scope, every number can be traced to an equation or a data sheet, and every step can be scripted for a lab exercise. > **Terms to be announced.** The Academic plan, who qualifies and how we check are not set yet. [Tell us about your course or lab](https://voltecx-web.nguyenvanqui291.workers.dev/contact) and we will write back when they are. ## For teaching - **55 built-in examples** with known answers, by category: basics, DC-DC, isolated, rectifiers, inverters, motor drives, grid, renewable energy and power quality. Each one says what it shows and what to try. - **A user manual in English and Traditional Chinese**, and a reference page for each of 137 parts, opened with F1. - **The free tier runs offline** with no account and no licence key, so students can install it on their own laptops. - **Two solvers.** Students can rerun a circuit on the deliberately simple reference solver and see that the answer holds. - **Circuit animation** shows current flow, node voltages and switch states on the schematic, step by step. - **Problems with fixes.** Errors name the component or node that caused them, with a fix to apply. ## For research - **Python and Jupyter:** run any command and get waveforms as NumPy arrays or pandas DataFrames. Sweeps and Monte Carlo runs are scripts you can rerun. - **Figures for papers and reports:** scope plots as SVG, schematic figures as SVG or LaTeX `circuitikz` (beta; compile your first figure and check it), design reports as HTML or PDF. - **Readable files:** Voltecx circuit files are plain JSON that keep numbers bit for bit, so a result can be reproduced from the file and a seed. - **Models with sources:** vendor devices cite their data-sheet revision and figure; the sizing and loop equations follow Erickson and Maksimović, *Fundamentals of Power Electronics*, 3rd edition. - **Your own blocks** as sandboxed WebAssembly, and a C99 export of control blocks for STM32G474 and TI F28379D boards. - **Bring your existing files:** SPICE netlists, LTspice files and files from other simulators open; LTspice files write back. ## What we will not promise Voltecx has not been compared with the waveforms of other simulators, and no result has been checked against a built board. If your lab measures a converter and wants to compare it with a simulation, we would like to hear about it: lab data is added only with the contributor's consent, with the bench, the probes and the date recorded next to it. ## Get in touch Write to [address published at launch](https://voltecx-web.nguyenvanqui291.workers.dev/contact) with your course or lab, the topics you teach and the number of seats you expect. We reply in English or Traditional Chinese. --- # About Voltecx URL: https://voltecx-web.nguyenvanqui291.workers.dev/about/ Voltecx is a power-electronics simulator made by Tecxmate, a software team in Taiwan. It is written from scratch in Rust, clean-room: from textbooks, papers, public data sheets and observed behaviour, never from anyone else's code, model libraries or example files. ## Why we built it Power-electronics engineers spend much of a design moving numbers between tools: a spreadsheet for sizing, a simulator for waveforms, a calculator for losses, a script for sweeps, a document for the review. We wanted one tool in which each of those steps is a command, so that an engineer, a script or an AI assistant can carry a design from a specification to a checked result, and every number can be traced back to where it came from. ## How we work - **Every result has a source.** Two solvers check each other. The accuracy report compares models with closed-form answers, data sheets and ngspice, and lists what is not validated yet. A value a data sheet does not give is left out, never guessed. - **Never crash.** A crash loses an engineer's work, so it comes before features. Every command is fuzzed with hostile input. - **Everything is a command.** The window, the command line, Python and AI assistants use the same commands, so nothing is reachable only by mouse. - **Say what is not done.** Our documentation keeps a list of what does not work yet, with dates. So does this site. ## Where it stands Voltecx 0.9.0 is in beta. The macOS build comes first; Linux and Windows packages are being tested. Plans and prices are not set yet. See the [FAQ](https://voltecx-web.nguyenvanqui291.workers.dev/faq) for the open items. ## Contact - Email: [address published at launch](https://voltecx-web.nguyenvanqui291.workers.dev/contact) - Sales and academic enquiries: [contact form](https://voltecx-web.nguyenvanqui291.workers.dev/contact) We answer in English or Traditional Chinese. ## Trademarks Voltecx and the Voltecx logo are trademarks of Tecxmate. LTspice is a trademark of Analog Devices, Inc. Other product names are trademarks of their owners. Voltecx is independent and not affiliated with, sponsored by or endorsed by them. --- # Use Voltecx with AI URL: https://voltecx-web.nguyenvanqui291.workers.dev/ai/ Every Voltecx action is a command, so an AI assistant can use the program the way you do: it builds the circuit, runs the simulation, reads the waveforms and tells you what it found. This page shows what to ask it and what it may touch. Outside AI tools cannot drive Voltecx. --- # Benchmarks URL: https://voltecx-web.nguyenvanqui291.workers.dev/benchmarks/ Every number on this page is read from the reports the build generates. --- # Voltecx design API for developers URL: https://voltecx-web.nguyenvanqui291.workers.dev/developers/ Voltecx's design engine also runs as a service on Voltecx Cloud, so your own tools can use it: a lab's test bench, a parts-selection script, a company design portal or an AI agent. The API runs the same engine and job queue as Auto Design in the desktop app. > **Not open yet.** The API is built and documented; it opens with Voltecx Cloud. [Tell us what you want to connect](https://voltecx-web.nguyenvanqui291.workers.dev/contact) and we will write back when it does. ## What it does | Step | What you get | |---|---| | Spec interview | The open questions of a partial spec, must ones first, and the design params once it is ready | | Feasibility | Physics and catalogue bounds on efficiency, ripple, thermal, size and cost, with the smallest change that makes each item reachable | | Auto Design | A converter designed from the spec end to end, as a circuit file that opens in Voltecx, with its report | | Compare | Topologies and control methods side by side, with the numbers behind the choice | | Validation | A circuit checked against the spec: line and load corners, start-up, transients, loop margins and Monte Carlo yield | | Reports | The design report (PDF or HTML) and the design summary folder | ## How it works - **Versioned HTTP endpoints** under `/v1/api/`, described by an OpenAPI 3.1 file. - **Organisation API keys.** An owner or admin makes keys on the account page; a key is shown once and Voltecx keeps only a hash of it. Revoke a key at any time. - **Quotas and usage.** Each key has a rate limit and each organisation a monthly number of design steps; the account page shows what was used. - **Example clients** in Python and in the `voltecx` npm package. - **Your designs stay yours.** Voltecx records that a call was made and how it ended, never the spec, the circuit or the result. The API needs a plan that includes Auto Design. The reference documentation and the OpenAPI file are published when the service opens. ## API terms The terms of use of the API are to be announced. Until they are published, the [Voltecx Terms](https://voltecx-web.nguyenvanqui291.workers.dev/terms) apply. --- # How we validate URL: https://voltecx-web.nguyenvanqui291.workers.dev/how-we-validate/ A simulator earns trust with evidence, not adjectives. This page says how we check Voltecx against results it did not produce, and what has actually been compared so far. Where nothing has been compared yet, we say so. ## Two reports - **The accuracy report** (`docs/accuracy.md`, `cargo xtask accuracy`) checks models one at a time: step responses against their closed form, converters against ngspice waveforms of the same netlist, switching energies against named data sheets. Its numbers are summarised on [Simulation you can check](https://voltecx-web.nguyenvanqui291.workers.dev/features/simulation). - **The validation report** (`docs/validation.md`, `cargo xtask validate`) checks whole circuits against reference results: another simulator's CSV export of the same circuit, a closed-form answer written out as a table, or a measurement from a lab bench. Each case lives in its own folder, `validation//`, with the circuit, the reference files and a `case.json` that names the signals, the time window and the tolerances. Both reports are generated by a program and committed with the code. A comparison outside its tolerance stays in the report; hiding it would make the report worthless. ## How a case is compared 1. Voltecx simulates the circuit. Each reference file is read with the same importer as **File › Import › Measurement**, so plain time/value tables and common oscilloscope exports load. 2. Both waveforms are put on one time grid over the window they share. 3. Three errors are measured, each against the limit the case sets: the RMS of the difference over the RMS of the reference, the difference of the peaks, and the phase of the fundamental. 4. For a lab measurement, the simulated waveform is first passed through a low-pass at the bandwidth of the probe and scope channel, because that chain cannot show anything faster. The chain's stated accuracy widens the limits, and the instrument, the probes and the date are recorded next to the result. Every reference must say which tool produced it, its version and the settings it was run with. A result without that provenance proves nothing. ## What has been compared so far As of October 2026, honestly: - **Closed form and ngspice.** Two small self-made RC circuits: a step response against its closed form and against ngspice-47, and a 1 kHz low-pass against its closed form, including the 45° phase lag. They prove the pipeline, not the models of power devices. - **Other simulators.** No export from another commercial simulator has been compared yet. Cases come only from circuits we or users drew themselves and the results exported from them; we never copy other tools' example files or models. - **Lab measurements.** None yet. The first data set will come from a prototype converter built by our team; its case exists as an empty template until the bench numbers are in. We will not fill it with simulated numbers. The current numbers are in `docs/validation.md`, regenerated with every change to the cases. ## Contributing your measurements After you compare a simulation with your own bench in **File › Import › Measurement**, **Share this validation with Voltecx** can send us the result. It is opt-in: nothing is sent until you tick the consent box, and the circuit goes only if you tick a second box. What is sent is the Voltecx version and solver, the kinds and counts of components, a fingerprint of the circuit, the topology, the operating point and instrument if you add them, and the summary errors per signal; never the waveforms, your name, account or network address. The dialog shows the exact payload first. We review each upload by hand. Accepted uploads are published only as per-model aggregates (for each version, solver and topology: the count and the median and 90th percentile of the RMS error), and only once a group has at least 3 uploads, so one bench's numbers never stand alone. The [privacy notice](https://voltecx-web.nguyenvanqui291.workers.dev/privacy) lists every field and how to withdraw an upload. ## Contribute a reference If you have a circuit you drew yourself and its results from another simulator or from your bench, we would like to compare against it. Send the circuit, the CSV export and the settings it was run with (for a measurement: the scope, the probes and the operating point) to [address published at launch](https://voltecx-web.nguyenvanqui291.workers.dev/contact). We publish a comparison only with your permission. --- # Power electronics design topics URL: https://voltecx-web.nguyenvanqui291.workers.dev/topics/ Each article answers one design question in its first paragraph, works an example with real numbers and the formula behind them, and ends with how to do the same in Voltecx. The formulas cite textbooks and standards by name; device values come from named data sheets. ## Sizing the power stage - [How to size a buck converter inductor](https://voltecx-web.nguyenvanqui291.workers.dev/blog/buck-inductor-sizing): ripple ratio, peak, RMS and saturation current. - [How to choose the output capacitor of a buck converter](https://voltecx-web.nguyenvanqui291.workers.dev/blog/buck-output-capacitor-selection): ripple, ESR, load step and DC-bias derating. - [How to choose the switching frequency of a DC-DC converter](https://voltecx-web.nguyenvanqui291.workers.dev/blog/choosing-switching-frequency): switching loss against magnetics size, minimum on-time and the EMI band. - [Boost converter design: duty cycle, inductor and the right-half-plane zero](https://voltecx-web.nguyenvanqui291.workers.dev/blog/boost-converter-design-rhp-zero) - [Flyback transformer design, step by step](https://voltecx-web.nguyenvanqui291.workers.dev/blog/flyback-transformer-design-steps) - [LLC resonant tank design](https://voltecx-web.nguyenvanqui291.workers.dev/blog/llc-resonant-tank-design) - [Dual active bridge: power, current and ZVS against phase shift](https://voltecx-web.nguyenvanqui291.workers.dev/blog/dual-active-bridge-phase-shift) - [Phase-shifted full bridge: where zero-voltage switching holds and where it is lost](https://voltecx-web.nguyenvanqui291.workers.dev/blog/psfb-zvs-range) ## Losses and heat - [Synchronous or diode buck: where the loss goes](https://voltecx-web.nguyenvanqui291.workers.dev/blog/synchronous-vs-diode-buck) - [MOSFET loss and junction temperature estimation](https://voltecx-web.nguyenvanqui291.workers.dev/blog/mosfet-loss-and-thermal-estimation) - [Heatsink selection: thermal resistance budget, interface pads and Zth](https://voltecx-web.nguyenvanqui291.workers.dev/blog/heatsink-selection-thermal-design) - [Dead-time effects in a half bridge](https://voltecx-web.nguyenvanqui291.workers.dev/blog/dead-time-effects) - [LDO post-regulator for an auxiliary 3.3 V rail: dropout, PSRR and heat](https://voltecx-web.nguyenvanqui291.workers.dev/blog/ldo-post-regulator-aux-rail) ## Switching, snubbers and clamps - [Double-pulse test: how to measure switching energy Eon and Eoff](https://voltecx-web.nguyenvanqui291.workers.dev/blog/double-pulse-test-switching-energy) - [RC snubber design: measure the ring, then size R and C](https://voltecx-web.nguyenvanqui291.workers.dev/blog/rc-snubber-design) - [Flyback RCD clamp design: clamp voltage, resistor and capacitor](https://voltecx-web.nguyenvanqui291.workers.dev/blog/flyback-rcd-clamp-design) ## Control loops - [Digital, analog or controller IC: choosing how to control a converter](https://voltecx-web.nguyenvanqui291.workers.dev/blog/digital-vs-analog-vs-controller-ic-control) - [Buck converter PI compensator design](https://voltecx-web.nguyenvanqui291.workers.dev/blog/buck-converter-pi-compensator-design) - [Measuring loop gain and phase margin in simulation](https://voltecx-web.nguyenvanqui291.workers.dev/blog/loop-gain-phase-margin-simulation) - [Averaged model or switching model: which simulation to run when](https://voltecx-web.nguyenvanqui291.workers.dev/blog/averaged-vs-switching-model) - [Peak current mode control and slope compensation](https://voltecx-web.nguyenvanqui291.workers.dev/blog/peak-current-mode-slope-compensation): subharmonic oscillation above D = 0.5 and how much ramp removes it. ## Input stage, EMI and AC front ends - [Input filter design and Middlebrook's stability criterion](https://voltecx-web.nguyenvanqui291.workers.dev/blog/input-filter-middlebrook-stability) - [Conducted EMI pre-compliance in simulation](https://voltecx-web.nguyenvanqui291.workers.dev/blog/conducted-emi-pre-compliance) - [Inrush current: how to estimate it and size an NTC limiter](https://voltecx-web.nguyenvanqui291.workers.dev/blog/inrush-current-ntc-sizing) - [Boost PFC basics: power factor, inductor sizing and bulk capacitor](https://voltecx-web.nguyenvanqui291.workers.dev/blog/boost-pfc-basics) - [Interleaved boost PFC: ripple cancellation, inductors and current sharing](https://voltecx-web.nguyenvanqui291.workers.dev/blog/interleaved-boost-pfc-ripple-cancellation) ## Robustness and verification - [Monte Carlo tolerance analysis of a power supply](https://voltecx-web.nguyenvanqui291.workers.dev/blog/monte-carlo-tolerance-analysis-power-supply) ## Models and files - [Use a manufacturer's SPICE MOSFET or diode model in Voltecx](https://voltecx-web.nguyenvanqui291.workers.dev/guides/use-vendor-spice-models) - [Move an LTspice project to Voltecx](https://voltecx-web.nguyenvanqui291.workers.dev/guides/migrate-from-ltspice) - [Switching to Voltecx from another simulator](https://voltecx-web.nguyenvanqui291.workers.dev/guides/switching-from-another-simulator) ## Where these steps sit in Voltecx The [design tools overview](https://voltecx-web.nguyenvanqui291.workers.dev/features/design-tools) shows the whole flow, from the requirements interview to the KiCad project. [Analyses](https://voltecx-web.nguyenvanqui291.workers.dev/features/analyses) lists the sweeps, frequency analyses and optimisers, and the [user manual](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/) has every command and menu. Questions about the product itself are in the [FAQ](https://voltecx-web.nguyenvanqui291.workers.dev/faq). --- # Power electronics glossary URL: https://voltecx-web.nguyenvanqui291.workers.dev/glossary/ Each entry gives a short plain explanation, the unit where there is one, and a link to the course lesson or article that uses the term. Where a definition follows a standard or textbook, the entry names it: R. W. Erickson and D. Maksimovic, *Fundamental of Power Electronics*, 3rd ed.; N. Mohan, T. Undeland and W. Robbins, *Power Electronics*, 3rd ed.; IEC 60664-1; CISPR 16-1-2. ## Converter operation - **CCM** (continuous conduction mode): the inductor current stays above zero for the whole switching period. Unit: none. [Buck converter lesson](https://voltecx-web.nguyenvanqui291.workers.dev/course/buck-converter) - **DCM** (discontinuous conduction mode): the inductor current falls to zero before the period ends and stays there until the next turn-on. Unit: none. [Flyback converter lesson](https://voltecx-web.nguyenvanqui291.workers.dev/course/flyback-converter) - **BCM** (boundary conduction mode): the inductor current just reaches zero at the end of the period, between CCM and DCM. Unit: none. [Boost PFC basics](https://voltecx-web.nguyenvanqui291.workers.dev/blog/boost-pfc-basics) - **Duty cycle**: the fraction of the period a switch is on. Unit: none, 0 to 1. [PWM explained](https://voltecx-web.nguyenvanqui291.workers.dev/blog/pwm-explained) - **PWM** (pulse-width modulation): a switch is driven at a fixed frequency and the on-time sets the average output. Unit: Hz for the frequency. [PWM explained](https://voltecx-web.nguyenvanqui291.workers.dev/blog/pwm-explained) - **Switching frequency**: how often the switch turns on per second; it trades switching loss against magnetics size. Unit: Hz. [Choosing a switching frequency](https://voltecx-web.nguyenvanqui291.workers.dev/blog/choosing-switching-frequency) - **Ripple**: the AC part of an inductor current or of an output voltage at the switching frequency. Unit: A or V peak to peak. [Buck inductor sizing](https://voltecx-web.nguyenvanqui291.workers.dev/blog/buck-inductor-sizing) - **Synchronous rectification**: a controlled switch replaces the diode so the conduction drop is a resistance, not a fixed voltage. Unit: none. [Synchronous or diode buck](https://voltecx-web.nguyenvanqui291.workers.dev/blog/synchronous-vs-diode-buck) - **Boost converter**: steps the voltage up; the input inductor current is continuous. Unit: none. [Boost and buck-boost lesson](https://voltecx-web.nguyenvanqui291.workers.dev/course/boost-and-buck-boost) - **Flyback**: an isolated converter that stores energy in a coupled inductor and delivers it while the primary switch is off. Unit: none. [Flyback transformer design](https://voltecx-web.nguyenvanqui291.workers.dev/blog/flyback-transformer-design-steps) - **LLC resonant converter**: a half or full bridge driving a series-resonant tank whose gain is set by the switching frequency. Unit: none. [LLC tank design](https://voltecx-web.nguyenvanqui291.workers.dev/blog/llc-resonant-tank-design) - **PSFB** (phase-shifted full bridge): a full bridge whose output is set by the phase between its two legs. Unit: none. [PSFB ZVS range](https://voltecx-web.nguyenvanqui291.workers.dev/blog/psfb-zvs-range) - **DAB** (dual active bridge): two bridges joined by an inductor; power flows with the phase shift between them. Unit: none. [Dual active bridge](https://voltecx-web.nguyenvanqui291.workers.dev/blog/dual-active-bridge-phase-shift) - **Totem-pole PFC**: a bridgeless boost power factor stage with a fast leg and a line-frequency leg. Unit: none. [Totem-pole PFC](https://voltecx-web.nguyenvanqui291.workers.dev/blog/totem-pole-pfc-explained) - **SEPIC**: a converter that can step up or down with a non-inverted output, using two inductors and a coupling capacitor. Unit: none. [SEPIC design](https://voltecx-web.nguyenvanqui291.workers.dev/blog/sepic-converter-design) - **Brake chopper**: a switch and resistor that dump regenerated energy from a DC bus. Unit: none. [Regenerative braking](https://voltecx-web.nguyenvanqui291.workers.dev/blog/regenerative-braking-brake-chopper) ## Switching and gate drive - **ZVS** (zero-voltage switching): the switch turns on after its voltage has fallen to about zero, so there is no turn-on loss from the output capacitance. Unit: none. [PSFB ZVS range](https://voltecx-web.nguyenvanqui291.workers.dev/blog/psfb-zvs-range) - **ZVT** (zero-voltage transition): an auxiliary network gives ZVS to a hard-switched leg for a short time around each turn-on. Unit: none. [Dual active bridge](https://voltecx-web.nguyenvanqui291.workers.dev/blog/dual-active-bridge-phase-shift) - **Hard switching**: voltage and current overlap during the switch transition, which costs energy at every edge. Unit: none. [Double-pulse test](https://voltecx-web.nguyenvanqui291.workers.dev/blog/double-pulse-test-switching-energy) - **Dead time**: the delay with both switches of a leg off, so they never conduct together. Unit: s. [Dead-time effects](https://voltecx-web.nguyenvanqui291.workers.dev/blog/dead-time-effects) - **Shoot-through**: both switches of a leg on at once, which shorts the bus. Unit: none. [Dead-time effects](https://voltecx-web.nguyenvanqui291.workers.dev/blog/dead-time-effects) - **Miller plateau**: the gate voltage stays flat while the drain voltage swings, because the gate current charges the gate-drain capacitance. Unit: V. [Gate signal timing](https://voltecx-web.nguyenvanqui291.workers.dev/blog/gate-signal-timing-propagation-delay-blanking) - **Qg** (gate charge): the charge the driver must supply to turn a device on. Unit: C. [MOSFET loss and thermal estimate](https://voltecx-web.nguyenvanqui291.workers.dev/blog/mosfet-loss-and-thermal-estimation) - **Qrr** (reverse-recovery charge): the charge a diode sweeps out when it turns off, which adds a current spike to the switch. Unit: C. [Double-pulse test](https://voltecx-web.nguyenvanqui291.workers.dev/blog/double-pulse-test-switching-energy) - **Eon / Eoff**: the energy lost in one turn-on or turn-off, measured on a double-pulse test. Unit: J. [Double-pulse test](https://voltecx-web.nguyenvanqui291.workers.dev/blog/double-pulse-test-switching-energy) - **Rds(on)**: the drain-source resistance of a conducting MOSFET; it rises with temperature. Unit: ohm. [MOSFET loss and thermal estimate](https://voltecx-web.nguyenvanqui291.workers.dev/blog/mosfet-loss-and-thermal-estimation) - **SOA** (safe operating area): the voltage and current region where a device may operate for a given time. Unit: V and A. [Derating rules](https://voltecx-web.nguyenvanqui291.workers.dev/blog/derating-rules-power-components) - **Bootstrap supply**: a diode and capacitor that power a high-side gate driver from the low-side supply. Unit: none. [Bootstrap capacitor calculation](https://voltecx-web.nguyenvanqui291.workers.dev/blog/bootstrap-capacitor-calculation) - **Propagation delay**: the time from a driver input edge to its output edge. Unit: s. [Gate signal timing](https://voltecx-web.nguyenvanqui291.workers.dev/blog/gate-signal-timing-propagation-delay-blanking) - **Blanking time**: a short window after a switch edge in which a sensed signal is ignored. Unit: s. [Gate signal timing](https://voltecx-web.nguyenvanqui291.workers.dev/blog/gate-signal-timing-propagation-delay-blanking) - **CMTI** (common-mode transient immunity): the largest dV/dt across an isolation barrier a driver tolerates without a wrong output. Unit: V/ns or kV/us. [CMTI of isolated gate drivers](https://voltecx-web.nguyenvanqui291.workers.dev/blog/cmti-isolated-gate-driver) - **Snubber**: a resistor and capacitor (or a clamp) that damps the ring on a switching node. Unit: none. [RC snubber design](https://voltecx-web.nguyenvanqui291.workers.dev/blog/rc-snubber-design) - **RCD clamp**: a diode, capacitor and resistor that limit the voltage spike from leakage inductance. Unit: none. [Flyback RCD clamp](https://voltecx-web.nguyenvanqui291.workers.dev/blog/flyback-rcd-clamp-design) ## Control and stability - **Crossover frequency**: where the loop gain crosses 0 dB. Unit: Hz. [Loop gain and phase margin](https://voltecx-web.nguyenvanqui291.workers.dev/blog/loop-gain-phase-margin-simulation) - **Phase margin**: how far the loop phase is above -180 degrees at crossover; it sets damping. Unit: degree. [Loop gain and phase margin](https://voltecx-web.nguyenvanqui291.workers.dev/blog/loop-gain-phase-margin-simulation) - **RHP zero** (right-half-plane zero): a zero of boost-type converters in CCM that adds gain and removes phase, which limits the crossover. Unit: Hz. [Boost converter RHP zero](https://voltecx-web.nguyenvanqui291.workers.dev/blog/boost-converter-design-rhp-zero) - **Slope compensation**: a ramp added to peak-current-mode control to stop subharmonic oscillation above 50 percent duty. Unit: A/s. [Slope compensation](https://voltecx-web.nguyenvanqui291.workers.dev/blog/peak-current-mode-slope-compensation) - **PI compensator**: a controller with a proportional and an integral term. Unit: none. [Buck PI compensator](https://voltecx-web.nguyenvanqui291.workers.dev/blog/buck-converter-pi-compensator-design) - **Middlebrook criterion**: the input filter output impedance must stay well below the converter input impedance to avoid instability. Unit: ohm. [Input filter stability](https://voltecx-web.nguyenvanqui291.workers.dev/blog/input-filter-middlebrook-stability) - **TL431 and optocoupler feedback**: the usual isolated feedback chain for a flyback. Unit: none. [TL431 feedback design](https://voltecx-web.nguyenvanqui291.workers.dev/blog/tl431-optocoupler-feedback-design) - **Sampling delay**: the time between measuring a signal and applying the duty it produces in a digital controller. Unit: s. [Digital control loop timing](https://voltecx-web.nguyenvanqui291.workers.dev/blog/digital-control-loop-timing) - **Cascaded loops**: an inner current loop inside an outer speed or voltage loop, the inner one faster. Unit: none. [Robot joint cascaded loops](https://voltecx-web.nguyenvanqui291.workers.dev/blog/robot-joint-servo-cascaded-loops) - **SPWM** (sinusoidal PWM): a sine reference is compared with a carrier to set the leg duties. Unit: none. [PWM explained](https://voltecx-web.nguyenvanqui291.workers.dev/blog/pwm-explained) - **SVPWM** (space-vector PWM): the voltage vector is built from the nearest switching states, which gives a higher bus use than SPWM. Unit: none. [Space-vector PWM](https://voltecx-web.nguyenvanqui291.workers.dev/blog/space-vector-pwm-explained) - **MPPT** (maximum power point tracking): a control that moves the operating point of a solar array to its maximum power. Unit: W. [Which converter topology](https://voltecx-web.nguyenvanqui291.workers.dev/blog/which-converter-topology-for-my-spec) - **SoC** (state of charge): the charge left in a battery as a fraction of its capacity. Unit: percent. [Which converter topology](https://voltecx-web.nguyenvanqui291.workers.dev/blog/which-converter-topology-for-my-spec) - **SoH** (state of health): the present capacity of a battery as a fraction of its new capacity. Unit: percent. [Which converter topology](https://voltecx-web.nguyenvanqui291.workers.dev/blog/which-converter-topology-for-my-spec) ## Power quality, EMI and safety - **PF** (power factor): real power divided by apparent power. Unit: none. [Boost PFC basics](https://voltecx-web.nguyenvanqui291.workers.dev/blog/boost-pfc-basics) - **THD** (total harmonic distortion): the RMS of the harmonics divided by the RMS of the fundamental. Unit: percent. [Boost PFC basics](https://voltecx-web.nguyenvanqui291.workers.dev/blog/boost-pfc-basics) - **EMI** (electromagnetic interference): unwanted noise a converter emits, conducted on wires or radiated. Unit: dBuV for conducted noise. [Conducted EMI pre-compliance](https://voltecx-web.nguyenvanqui291.workers.dev/blog/conducted-emi-pre-compliance) - **LISN** (line impedance stabilisation network): a standard network that gives the conducted-emission measurement a fixed source impedance, defined in CISPR 16-1-2. Unit: ohm. [Conducted EMI pre-compliance](https://voltecx-web.nguyenvanqui291.workers.dev/blog/conducted-emi-pre-compliance) - **Common mode and differential mode**: noise current that flows in both lines the same way, or in opposite ways. Unit: A. [Conducted EMI pre-compliance](https://voltecx-web.nguyenvanqui291.workers.dev/blog/conducted-emi-pre-compliance) - **Creepage and clearance**: the shortest distance along a surface, and through air, between two conductors, set by IEC 60664-1. Unit: mm. [Derating rules](https://voltecx-web.nguyenvanqui291.workers.dev/blog/derating-rules-power-components) - **Derating**: using a part below its rated stress for margin and life. Unit: percent of rating. [Derating rules](https://voltecx-web.nguyenvanqui291.workers.dev/blog/derating-rules-power-components) - **Inrush current**: the surge when an input capacitance first charges. Unit: A. [Inrush current and NTC sizing](https://voltecx-web.nguyenvanqui291.workers.dev/blog/inrush-current-ntc-sizing) ## Components and thermal - **Core loss**: the energy a magnetic core dissipates per cycle from hysteresis and eddy currents. Unit: W. [How to choose an inductor](https://voltecx-web.nguyenvanqui291.workers.dev/blog/how-to-choose-an-inductor) - **Saturation**: the core flux density reaches its limit and the inductance collapses. Unit: A for the saturation current. [Buck inductor sizing](https://voltecx-web.nguyenvanqui291.workers.dev/blog/buck-inductor-sizing) - **Litz wire**: many insulated strands twisted together to reduce skin and proximity loss. Unit: none. [How to choose an inductor](https://voltecx-web.nguyenvanqui291.workers.dev/blog/how-to-choose-an-inductor) - **ESR** (equivalent series resistance): the resistance in series with a capacitor, which sets its ripple loss. Unit: ohm. [Buck output capacitor](https://voltecx-web.nguyenvanqui291.workers.dev/blog/buck-output-capacitor-selection) - **DC-link capacitor**: the bulk capacitor on a DC bus that carries the ripple current of an inverter. Unit: F. [DC-link capacitor sizing](https://voltecx-web.nguyenvanqui291.workers.dev/blog/dc-link-capacitor-sizing-inverter) - **Rth and Zth** (thermal resistance and impedance): the temperature rise per watt, steady state and for a pulse. Unit: K/W. [Heatsink selection](https://voltecx-web.nguyenvanqui291.workers.dev/blog/heatsink-selection-thermal-design) - **Junction temperature**: the temperature of the silicon, estimated from loss and thermal resistance. Unit: degree C. [MOSFET loss and thermal estimate](https://voltecx-web.nguyenvanqui291.workers.dev/blog/mosfet-loss-and-thermal-estimation) - **Tolerance analysis**: running a design many times with random part values to see the spread of a result. Unit: none. [Monte Carlo tolerance analysis](https://voltecx-web.nguyenvanqui291.workers.dev/blog/monte-carlo-tolerance-analysis-power-supply) ## Voltecx terms - **Subsystem**: a group of parts wrapped as one block with named pins; you open it to see the inside. Unit: none. [Power supply product design flow](https://voltecx-web.nguyenvanqui291.workers.dev/blog/power-supply-product-design-flow) - **Net label**: a name on a wire; wires with the same label are connected, so signals cross the page without long wires. Unit: none. [Power supply product design flow](https://voltecx-web.nguyenvanqui291.workers.dev/blog/power-supply-product-design-flow) - **Fast solver and reference solver**: two independent solvers; the simple reference solver checks the fast one. Unit: none. [Five things to check in a simulation](https://voltecx-web.nguyenvanqui291.workers.dev/blog/five-things-to-check-in-power-electronics-simulation) - **Averaged model and switching model**: a model of the cycle average, fast but without ripple, against a model that resolves every switch edge. Unit: none. [Averaged or switching model](https://voltecx-web.nguyenvanqui291.workers.dev/blog/averaged-vs-switching-model) - **Design panel**: the panel that sizes a converter from a specification and checks the result by simulation. Unit: none. [Which converter topology](https://voltecx-web.nguyenvanqui291.workers.dev/blog/which-converter-topology-for-my-spec) - **Switching-frequency sweep**: running one design at several frequencies to compare loss, ripple and size. Unit: none. [Switching-frequency sweep](https://voltecx-web.nguyenvanqui291.workers.dev/blog/switching-frequency-sweep-worked-example) --- # Design tools, from the first question to the KiCad project URL: https://voltecx-web.nguyenvanqui291.workers.dev/features/design-tools/ Voltecx takes a converter from a list of requirements to a checked design you can hand to layout. Each step below is a command with its own menu item, so you can run the whole flow, start in the middle with your own circuit, or let the AI assistant run it for you. Items marked *in the next release* are merged for the next beta and are not in Voltecx 0.9.0 yet. ## 1. Answer a few questions *In the next release.* The requirements interview (`spec.questions`, **Design › Automate › Requirements Interview**) asks for what your spec is missing, in rounds: first the application, input, output, load and isolation, then ripple, efficiency, load step, ambient, cooling and protections, then the EMI class, standards, auxiliary rails, service life and, for an isolated design, the transformer core. The application you pick (server power supply, charger, LED driver, solar and so on) sets the suggested defaults. Each question shows its default and why it matters, and **Use the defaults** takes a whole round at once. You confirm the spec in a summary table before anything runs. The AI assistant asks the same questions the same way; a script with a full spec skips the interview. ## 2. Check the spec is within reach *In the next release.* Before anything is sized, `spec.feasibility` bounds what any design could reach: efficiency from the semiconductor losses alone, output ripple from the best catalogue capacitor bank, and junction temperature on the best catalogue heat sink, with size and cost targets when you give them. A requirement out of reach comes back with the smallest change that brings it within reach, such as a lower efficiency target or a different switching frequency. Automatic design runs this check first, so an impossible spec stops before any simulation. ## 3. Compare topologies and control `design.compare` (**Design › Automate › Compare Topologies and Control**) answers "why this topology?" with a table: for each ranked topology, the efficiency from semiconductor and magnetics losses, device stresses, part count, magnetics volume, catalogue cost and how hard the loop is to close, with pros, cons and a sentence on why the chosen one won. On a buck, boost or buck-boost it also designs voltage mode, peak current mode, average current mode and a digital PI for the same phase margin and simulates each through a load step. Other topologies get the topology table without the control comparison. *In development:* a choice of control implementation in automatic design: digital firmware (today's path), an analog op-amp compensator, or a controller IC. ## 4. Design it automatically `design.auto` (**Design › Auto Design**) draws the chosen topology, sizes the power stage and the magnetics, closes the voltage loop, verifies every corner of the spec by simulation, picks parts from cited data sheets and writes the report. The magnetics search covers ETD, PQ, RM, EFD and planar ferrite sets read from vendor data sheets. *In the next release:* the winding of each magnetic design laid out layer by layer, with Dowell's AC loss of every layer, foil and litz included, interleaving such as P/S/P, the leakage inductance from the arrangement and a cross-section view, plus the data sheet's own core-loss points beside the model where the vendor publishes them; and auxiliary rails (an LDO for the MCU's 3.3 V, a gate-drive bias or a post-regulator), each checked for dropout, ripple through its PSRR and junction temperature, and drawn on the schematic as one subsystem. [How automatic design works](https://voltecx-web.nguyenvanqui291.workers.dev/features/auto-design). ## 5. Weigh cost against lifetime *In the next release.* Give the spec a cost limit and a service life, and the bill of materials prefers the cheapest parts that carry the stress, while each electrolytic, polymer or hybrid capacitor that would wear out early is swapped for one that lasts. `design.tradeoff` (**Design › Design Steps › Trade-offs**) puts the choices in one table: efficiency, board area, cost per board and shortest capacitor life for each capacitor option, with what each gain costs. Voltecx ships no price it has not read on a cited page, so give your prices or connect Nexar; a part without a price is listed, never guessed. ## 6. Run each test case on the Test Bench **Simulation › Test Bench** runs the checks of your spec one case at a time: each corner, start-up, load step, hold-up, over-current, over-voltage, under-voltage lockout and inrush. Each run keeps its waveforms with the limits drawn on the scope, so you can look at a failing row, fix the circuit, run the case again and compare the two runs. [Test Bench in the manual](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/18-test-bench/). ## 7. Estimate EMI `emi.conducted` (**Design › Automate › Conducted EMI**) puts a LISN on a copy of the circuit, reads the input current through a model of a CISPR receiver with peak, quasi-peak and average detectors, compares it with the CISPR 32 class A or B limit and sizes a damped input filter when the margin is short. `emi.radiated` estimates radiated emission from 30 MHz to 1 GHz and tries three layout changes to show which helps most. *In the next release:* a common-mode stage (choke and Y capacitors) in the filter, AC mains inputs with a LISN on line and neutral, optional parasitic elements (capacitor ESR and ESL, winding capacitance, switch Coss) taken only from the circuit or cited data, and a **Radiated EMI** form whose assumed values you can replace with your board's. Both are pre-compliance estimates, not measurements. [EMI in the manual](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/06-analyses/). *In the next release:* once you have routed the board in KiCad, Voltecx reads the `.kicad_pcb` back. `layout.extract` finds each power loop on the copper and gives its inductance, its area and the switch node's capacitance to the planes around it. `layout.ringing` simulates the ring that this inductance and capacitance put on the switch node, and checks it against the hand calculation. Given the same board, `emi.radiated` uses the routed loop area. It also uses the switch node's capacitance to a chassis or heat-sink fill, which drives the common-mode current, so the radiated estimate is based on your copper rather than typical values. These are formula estimates from the board geometry; fringing fields are left out. [Layout and the routed board in the manual](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/16-automatic-design/). ## 8. Hand it over The design report comes as HTML, Markdown and JSON, in English or Traditional Chinese, and **Export Design Summary Folder** (command palette) writes it as one folder with the schematic and plots. **File › Export › Bill of materials** picks catalogue parts that meet the simulated stress, and **File › Export › KiCad project** writes a KiCad 8 schematic, project and design rules. Voltecx writes no board file: the layout is yours to draw. ## Tools that help along the way - **Ask AI** (*in the next release*): right-click a part, a net, a parameter in Properties, a scope trace or a time on the plot, and it becomes context in the AI panel. Suggested fixes come back as proposals you accept or reject. [The AI assistant](https://voltecx-web.nguyenvanqui291.workers.dev/features/ai-assistant). - **Tidy Schematic** (*in the next release*, **Circuit › Layout › Tidy Schematic**): moves the control parts out of the power stage, separates overlapping symbols, gives each grounded pin its own ground symbol and carries long signal wires by net label, in one undo step. Only positions change; the netlist stays the same. - **FEMM link** (*in the next release*): in the Design Magnetics result each design row has **Export FEMM Model** (the `.fem` file and the Lua script that solves it in FEMM 4.2) and **Import FEMM Results** (L, M and k written into the selected inductor or transformer in one undo step); the same items are under **Design › Field Solver**. With **Preferences › Preview features** on, **Field Solve** gets L, M and k and a map of the field from Voltecx's own 2D field solver, and **Core Loss from Last Run** maps the core loss of the part's simulated current. - **C Block code editor:** double-click a C block, or use **Circuit › C Code**, to edit its code with line numbers, syntax colours and problems marked while you type. Save is one undo step. - **Wireless power link** (*in the next release*, **Design › Design Steps › Wireless Power Link**): the series or series-parallel compensating capacitors of an inductive charging link, the bridge voltage for a target power, the coil currents and capacitor voltages, the link efficiency with its best load, and efficiency and power against the coupling factor, which is what a misaligned pad does. - **Pad coupling** (*in the next release*, **Design › Design Steps › Pad Coupling**): the self-inductances, mutual inductance and coupling factor of two air-cored circular pads from their radii, turns, wire and gap, and the coupling against lateral misalignment down to the offset where it reaches zero. Apply writes them into the link's coupled inductor. - **Parts:** vendor devices that cite their data sheets. *In the next release:* Infineon IGBT power modules (half bridges and six-packs) and more discrete IGBTs. [Models and parts](https://voltecx-web.nguyenvanqui291.workers.dev/features/models-and-parts). - **On the scope** (*in the next release*): summary cards for output, ripple, duty and efficiency; up to 8 reference runs on one plot; and a Run History of cards you can compare and restore. [Debugging and the scope](https://voltecx-web.nguyenvanqui291.workers.dev/features/debugging-and-scope). ## Know the limits A pass means the design meets the spec in Voltecx's models and data. It is not a safety or compliance result, and no design has been checked against a built board yet. EMI, layout and price figures are estimates. Automatic design runs on Voltecx Cloud and is a Pro feature; see [pricing](https://voltecx-web.nguyenvanqui291.workers.dev/pricing). --- # Automatic design from a specification URL: https://voltecx-web.nguyenvanqui291.workers.dev/features/auto-design/ A specification goes in; a checked converter and a report come out. `design.auto` chains the design steps an engineer would take by hand and checks each one by simulation, so you start from a design that has already been run at every corner of your spec. Automatic design is one step of the design flow. [Design tools](https://voltecx-web.nguyenvanqui291.workers.dev/features/design-tools) shows the steps before and after it: the requirements interview, the feasibility check, the topology and control comparison, the Test Bench and the EMI estimate. ## Write the spec Three fields are required: the input voltage, the output voltage and the load current. `{"vin": 12, "vout": 3.3, "iout": 5}` is a complete spec. Add the limits you care about and Voltecx checks them; a limit you leave out is listed as not checked. | You can ask for | Checked by | |---|---| | Output ripple, regulation over the input and load range | Simulation at every corner | | Load step and line step (dip and recovery time) | Simulation | | Start-up time and overshoot | Simulation | | Efficiency at up to 16 load points | Loss model on the switching circuit | | Junction temperature at the hottest ambient | Thermal model of each device | | Phase and gain margin | Loop-gain measurement | | Yield with part tolerances | Seeded Monte Carlo | In the desktop app the spec is a form under **Design › Auto Design**. From a script it is JSON. ## Answer a few questions first Not sure what to put in the spec? The requirements interview (`spec.questions`, or **Design › Automate › Requirements Interview** in the desktop app) asks for what is missing, in rounds: first the application (server PSU, charger, LED driver, solar and so on), input, output, load and isolation, then ripple, efficiency, load step, ambient and cooling, priority, protections and the magnetics you prefer, then the EMI class, standards, control implementation, auxiliary rails, service life and, for an isolated design, the transformer core and winding. The application sets the suggested efficiency, EMI class, standards and life. Each question comes with a suggested default and why it matters, and you can take a whole round of defaults at once. You see the spec as a summary table and confirm it before the design runs. The AI assistant asks the same questions the same way. Scripts with a full spec skip the interview. ## What the run does 0. **Checks the spec is within reach.** Before anything is sized, `spec.feasibility` bounds the efficiency (the semiconductors' losses alone), the output ripple (the best catalogue capacitor bank) and the junction temperature (the best catalogue heatsink). An efficiency or ripple no design can meet stops the run at once, with the reason and the smallest change that brings it within reach, such as a lower efficiency target or a lower switching frequency; a junction too hot is listed as an open item. 1. **Ranks topologies** for your spec and draws the best one it can design: buck, synchronous buck, boost, synchronous boost, buck-boost, SEPIC, flyback, four-switch buck-boost, multiphase buck, LLC or phase-shifted full bridge. 2. **Sizes the power stage** from textbook equations, then designs each inductor or transformer (core, material, gap, turns and wire) from the simulated current. 3. **Closes the voltage loop.** When the spec has a load step, or the converter has a right-half-plane zero, the loop is designed over every corner, including firmware delay and light-load discontinuous conduction. Instead of firmware the loop can be built from parts: an op-amp network, or a controller IC. On a boost or flyback the controller is the UCx843 in peak-current mode in the circuit, with its sense resistor, current limit and slope compensation for duties above 50 %, each value from TI's data sheet. 4. **Verifies every corner** of the spec and returns one row per requirement. Where a part value can fix a failing row (output capacitance for ripple, for example), it tunes and checks again. 5. **Chooses parts** from the vendor library (each device cites its data sheet), then computes efficiency, junction temperatures, part stress and the worst case over tolerances. 6. **Prepares the hand-off:** gate driver and bootstrap sizing, the sense network into the ADC, protection thresholds, fixed-point firmware, a conducted-EMI estimate with an input filter when one is needed, layout hints for the hot loops, a bill of materials and a KiCad schematic. 7. **Adds auxiliary rails** when the spec asks: 3.3 V for the MCU, a gate-drive bias or a post-regulator on the output. Each gets an LDO from a catalogue of TI and Microchip parts, every value cited to its data sheet, checked for dropout headroom over the input range, ripple through its PSRR at the switching frequency and junction temperature. The rails go into the schematic as one subsystem, then onto the bill of materials and into the report. With `auto.blocks`, the circuit comes back as a block diagram you can read: one subsystem per design step (power stage, EMI filter, protection, sensing, controller, gate drive) in power-flow order, the control row joined by net labels and each block showing its key values. **Circuit › Layout › Group into Blocks** does the same for a circuit you drew yourself, and one undo takes it back. The same spec and seed give the same circuit and the same report. Runs have hard caps on simulations and solver steps. ## Read the report The report comes as JSON, Markdown, HTML and SVG, in English or Traditional Chinese. Every number comes from a simulation or from a textbook equation printed beside it. A failed design is still useful: the report names the stage that stopped it, the rows that failed and the next step for each. The **not checked** list says what the run did not test, such as radiated emission. *In the next release.* The spec stays with the design: it is saved in the circuit's file, so the Test Bench, `spec.verify`, the EMI estimate (its limit, such as CISPR 25 class 3) and the thermal check use it after you reopen the file. ## Faster, and a report to hand over Automatic design tries the converter on a circuit-averaged model first and confirms the result on the switching circuit. After a verification passes, the switching runs start from the averaged steady state, so they need about four loop time constants instead of the slowest corner's settling time. One command, `report.designSummary`, writes the report as a folder to hand over: a self-contained `index.html`, `report.md`, the schematic as PNG and SVG, and the Bode plot and key waveforms as SVG. Everything is in English or Traditional Chinese, as you choose. *In the next release.* The report travels with the file: Auto Design keeps a record of its report with the circuit, so after you reopen the `.pcraft`, on any computer, `report.export` and `report.designSummary` write the same report without running the design again. ## Cost and lifetime as targets Add `"cost": {"max": 12, "qty": 1000}` and `"life": {"years": 10, "ambient": 60}` to the spec. With a cost limit the bill of materials picks the cheapest of the parts that carry the stress, priced at the quantity breaks of the whole build, and the run stops with "not feasible at this cost" when one board costs more. With a life target each electrolytic, polymer or hybrid capacitor that would wear out sooner is swapped for an alternate that lasts, using its manufacturer's own life formula. The report's **Cost and life** chapter shows a trade-off table: efficiency, board area, cost per board and shortest capacitor life for each capacitor choice, with what each gain costs, such as "+12 % cost for +4.0 years of life". `design.tradeoff` gives the same table for any simulated circuit (**Design › Design Steps › Trade-offs**). Voltecx ships no price it has not read on a cited page, so give your prices or connect Nexar; a part without a price is listed, never guessed. Add `"missionProfile"` to `life` (load and ambient against time, with the power-cycling model) and the `life` gate also checks the power semiconductors' thermal-cycling life under that profile, from `design.lifetime`. ## Why this topology, and which control `design.compare` puts the choice in a table: for each ranked topology, the efficiency with semiconductor and magnetics losses, the device stresses, the part count, the magnetics volume, the catalogue cost and how hard the loop is to close, with pros and cons and a sentence on why the chosen one won. On the chosen buck, boost or buck-boost it then designs voltage mode, peak current mode, average current mode and a digital PI for the same phase margin and simulates each through a load step: bandwidth, margins, dip and settling time, and what each takes to build. The design report has the same chapter, and the assistant answers "why this one?" from it. ## Use each tool alone Every stage is a command you can run on your own circuit: `spec.feasibility` (also with size and cost targets and your prices), `topology.suggest`, `magnetics.design`, `design.robustLoop`, `analysis.pareto` (a seeded NSGA-II search of the design space), `spec.verify`, `design.digitalize`, `emi.conducted`, `layout.hints`, `bom.export` and `file.exportKicad`. The single-step design tools (`design.converter`, `design.voltageLoop` with automatic Type III, `design.currentLoop`, `design.llc`, `design.protection`, `design.gateDrive`) are in the Design panel. ## Know the limits - A pass means the design meets the spec **in Voltecx's models and data**. It is not a safety or compliance result, and it has not been compared with hardware. - PFC is not part of `design.auto` yet. The LLC and four-switch buck-boost keep an open loop, and the report says so. - EMI, layout and price figures are estimates. The EMI stage is a pre-compliance estimate against CISPR 32, not a measurement. - The vendor device library has 22 parts. The magnetics search uses the OpenMagnetics MAS starter set and 21 ferrite shapes of the ETD, PQ, RM, EFD and planar E and ER families read from the Ferroxcube and TDK data sheets, so a 200 W flyback gets candidates from several core families. Confirm the chosen core, gap and wire against the manufacturer's data sheet. - The KiCad export writes a schematic, a project and design rules, not a board. Automatic design is a Pro feature. See [pricing](https://voltecx-web.nguyenvanqui291.workers.dev/pricing). --- # Simulation you can check URL: https://voltecx-web.nguyenvanqui291.workers.dev/features/simulation/ A simulator is only useful if you can trust its numbers. Voltecx is built so that you can see why a number is right, or find out quickly that it is not. ## Two solvers that check each other - **Fast solver** for everyday work. It is built for switching circuits: it lands exactly on switching events, reuses matrix factorisations while the switches stay in the same state, offers fixed or error-controlled variable steps, and switches to a sparse solver for large circuits. - **Reference solver**, deliberately simple and always fixed-step. Its job is to be an independent check. Run the same circuit with `{"solver": "reference"}` and compare. The automated tests check the fast solver against the reference solver, and both against closed-form answers and stored ngspice waveforms. `design.auto` reruns the nominal corner on the reference solver and flags any row where the two disagree. After every run, both solvers look over what they recorded. A node voltage or part current that jumps a millionfold in one step, or a value that is not a number, is listed in Problems as a *Suspect result* on that node or part (*in the next release*), so a solver glitch is never plotted as if it were the circuit. ## The accuracy report `docs/accuracy.md` is generated by running models through the engine and comparing them with a reference that is not the simulator. On 2026-10-17, **22 of 22 comparisons were within tolerance**: | Group | Reference | Typical error | Tolerance | |---|---|---|---| | RC, RL and RLC step responses | closed form and ngspice-47 | below 1e-6 | 1e-4 to 1e-3 | | Half-wave rectifier, with and without filter | ngspice-47 | 3.6e-4 to 5.0e-4 | 2e-3 to 3e-3 | | Buck 48 V → 12 V start-up, 100 kHz | ngspice-47 | 1.3e-4 to 5.7e-4 | 1e-3 to 2e-3 | | SiC MOSFET double pulse, Eon and Eoff | Wolfspeed and Infineon data sheets | 6.9 % to 14.3 % | 30 % | The report also has a "not validated yet" list: switching energy from a measured double-pulse test, magnetics loss against a measured inductor, efficiency against a built board and junction temperature against a measured heatsink. Nothing on that list is claimed. Whole circuits are checked against reference results in a second report, `docs/validation.md`; [How we validate](https://voltecx-web.nguyenvanqui291.workers.dev/how-we-validate) explains the method and what has been compared so far. ## Device data with a source Vendor parts in the library (Wolfspeed, Infineon, ROHM, Texas Instruments, Nexperia) carry the manufacturer, the data-sheet URL, the revision and the figures their values were read from. A value a data sheet does not give is left out, never guessed. SiC and GaN switches have a dynamic gate model for switching edges. Bring your own part by importing its data-sheet tables as CSV. ## Ideal against Real, side by side The toolbar's **Models: Ideal | Real** switch runs the same circuit with every parasitic and loss unset, or as entered. Real also puts MOSFETs that carry gate data on their dynamic switching model and diodes with `is` and `n` on their exponential model, without editing the circuit. Run once in each and the second run overlays the first and shows a table: the output voltage's average and ripple, the efficiency, the total loss and the three largest part losses, with the difference. A hint beside the switch counts the parts that still have no losses set, and Problems offers to fill a catalogue part's ESR or DCR from its data sheet; a part without one is listed with no data, never a guessed value. [Before and after pictures](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/10-models/#seeing-what-real-changes). ## The periodic steady state in a few periods **Steady State** skips the start-up: a shooting-Newton search solves for the state at the start of a period that comes back after one period, then checks it by running on until the waveform repeats. On the LLC half-bridge example it takes 10 periods where stepping period by period takes 156; on a boost PFC with 4.7 mF it takes 12 line periods where stepping takes about 100. A circuit with more than 64 states, or a search that does not converge, falls back to stepping. [Example and limits](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/04-simulation-settings/#example-the-llc-half-bridge). ## Hours of a battery in under a second A real pack charges over hours, and a switching run of one hour at a 1 µs step is billions of steps. `simulation.batteryRun` runs the converter on its averaged model in short bursts and jumps the batteries' charge between them, with the charge controller's constant-current and constant-voltage logic still in the loop. On the `batteryChargerLongRun` example, four 4.5 Ah cells charged from 20 % to full over 1.5 hours, the run takes 39 674 steps where a switching run would take about 2.7 billion. Checked against the battery's own equations on a 4s 5 Ah pack, the change from constant current to constant voltage, the termination time and the final charge are within 0.6 %. `simulation.batteryZoom` then runs a few milliseconds of the switching circuit from any point of the long run, to show the ripple half an hour into the charge. The long run has no ripple of its own, and it runs from the console or a script, not yet from a menu. [How to run it](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/04-simulation-settings/#hours-of-a-battery-simulationbatteryrun). ## Built not to crash A crash loses work, so Voltecx treats it as the worst bug. Malformed files, bad parameters and diverging circuits come back as errors that name the component or node. Every command is fuzzed with hostile parameters, and an import run over 699 public sample files produced no crash. ## What you can simulate Switches, diodes, MOSFETs and IGBTs with loss tables, thyristors, transformers and coupled inductors with saturation, control blocks and digital control with sample delay, thermal networks, motors and mechanical loads, batteries, solar modules, supercapacitors, fuel cells, the three-phase grid, EMI parts such as LISNs and common-mode chokes, behavioural ICs, and your own blocks as sandboxed WebAssembly. Long runs park older results on disk, and a run that would exceed the available memory is stopped before it starts. ## Examples you can see before you open them About 60 example circuits ship with Voltecx, from an RC step to motor drives, grid converters and an HVDC link. Help > Examples lists them by category with search, and shows the selected one's schematic, its main signals from a real run, its key specs and what it teaches. Open it, open and run it, or start Auto Design from a DC-DC example's operating point. [How to use it](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/15-examples/). If you know what you want, press Cmd+K and type: the command palette lists matching examples, then your recent files, then commands, and previews the highlighted one's schematic and waveform on the right. Enter opens it, Cmd+Enter opens it and runs it. [Keys](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/03-wiring-and-shortcuts/#the-command-palette). ## Not done yet - No comparison with the reference waveforms of other simulators. That needs reference waveforms from users of those tools. - No side-by-side speed comparison with any commercial simulator. - No lab measurements yet. See [analyses](https://voltecx-web.nguyenvanqui291.workers.dev/features/analyses) for what you can measure once a run is done. --- # Analyses for power electronics URL: https://voltecx-web.nguyenvanqui291.workers.dev/features/analyses/ A transient run is the start. These analyses answer the questions a design review asks. Each one is a command, so you can run it from the menu, a script or an assistant. ## Frequency domain - **Loop gain** with gain and phase margin, on the switching circuit itself (`analysis.loopGain`). - **AC sweep** and **impedance** of a port (`analysis.acSweep`, `analysis.impedance`). - **DC operating point**, **DC sweep** and **DC transfer function** (`analysis.op`, `analysis.dcSweep`, `analysis.transfer`). - **FFT** with harmonics and THD (`analysis.fft`). ## Loop gain of a switching converter in two periods a frequency On a circuit that switches, the frequency response uses the `periodic` method by default: it finds the periodic steady state, models one switching period about it, and reads each frequency from two more periods instead of a settled run. The closed-loop buck example's loop gain at 12 frequencies takes 16659 solver steps; measuring by injection into a running simulation needs more than 20 million steps for the same sweep. On the closed-loop buck and boost it matches a fine-step injection within 0.2 dB and 1° up to a third of the switching frequency. Above half the switching frequency the reply warns that the response aliases. [Example and limits](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/06-analyses/#example-the-loop-gain-of-the-closed-loop-buck). ## Variation and robustness - **Parameter sweep** in one or two variables or part values, run in parallel, with several measurements per run and the waveforms overlaid (`analysis.paramSweep`, `analysis.paramSweep2d`). *In the next release:* right-click a value in Properties › **Sweep** opens the sweep filled in for it, a decade each side, with the family overlaid on the scope. - **Monte Carlo** with uniform or Gaussian tolerances, a seed you set, and the yield against your limits (`analysis.monteCarlo`). - **Worst case** over a tolerance box, **sensitivity**, and **optimise** toward a target. - **Tune to spec** (`analysis.tuneToSpec`) changes a part value until a failing requirement passes, where a part value can fix it. ## Sweeps that keep every waveform and measure several numbers A sweep, a 2-D sweep or a Monte Carlo run can keep chosen waveforms of every point, so the scope overlays the family in one colour per point (`v(out) · L1.l = 47u`), as a stepped run in a SPICE tool does. The same sweep can measure up to 16 numbers per run and answer with one table: three inductors on the buck example give the inductor ripple (1.93, 0.91 and 0.42 A) and the output mean in one pass. Targets are a circuit variable or a part's parameter (`L1.l`) in every analysis, and Monte Carlo and worst case take the same tolerance list. The kept waveforms hold up to 256 MB (64 MB in the browser); a sweep that would need more is refused before it runs, and they are not saved with the file. [Example and limits](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/06-analyses/#example-three-inductors-two-numbers-each-one-overlay). ## Losses, heat and stress - **Losses** of every switch and diode over a window, split into conduction and switching (`analysis.losses`), and the full-load **loss chart**: a Sankey from the input to each kind of loss and each part, with one stacked bar per part (`analysis.lossChart`, **Analysis › Loss Chart**; see [thermal](https://voltecx-web.nguyenvanqui291.workers.dev/features/thermal)). - **Thermal**: junction temperatures through the thermal network, with a slower multi-rate thermal step for long runs (`analysis.thermal`). - **Efficiency** at several loads and **junction temperature** at your hottest ambient (`design.efficiency`, `design.thermal`). - **Lifetime under a mission profile**: give load and ambient against time, and Voltecx finds each switch's junction temperature over it from the simulated losses and the data sheet's thermal impedance, counts the temperature swings (rainflow counting, ASTM E1049) and turns them into years of bond-wire and solder life with a published power-cycling model: LESIT, the Semikron Danfoss AN 21-001 model, CIPS2008 with your coefficients, or the power-cycling curve of your module's data sheet (`design.lifetime`, **Design › Design Steps › Lifetime**). - **Stress**: each part's peak and RMS current, peak voltage, di/dt, dv/dt and loss against its derated rating (`analysis.stress`), then parts from the library that cover that stress at the lowest loss. ## Switching behaviour `analysis.softSwitching` reads every gate edge of every switch. It calls each turn-on ZVS, partial or hard, measures the energy lost to hard turn-ons from the device's Coss, and checks each leg's dead time against how long the switch node took to swing: too short, too long, or about right, with a value to use. With a load sweep it shows where zero-voltage switching is kept and where it is lost. ## Grid harmonic limits `analysis.gridHarmonics` holds a line current to the current distortion limits of IEEE Std 519-2014 Table 2: each order 2 to 50 in percent of the demand current for the grid's short-circuit ratio, and the total demand distortion. For twelve-pulse and higher rectifiers it applies the √(q/6) allowance on the characteristic orders when the other orders are quiet enough. ## On the scope Cursors, logic lanes, math signals, power and power factor, THD, and measurements of min, max, mean, RMS, peak-to-peak and the last value. Compare a run with earlier runs on the same axes. The **Run History** reads like a pull-request list: two quiet lines per run with what changed and the largest change of its key results (green closer to the spec, amber further); click a row to see every key result and every changed value before and after, compare two runs side by side (their results, and their circuits drawn side by side with the changes highlighted), or restore a run's values in one undo step. Export waveforms as CSV, MATLAB MAT-file or LTspice `.raw`, and plots as PNG or SVG for a report. **Circuit animation** (Shift+F8) plays the result on the schematic: current dots on the wires, node voltages as colour, switch states. ## EMI - **Conducted EMI** (`emi.conducted`, **Design › Automate › Conducted EMI**): a LISN on a copy of the circuit, the input current read through a model of a CISPR receiver with peak, quasi-peak and average detectors against the CISPR 32 class A or B limit, and a damped input filter sized when the margin is short. - **Radiated EMI** (`emi.radiated`): an estimate from 30 MHz to 1 GHz at 3 m or 10 m, from the switch node and the hot loop, with three layout changes tried to show which helps most. - *In the next release:* a common-mode stage (choke and Y capacitors) in the filter, AC mains inputs with a LISN on line and neutral, optional parasitic elements taken only from the circuit or cited data, and a **Radiated EMI** form that lists every assumed value for you to replace. Both are pre-compliance estimates, not measurements. [Where EMI fits in the design flow](https://voltecx-web.nguyenvanqui291.workers.dev/features/design-tools). ## Debugging `analysis.diagnoseWaveforms` and the debugging tools look for the usual reasons a converter misbehaves, and the Problems panel turns errors into fixes you can apply. `circuit.explain` describes an imported circuit so you can check that it is what you expected. ## Test Bench **Simulation › Test Bench** runs one case of your spec at a time (a corner, start-up, load step, hold-up, OCP, OVP, UVLO, inrush) and draws its limits on the scope, so you can fix a failing row and compare the two runs. **Run All and Report** makes the test report: every case plus the loop gain, efficiency and losses, junction temperatures, component stress and conducted EMI, as one PDF or one interactive HTML page with a Markdown copy. Each failure comes with its next step, and **Copy for AI**, **Open in Claude** and **Open in ChatGPT** hand the report to an assistant that explains it. Every result window can copy its table as CSV with full precision. --- # An AI assistant that proposes, never overwrites URL: https://voltecx-web.nguyenvanqui291.workers.dev/features/ai-assistant/ The assistant works inside the desktop app, next to your schematic. Describe what you want: "Why does V(out) ripple exceed spec?" or "Design a 48 V to 12 V, 10 A buck". It looks at the circuit, runs simulations, measures waveforms and answers with what it found. ## Start from a sentence When no circuit is open, the app shows its **Start page**. Its first box says *Describe a converter*. Type the converter in a sentence (input, output, power, isolation) or click one of the example requests, then press **Design it**. The sentence goes to the assistant, which asks what is missing and runs automatic design. Under it are New, Open and Import, your recent files with how long ago each changed, four example circuits with their waveforms, and links to the tutorials, the keyboard shortcuts and what is new. ## Proposals, not surprises The assistant has read-only tools. Every change it wants to make arrives as a **proposal**: a ghost on the schematic with a card that says what it does. You accept it or reject it. When it asks for a new design, it runs automatic design on a scratch copy and shows the result as a new-circuit card. - **Checkpoints** let you go back to the circuit as it was before any message. - **@ mentions** point at a part, a net or a signal: `@R1`, `@v(out)`. - **Slash commands** start common work in a word: `/design 48 V to 12 V, 10 A`, `/simulate`, `/tune`, `/explain @L1`, `/fix`, `/verify`, `/report`, `/paper`, `/compare`. Each playbook is a command too, and a Markdown file in your settings folder becomes your own. - **Tune to spec** asks the assistant to move part values until a requirement passes. - **Tab suggestions** offer the next part while you draw. They run on your machine and need no key. - Each tool call shows as one row ("Ran simulation · 0.8 s", "Proposed: add C2"). Click it to see the call and its result. Each circuit keeps its own chat, saved in the circuit file when you save it, unless you turn that off in Preferences. ## Your key, your data Today the assistant uses **your own Anthropic API key**, billed to your account. You paste it in **Preferences › AI Assistant**, and Voltecx keeps it in the system's credential store (macOS Keychain, Windows Credential Manager or Secret Service). It is never written to a circuit file, a settings file or a log. Nothing goes to the network until you press Send. Then your message, the selection and the circuit data the assistant asks for go to Anthropic's API, and nowhere else. You choose the model in Preferences. ## Signed in to Voltecx When you are signed in, the assistant can run through the Voltecx service instead of your own key. Each plan has its own rate limit and daily and monthly allowance. When you reach one, the message says which limit it was, when it resets and where to upgrade. The service meters usage per account and never logs your API key or shows it to anyone. Prices are not set yet. See [pricing](https://voltecx-web.nguyenvanqui291.workers.dev/pricing). ## The assistant in a terminal The same assistant also runs outside the window, and only there: outside AI tools cannot drive Voltecx. - `powercraft-cli chat` is a chat in the terminal, and `powercraft-cli chat -p "..."` answers one message from a script. - Whatever it builds, a part added without a spot never lands on another (it takes the nearest free spot), overlaps show in Problems with a one-click Move apart, `schematic.tidy` moves the controller out of the power stage and carries its signals by net label, and `schematic.metrics` lets the assistant check the drawing has no overlaps before it says the circuit is done. In the terminal the assistant reads and writes files only inside the folders you name. Without them it can reach no file at all. ## Limits - The assistant can misunderstand you, and it can be wrong. Check what it proposes the way you would check a colleague's change. - The automated tests of the assistant panel use a scripted model, not the live API. - The browser version has no assistant. - The assistant is a Pro feature. A cloud-hosted assistant with AI credits is planned and not available yet. See [pricing](https://voltecx-web.nguyenvanqui291.workers.dev/pricing). --- # Works with your LTspice, SPICE and other simulator files URL: https://voltecx-web.nguyenvanqui291.workers.dev/features/file-compatibility/ Your existing circuits are worth more than any new tool. Voltecx supports many formats. It opens them, tells you exactly what it could not map, and, for LTspice and several other formats, writes your changes back into the original file. ## What opens and what writes back | Format | Read | Write | |---|---|---| | Voltecx `.voltecx` (and `.pcraft` from older versions) | yes | yes. Plain JSON, so version control shows what changed | | SPICE netlist (`.cir`, `.net`, `.sp`, `.spice`) | yes | yes. Parts with no SPICE equivalent are listed as warnings | | LTspice schematic `.asc` | yes (beta) | yes, back into the same file | | Files from other simulators | yes (beta) | depends on the format. Where Voltecx cannot write a format, **File > Save** asks for a new `.voltecx` file | ## Write-back that keeps your project clean The imported file is kept inside the circuit. When you edit and export, Voltecx changes only the lines your edits touch. Change one value and one line changes. A file you did not edit comes back byte for byte. On a set of public sample files, **all 332 LTspice files and all 122 files in the other supported write-back format** came back byte for byte, with no crash in 699 files (measured on 2026-10-15). Net labels go both ways: LTspice `FLAG`s and the named-tag blocks of other simulators become labels, and labels you add or rename are written back. ## LTspice files in detail - `.include`, `.lib` and `.asy` symbol files are followed, relative to the file, with a symbol search path for libraries. - Directives are read: `.step`, `.ac`, `.op`, `.dc`, `.tf`, `.meas` and `.options`. `analysis.runImported` runs what the file asked for without editing the circuit. - `Rser`, `Lser` and `Rpar` become winding resistance, ESR, ESL and core loss. PWL sources import as PWL sources. - Files saved in the Windows code page or as UTF-16 are read and written back in the same encoding. Read the [migration guide](https://voltecx-web.nguyenvanqui291.workers.dev/guides/migrate-from-ltspice). ## Files from other simulators Schematics from other simulators open with their parts placed where they were and the wiring rebuilt from the drawing. Control code written in a C block is not run when the format cannot carry it across; the code is kept with the circuit, with a comment that names the net on each pin, so you know what to rebuild. Parts that were not mapped are listed in the Problems panel, most important first. Read the [guide for switching from another simulator](https://voltecx-web.nguyenvanqui291.workers.dev/guides/switching-from-another-simulator). ## Boards in other PCB tools The KiCad project Voltecx exports is also how a design reaches other PCB tools: many of them import a KiCad 8 project. The folder stands on its own, with every symbol defined in the schematic, footprints named by their KiCad library id and no path from your computer. Read [Open a Voltecx board in another PCB tool](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/09-import-export/#open-a-voltecx-board-in-another-pcb-tool). ## Honest limits - Another PCB tool's KiCad importer may skip custom design rules; check high-voltage clearances there. - Nothing was opened in another tool to test the write-back. The guarantees come from the file format rules and tests on public sample files. - In LTspice files, rewiring a symbol or changing its orientation is reported, not written. In some other formats, edited connections lose their drawn bend points. - Import says which parts were not mapped. Read the warnings before trusting a converted circuit, and run `circuit.explain` to check the topology. - Many files that do not simulate rely on variables defined outside the file, such as a missing include or a MATLAB script. ## Trademarks LTspice is a trademark of Analog Devices, Inc. Other product names are trademarks of their owners. Voltecx is an independent product, not affiliated with or endorsed by them. Names are used only to describe file compatibility. --- # Everything is a command you can script URL: https://voltecx-web.nguyenvanqui291.workers.dev/features/automation/ Every action in Voltecx is a named command: `circuit.addComponent`, `simulation.run`, `analysis.acSweep`, `design.auto`. The menus, the command palette (Cmd+K), the command line, Python and AI assistants all call the same list of more than 170 commands. A new feature cannot ship without being reachable from all of them. ## The command line `powercraft-cli` runs the engine without a window. ```sh # Open the buck example, simulate it with the fast solver, measure after 3 ms powercraft-cli run \ --cmd file.openExample --params '{"name":"buck"}' \ --cmd simulation.run --params '{"solver":"fast"}' \ --cmd scope.measure --params '{"signals":["v(out)","i(L1)"],"t0":"3m"}' \ --out buck.voltecx ``` Each command prints one line of JSON. `powercraft-cli commands` lists them all. `powercraft-cli convert` converts between formats, and `powercraft-cli sim` runs a saved circuit and checks numbers against limits, with an exit code your build system can read: ```sh powercraft-cli sim pol.voltecx --tend 5m \ --expect 'mean(v(out), 4m, 5m) in 3.2..3.4' \ --expect 'pp(v(out), 4m, 5m) < 0.05' ``` That makes a converter design something you can test in continuous integration, like code. Lab data goes in the same way. With a folder allowed, a scope export is named by its path, with no escaping: ```sh powercraft-cli run --in pol.voltecx --root lab \ --cmd simulation.run \ --cmd file.importMeasurement --params '{"path":"scope.csv","map":{"v(out)":"CH1"}}' ``` *In the next release.* With `--root DIR`, a file opened with `--in` from that folder is saved back by `--cmd file.save`, and a command that needs a simulation first (a BOM, the scope's measurements, the stresses) says so in its error instead of stopping the chain without a reason. ## Python and Jupyter The `powercraft` Python package runs any command by its id and returns waveforms as NumPy arrays, or a pandas DataFrame. ```python import powercraft s = powercraft.Session() s.execute("file.openExample", {"name": "buck"}) s.run(solver="fast") w = s.waveforms(["v(out)", "i(L1)"]) print(w["v(out)"].max()) ``` ## Scripts, batches and background jobs - **Tools › Scripting** runs a text file of commands as one undo step, with `for` loops, `if`/`else`, `set` for arithmetic and `break`. A script that sweeps the switching frequency can stop at the first point whose ripple meets the target. Every script ends: at most 10,000 steps and 10 minutes by default, checked before and while it runs. [Example and limits](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/13-tools-menu/#scripting). - **Tools › Parameter Sweep** runs many cases. - Long work runs as a background job with progress and cancel (`job.start`, `job.status`, `job.cancel`). ## Servers for agents and tools - `powercraft-cli serve` speaks JSON-lines over stdio. - Every command has a JSON Schema. - The desktop app opens a token-protected local channel with `--control`, so a test or an assistant can drive the running window and take screenshots. File access is limited to the folders you allow. Without them, nothing outside reads or writes a file. ## Files that diff A `.voltecx` file is plain JSON that keeps numbers bit for bit, written the same way every time: saving an unchanged circuit changes no byte, and changing one value changes one line. Put it in version control and a diff shows what changed. `file.diff` compares two versions of a circuit, two runs of the Run History, or a file with the circuit you have open, including LTspice, SPICE and imported files from other simulators. **File › Compare With File** draws the two schematics side by side, with added parts green, removed parts red and changed ones amber, and every change listed before and after. In a terminal, `powercraft-cli diff a.voltecx b.voltecx` prints a line per change, and it works as git's diff driver, so `git diff` and `git difftool` show circuit changes instead of JSON lines: ```sh git config diff.voltecx.command 'powercraft-cli diff' printf '*.voltecx diff=voltecx\n' >> .gitattributes ``` See the [AI assistant](https://voltecx-web.nguyenvanqui291.workers.dev/features/ai-assistant) for the assistant inside the app. --- # From control model to C code URL: https://voltecx-web.nguyenvanqui291.workers.dev/features/code-generation/ When the controller is digital, the model should lead to code you can put on the microcontroller. Voltecx generates C from the same blocks you simulated, and tells you what it did not generate. ## Portable C99 from your control blocks **Tools › Code Generation** turns the sampled control blocks of a circuit into two files, a header and a source. The code has no `malloc` and no global variables: call `_init()` once and `_step()` at every sample. Choose `float` or `double`. Covered blocks include gains, sums, limiters and comparators, the Clarke, Park and dq transforms, SVPWM, ADC and zero-order hold, discrete transfer functions, FIR and IIR filters up to 32 taps, discrete integrators, and discrete PI and PID with anti-windup. Blocks that are not generated (PWM carriers, continuous blocks, time sources, logic) are listed in the reply with the reason. Nothing is guessed. A signal that crosses between generated and non-generated blocks becomes a field of the input or output structure. ## Microcontroller targets | Target | What is added | |---|---| | `stm32g474` | TIM1 PWM with complementary output and dead time (a three-phase PWM on channels 1 to 3, a second phase-shifted bridge on TIM8), ADC1 triggered by the timer, and the interrupt that runs the controller and writes the duties | | `f28379d` | ePWM1 with dead band (a three-phase PWM on ePWM1 to ePWM3, a second phase-shifted bridge on ePWM2, synchronised by ePWM1), ADC-A started by SOCA, the interrupt, a `main`, and a Code Composer Studio project spec | Timer counts follow the circuit's PWM and dead-time blocks. The dead time is rounded up to whole timer counts, so it is never shorter than in the model. ## Fixed point and software in the loop `design.digitalize` turns a compensator into a 2p2z or 3p3z difference equation (Tustin with prewarping, or matched poles and zeros), rounds the coefficients to `float32`, `q15`, `q31` or a format such as `q7.24`, and reads the loop gain again with the rounded coefficients, the computation delay and the PWM delay. You see the phase margin the firmware will really have. With `apply`, the compensator goes into the circuit as a `ztf` block holding the stored coefficients, with the analog block's output limits and anti-windup, so the simulation, the spec check, the exported C and both in-the-loop tests run one controller: the one the MCU will run. `q15` and `q31` choose the integer bits that hold every constant of the code, so a 3.3 V reference and the coefficients share one format and the export writes the stored integers exactly. In automatic design, the firmware and its software-in-the-loop files come out with the rest of the hand-off, next to the report. ## See what the real controller computes Add a UART log to the generated code and read the capture back with `debug.serialLog`, next to the simulated signals. Frames carry a step counter and a CRC, and the logger never waits for the UART. ## How it was checked, and what to do next The tests run the generated assignments against the simulator's own block evaluation, and they agree to 1e-9. Compile the code with your own toolchain and check it against your simulation before you rely on it. --- # Errors that take you to the part, and a scope that keeps up URL: https://voltecx-web.nguyenvanqui291.workers.dev/features/debugging-and-scope/ Most of the time in simulation goes to finding what is wrong and looking at the answer. Voltecx shortens both. ## Click the error, land on the part A failed run names the part or net that caused it, even when it sits inside a subsystem: a singular matrix at a capacitor, a floating node, a source loop. The console and the assistant panel show a link, **Show the part on the schematic**. It enters the subsystem, selects the part and highlights the net. Scripts get the same place in the `where` field of the problem. ## Waveforms while it runs The scope draws a simulation as it goes, about four times a second, thinned to the width of the plot. The time axis spans the whole run from the first moment, so the traces grow from left to right like a scope sweep. Run and Cancel work as before, and the preview changes neither the run nor its result. When the run ends, the finished result takes over. ## Long runs stay smooth The scope keeps an index of each signal it shows, so panning and zooming a run of millions of samples draws only what fits on the screen. The extremes, mean and RMS are the same as a scan of every sample would give. ## One set of gestures *In the next release.* The schematic and the scope's plots answer the mouse the same way. A trackpad's two-finger scroll pans and a mouse wheel zooms, with no setting to change; Space-drag or a middle drag pans; Cmd-drag on empty space zooms to the box you draw; a double click on empty space fits everything; the right button only opens the menu. The pointer shows what a drag will do over a part, a pin or a wire, and the status bar says it in words. ## Several references on one plot **Keep as reference** keeps the latest run on the scope, and you can keep up to 8 of them: each is drawn dashed under the next runs in a colour and dash of its own, named in the legend (`v(out) · Ref 1`), and shown, hidden, renamed or removed from the toolbar's **References** list. A reference is a tagged run of the run history, so it is saved with the circuit and measured against the latest run without a second copy. Scripts use `scope.references`. [How it works](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/05-scope/#reference-traces). ## A signal list in groups *In the next release.* The scope's signal list sorts the run's signals into Voltages, Currents, Control signals, Losses & energy, Thermal, Math, References and Imported, each with its count. The kind comes from what a signal measures, so a meter's output lands with the voltages or currents whatever its net is called. Click a header to close a group, right-click it to show or hide the whole group, and type in the filter to open every group with a match. The signals inside a subsystem sit in a closed sub-group of their own. [Choosing signals](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/05-scope/#choosing-signals). ## Cross-probing between schematic and scope *In the next release.* Select a part or a wire and the traces that read it turn bold: `i(L1)` for L1, `v(out)` for net `out`, and any math signal computed from them. The other way round, the ⌖ button on a row of the signal list selects the part or net that signal reads and zooms the schematic to it, and a click on a legend entry selects it too. Agents get the same mapping from `waveform.source`. [How it works](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/05-scope/#cross-probing). ## A scope you can read at a glance *In the next release.* Each plot labels four to eight round values on its y axis, with light gridlines between them, and its time axis ends where the data ends. Hover a plot to read the time and every trace's value at the nearest sample. A switching trace over thousands of cycles is drawn as a light envelope (thin max and min lines, the cycle average bold) with a note that says so; after such a run the plots open on its last 5 periods under an overview strip of the whole run, and **Zoom to 5 Cycles** shows five periods anywhere in one click. [How to read the scope](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/05-scope/#reading-a-value-and-a-dense-trace). The scope's toolbar keeps the tools of almost every run in its row (zoom to fit, zoom in and out, autoscale, cursors, the measurement picker) and the rest under **…** in four named groups (Zoom, Cursors, Plots, Export), and every icon, there, in the main toolbar and in the activity bar, says on hover what it is called, its key and what it does in one line. Stacked plots are named **Plot 1**, **Plot 2**, and a small FFT icon in each plot's header turns that plot into its spectrum. ## Waveforms for MATLAB, Python and LTspice Besides CSV, the scope writes its signals as a MATLAB MAT-file or an LTspice binary `.raw`, from its Save dialog or with `scope.export`. MATLAB and `scipy.io.loadmat` read the MAT-file, with time in double precision, each signal as a column under a MATLAB name (`v(out)` becomes `v_out_`) and the original names alongside; LTspice and its Python readers open the `.raw`. For the buck example's 13 signals at 80001 points, the CSV is 10.7 MB and either binary file 4.80 MB. File > Import Measurement reads both back, and HDF5 is not written. [Example and limits](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/05-scope/#example-the-buck-example-as-csv-mat-file-and-ltspice-raw). ## Lab captures from logic analysers and USB scopes *In the next release.* File > Import Measurement opens a sigrok session (`.sr`), the file PulseView saves from cheap logic analysers and USB scopes. Each logic probe becomes a 0/1 trace (a gate signal, a fault flag) and each analog channel a trace on the capture's sample clock, laid over the simulation and compared like a scope CSV. Long captures are thinned by a whole stride, with a note. A Value Change Dump (`.vcd`) from GTKWave, sigrok or an HDL simulator opens the same way, so an MCU's PWM or an FPGA controller's run lies over the circuit. Binary captures from Tektronix (`.isf`), Keysight (`.bin`) and LeCroy (`.trc`) scopes keep their full resolution, vertical scale, unit and trigger position. [Import Measurement](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/09-import-export/). ## Measurements that say what they mean *In the next release.* Above the measurements, summary cards read the window between the cursors: the output voltage against its target, the ripple in mV and as a share of the output, the duty read from the PWM signal, and the efficiency, with the input source and the load found in the circuit. A card says OK or Check only when the Test Bench spec gives a limit. Below them, one table has a row per signal, power-stage voltages and currents apart from control signals, with mean, RMS and ripple; expand a row for its values at the cursors, min and max. Every number comes from the `scope.summary` command, so a script or an agent reads the same figures. [The measurements](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/05-scope/#summary-cards). ## Run History you can compare and restore *In the next release.* The Run History reads like a pull-request list: two quiet lines per run, a title that says what changed (`R1 1 kΩ → 2 kΩ`, `Ideal mode`, `3 changes`) and one line with the run's number, when it ran and the largest change of its key results. Click a row for every key result and every changed value before and after, tick two runs' Compare to see them overlaid with a side-by-side table, or restore a run's values in one undo step (`runs.restore`). Parts added since that run stay and are listed. ## Drag and drop Drop a file on the window and Voltecx routes it by extension, then by content: a `.voltecx` circuit opens in its own tab, an LTspice, PLECS or SPICE file is imported, and a scope CSV goes to Import Measurement. A file it cannot use is refused with a line that says why. Drag a part from the library onto the schematic and it lands on the grid point under the pointer. The manual has the details: [the scope](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/05-scope/), [problems and quick fixes](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/08-problems-and-fixes/) and [wiring](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/03-wiring-and-shortcuts/). --- # State machines, control blocks, buses, thermal parts, GaN devices, IGBT modules, controller ICs, power-IC architecture blocks and your own parts URL: https://voltecx-web.nguyenvanqui291.workers.dev/features/models-and-parts/ ## State machines with a graph A start-up, precharge, takeover or fault sequence is one `stateMachine` block instead of a tangle of gates and latches. You list the inputs, outputs, states and transitions with their guards. The **state graph** draws the states and transitions, and highlights the state that is active at the playback time, or at the end of a run. ## GaN devices and controller ICs GaN transistors (EPC2045, EPC2218, EPC2302, TP65H050G4WS, GS66508T) are drawn without a body diode, conduct in reverse through their data-sheet third-quadrant drop, and carry a dynamic on-resistance factor. The `buckGan` example is a 48 V to 12 V synchronous buck built from them. Controller ICs of the LM5145 class (voltage-mode synchronous buck) and the LM5122 class (peak-current-mode synchronous boost) are modules you place with named pins. ## Architecture blocks for power-IC design Before a power IC is drawn at transistor level, its architect chooses the control scheme with the real power stage. Voltecx has the blocks for that stage: a peak-current-mode modulator with slope compensation, a constant on-time modulator, a hysteretic modulator, a soft-start reference, a UVLO comparator and hiccup over-current protection, each a module with named pins. Each block cites the paper or application note its equations come from, and every default is a design value you set, not a part's number. Three examples close a synchronous buck through them, and the tests check each loop against its equation: the control voltage of the averaged modulator within 2 %, Ridley's subharmonic boundary, the constant on-time frequency within 2 % and its ESR stability condition, the hysteretic frequency within 10 %. Voltecx does not do transistor-level IC design: no PDKs, BSIM sign-off or layout. [The blocks and their checks](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/10-models/#architecture-blocks-for-power-ic-design). ## IGBT power modules from their data sheets The device library holds IGBT power modules: Infineon EconoDUAL 3 half bridges from 650 V to 1700 V and 300 A to 900 A, and EconoPACK 3 and EasyPACK six-packs from 25 A to 100 A, plus TRENCHSTOP 7 and 5 discrete IGBTs. Each carries the output characteristic, Eon, Eoff and the diode's Erec over current at the data sheet's temperatures, the junction-to-case (or, without a baseplate, junction-to-heat-sink) Foster chain, and the pinout of every switch position. Every value names its data sheet, revision and figure. `library.search` with `module: true` lists them, `design.parts` ranks them with the discrete parts, and a module's id on the IGBTs and diodes of an inverter gives its conduction and switching losses. ## Op-amps with a real phase margin The `opAmp` module can add a second pole set by the data sheet phase margin, the CMRR and the input bias current, so an analog compensator near the op-amp's bandwidth no longer looks better than it is. Presets for the TI TL072, OPA2171 and TLV9062 carry their data sheet values, each cited to its table row. Without these options the model stays the single-pole LM358B one, with unchanged results. ## Vendor SPICE models Pick a `.subckt`, or a `.model` card of a diode, MOSFET or BJT, from a vendor file and place it in your circuit as a subsystem with the model's pin names, in one undoable step. The vendor file stays on your disk, and encrypted models are refused with a clear message. Power-MOSFET `VDMOS` cards keep their capacitances and body diode, diode cards with `CJO` or `TT` keep their junction capacitance and recovery charge, and `LEVEL=3` MOSFET cards are read at level 3. In a 400 V, 20 A double pulse a VDMOS card gives the same turn-off energy as ngspice (202 µJ) and a turn-on energy within 8 % of it (1.10 mJ against 1.02 mJ). Whatever a card holds that is not modelled, such as breakdown or temperature coefficients, is named in a warning. [Example and limits](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/10-models/#example-a-vdmos-a-diode-and-a-level-3-mosfet-card). ## Behavioural B sources Vendor macro-models build channels, clamps and controller stages from SPICE `B` sources: a voltage or current given by a formula of node voltages, element currents and time, with LTspice's functions (`if`, `limit`, `table`, `u`, `pwr` and more). They import with the netlist or the vendor subcircuit. A source of node voltages is solved with the circuit, as SPICE does, so a MOSFET macro-model whose channel is a B source matches ngspice within 0.4 % in switching energy; a source that reads an element current follows one step late, and the import says so. `ddt`, `idt`, `delay`, `laplace` and `? :` are not supported and are named in a warning. [Example and limits](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/10-models/#behavioural-b-sources). ## Control blocks: tables, rate limits, delays and relays Besides the PI, PID, transfer-function and digital blocks, the control library has a 2-D lookup table (bilinear, held at the edges of its grid), a state-space model, a zero-pole-gain block, a filtered derivative, a rate limiter, a transport delay, a relay with hysteresis and a formula block (`expr`) of up to eight inputs, time and the circuit variables. A reference step through a rate limiter, for example, lowers the inductor-current peak of the closed-loop buck example from 7.24 A to 6.76 A. Code generation leaves out the table, the rate limiter, the delay and the formula block, and says why. [Example and limits](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/10-models/#linear-forms-tables-rate-limits-delays-and-relays). ## Buses for control wiring One wire carries a three-phase set, a dq pair or a group of gate signals. A bus mux joins up to eight signals, a demux splits them again, and a selector picks elements. Gains, sums, PI controllers, logic gates and dead times work on every element of a bus, and the Clarke and Park transforms, the three-phase PWM and SVPWM take a three-phase bus on one pin. A bus is wiring only: the circuit simulates exactly as the same drawing with separate wires, as the `inverter3Bus` example shows. Buses carry control signals only, never electrical ones. A PLECS model's vector signals import as buses when they fit, with the muxes, demuxes and selectors as bus blocks, and still write back byte for byte. [Example and limits](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/03-wiring-and-shortcuts/#buses), and [PLECS vectors](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/09-import-export/#ltspice-and-plecs-beta). ## Thermal parts from the data sheet Put a data sheet's thermal model on the schematic: a Foster table (`foster`), points read off a Zth(t) curve that are fitted to a Foster chain (`zth`), a Cauer ladder (`cauer`), and a catalogue heatsink placed by `thermal.placeHeatsink` with the data sheet's sink-to-ambient resistance at the heat it carries and the airflow. A MOSFET dissipating 2.30 W on a four-stage Foster chain and a Same Sky HSE17-252525P in still air settles at 68.74 °C junction and 67.59 °C case from a 40 °C ambient, as the analytic answer gives. A switch can stand for N paralleled devices (`nParallel`): the current is shared, the losses add up, and each device keeps its own junction on one device's Zth over N, with the heatsink shared. The Problems tab checks Foster, Cauer and Zth data (stages out of order, a curve that falls, a fit that misses by more than 5 %) and offers a one-click sort, repair or refit. None of these parts has a starting value: without its data-sheet numbers a part stops the build, and the catalogue heatsinks carry no heat capacity. [Example and limits](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/04-simulation-settings/#example-a-mosfet-on-a-foster-chain-and-a-catalogue-heatsink). ## Custom symbols Draw a symbol on the grid, bind its pins to a subsystem or a built-in part, keep it in the project or your own library, and place it like any part. A symbol only changes how the part looks: the netlist never sees it. The manual has the details: [models](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/10-models/), [devices and modules](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/06-analyses/) and [examples](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/15-examples/). --- # Licence modules, a free trial and protected blocks URL: https://voltecx-web.nguyenvanqui291.workers.dev/features/licences-and-protection/ ## Modules A licence unlocks modules: Core, Motor Drive, Digital Control, Thermal, Magnetics, Renewable & Grid, Parts & ICs, EMI & Layout, Cloud AI and Import from other formats. Core is in every tier. A part whose module you lack shows a lock badge in the library. You can still place, edit and open it; a simulation run or a gated command stops with a message that names the part and the module. ## Free trial and updates A free trial unlocks every module until it ends, with a badge that counts the days. After that Voltecx runs as Free, and your files still open. The app checks for a new version once a day with a signed request and always asks before it updates. Prices are not set yet: see [pricing](https://voltecx-web.nguyenvanqui291.workers.dev/pricing). ## Protected blocks Seal a sub-circuit with `subsystem.protect`, with or without a password. The block shows its public ports and parameters, simulates as a black box, and hides the parts inside: recordings, errors and warnings do not name them, and the netlist, native, KiCad and code exports refuse a circuit that places one. Share a block as a `.pcblock` file. The manual has the details: [install and licence](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/01-install/) and [preferences and saving](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/14-preferences-and-saving/). --- # The Test Bench, one test case at a time URL: https://voltecx-web.nguyenvanqui291.workers.dev/features/test-bench/ `spec.verify` checks every corner of a spec in one go and answers with a table. The Test Bench (**Simulation › Test Bench**, `simulation.testBench`) runs the same checks one case at a time and keeps each run's waveforms. You can look at a failing case on its own scope with the limit drawn on it, change the circuit, run that case again and put the two runs side by side. Every button is a `testbench.*` command, so a script or an assistant can do the same. ## A spec form filled from the circuit *In the next release.* The **Spec** section at the top has the same rows as the Auto Design form. Nominal input, output voltage and maximum load current go under **Required**, the other targets below them, and the temperature and loop-margin limits sit closed under **Limits**. **Use spec from Auto Design** fills it with the spec Auto Design opens with. That is the last Auto Design run's spec if there is one. If not, Voltecx reads the open converter's input, output and load current and marks those rows *from circuit*. For a closed loop the output comes from the reference, and for an open loop from the ideal duty ratio. A spec you already have as JSON goes in through **… › Paste JSON** and **Apply**. **List Cases** (`testbench.list`) turns the spec into cases and simulates nothing. *In the next release:* once the cases are listed, the Spec section folds away to give them room; click it to open it again. ## Case sections and Edit as JSON *In the next release.* Under the Spec rows, **Test Bench cases** holds the sections the Spec section has no rows for: - **Start-up** sets the longest start-up time and the largest overshoot, and adds the start-up case. - **Hold-up** sets the hold-up time and the lowest input voltage, and adds the hold-up case. - **Line step** sets the step's from and to voltages, the largest deviation and the longest settling time. `spec.verify` checks these limits, and a mains spec gets its own line-step cases. Tick a section to add it and untick it to remove it. Every field shows its unit, so `6m` in a seconds field means 6 ms. **Circuit binding** has pickers for the input source, the load and the output net when the automatic choice is wrong. The automatic choice knows the bridge converters too: a dual active bridge, a phase-shifted full bridge or an LLC runs its cases without a binding. **Edit as JSON** opens the whole spec as JSON text, pretty-printed, so you can read or change any field, and **Apply** writes it back. The form and the JSON are the same spec: keys the form does not show are kept. ## The cases From a DC spec the bench makes one case per electrical corner (each input by each load), a start-up case at nominal input and full load, a load step at each input and a hold-up case. From `design.testPlan` it adds an over-current case, an over-voltage case, an under-voltage start case and an inrush case. A mains spec (with `vinAc`) gets AC corners read over two whole line cycles for power factor, THD and DC-link ripple, plus an AC load step, AC line steps and an AC hold-up. Test-plan steps that no simulation can show, such as a hipot test or a part check, are not cases. The reply lists them under `notSimulated` with the reason. ## Pass or fail, case by case Click a case to run it, or use **Run All** (in parallel) or **Re-run Failed** (`testbench.run` with `all` or `failed`). Each run is a background job with progress and Cancel in the status bar. Every case carries a chip: **Pass**, **Fail**, **Not measured** (the run or a reading failed; hover over the limit for the reason) or **Not run**. A ⟳ after the title means the circuit has changed since that run. The scope on the right has one plot per signal of the case, with each limit drawn on its signal. A band is a shaded area between two levels, such as the regulation band. A line is a dashed level, such as the overshoot limit or the current trip. A window is a pair of dashed vertical lines, such as the start-up time allowed. Their time axes are linked, so zooming one zooms them all. *In the next release:* all the plots open on one time range, the end of the latest trace or limit window plus 3 %. Below the plots, a table gives each limit's measured value, what is required, the margin to the nearest bound (negative when outside) and the verdict. ## Compare two runs Pick an earlier run in **Overlay** (`testbench.compare`). Its traces are drawn dashed on the same plots, and the table adds that run's measured values and the difference. The usual loop: run a case, change a part, run it again, overlay the first run. The bench keeps the last 64 runs with their waveforms, and `testbench.results` reads them back. ## Export **Export CSV** (`testbench.export`) writes one row per limit of every case, using each case's latest run. **Copy JSON** puts the cases and every run, without the waveforms, on the clipboard. ## The spec is saved with the circuit *In the next release.* The spec a circuit is designed for is saved in its file. Auto Design stores its own, and `spec.set` stores one for an example or an imported circuit. Open the file again next week and **List Cases** (`testbench.list {}`) lists the same cases, with no spec typed in again. `spec.verify`, the conducted EMI estimate and the thermal check read the same stored spec, and each reply says it did. ## How it relates to spec.verify The two use the same spec and the same benches. `spec.verify` (**Design › Automate › Verify Against Spec**) is the one-shot check that also stops each automatic design loop, and it returns one table for the whole spec. The Test Bench splits that check into cases you can run, look at and repeat one by one, and it adds the cases only it simulates: start-up, hold-up and the protection trips from the test plan. Neither edits your circuit: each case runs on a copy set to its corner. ## From a script The commands do what the buttons do. This opens the closed-loop buck example, lists the cases for a 48 V to 12 V spec, runs them all and returns the CSV text: ```sh powercraft-cli run \ --cmd file.openExample --params '{"name":"buckClosedLoop"}' \ --cmd testbench.list --params '{"spec":{"vin":{"min":44,"nom":48,"max":52},"vout":{"nom":12,"tolPct":2},"iout":{"min":2.5,"max":5},"loadStep":{"from":2.5,"to":5,"maxDroopPct":5,"maxSettle":"2m"}}}' \ --cmd testbench.run --params '{"case":"all"}' \ --cmd testbench.export --params '{"format":"csv"}' ``` `testbench.compare {"a":"tb1","b":"tb2"}` then compares two runs by their ids. At bring-up, `testbench.measure {"case":"corner-48V-5A","csv":"…","map":{"v(out)":"CH1"}}` reads your scope export against the same case's limits, with the same readings, and keeps it as a measured run beside the simulated ones. `testbench.compare` then shows simulation, measurement and limit side by side. ## Know the limits A pass means the case meets its limit in Voltecx's models. It is not a safety or compliance result. For a mains spec, start-up from the mains and the protection trips are not simulated. More in [design tools](https://voltecx-web.nguyenvanqui291.workers.dev/features/design-tools) and [debugging and the scope](https://voltecx-web.nguyenvanqui291.workers.dev/features/debugging-and-scope). The manual has the full chapter, [the Test Bench](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/18-test-bench/), and [tutorial 11](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/11-test-bench/) walks through a failing load step, the fix and the comparison. --- # Example circuits that run as soon as they open URL: https://voltecx-web.nguyenvanqui291.workers.dev/features/examples/ Voltecx 0.9.0 comes with 61 example circuits, and the next release adds nine more. Each one is a working circuit with a known answer: open it, press F5, change a value and run it again. The examples are built in code rather than read from files, so they also open in the browser version. Each one has a category, a one-line description in English and Traditional Chinese, and the signals the scope shows when it opens. ## Three ways in - **File › Open Example** has one submenu per category. Point at an example to read what it shows. - **Help › Examples** (`help.examples`) opens a window that lists every example under its category, with its description and an **Open** button. - *In the next release:* the **Start page**, shown while no circuit is open, has four example cards, each with the waveform of its real run: the synchronous buck, the boost, the flyback and the three-phase inverter. **All N examples** opens Help › Examples. Each example opens in a new tab with the schematic fitted to the window and the scope set to that example's main signals. From a command it is `file.openExample` with the example's name, for example `{"name": "buckSync"}`. From the AI assistant or the command line the same command runs by id. ## What is in the library The examples are filed under ten categories. A few from each, including the nine of the next release listed below: - **Basics:** RC, RL and RLC step responses; relaxation, 555, Wien-bridge and Colpitts oscillators; a double-pulse test. - **DC-DC:** open- and closed-loop buck and boost, a synchronous buck, a GaN synchronous buck at 500 kHz, a buck with a thermal model, a SEPIC, a Ćuk converter, a Zeta converter, an inverting buck-boost, LED drivers (a hysteretic buck with PWM dimming, a boost with analog and PWM dimming), a CC-CV battery charger, and a USB Power Delivery source and sink (a fixed 9 V contract, then PPS in current limit charging a battery). - **Isolated:** flybacks (open loop, closed loop, and one whose loop closes through a TL431 and an optocoupler), a forward converter with a reset winding, an active-clamp forward, a quasi-resonant flyback, an LLC half bridge, a CLLC, a dual active bridge and a phase-shifted full bridge. - **Rectifiers:** half-wave, three-phase diode bridge, a phase-controlled thyristor bridge (firing angle, commutation overlap and inversion) and a Vienna rectifier. - **AC control:** a TRIAC lamp dimmer and a TRIAC heater controller. - **Inverters:** half bridge, three-phase inverters (one with dq current control and a thermal model), a single-phase full bridge with sine PWM, three-level NPC and T-type inverters, and an MMC leg. - **Motor drives:** induction motor with V/f, field-oriented and direct torque control; PM synchronous motor with field-oriented and sensorless control; a DC motor on a buck chopper; a six-step brushless DC drive; and a switched reluctance drive. - **Grid:** a grid-tie inverter with a PLL and an LCL filter, a three-phase active front end, a STATCOM and a point-to-point HVDC link with MMC stations. - **Renewable energy:** a solar charger with MPPT, a fuel-cell load step, a quasi-Z-source PV inverter that boosts by shoot-through, and wind turbines with a PM generator and a doubly fed generator. - **Power quality:** boost, interleaved and totem-pole bridgeless PFC, a shunt active power filter, a conducted-EMI bench, 24 V input protection, a surge into a varistor, a flyback RCD and TVS clamp, and a constant-power load behind an input filter. ## Recently added *In the next release.* New examples: - `sepic` turns 12 V into 12 V at a duty cycle of 0.5, with the switch node swinging to 24 V. `cuk` turns 12 V into −12 V, with smooth current at both ends. - `zeta` turns 12 V into 12 V at a duty cycle of 0.5 without inverting, with a smooth output current through its second inductor. `invertingBuckBoost` turns 12 V into −12 V through one inductor that carries the input and output current together. - `fourSwitchBuckBoost` steps 9–16 V up or down to the USB Power Delivery levels 5, 9, 15 or 20 V at 3 A with one inductor between a buck and a boost leg, and rides an input step from 9 V to 16 V from the boost region into the buck region. - `coupledBoost` is a two-phase interleaved boost (24 V to 200 V, 300 W) on one inverse-coupled inductor pair: at a duty of 0.5 the input ripple nearly cancels, and the coupling cuts each phase's ripple to about a quarter at the same leakage inductance. - `forward` converts 48 V to 12 V at 5 A with a reset winding, so the drain rises to 96 V. `activeClampForward` is the same converter with an active clamp, and its magnetising current swings evenly about zero. - `pushPull` converts 48 V to 12 V at 5 A with two switches on a centre-tapped transformer; each drain holds 96 V and an RCD clamp catches the leakage spike at about 120 V. - `halfBridgeDcdc` converts 380 V to 12 V at 20 A with a split-capacitor half bridge and a current-doubler rectifier whose two inductors cancel much of each other's ripple. - `passiveBalancing4s` is a four-cell lithium-ion pack whose cells start 10 % of charge apart; bleed resistors switched by a balancer module bring every cell down to the lowest one. - `activeBalancing4s` balances the same pack with three switched flying capacitors: charge moves between neighbouring cells and they meet at the mean charge, with almost no loss. - `inductorBalancing4s` balances it with three buck-boost stages, one inductor between each pair of neighbouring cells: the same meeting at the mean charge, with charge carried by inductor current instead of capacitors. - `packThermal4s` runs four LiFePO4 cells at 10 A, each cell's losses warming a measured two-node model of its core and can; after 10 minutes the core is 1.9 K hotter than a sensor on the can would read. - `agedPack4s` discharges four 75 Ah cells aged 300 days at 1 C; the one that aged 10 K hotter has 13.5 % less capacity, empties first and strands the charge left in the other three. - `qrFlyback` (325 V to 12 V at 2 A) turns on in the first valley of the drain ringing, at about 226 V instead of 426 V. - `activeClampFlyback` (375 V to 20 V at 5 A) recycles the leakage energy through a clamp switch and turns its main switch on at zero voltage; the drain peaks near 504 V. - `cllc` moves 2 kW between two 400 V sides through two SiC full bridges switching together at the resonant frequency. - `threePortDab` joins a 400 V source, a 200 V battery and a 100 V load through three full bridges on one transformer core; two phase shifts split 6.3 kW between charging the battery and feeding the load, and a negative battery phase shift discharges it. - `threePortDabClosedLoop` closes a battery current loop and a load voltage loop on those two phase shifts: the battery goes from charging to discharging at 1 kW while the 2 kW load stays at 100 V. - `threePhaseDab` moves 10.4 kW from 800 V to 400 V through two three-phase bridges on a wye-wye transformer at a 30 degree phase shift; a negative shift sends it back. - `solidStateTransformer` turns the 230 V mains into an isolated, regulated 200 V at 1 kW: a power-factor corrected 400 V link, then a 20 kHz dual active bridge whose output loop sets the phase shift. - `solidStateTransformerAc` goes on to AC: an inverter on the isolated bus makes 115 V, 50 Hz at 1 kW, so the mains reaches the load through the 20 kHz link. - `wptSeriesSeries` is a wireless power transfer link at 85 kHz: two loosely coupled coils (k = 0.2), each tuned by a series capacitor, carry 100 W across an air gap, and the output current stays the same when the load changes; a parameter sweep on `k` shows the link efficiency falling from about 96 % at k = 0.2 to 93 % at k = 0.1, as the analytic curve says. - `wptSeriesParallel` tunes the secondary coil with a parallel capacitor instead: the output becomes a voltage source, about 65 V whatever the load, and the primary capacitor is tuned to `L1·(1 − k²)` so the bridge still sees a pure resistance; its efficiency against `k` follows the analytic curve too. - `wptRobotDock` charges a mobile robot's 13S4P lithium-ion pack over a series-series link at 85 kHz with no converter on the robot: the link itself holds the charge current at 4.7 A whatever the pack's voltage, and shows why a dock must back off when the robot parks off its pad, since the current grows as the coupling falls. - `wptEvCharger` charges an electric car's 96S20P lithium-ion pack at 3.3 kW, the WPT1 class of SAE J2954, over a double-sided LCC link at 85 kHz: the ground pad's current does not depend on the car, and misalignment lowers the charge current instead of raising it. - `electrolyzerInterleavedBuck` feeds a 200-cell electrolyzer stack 1.27 kA from a 1 kV link through four buck phases a quarter period apart, each on its own average-current loop so they share the current evenly; the summed ripple is a quarter of one phase's, as the interleaving formula says. - `electrolyzerAfe` is the whole active-front-end electrolyzer supply: an IGBT bridge draws 0.51 MW from a 690 V grid at unity power factor into a 1.1 kV link, four interleaved buck phases feed the stack 1.27 kA, and the line current passes even the strictest row of the IEEE 519 harmonic limits. - `tTypeInverter` is a three-level T-type inverter on a split 800 V link that makes 624 V peak line to line into an 8 kW load. - `fourLegInverter` keeps three 230 V phases balanced on a 100/50/20 % load with a fourth leg driving the neutral by carrier-based 3D space-vector modulation, and turns into a three-leg inverter with a floating or split-capacitor neutral by one variable for comparison. - `chbInverter` is a five-level cascaded H-bridge inverter: two cells on isolated 400 V sources with phase-shifted carriers make 720 V peak, with the first harmonics at four times the 2.5 kHz switching frequency. - `matrixConverter` turns a 400 V, 50 Hz supply directly into 30 Hz at half the voltage with nine bidirectional switches and Venturini's modulation, with sine input currents behind an LC filter and never two switches of an output on at once. - `switchedCap` steps 48 V down to 12 V at about 200 W with no inductor: three flying capacitors and ten switches on two clock phases, with an output resistance that follows the Seeman-Sanders estimate as the capacitors or the clock change. - `threeLevelBoost` boosts a 300 V PV string to a split 800 V link with two switches that each block only 400 V, an inductor ripple at twice the switching frequency, and a loop that keeps the two link capacitors equal when their loads differ. - `totemPolePfc` is a 1 kW totem-pole bridgeless PFC with a GaN half bridge at 65 kHz. - `bridgelessPfc` is a 400 W dual-boost bridgeless PFC: two boost inductors, two switches on one gate and two slow diodes. - `srmDrive` drives a three-phase 6/4 switched reluctance machine from 48 V with current chopping at 8 A. - `dcMotor4q` is a four-quadrant dc drive: a maxon RE 40 on a 24 V H-bridge reverses between ±400 rad/s with cascaded speed and current loops, regenerates into a link behind a blocking diode, and a brake chopper clamps the bus below 28 V. - `zvtBoost` is a zero-voltage-transition boost, 200 V to 400 V at 500 W and 200 kHz: an auxiliary switch and a resonant inductor ring the switch node to zero before the main switch turns on, and `zvt = 0` runs the same circuit hard-switched for comparison. - `lccHvdc12Pulse` is a twelve-pulse line-commutated HVDC link scaled down to 400 V grids: the rectifier steps its DC current from 8 A to 10 A by firing angle while the inverter holds an 18° extinction angle, and the supply current keeps the 11th and 13th harmonics but not the 5th and 7th. - `svcTcr` is a static VAR compensator on a weak 11 kV bus: a delta thyristor-controlled reactor and a tuned capacitor bank, whose firing angle a PI moves to hold the bus at 11 kV when an inductive load switches in. - `amrRobotSystem` runs a whole mobile robot's power system over a 40 s pick-and-return task with a turn each way: a 13S pack behind its BMS's charge and discharge FETs, two wheel drives, a lift and the 24, 12 and 5 V rails, all locking out when the bus sags, with the energy of each consumer, each rail's efficiency and the runtime left, checked against the drive and lift equations. - `amrRail12Gan` switches that robot's 12 V rail as a 500 kHz GaN buck next to its averaged model, so you can see what an average leaves out: the inductor ripple and the 0.14 W the switches lose conducting in reverse through each dead time. - `amrRail24Gan` does the same for the robot's 24 V actuator rail at 30 W: at half the current, the dead-time loss the average leaves out is a larger share of what the rail really loses. - `amrRail5Gan` switches the robot's 12 V to 5 V sensor rail at 8 W: at 5 V the GaN switch's reverse drop through the dead time costs 1.3 % of the power, more than on any other rail. - `amrWheelGan` drives the robot's wheel motor from a 40 kHz GaN bridge under field-oriented control, next to its averaged model: the motor's own copper loss is so much larger than the bridge's that the two agree within 0.04 %. - `robotJointServo` is a robot-joint servo: a 48 V GaN inverter at 40 kHz, an encoder and cascaded position, speed and current loops through a 50:1 gear, with each loop bandwidth checked against its design. - `regenBrake` brakes an AMR wheel into a 48 V bus whose battery cannot take charge: a brake chopper holds the DC link between 56 and 58 V, and the energy balance is checked. - `evDriveCycle` drives a mid-size electric car over the FTP-75 urban schedule from a 348 V pack: wheel energy out and back, how much braking the battery management lets back into the pack and how much the friction brakes take, the 12 V DC-DC and battery with their loads, kWh/100 km and state of charge, checked against the road-load equation over the EPA trace. All values in the examples are illustrative: they are chosen to show the circuit working, not to match a product. ## A small demo for each part `component.example` opens the small circuit that shows one library part at work, as a new laid-out circuit. In the app it is the **Open example** button of the component guide (**Help › Component Guide**, or F1 on a selected part). `file.openExample` takes the same demos as `demo:`, for example `demo:mosfet`. ## Lessons and tutorials The **Lessons** view of the side bar walks you through a task one step at a time: your first buck in 10 minutes, importing a file from another simulator, closing the loop with Voltage Loop, designing a converter from a spec, debugging with a scope CSV, and drawing your own symbol. Each step is one short sentence with the values it uses. Its button does the step for you (it places the parts, runs the simulation, or opens Auto Design filled in with the spec), **Show me** outlines the control it uses, and the lesson watches for the result: "Waiting for: …" turns into a green check, and **Next** waits for it. The same steps are commands: `lesson.list` lists the lessons, `lesson.get` returns one with its steps, and `lesson.check` checks the active circuit against a step, so a script or an agent can follow a lesson too. The [tutorials](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/) go further, in 17 chapters from the first buck to PFC, LLC, grid-tie and MMC. Each picture is a screenshot of the current build, and a test runs every tutorial's steps and checks its numbers. ## From a script Open an example, run it and list the lessons: ```sh powercraft-cli run \ --cmd file.openExample --params '{"name":"totemPolePfc"}' \ --cmd simulation.run --params '{"solver":"fast"}' \ --cmd lesson.list --params '{}' ``` `powercraft-cli run --cmd component.example --params '{"slug":"mosfet"}'` opens the MOSFET demo the same way. The manual's [examples chapter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/15-examples/) describes every example with things to try. See also [simulation](https://voltecx-web.nguyenvanqui291.workers.dev/features/simulation) and [models and parts](https://voltecx-web.nguyenvanqui291.workers.dev/features/models-and-parts). --- # Run history, checkpoints, diffs and review comments URL: https://voltecx-web.nguyenvanqui291.workers.dev/features/history-and-sharing/ A design moves through dozens of runs and edits before anyone else sees it. Voltecx keeps each run with what changed, lets you go back to any saved state, tells you exactly what differs between two versions, and keeps a reviewer's notes in the file itself. Everything below is a command, so a script or an assistant can use it as well. ## Run History reads like a commit list Every simulation is kept with what changed since the run before. **Simulation › Runs** (`runs.list`) lists the runs. You can tag a run to keep it (`runs.tag`, `runs.untag`), remove one (`runs.remove`), drop every untagged one (`runs.clear`), and compare runs signal by signal: mean, RMS, min, max and final value, with the difference from a reference run (`runs.compare`, also **Simulation › Compare Runs**). The last 10 untagged runs and every tagged run stay in memory, up to a fixed count and size, and tagged runs are saved with the circuit in a bundle (below). *In the next release.* The Run History, also the **Runs** view of the side bar, shows one card per run, newest first. A card's title is the tag you gave the run, or what changed since the run before: `Q2: ron 1.8m→3m`, `added Rstep`, or **First run**. Under the title are the run's number, how long ago it ran and its key results, each with its change from the run before (green ▲, red ▼). Re-runs with no changes fold into one line. Click a title to open the card: a table of every changed value, **Before** and **After**, plus the parts added or removed and any new connections. - **Show on scope** draws the run dashed over the latest one. - **Compare** on two cards overlays both and adds a side-by-side table of each signal's results and the difference. - **Restore** (`runs.restore`) sets the circuit's parameter values, circuit variables and simulation settings back to that run's, in one step that Undo takes back. Parts added or removed since then stay and are listed. - **Tag**, **Rename**, **Untag** and **Delete** sit on each card. ## Several reference traces *In the next release.* **Keep as reference** in the scope toolbar keeps the latest run as a reference. You can keep up to 8, each drawn dashed under every later run in its own colour and dash and named in the legend (`v(out) · Ref 1`). A reference is a tagged run, not a copy, so it is saved in a bundle and measured against the latest run like any overlaid run. The **References** list shows, hides, restyles, renames or removes them. Scripts use `scope.references` with `list`, `add`, `show`, `rename`, `style`, `remove` and `clear`. ## Undo history **Edit › Undo List** opens a tab beside Properties in the right column. It lists every undo step of the circuit, oldest first, with the current one highlighted and the undone ones dimmed. Hover over a step to see what it changed, and click it to jump there in one move; the later steps stay until the next edit. Scripts use `edit.history` (with `step`, what that step changed) and `edit.goToHistory`. ## Checkpoints A checkpoint is a named snapshot of the circuit. `checkpoint.create {"label": "sent to layout"}` takes one, `checkpoint.list` lists them with what has changed since each, `checkpoint.diff` gives that change in full, and `checkpoint.restore` puts the circuit back as one undoable step. Up to 50 are kept per circuit. The AI assistant takes a checkpoint before each turn, so every turn has a **Restore** button, and each stage of automatic design leaves one behind. ## Compare two versions `file.diff` says what changed between two versions of a circuit and opens nothing. Each side can be a `.voltecx` file, a file in another supported format, a circuit you have open, circuit or netlist text, or a checkpoint. A checkpoint's label works as a version tag: `{"a": {"checkpoint": "sent to layout"}}` compares the newest checkpoint with that label against the circuit now. The reply lists each change once: - parts added, removed and renamed (a rename is one change, not a removal and an addition); - parameters that differ, with their units (`C1.c: 1 µF → 2.2 µF`); - wiring per net, and nets that were only renamed; - circuit variables, simulation settings and subsystem definitions. Each change also comes as one sentence in English and Traditional Chinese. For the results, `bom.diff` compares two `bom.export` replies: lines added and removed, a changed part number, value, quantity, footprint or price per reference designator, and the change in total cost, pieces and board area. `spec.diff` compares two `spec.verify` replies row by row: what now fails, what now passes, what measures differently, and the verdict before and after. ## Review comments in the file Comments work as in Figma. The **Comment** tool (**Shift+C**) drops a pin with a click or pins an area with a drag, and a box opens beside the pin to type in. Point at a pin to read its first message and the number of replies; click it to open the whole thread on the schematic, reply with **Enter**, resolve it with the check mark or delete it. The **Comments** view of the side bar lists the same threads, numbered as their pins, and also pins a thread to a selected part or net or to a point on a waveform ([how it looks](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/14-preferences-and-saving/#review-comments)). The threads are saved in the circuit file, so a colleague reviews by opening the same file, with no account and no server. Every change is one undo step. **Merge Comments from File** brings in the threads and replies from a colleague's copy, and merging the same copy twice adds nothing. Scripts use `comment.add`, `comment.reply`, `comment.resolve`, `comment.reopen`, `comment.delete`, `comment.list` and `comment.merge`. ## The .voltecx file A circuit file is plain JSON that keeps every number bit for bit, so it works in version control and reads in a text editor. *In the next release:* circuits are saved as `.voltecx`, and files saved earlier as `.pcraft` open as they are. A circuit can also be saved as a bundle (`file.save {"bundle": true}`), one file that adds the last simulation result, the tagged runs and a thumbnail. On opening a bundle, the scope shows the saved result without a new run if the circuit has not changed since. A save that names no form writes a bundle when the circuit has tagged runs, so they are not lost. Runs read from a bundle keep their waveforms but not the circuit they ran on, so **Restore** does not apply to them. ## Signed saves Each save is signed with a key that belongs to your installation. The status bar shows **Signed**, **Modified after signing** or **Unsigned**, and **File › Protection › Verify Signature** (`file.verify`) shows the key, the licence id and the time. **Trust This Signer** (`signing.trust`) names a colleague's key, so their files read as signed by that name. `signing.status`, `signing.setEnabled` and `signing.untrust` do the rest. A signature shows that a file is unchanged since the holder of that key saved it. It does not show who made it unless you trust their key, and in a bundle only the circuit is signed. To share a sub-circuit that simulates without showing its inside, see [protected blocks](https://voltecx-web.nguyenvanqui291.workers.dev/features/licences-and-protection). ## From a script Run the RC example, tag the run, take a checkpoint, change R1, run again, then compare the runs and the circuit with the checkpoint: ```sh powercraft-cli run \ --cmd file.openExample --params '{"name":"rc"}' \ --cmd simulation.run --params '{}' \ --cmd runs.tag --params '{"id":"r1","tag":"1k"}' \ --cmd checkpoint.create --params '{"label":"before R1"}' \ --cmd circuit.setParam --params '{"component":"R1","key":"r","value":"2k"}' \ --cmd simulation.run --params '{}' \ --cmd runs.compare --params '{}' \ --cmd file.diff --params '{"a":{"checkpoint":"before R1"}}' ``` The manual covers [the Run History and references](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/05-scope/), [comparing versions](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/09-import-export/) and [bundles and signed files](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/14-preferences-and-saving/). See also [debugging and the scope](https://voltecx-web.nguyenvanqui291.workers.dev/features/debugging-and-scope) and [automation](https://voltecx-web.nguyenvanqui291.workers.dev/features/automation). --- # A scope built for switching waveforms URL: https://voltecx-web.nguyenvanqui291.workers.dev/features/scope/ The scope is where a run turns into answers: the output voltage against its target, the ripple of one period, the efficiency, the dead time between two gate edges. Every reading in the window is a command too, so a script or an agent reads the same numbers you see. This page covers the scope in depth. For error links, the live preview of a running simulation, binary waveform files and drag and drop, see [errors and the scope](https://voltecx-web.nguyenvanqui291.workers.dev/features/debugging-and-scope). ## Signals in groups you can fold *In the next release.* The **Signals** list sorts a run's signals by what they measure: **Voltages**, **Currents**, **Control signals** (gate signals, duties, controller outputs, flags), **Losses & energy** (`E(…)` and power meters), **Thermal** (`T(…)`), **Mechanical** (shaft and rotor signals of a motor drive), **Math**, **References** and **Imported**. Each header shows its count, and a group with nothing in it is left out. A voltage or current meter lands with the voltages or currents whatever its net is called, and a signal that feeds a PWM block's duty input lands with the control signals. - Click a header to close or open the group. Each circuit remembers which groups you closed, and a closed group still lists the signals it has on the scope, so a shown trace never vanishes from the list. - Right-click a header for **Show all** or **Hide all**. - Type in the filter box and every group with a match opens; clear it and the groups go back to how you left them. - Signals inside parts (a source's series resistance, the nets inside a subsystem) are hidden until you tick **Show internal signals**. Then each part gets a closed sub-group of its own, so a large controller does not flood the list. Already in 0.9.0: when nothing is ticked, a run picks up to four signals for you: an output voltage first, then inductor currents, then other voltages and currents. It skips flat signals and switching signals that would draw as a solid block. ## Results panel: Summary, Signals, Power, Runs *In the next release.* The panel beside the plots has four tabs: **Summary**, **Signals**, **Power** and **Runs** (with the number of runs). Summary opens with a context line (steady state, the last 5 of N switching periods, the window, the PWM duty) and one **Copy ▾** menu, then three cards in a row that read the window you are looking at (or the window between the cursors): **Output** against its Test Bench target, green with a tick or amber with **Check** when the spec gives a limit, **Ripple** as a share of the mean (over the last five switching cycles when the window holds more, so the start-up does not read as ripple), and **Efficiency** with the loss. Numbers are monospaced with smaller units. Efficiency needs no setup. The scope looks for the input (a DC source or battery to ground) and the output (a resistor or power load to ground), preferring nets named `in…` and `out…`, and shows `Pin · Pout · loss` with the parts it used. When it cannot find them, it says why and you add the pair by hand. Below the cards sits one aligned table with a row per shown signal, in two groups: **Power stage** (`v(…)` and `i(…)`) and **Control signals**, each with a dot in its trace's colour and right-aligned numbers. A 0/1 PWM signal reads `duty 26.0%` instead of a mean. Frequency and duty read under the rows of the signals that have them, never as a column of dashes. Each row's **…** menu holds the FFT, the signal's own measurements, its frequency and duty, its values at the cursors with their difference, minimum and maximum, and a copy of its row. The three latest runs follow, with **All N runs →**. **Measurements to show** picks the columns, in four groups: Basic (mean, RMS, min, max, p-p, peak and valley with their times), AC (AC RMS, crest factor, frequency, period, duty, THD), Transient (overshoot, undershoot, rise, fall and settling time with its band) and Power. **Copy ▾** puts the table as CSV or tab-separated plain SI numbers on the clipboard for a spreadsheet; the column picker and the copy buttons are in 0.9.0 already. Every figure comes from `scope.summary`, which returns the rows, the output card, the duty, the automatic power and the window in switching periods. ## Several references, each a tagged run *In the next release.* **Keep as reference** keeps the latest run on the plot, drawn dashed under every later run, in a colour and dash of its own. Keep up to 8 per circuit. A reference is not a copy of the waveforms: keeping one tags that run in the Run History (`Ref 1`, `Ref 2`, or the tag it already had), so it is saved with the circuit and measured in the **Δ vs latest** table like any overlaid run. The **References** list shows, hides, renames, restyles or removes each one; an imported bench measurement is listed there too, as **Measured**. Scripts use `scope.references` with `add`, `list`, `show`, `rename`, `style`, `remove` and `clear`. ## Duty in percent, and a second unit on the right In the **Quick** tab, voltages, currents, duties and other signals go on separate plots stacked on one time axis, so a 100 V trace does not flatten a 1 A trace. *In the next release.* A signal that feeds a PWM block's duty input is a ratio, so its axis, legend and measurement values read in percent (`24%`, not `240m`); exports and scripts keep the ratio itself. *In the next release.* **Plot 1**, **Plot 2**, … beside a shown signal moves it to the next plot, and a plot that holds traces in two units labels its left axis with the first and adds a right axis with the second, on the same scale, with each legend value in its own trace's unit. Already in 0.9.0: **Add Plot** and **Remove Plot** in the toolbar split a crowded plot or merge the lowest one into the one above. For a set of signals you look at often, the **+** tab makes a named scope that is saved with the circuit (`scope.new`, `scope.addSignal`), with up to eight y axes. ## Read a dense trace *In the next release.* Each plot labels four to eight round values on its y axis, with as many digits as the step needs, so a 105 V output with a volt of ripple reads `105V 105.5V 106V`. Move the pointer over a plot and a crosshair snaps to the nearest sample: the header reads the time and each trace's value, and every time plot shows the same moment. A switching trace over thousands of cycles would fill a solid block. The scope draws it as an envelope instead: a light fill between thin max and min lines, with the cycle average bold on top, and says **envelope: zoom in to see each cycle**. **Zoom to 5 Cycles** (**Scope › Zoom to 5 Cycles**, menu id `scope.zoomCycles`) narrows the view, about its middle, to five periods measured from the trace's repeating swing. A trace with no repeating swing in view says so instead. *In the next release.* After such a run the plots open on its **last 5 switching periods**, the steady state, readable without zooming. A thin overview strip above them shows the whole run with a box where you are looking: drag the box to move, drag its edges to resize, click to jump. **Whole run** and **Last cycles** in the plot header choose what the next run opens on (menu ids `scope.wholeRun`, `scope.lastCycles`). With the pointer over the plots, **←** and **→** page the view one window at a time and **Shift+←** / **Shift+→** one switching period. [The overview strip in the manual](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/05-scope/#reading-a-value-and-a-dense-trace). ## Cursors and measurements **Cursors** (**C** over the scope) puts two vertical lines on the plot. The readout gives both times, `Δt` and `1/Δt`, and the measurements then read between them. Put the cursors one switching period apart and `1/Δt` reads the switching frequency, while a `Δ` near zero in a row tells you the circuit has reached steady state. From a script, `scope.cursors` gives the values at both cursors, `dt`, `1/dt`, the change in each signal and the mean and RMS between. `scope.measure` returns everything at once for chosen signals and a window: statistics, THD against a fundamental, real and reactive power from a voltage and a current, duty and frequency of a switching waveform, oscillation and step-response figures. ## Math signals A math signal is computed from the others after every run and then behaves like any signal: it is listed (marked **ƒ**), plotted, measured and exported, and it is saved with the circuit. The **+** icon beside the signal filter opens `scope.addMath`; right-click a voltage and choose **Math: power v·i** for instantaneous power. Expressions use the signals as listed, SI prefixes, the usual operators and functions, and three operators over time: `ddt(x)` for the derivative, `integ(x)` for the running integral (energy from power, charge from current) and `avg(x, T)` for a moving average over `T` seconds. For example `integ(v(in)*i(V1))` or `avg(abs(i(L1)), 20u)`. When the latest run cannot compute one, the **Math** section says why. ## Power and efficiency The **Power** tab shows Pin, Pout, the loss and the efficiency found in the circuit, then adds power rows from any voltage and current (the table appears with the first row): **P** (mean of v·i), **S** (Vrms·Irms), **Q**, **Q₁** (the signed reactive power of the fundamentals) and **PF**. With two rows or more an **Efficiency** line gives η = Pout/Pin for the rows you pick. Right-click a voltage and choose **Power with** › a current for a quick row. The same figures come from `scope.power` and `scope.efficiency`. Measure over whole periods for exact figures on AC or switching signals. ## FFT, XY and logic lanes - **FFT.** The **FFT** icon on a signal row shows its spectrum over the visible window (`analysis.fft`). *In the next release:* a **Spectrum** icon in each plot's header turns the whole plot into its spectrum and back. - **XY Mode** plots every shown signal against one you pick in the **X:** list, for a phase portrait or a current against a voltage. - **Logic Lanes** draw 0/1 signals as thin logic lanes and whole-number signals with 2 to 16 levels (a state index, a counter) as bus lanes under the plots, with a state machine's state names printed in place of numbers. A cursor can snap to a lane's edges, so `dt` reads a PWM period, a dead time or the delay from a flag to a gate, and a trigger can set the view on the first rising or falling edge. [Logic lanes in the manual](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/05-scope/#logic-lanes). - *In the next release.* **Named markers and edge search.** Place as many named markers as you need (A, B, C… or your own labels); they are saved with the scope, and the readout lists the time between them. **[** and **]** move cursor 1 to the previous or next edge of a trace: a logic change, or the crossing of an analog trace's middle level. A bus lane prints its values in hex, binary, unsigned, signed or by name. [Markers in the manual](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/05-scope/#markers-and-edge-search). ## Plots in windows of their own **Open in Separate Window** (or **View › Detach Scope**) moves the whole scope into its own window, which follows the circuit tab you pick and reopens where you left it, also on a second monitor. **Scope › Plot Windows › Detach All Plots** gives each plot a window, tiled over the screen in a grid, and **Scope › Plot Windows › Tile Plot Windows** and **Scope › Plot Windows › Dock All Plots** lay them out again or bring them back. **Edit › Preferences › After each run** chooses what a run does: **Keep in the dock**, **Whole scope in one window** (the default) or **Each plot in its own window**. A run started by a script or an agent leaves the windows alone. While the results are in another window, the dock gives the canvas its space back. *In the next release:* if the Scope is the tab you picked, the dock shows one line after a run, **Results opened in the scope window · Bring to front**, so a run never lands you on an empty tab. ## Export CSV, PNG and SVG **Save Image** writes a PNG of the plots as shown or a vector SVG with axes, tick labels with units and a legend, ready for a report; **Copy Image** puts the PNG on the clipboard. **Export data** writes the shown signals as CSV, for the visible window or the whole run, at full resolution, or copies the visible window as CSV text. `scope.export` does the same from a script, with a choice of signals, window and image size. ## The same gestures as the schematic *In the next release.* The plots answer the mouse and trackpad as the schematic does: a drag pans (or draws a box with **Zoom Box** on), Cmd-drag zooms to a box, a double click fits, and the right button opens the menu. The toolbar holds the icons used most, in three groups (the rest are in the **Scope** menu), and every icon names itself, its key and what it does on hover. [The full gesture set](https://voltecx-web.nguyenvanqui291.workers.dev/features/debugging-and-scope). ## From a script Open the buck example, run it, and read one 100 kHz switching period at the end of the run: ```sh powercraft-cli run --root work --cmd file.openExample --params '{"name":"buck"}' \ --cmd simulation.run --params '{}' \ --cmd scope.summary --params '{"t0":"3.99m","t1":"4m"}' \ --cmd scope.cursors --params '{"t1":"3.99m","t2":"4m","signals":["v(out)","i(L1)"]}' \ --cmd scope.addMath --params '{"expr":"v(out)*i(R1)","name":"pout"}' \ --cmd scope.power --params '{"v":"v(out)","i":"i(R1)","t0":"3.99m","t1":"4m"}' \ --cmd scope.export --params '{"format":"svg","path":"buck.svg","t0":"3.9m","t1":"4m"}' ``` `scope.summary` (*in the next release*) finds `Vin` as the input and `R1` as the load by itself and reports the efficiency with the output card. Each command prints one JSON line. [Scripting every step](https://voltecx-web.nguyenvanqui291.workers.dev/features/automation). The manual has every button, column and option: [the scope](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/05-scope/). See also [the schematic editor](https://voltecx-web.nguyenvanqui291.workers.dev/features/schematic-editor) and [analyses](https://voltecx-web.nguyenvanqui291.workers.dev/features/analyses). --- # A schematic editor that keeps drawings readable URL: https://voltecx-web.nguyenvanqui291.workers.dev/features/schematic-editor/ A power-electronics schematic is easy to read when the power stage runs in signal-flow order, control sits in its own area and the two are joined by labels instead of long wires. The Voltecx editor is built around that drawing style: grounds are local, signals travel on net labels, a controller is one block with named pins, and one command tidies a drawing that has grown untidy. Every edit is an engine command and one undo step, so a script or the AI assistant edits the schematic the same way you do. ## A part library you can search The library groups the parts by kind: Sources, Sensors & meters, Passives, Switches & diodes, Magnetics, Machines & mechanical, Control, Thermal and Other, then the Device models. Type in the search box and the groups give way to one list of matches, found by type name or display name, in English or Traditional Chinese. A rating such as `30 V` or `40 A` narrows the device models to that voltage class, or to at least that current. Click a part to place it in free space near the middle of the view, drag it onto the schematic, press its key with the pointer over the canvas (**R**, **L**, **C**, **D**, **G**, **V**, **I**, **S**, **M**, **T** in the Classic keymap a new installation starts with) and click where it goes, or use the **Insert** menu or the **Parts Bar** (**View › Parts Bar**). A new part starts with a typical value for each value it needs, so a circuit simulates as soon as it is wired. An IC goes in as a module with named pins (`ic.place`). ## Placement that never stacks symbols *In the next release.* A part added without a chosen spot, from the library, a script or the assistant, takes the nearest free grid spot with room around it. The placing commands take `overlap`: `shift` moves the part to free space, `refuse` fails and names both parts, `allow` keeps the spot. If two symbols do end up on top of each other, the Problems tab warns and its fix moves one apart. `schematic.metrics` reports overlaps, wire crossings, wire length and the share of nets drawn as labels. ## Wiring Press **W**, or press on a pin and drag, then let go on another pin or on a wire to join its net; a dot marks every junction. Wires follow their parts when you move them. Drag a wire to put a corner in it, and **Straighten Wire** in its right-click menu removes the corners. Hover a wire to light up its whole net and see its name and pin count. Dropping a part so that a pin lands on another pin connects the two. Right-click a pin for **Disconnect Pin**; delete a wire and the net splits only where it has to. ## Net labels and local grounds A net label names a net at a pin: two pins with the same label are one net, with or without a wire between them. Press **N** over a pin, or use the **Net Label** tool. `schematic.addLabel` places one of kind `net` (keeps the wires), `goto` or `from` (control signals drawn as flags), `rail` (a power rail symbol) or `port`. **Draw Net as Labels** and **Draw Net as Wires** in a wire's or label's right-click menu switch how a whole net is drawn (`schematic.labelNet {"mode":"labels"}`). **Circuit › Layout › Auto Label Long Nets** (`schematic.autoLabel`) draws every net whose wire is 20 grid units or longer as labels, and with `names` gives editor-made nets short names such as `VIN`, `SW`, `VOUT`, `GATE_H`. Switching a net between wires and labels never changes what is connected. Ground is local by default: every grounded pin gets its own ground symbol, and no ground wire runs around the page. A rail net shows its rail symbol at every pin the same way. ## Subsystems and blocks **Circuit › Subsystem › Create Subsystem** (**Cmd+G**, `circuit.createSubsystem`) turns the selected parts into one block; the nets that cross the boundary become its named pins. Double-click the block (`circuit.enterSubsystem`) to edit inside it; a breadcrumb bar shows where you are. *In the next release:* the bar starts with a **‹ Back** button that shows its key, **Esc**, and the first time a hint says how to get out. A big subsystem then opens at a zoom where its labels stay readable; when it is larger than the canvas, the view starts at its top-left corner, where the signals come in. *In the next release:* definitions can declare parameters, so one subsystem serves instances with different values. *In the next release.* **Circuit › Layout › Group into Blocks** (`circuit.groupBlocks`) groups a whole converter at once by design step: POWER_STAGE, EMI_FILTER, PROTECTION, SENSING, CONTROLLER and GATE_DRIVE. The top level then shows the sources, blocks and loads in power-flow order, with sensing, controller and gate drive in a row underneath joined by net labels, and each block's key values above it (`L1 22µH · PWM 100kHz`). Without `apply` the command only returns the proposal. Applied, it is one undo step, the flattened netlist is checked to be identical, and probes and scope signals follow the parts (`i(L1)` becomes `i(XPWR.L1)`). ## Several sheets, one netlist *In the next release.* A flat design can be drawn over several sheets: the power stage on one, its control on another, the auxiliary supply on a third, joined by net labels the way a real converter is drawn. **Circuit › Sheets › Add Sheet** (`schematic.addSheet`) adds one, tabs under the canvas switch between them, and **Move to Sheet ›** in a part's right-click menu (`schematic.moveToSheet`) moves the selection. A net that ends up on two sheets is drawn with labels on both. Sheets are only a drawing: the netlist and the simulation are the same however the parts are spread. **File › Print** writes one page per sheet, each with its own title. The sheets go to KiCad as a hierarchy. **File › Export › KiCad project** (`file.exportKicad`) makes sheet 1 the top `.kicad_sch`, with a named sheet box for each other sheet, and writes each other sheet to its own file beside it. The pins carry global labels, so the nets join across the files. Opening the top file with `file.importKicad` puts every part back on its sheet, and a renamed sheet 1 keeps its name, carried in the title block because KiCad's top sheet has none. Read [Open a KiCad schematic](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/09-import-export/#open-a-kicad-schematic). ## Tidy, lay out, annotate - *In the next release.* **Circuit › Layout › Tidy Schematic** (`schematic.tidy`) moves control parts out of the power stage, separates overlapping symbols, gives each grounded pin its own ground symbol, and draws as labels every signal that reaches a power part, runs through the power stage or is 20 grid units or longer. With three or more control parts it offers a subsystem for them without making one. Only positions and how nets are drawn change. - **Circuit › Layout › Auto Layout** (`schematic.autoLayout`) places and turns every part like a textbook schematic: source on the left, the series path on a top rail, shunt parts down to ground, meters beside what they measure, control blocks above by signal flow. It suits ladder-like power stages and is a starting point; Tidy and your own moves finish the drawing. - **Circuit › Layout › Annotate Designators** (`schematic.annotate`) renumbers designators in reading order, so R1 is the top-left resistor. Names like `Vin` or `Rload` stay, and pins, labels, probes and expressions follow. *In the next release:* annotate only the selection, start at a number (R101), go column by column, keep locked designators, and preview the old → new list first. Each is one undo step and leaves the netlist as it was. ## Find and replace *In the next release.* **Cmd+F** finds parts by name, kind or value, and nets by name. Its Replace row (**Edit › Find and Replace**, `edit.replace`) changes a value such as `100u` to `220u`, a part-name prefix such as `R` to `RS`, or a net name such as `out` to `vout`, in one undo step. Labels, probes, scope signals and expressions follow a renamed part or net. The count shows how many changes **Replace All** will make before you press it, and a duplicate or invalid name is refused before anything changes. ## Big circuits at every zoom *In the next release.* Part names stay at least 11 points high at every zoom. Below 50 % the values and pin names are left out, below 30 % each subsystem is drawn as one box with its name, and below 15 % only shapes and subsystem boxes remain. On a level with more than 60 parts the minimap shows by itself; **View › Minimap** turns it off, and **Edit › Preferences › Minimap on large circuits** turns the automatic minimap back on. ## Classic keymap *In the next release.* **Edit › Preferences** and **Help › Keyboard Shortcuts** have a **Keymap** list. **Classic** is for engineers used to other power-electronics simulators: one plain letter places a part (**R**, **L**, **C**, **D**, **G**, **V**, **I**, **S**, **M** for a MOSFET, **T** for an IGBT), **W** wires, **N** labels a net and **Cmd+R** (Ctrl+R) rotates. In every keymap, the Rotate and Flip keys turn a part on the pointer before you click to put it down; Esc or a right-click cancels it. Switching is one step that **Undo** reverses, and keys you change afterwards stay on top. **Edit › Preferences › Input and shortcuts** lists every key, so you can change one in place: a key another command already has is refused, and the message names that command and its menu. Engineers coming from KiCad or Altium Designer can pick the **KiCad** or **Altium** keymap instead: **L** labels a net and **A** picks a part as in KiCad, **PgUp**, **PgDn** and **F9** zoom and run as in Altium. [The keymaps side by side](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/03-wiring-and-shortcuts/#keymaps). ## Pan and zoom like Figma *In the next release.* Two fingers on a trackpad move the view, and **⌘-scroll** (Ctrl-scroll) or a pinch zooms about the pointer. **H** picks the Pan tool, whose left drag pans; **V** goes back to Select; hold **Space** to pan in any tool. A mouse wheel still zooms by default (**Edit › Preferences › Scroll wheel**), and **Shift**+wheel pans sideways. The DC source's key is now **Shift+B**. [Every key](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/03-wiring-and-shortcuts/#moving-around). ## Select, edit together, align Drag on empty space for a selection box; drawn left to right it selects the parts wholly inside it. *In the next release* a box drawn right to left is dashed and selects every part it touches. *In the next release* the box is translucent, so the parts under it stay visible. **Shift** adds to the selection. Move, rotate (**R**), mirror (**X**, **Y**), duplicate or delete the whole selection in one step. With several parts of one kind selected, **Properties** shows their **Shared parameters**: a field that shows the common value edits them all, and an empty field means they differ. With two or more parts selected, the right-click menu has **Align** (left, centre, right, top, middle, bottom), and with three or more, **Distribute Horizontally** and **Distribute Vertically** (`circuit.align`). Shifts are whole grid units, so pins stay on the grid. ## Properties in its own tab *In the next release.* The right column has two tabs, **Properties** and **Chat**. Selecting a part opens it on Properties, and the view shifts so the part you clicked stays under the pointer. Each parameter has a readable name with its key under it, its unit and a small **?**: hover it for the first sentence of the description, click it to open the component guide at that row. As in 0.9.0, losses, parasitics and data-sheet values wait under **Advanced (N)**, and any of them that is set shows among the first ones. ## Your own symbols **Library › Editors › Symbol Editor** draws a part symbol of your own: lines, boxes, arcs, circles, polygons (filled or not), text and pins on a snapping grid. *In the next release:* the **Select** tool picks a shape or pin and moves it, and edits a pin's name, number and side; parts drawn with the symbol redraw at once. Bind it to a subsystem or a built-in part kind, place it like any part, or start from the selected part. Save it to your library or export it as a symbol file. A symbol only changes the drawing; the netlist never sees it. Scripts use the `symbol.*` commands, from `symbol.new` and `symbol.draw` to `symbol.bind` and `symbol.place`. ## Notes, title block and export The **Text** tool (**T**) puts a note on the schematic, with several lines, a size and a colour. `schematic.setTitleBlock` stores the author, date, revision and company for the title block, so every printed sheet and the KiCad export say the same. `file.exportSchematic` (command palette, **Cmd+K**) writes the drawing as SVG, PNG, PDF or LaTeX (`tex`, circuitikz). With `page` it goes on an A4 or Letter sheet with a frame and the title block; the frame is lettered with zone references as in KiCad or Altium (rows A, B, C… from the top, columns 1, 2, 3… from the left, 50 mm fields from the sheet's centre lines as ISO 5457 lays them out), so a reviewer can point at "Q1 in B3", and `subsystems` adds a sheet for the inside of each subsystem. The SVG and PDF typeset every label and note for a report; the PNG letters them too, in a small pixel font, so a picture pasted into a chat or an issue still names every part. **File › Print** writes a black-on-white sheet ready to print. *In the next release:* on the desktop it opens the system's print dialog on the sheet, and **File › Export › Schematic** saves it as an A4 PDF. ## Clear in a narrow window *In the next release.* Every icon in the main toolbar and the activity bar names itself, its key and what it does on hover. In a window narrower than 1280 points, the library starts folded to its icons and the Properties column opens as a drawer over the edge of the canvas, so the drawing keeps its width. Side bars are at most 360 points wide, and the bottom dock runs the full width of the window. ## From a script Tidy the closed-loop buck, check the drawing, renumber it and export a titled A4 sheet: ```sh powercraft-cli run --root work --cmd file.openExample --params '{"name":"buckClosedLoop"}' \ --cmd schematic.tidy --params '{}' \ --cmd schematic.metrics --params '{}' \ --cmd schematic.annotate --params '{}' \ --cmd schematic.setTitleBlock --params '{"author":"Power team","revision":"B"}' \ --cmd file.exportSchematic --params '{"path":"buck.svg","format":"svg","page":"a4"}' ``` `schematic.tidy` and `schematic.metrics` are *in the next release*; `schematic.metrics` should report `overlaps: 0` before you call a drawing done. [Scripting every step](https://voltecx-web.nguyenvanqui291.workers.dev/features/automation). The manual has every key and menu: [wiring and shortcuts](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/03-wiring-and-shortcuts/), with [subsystems](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/03-wiring-and-shortcuts/#subsystems) and [Tidy Schematic](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/03-wiring-and-shortcuts/#tidy-the-schematic). See also [the scope](https://voltecx-web.nguyenvanqui291.workers.dev/features/scope) and [models and parts](https://voltecx-web.nguyenvanqui291.workers.dev/features/models-and-parts). --- # Electro-thermal simulation, from losses to junction temperature and cooling URL: https://voltecx-web.nguyenvanqui291.workers.dev/features/thermal/ In Voltecx the losses and the temperatures are solved together. Each switch and diode reads its conduction and switching loss from its data-sheet tables at the present current, voltage and junction temperature, and puts that heat into a thermal network drawn on the same schematic. The junction temperature then feeds back into the on-resistance and the loss tables on the next step. This page shows how to set up that loop, read it, start it warm and choose the cooling. [Models and parts](https://voltecx-web.nguyenvanqui291.workers.dev/features/models-and-parts) lists the thermal parts themselves. Items marked *in the next release* are merged for the next beta and are not in Voltecx 0.9.0 yet. ## The thermal path on the schematic A device heats a thermal net: set its `thermal` parameter to a net name such as `tj` or `hs`. Everything from there to the air is drawn with thermal parts: `rth` and `cth`, an `ambient` at a fixed temperature, a data sheet's Foster table (`foster`), points read off its Zth(t) curve and fitted to a Foster chain (`zth`), a Cauer ladder (`cauer`) and a catalogue `heatsink`. The two network forms behave differently, and Voltecx uses each where it is right. A Foster chain is how data sheets publish Zth(t), but its inner nodes have no physical meaning, so it adds exactly only into a side that stores no heat, such as an ambient or a heatsink without a heat capacity. Into a side that stores heat (a `cth`, a Cauer ladder or a device's junction ladder) it becomes the equivalent Cauer ladder, as a device's own junction-to-case chain does, so the case and the heatsink do not heat up at the first step. `form` forces one or the other. None of these parts has a starting value: a part without its data-sheet numbers stops the build and names what is missing. ## Losses from the data sheet A library device carries its output characteristic and its turn-on, turn-off and reverse-recovery energies over voltage, current and temperature, each value cited to its data sheet. The `inverter3Thermal` example embeds such tables for a 1200 V, 50 A class IGBT and its diode (illustrative values, not a real part) so the file simulates the same everywhere. `analysis.losses` (**Analysis › Losses**) gives each switch and diode's average loss over a window you choose, split into conduction and switching energy. The split is what tells you which change helps: a conduction-dominated device wants a lower on-resistance or more devices in parallel, a switching-dominated one wants a lower frequency or faster edges, and a device whose loss is low but runs hot wants a better thermal path. By default the switching energies count toward the loss totals only; **Draw switching loss** in the simulation settings (`switchingLossFromCircuit`) makes each switching event take its energy from the circuit, so the terminal powers and the efficiency include it. ## Where the watts go: the loss chart *In the next release.* **Analysis › Loss Chart** (`analysis.lossChart`) draws the full-load loss budget as a Sankey: the output runs straight across the top, and the losses leave the input in one lane per kind (conduction, switching, gate drive, winding copper, core, capacitor ESR, and the rest no part explains) before fanning out to the parts. Under it, one stacked bar per part, largest first. It runs `design.efficiency` itself, so no simulation is needed first. ![The loss chart of the buck example: 57.4 W in, 55.0 W out and 2.47 W lost, almost all of it in D1's conduction.](https://voltecx-web.nguyenvanqui291.workers.dev/media/features/thermal/loss-chart-buck-en.svg) On the `buck` example 57.4 W goes in and 55.0 W comes out (95.70 %). Of the 2.47 W lost, D1 takes 2.43 W in conduction, S1 34.5 mW and C1 1.83 mW. Every watt on the chart is a number of the loss table, never scaled or rounded away. A budget whose input misses the output plus the losses by more than 0.5 %, or a loss that is not a finite, non-negative number, is refused by name instead of drawn. The same chart is `loss-chart.svg` in the design summary folder, and `format` gives it as SVG, PNG or JSON. More in the manual: [the loss chart](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/06-analyses/#the-loss-chart). ## Junction temperatures and their limits `analysis.thermal` (**Analysis › Thermal**) lists every recorded temperature `T(…)` of the last run with its final, highest and lowest value. *In the next release.* every switch kind has a `tjMax` parameter (°C), and 146 of the 150 vendor devices in the library carry the data sheet's maximum junction temperature, each with the table and row it came from. For the Infineon IGBT modules it is Tvj op, the temperature allowed under switching conditions (150 °C or 175 °C by series). Both solvers watch every junction that has a limit after each accepted step. A junction that passes its limit: - adds a warning to the run that names the part, the peak, the limit and where the limit came from, and the first crossing time, found within the step; - adds `limit`, `limitFrom`, `marginK`, `pass` and `crossedAt` to its row of `analysis.thermal`, and the result window draws a failing row in red; - shows as the problem `thermal.overTemperature` in the Problems tab for as long as the result belongs to the circuit as it is; - ends the run at the first crossing when **Stop when too hot** (`stopOnOverTemperature`) is on in **Properties › Simulation**. ## Start warm, not cold Every thermal node starts at ambient by default. A heatsink takes seconds to minutes to warm up, while a converter run lasts milliseconds, so a short run shows only the fast rise of the die. In `inverter3Thermal` the heatsink's time constant is 15 s, and in its 0.1 s run the heatsink rises by 0.1 K. *In the next release.* `thermalStart` in `simulation.settings` (from a script or the CLI; the desktop panel has no control for it yet) sets where the network starts: - `ambient` (the default): every node at ambient, as before. - `steady`: a pre-run finds the electrical steady state with the temperatures held, measures each loss source's average heat, and solves the network's DC steady state with it. Because the losses depend on the temperature, it repeats up to 5 rounds, until no node moves by 0.1 K. The run itself then starts at t = 0 at those temperatures, and its reply says how many rounds it took and the last round's largest change (`residualK`). - a map such as `{"Q1.j": 95, "hs": 80}`: those nodes start at those temperatures. On the `buckThermal` example (48 V to 12 V at 5 A, 100 kHz) at an 85 °C ambient, with `tjMax` 125 °C on Q1, a 2 ms run from ambient reads Q1's junction at 89.8 °C, a 35.2 K margin that looks comfortable and is wrong. With `thermalStart: "steady"` the same run starts after 2 rounds (`residualK` 0.015) and reads 105.5 °C, a 19.5 K margin. `analysis.losses` puts Q1 at 13.7 W, almost all of it switching (27.0 mJ against 0.35 mJ of conduction over the run), so the fix is the frequency: at 50 kHz Q1 dissipates 7.1 W and peaks at 95.6 °C, a 29.4 K margin. For a long run, `thermalStep` (**Properties › Simulation › Thermal step**) steps the thermal network on its own slower grid with the average device power, while the circuit keeps its own step. About a tenth of the fastest thermal time constant (`50u` for `inverter3Thermal`) stays within 1 % of the single-rate run. ## Paralleled devices and data checks *In the next release.* one switch, diode or MOSFET can stand for N identical devices (`nParallel`, 1 to 1024). The current is shared, the losses add up, and the junction chain of a library device becomes one device's Zth,jc over N, so the junction node reads one device's temperature while the case gets the total heat. Two IGBTs of 0.5 K/W on a case-to-ambient path of 2.0 K/W, dissipating 10 W in all, run each junction at ambient + 10 W × (0.5/2 + 2.0) K/W, which is 22.5 K above ambient. Sharing is assumed ideal: no spread of threshold, on-resistance or layout between the devices. The Problems tab also checks the thermal data you type in: a Foster table whose time constants do not rise, a Zth curve whose times do not rise or whose impedance falls, a fit that misses its curve by more than 5 % of its largest impedance, and lists of different length or with a value that is not positive. Where it can repair one without inventing a value, it offers a one-click fix: sort the stages, sort and flatten the curve, or fit with more terms. ## Pick the cooling and put it on the schematic `design.thermal` (**Design › Design Steps › Thermal**) runs one simulation for the losses and gives every switch and diode's junction temperature at your hottest ambient against `tjMax` (125 °C unless you say otherwise), with the thermal resistances taken from the circuit's own network when it has one. It then picks the cooling from cited catalogues: for each TO-220 or TO-247 device the lightest heatsink that keeps the junction at or below the limit, read at the airflow you give, with the interface pad of lowest resistance; for each SMD device the smallest copper area its data sheet rates it on that is enough. A device without a package or thermal data is named in the notes, never guessed, and a failing result names the heatsink resistance that would pass. `thermal.placeHeatsink` (**Design › Design Steps › Place Heatsink**) then places the chosen heatsink as a `heatsink` part, with the data sheet's sink-to-ambient resistance at the heat it carries and the airflow, and an ambient part if you ask, in one undo step. The catalogue holds 11 heatsinks from Same Sky and Ohmite, each with its data sheet and revision. Their data sheets give no heat capacity, so a placed heatsink has none: add a `cth` from the data sheet when it gives one, if you want to see the warm-up. On a circuit with no thermal network yet, `design.thermal` with **Apply** (`apply: true`) writes everything it picked in one undo step: each device's thermal net and junction-to-case path (its data sheet's chain when the part has one), the pad and heatsink or the board copper, one ambient part, and a steady thermal start. The next simulation then records every junction temperature. A device with no pick is listed, and a circuit that already has a thermal network is left as it is. ## On the board: copper, vias and the hot spot *In the next release.* Once the circuit has a board, `board.thermal` (from a script, the CLI or the assistant; it has no menu item yet) solves the temperatures of the board itself. It turns the copper, the vias, the stack-up and the outline into a grid of square cells, puts each part's loss from the last run into the cell under its largest pad, and cools each face to the ambient through a heat-transfer coefficient you give. The reply gives every part's case and junction temperature, the hottest cell and the rise of every cell on every layer. It changes nothing on the board, so you can widen a pour, add thermal vias and call it again to see what the change bought. - **Copper heats too.** With `copperHeat`, the DC current of the power nets you name is solved over their copper, as the IR-drop check does, and each cell's I²R loss goes in as heat on its own layer. A narrow neck in a high-current pour shows up as its own hot spot. In the Board window, **Board temperature** draws the map with the copper's heat already in it: the nets the **Current density** overlay solved, else every net the run carries current through. Under the scale it says how many watts the copper adds, and the conductor with the worst rise is outlined in red. - **Every track and via.** The same call lists each track, arc and via of those nets with its current and two rises side by side: the IPC-2221 §6.2 conductor formula, flagged as IPC-2221 because the IPC-2152 charts are not shipped yet, and the hottest board cell along it, which includes the parts' heat. With `transient` in the same call, each also gets its peak board rise during the transient and when it was reached, so an overload pulse shows how hot a track ran even after it has cooled. Add `transient.conductorRises: true` and each one also gets its whole curve, `transientRiseK`: its board rise at every recorded time of the transient, ready to plot a track's warm-up during a startup. - **Hot copper heats more.** The copper's resistance is taken at the ambient unless you add `copperHeat.coupled: true`. Then each cell's heat follows its own temperature, 0.393 % per kelvin at 20 °C (IEC 60028), in the steady map and step by step in the transient. If the copper makes heat faster than the board sheds it, the call is refused as thermal runaway instead of returning a temperature. - **Startup and pulses.** `transient` steps the same grid in time, so the copper stores heat: the planes and traces, and each via's barrel, half to each layer it joins; with `followRun` each part's loss follows its own loss waveform from the run, and the copper heat follows its net's current, so a startup or an overload pulse heats the board as it heated the parts. - **Junctions follow their Zth,jc.** In the transient, a part whose library device carries its data sheet's junction-to-case Foster chain, or a `losses` entry with `zthJc`, has its junction follow that chain above the case, so a pulse shorter than the package's time constants no longer lifts the junction by the whole loss × Rjc at once. A part without a chain, or with one the CSV import made up from Rth,jc alone, keeps loss × Rjc above its case and is named in the reply. Nothing is filled in for you: a layer without a thickness or copper weight, or a dielectric without a thickness, is refused by name, and the laminate's heat capacity comes from its data sheet or the transient warms faster than the board would. More in the manual: [board temperatures](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/22-board/#board-temperatures) and [DC IR drop](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/22-board/#dc-ir-drop-and-current-density). ## Examples to open - **File › Open Example › DC-DC › Buck converter with thermal model** (`buckThermal`): the MOSFET's losses heat its junction through 1.5 K/W to a heatsink held at the ambient's temperature; the run above. - **File › Open Example › Inverters › Three-phase inverter with current control and thermal model** (`inverter3Thermal`): a 600 V, 10 kHz IGBT inverter with dq current control, every IGBT and diode on a Foster junction-to-case chain and one shared heatsink of 0.15 K/W and 100 J/K. - **File › Open Example › Power quality › NTC heatsink temperature sensor** (`ntcHeatsink`): a diode heats a heatsink by 8 W, and an NTC on the heatsink lowers a divider voltage as it warms to 41 °C, the signal an over-temperature protection reads. ## With an assistant *In the next release.* the built-in assistant has a thermal skill. Ask it for a thermal check: it checks that every power device has a thermal path and says where each value came from, runs the worst corner with a steady start, reads `analysis.thermal`, `analysis.losses` and `analysis.stress`, and proposes the fix the loss split points to, changing one thing at a time, until every junction keeps 25 K of margin at every corner, or the spec's own margin. It proposes; you decide what changes in the circuit. [The AI assistant](https://voltecx-web.nguyenvanqui291.workers.dev/features/ai-assistant). ## From a script The `buckThermal` run above, from the command line (with a version that has `tjMax` and `thermalStart`): ```sh powercraft-cli run --cmd file.openExample --params '{"name": "buckThermal"}' \ --cmd circuit.setParam --params '{"component": "Q1", "key": "tjMax", "value": 125}' \ --cmd circuit.setParam --params '{"component": "Amb", "key": "t", "value": 85}' \ --cmd simulation.settings --params '{"tEnd": 0.002, "thermalStart": "steady"}' \ --cmd simulation.run --params '{}' \ --cmd analysis.thermal --params '{}' \ --cmd analysis.losses --params '{}' ``` ## Know the limits A junction temperature is only as good as its losses and its thermal path. The circuit's thermal network leaves out heat spreading in the board and neighbouring parts heating each other; `board.thermal` adds both once there is a layout. Neither models the enclosure or the data-sheet spread of thermal resistance. A placed heatsink's resistance is read once, at the heat you give, and stays fixed during the run. No model here has been compared with a measured board yet. The thermal parts and the thermal commands are in the Thermal licence module; see [licences](https://voltecx-web.nguyenvanqui291.workers.dev/features/licences-and-protection). More in the manual: [thermal parts, the thermal step and the warm start](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/04-simulation-settings/#thermal-parts-on-the-schematic), [losses, thermal and over-temperature](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/06-analyses/#losses-thermal-and-fft), and the [thermal and losses tutorial](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/08-thermal-losses/). Related pages: [analyses](https://voltecx-web.nguyenvanqui291.workers.dev/features/analyses), [automatic design](https://voltecx-web.nguyenvanqui291.workers.dev/features/auto-design). --- # Field solver (Preview), inductance, core loss, heat and force from the field URL: https://voltecx-web.nguyenvanqui291.workers.dev/features/field-solver/ A circuit model of an inductor or transformer is only as good as its numbers: L, the coupling, the saturation knee, the core loss and the temperature rise. Voltecx's own field solver finds them from the magnetic field of the part itself, in the same program as the circuit, and writes them back into the part so the simulation runs on them. It is a **Preview** feature: it has not passed its release gate, and every result says so. The [manual chapter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/21-field-solver) shows each step; the [command reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference) has a page per command. ## From a design to its field Design an inductor or transformer with **Design › Automate › Design Magnetics**, select it, and choose **Design › Field Solver › Field Solve**. Voltecx draws the section of the E core or ring core with its windings, meshes it automatically with three elements across every gap, and solves the field with 1 A in each winding in turn. You get L of each winding from the field energy, M and k, and the magnetising and leakage inductances, and one click writes them into the part as one undoable step. The field window draws |B| or |H| as a smooth map with flux lines, the mesh and the region outlines, with a probe and a print-resolution image export. Every solve carries a hash of its input, so a stored result can be checked against a fresh one. ## Core loss, saturation, heat and force - **Core loss from the last run**: the part's current from the last simulation drives the model, B(t) is found in every core element (on the data-sheet B-H curve for N87, N97, 3C90 and 3C95), and the iGSE gives the loss density, the total and the 99th-percentile |B| checked against saturation. In 3D the loss can include the end turns: the wound E core, one eighth meshed. - **Flux map**: a current sweep on the B-H curve gives the saturating inductor's flux-linkage table, which both circuit solvers then follow. - **Thermal**: the steady temperature of core and windings from their losses, with the core loss and the AC winding loss iterated with the temperature. It runs on the planar section or on the 3D model, extruded or revolved: with the end faces insulated, the extruded model matches the planar solve, and a ring core can carry its winding copper as a solid, or have its conducting parts heated by their 3D eddy-current loss. - **Force and torque** by the weighted stress tensor, checked by virtual work, in 2D and on the 3D model (on a permanent magnet too); **winding capacitance** from an electrostatic solve, proposed as capacitors on the schematic; **eddy-current transients**; **line profiles** and **region tables**. - **3D**: the same design extruded or revolved, wound with its end turns, solved on its B-H curve, or imported from STL or STEP. ## The 3D window and the 3D report A 3D result opens in its own window. It draws every body of the model in colour with a legend and a probe like the 2D map: - **Bodies:** each body can be shown, hidden or made see-through. The window opens on the magnetic parts with the air hidden. - **Section plane:** a section along x, y or z at any position cuts the model and shows the field on the cut, including in the hidden air of the gap. - **Shading:** flat element values (the numbers the solve reports) or smooth shading. - **Flux tubes:** each tube carries the same share of the flux through the section. - **Orbit camera:** drag to orbit, right-drag to pan, scroll to zoom. The window shows a field solve's |B| for each winding, and a core loss's loss density next to |B| at the instant of the peak. A 3D thermal solve opens on its temperature over every body, with the hot spot and each region's loss, mean and maximum listed above the view. For |B| and the loss density, the colour scale tops out at the core's 99th percentile, so a few elements at the gap's corners do not wash out the picture. **Export Design Report** (`report.export`) draws each 3D result twice: from outside, and cut at the mid-plane across the depth. That covers |B| on the magnetic parts with flux tubes, the core's loss density and the temperature of every solid. Captions are in English and Traditional Chinese. **Save View for Report** in the 3D window keeps the view on the screen: camera, section, opacity and shading, up to eight views. The report then adds one picture of each 3D result per saved view (`field3dViews`). `field3dCamera` instead draws the two pictures from one given camera. ## The accuracy table Every claim of the field solver is a row of the accuracy report, regenerated from the code and failing the build when a measured row misses its target or gets worse. These are the 31 measured rows; all pass. 18 more rows (hardware measurements, the data sheet's AL, performance on the minimum supported machine, cross-platform reproducibility) are pending and name the task that will fill them. Errors are in % unless the target names another unit. | Row | What it checks | Ours | Reference | Error | Target | |---|---|---|---|---|---| | `analytic_coax_2d` | B at radii and L per metre of a coaxial line | 3.184e-5 | 3.195e-5 | 0.36 | ≤ 1 % | | `analytic_wire_2d` | B at radii around a wire | 1.003e-4 | 1e-4 | 0.33 | ≤ 1 % | | `analytic_toroid_axisym` | L and B of a toroid, axisymmetric | 1.622e-7 | 1.622e-7 | 2.0e-7 | ≤ 1 % | | `analytic_sphere_3d` | B inside a magnetic sphere, 3D | 2.985 | 2.997 | 0.41 | ≤ 1 % | | `analytic_spheroid_3d` | B inside a magnetic spheroid and the torque on it in a tilted field, 3D (mN·m) | 939.5 | 946.1 | 0.70 | ≤ 1 % | | `analytic_magnet_cylinder_2d` | Mean B inside a magnetized cylinder | 0.4995 | 0.5 | 0.11 | ≤ 0.5 % | | `analytic_magnet_dipole_2d` | Field outside that cylinder, a 2D dipole | 0.2326 | — | 0.23 | ≤ 1 % | | `analytic_magnet_sphere_axisym` | Mean B inside a magnetized sphere | 0.6663 | 0.6667 | 0.059 | ≤ 0.5 % | | `analytic_magnet_sphere_dipole_axisym` | Field outside that sphere, a dipole | 0.1978 | — | 0.20 | ≤ 1 % | | `analytic_magnet_energy_2d` | A magnet's energy and co-energy | 31.31 | 31.29 | 0.067 | ≤ 1 % | | `magnet_gap_circuit` | Mean B of a magnet in a core's gap | 1.14 | 1.129 | 0.97 | ≤ 2 % | | `force_parallel_wires_2d` | Force between two parallel wires, four ways | −1.398e-7 | −1.4e-7 | 0.17 | ≤ 0.5 % | | `force_wire_over_iron_2d` | Force on a wire over iron, four ways | −7.987e-5 | −7.984e-5 | 0.16 | ≤ 1 % | | `convergence_order_smooth` | Observed order of the energy error | 2.005 | 2 | 0.005 | 2 ± 0.3 | | `convergence_e25` | Extrapolated L of the E25 against the reported L | 91.73 | 91.83 | 0.11 | ≤ 0.5 % | | `boundary_distance` | L change when the air box doubles | 90.84 | 90.84 | 6.3e-4 | ≤ 0.2 % | | `open_boundary_two_wire` | L per metre of a two-wire line in open space | 1.292 | 1.297 | 0.37 | ≤ 0.5 % | | `open_boundary_two_wire_electrostatic` | C per metre of the same line | 9.325 | 9.293 | 0.34 | ≤ 0.5 % | | `energy_vs_flux_linkage` | L from flux linkage against L from energy | 90.84 | 90.84 | 1e-9 | ≤ 1e-6 relative | | `reciprocity` | M12 against M21 of two-winding models | 49.21 | — | 1e-7 | ≤ 0.5 % | | `solver_oracle` | Iterative against direct sparse solve | 1e-9 | — | 1e-9 | ≤ 1e-6 relative | | `port_regression` | The Rust solver against its prototype on the same mesh | 102.5 | 102.5 | 3.6e-6 | ≤ 0.01 % | | `mesh_quality` | Smallest element angle of the automatic mesher | 25.43 | — | 25.43 | ≥ 20° | | `mesher_independence` | E25 drawn as a sketch, automatic mesh, L (µH) | 91.45 | 91.83 | 0.42 | ≤ 0.5 % | | `extrusion_3d_vs_2d` | 3D extrusion against 2D, L (µH) | 91.53 | 91.49 | 0.043 | ≤ 1 % | | `boundary_distance_3d` | L change when the 3D air box doubles | 90.82 | 90.82 | 2.1e-4 | ≤ 0.2 % | | `reciprocity_3d` | M12 against M21 in 3D | 90.41 | 90.41 | 1e-7 | ≤ 0.5 % | | `thermal_analytic` | Temperature rise and gradient of a slab and a cylinder | 0.1565 | 0.1562 | 0.15 | ≤ 1 % | | `thermal_coupling` | Change between the last two magnetic-thermal iterations (K) | 0.01433 | — | 0.014 | ≤ 0.5 K | | `homogenized_bundle` | R_ac/R_dc of a homogenized round-wire bundle against the strand-resolved solve | 66.78 | 70.16 | 4.8 | ≤ 5 % | | `ac_resistance_dowell` | AC resistance where Dowell's assumptions hold | 18.18 | 18.14 | 0.20 | ≤ 5 % | A 3D model of the TEAM 13 benchmark is also compared with its published measurements: the RMS error of the section-average flux density is 1.1 % to 1.4 % of the RMS measured value, for the two published gap values. Interpolated to the model's 0.5 mm gap it is 1.16 %, inside the 1.2 % by which the two published gaps' measurements differ, and the accuracy report holds it there as a pass row. ## What it does not do yet The field solver stays in Preview until the hardware rows (low-current L, saturation knee, ripple, core loss and temperature rise against the bench) pass. The 2D field solve is magnetostatic and linear and gives no AC resistance; B-H curves exist for four ferrites; a model has at most two circuits; the drawing canvas has no Solve button yet, so a hand-drawn section is solved from Quick Open, the CLI, Python or an agent. Turn it on in **Edit › Preferences › Simulation**. --- # Isolating ICs and gate drive, checked in the switching circuit URL: https://voltecx-web.nguyenvanqui291.workers.dev/features/isolation-and-gate-drive/ Every signal that crosses an isolation barrier goes through a part with limits of its own: an optocoupler whose gain drifts with current, temperature and age, a digital isolator with a delay and a slope it survives, an isolated amplifier with its bandwidth and clipping, a gate driver with its UVLO and peak current. Voltecx places each of them as a module with the data sheet's pin names and numbers, simulates it inside the switching circuit, and checks it against what the circuit does to it. Then it sizes the gate drive, splits the power and control grounds on the schematic and lists the clearance and creepage the barrier needs. Items marked *in the next release* are merged for the next beta and are not in Voltecx 0.9.0 yet. ## Isolating ICs as modules `ic.place` puts an IC into the circuit as a subsystem with named pins (unconnected, to be wired with `circuit.connect`), in one undo step. A `preset` places a real part: its data-sheet values and pin names, each value cited to its table or figure, and `ic.describe` lists the parameters with their unit, range and source. The models are behavioural, built from the numbers that matter to a power stage, not the vendor's transistor-level model. The isolating ones: | IC (`name`) | Default part | What it models | Presets | |---|---|---|---| | `optocoupler` | Vishay TCET1100 | LED, current transfer ratio (CTR) over LED current and ambient temperature, phototransistor pole, saturation | Sharp PC817, Lite-On LTV-817, Vishay SFH617A | | `digitalIsolator` | TI ISO7710 | Input thresholds that follow VCC1, 11 ns delay, push-pull output, UVLO, default output | | | `isolatedAmplifier`, `isolatedAmplifierAmc1302` | TI AMC1301, AMC1302 | Gain, bandwidth, signal delay, clipping, differential output | | | `isolatedVoltageSensor` | TI AMC1311 | A resistive divider into an isolated amplifier | TI AMC3330 | | `gateDriverIso` | TI UCC21756-Q1 | UVLO, propagation delay, source and sink resistance, DESAT protection, soft turn-off, latched fault | TI UCC21750, Infineon 1ED3491MU12M and 1ED3124MU12H, Skyworks Si82391CB | The optocoupler's CTR is the data sheet's curve, not one number. `ctrScale` moves the whole curve to another CTR bin or to an end-of-life value, and `tAmb` applies the curve's temperature factor, so a loop can be checked at the bin's highest, lowest and aged gain. A placed PC817, for example, carries a CTR of 149 % at 1 mA and about 276 % at 5 mA read off the Sharp data sheet (sheet OP18002EN). [Every IC template](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/10-models/#behavioural-ics-beta). ## Feedback across the barrier An isolated supply regulates on its secondary and crosses the barrier with a TL431 and an optocoupler. **File › Open Example › Isolated › Flyback with TL431 and optocoupler** (`flybackTl431`) closes a 12 V flyback's loop through both, and holds 12.06 V at full and half load in both solvers. The TL431 model regulates down to zero cathode current, as a real one does not: `circuit.problems {"run": true}` warns when it carries less than the 1 mA its data sheet asks for during more than 20 % of the second half of the run. For an isolated flyback, automatic design sizes this feedback as its `isolatedFeedback` stage: a TL431C, a TCET1100-family optocoupler bin and a type II network into a UC3843-class peak-current-mode controller, checked at the bin's highest, lowest and aged CTR. [Automatic design](https://voltecx-web.nguyenvanqui291.workers.dev/features/auto-design). ## CMTI checked against the simulated dv/dt *In the next release.* A SiC or GaN switch node moves at 50 to 200 V/ns, and an isolator whose common-mode transient immunity (CMTI) is lower lets a glitch through: a wrong logic level, a spurious gate pulse. Every part that crosses a barrier (`optocoupler`, `highSpeedOpto`, `digitalIsolator`, `gateDriverIso`) now measures the slope of the voltage across its own barrier during the run, over a 1 ns window, short enough not to average away a 4 ns edge. While the slope is above the part's `cmti` rating, the output glitches for `tGlitch`, and after the run the Problems tab lists `isolation.cmtiExceeded` with the part selected, for example "CMTI exceeded: 120 V/ns > 100 V/ns rating on U1". What the tests show, in both solvers: - A digital isolator at its ISO7710 default (100 V/ns typical, data sheet SLLSER9E) holds its output when its far ground jumps 600 V in 7.5 ns (80 V/ns), and drops it for 20 ns when the same 600 V takes 5 ns (120 V/ns). - The UCC21750 preset (150 V/ns minimum, data sheet SLUSD78C Table 6.8), with its input held low, puts a spurious pulse of more than 2 V on the gate when 800 V hits its COM pin in 4 ns (200 V/ns), and less than 0.1 V in 6 ns (133 V/ns). Only cited ratings are filled in. The TCET1100 and UCC21756-Q1 defaults have no CMTI in Voltecx yet, so their `cmti` is 0: the slope is measured, nothing glitches and nothing is reported until you enter your part's value. The glitch width (20 ns) is an assumption, because data sheets give CMTI as a pass or fail limit, not the shape of the failure. ## A high-speed logic optocoupler *In the next release.* `highSpeedOpto` is the 10 MBd class of logic-output optocoupler used for PWM and fault signals: an LED threshold current, separate high-to-low and low-to-high delays (so a pulse comes out longer or shorter by the pulse-width distortion), an open-collector or totem-pole output, output capacitance, a supply range and a CMTI. No data sheet of this class has been read into Voltecx yet, so every default is labelled "typical, user must set": set them from your part. Its `optoLink` application circuit (`circuit.applicationCircuit {"ic": "highSpeedOpto", "topology": "optoLink"}`) drives the LED with a square wave across a 100 V ground offset. *In the next release.* An isolating IC's symbol draws the barrier as its boundary: the first side's pins on the left, the second side's on the right, and a dashed line through the box. Only the drawing changes, never the netlist. ## Gate drive `design.gateDrive` (**Design › Design Steps › Gate Drive**) designs the gate drive of every switch in the circuit. A switch whose reference is off ground is high side and pairs with the switch below it. Each group gets a driver from a catalogue of 20 TI and Infineon parts, from UCC27211, UCC27517 and UCC21520 to 1EDN7550B and IR2110, every number from the cited data sheet: a low-side driver for a lone low-side switch, a half-bridge driver with bootstrap for a high-side one, an isolated one with `isolate: true`, chosen by supply, UVLO, bus voltage, peak current and the shortest propagation delay. It then sizes: - the turn-on and turn-off gate resistors, for the driver's peak current or for the edge time you ask for (TI SLUP169); - the bootstrap capacitor and the VDD bypass, rounded up to E6 (TI SLUA887A); - the drive power, and the dead time against the driver's delay matching plus the turn-off edge. A data sheet's gate charge is measured at one gate voltage, so the command scales each switch's Qg to the voltage that really drives it: a CSD17573Q5B driven at 10 V needs 111 nC, not the 49 nC its data sheet gives at 4.5 V. It also checks VDD against each device's VGS(max), and a negative off-voltage against VGS(min). It changes nothing in the circuit; automatic design runs it as its gate-drive stage and puts the driver on the bill of materials. ## Power ground and control ground `schematic.splitGrounds` (**Circuit › Split Power and Control Ground**) splits the ground on the schematic into the power return PGND (the hot loops and the power stage) and the control return AGND (parts with a ground pin whose other nets no switch, diode, winding or source touches, such as a feedback divider's foot). Every ground pin moves to its net, each net gets a ground symbol and rail labels, and a 0 Ω link NT1 joins them at one point, in one undo step. On `flybackTl431` it puts Vin, S1, Cy, Rbleed and Vpull on PGND and Cpole, Mfb, Rsn and U3 on AGND. The simulation is unchanged, because both nets still meet at ground; `file.exportKicad` then writes PGND and AGND apart with NT1 as a net tie. `"apply": false` only proposes the split. ## Clearance and creepage across the barrier `design.safety` (**Design › Design Steps › Safety**) finds every isolation barrier (the windings of a transformer or coupled inductor, and the parts you list in `barrier`, such as an optocoupler, an isolated driver or a Y capacitor), and gives every pair of nets across it, and from each side to protective earth, its working voltage: peak and RMS from the last simulation, else from the spec. It then applies the clearance and creepage method of IEC 62368-1:2018 for basic and reinforced insulation: procedure 1 at the peak, procedure 2 with the mains transient on the input side, the altitude factor above 2000 m, and creepage from the RMS voltage, pollution degree and material group. Voltecx has no licensed copy of the standard, so its tables are empty: every distance comes back null, `missing` lists each table cell the result needs, and `verify` fails until they are filled. What you get today is the barrier, its sides, the working voltages and the list of lookups to make in your own copy. On `flybackTl431` it finds the transformer's barrier with 353 V peak and 16.0 V RMS across it and lists 39 table cells to look up. The reply also lists what the transformer construction needs (triple-insulated wire, tape, margins), and `file.exportKicad` adds a note per barrier. It is not a safety approval. *In the next release.* An optocoupler, isolated amplifier or digital isolator placed with `ic.place` joins each of its sides on its own, without being listed in `barrier`. An isolated design from automatic design keeps its secondary on its own ground (`sgnd`, with its own symbol), joined to the primary only through the transformer, the parts made to cross the barrier and a documented 10 kΩ simulation tie, and draws the barrier as a dashed line. ## From a script Place a PC817, size the gate drive of the buck example, then check the barrier and the grounds of the TL431 flyback: ```sh powercraft-cli run --cmd file.openExample --params '{"name": "buck"}' \ --cmd ic.place --params '{"name": "optocoupler", "preset": "PC817", "instance": "U2"}' \ --cmd design.gateDrive --params '{"vdd": 12}' powercraft-cli run --cmd file.openExample --params '{"name": "flybackTl431"}' \ --cmd simulation.run --params '{}' \ --cmd design.safety --params '{"pollutionDegree": 2, "materialGroup": "IIIb"}' \ --cmd schematic.splitGrounds --params '{"apply": false}' ``` ## Know the limits The ICs are behavioural models from data-sheet numbers, not the manufacturer's transistor-level models, and a default marked `assumption` is the model's guess, not a data-sheet value. CMTI is checked only for parts whose rating is set. The clearance and creepage distances wait for the standard's tables, and nothing here is a safety approval or a certification. The IC library and `design.gateDrive` are in the Parts & ICs licence module, and `design.safety` in EMI & Layout; see [licences](https://voltecx-web.nguyenvanqui291.workers.dev/features/licences-and-protection). More in the manual: [behavioural ICs, CMTI and feedback across the barrier](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/10-models/#fast-isolation-and-cmti), and [the design steps, gate drive and safety among them](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/16-automatic-design/#the-tools-one-by-one). Related pages: [models and parts](https://voltecx-web.nguyenvanqui291.workers.dev/features/models-and-parts), [design tools](https://voltecx-web.nguyenvanqui291.workers.dev/features/design-tools), [EMI](https://voltecx-web.nguyenvanqui291.workers.dev/features/emi). --- # EMI estimates, from the LISN to the input filter and the layout URL: https://voltecx-web.nguyenvanqui291.workers.dev/features/emi/ Voltecx estimates a converter's electromagnetic emission while it is still a schematic: the conducted noise through a LISN on the input, a filter that brings it under the limit, the radiated field from the switch node and the hot loop, and the layout that matters for both. Every number on this page is a pre-compliance estimate, not a compliance measurement. Each reply says `preCompliance: true` and each label says it is an estimate. Use it to find the problem early, size the filter and compare layouts; only a measurement in an accredited set-up says whether a product passes. Items marked *in the next release* are merged for the next beta and are not in Voltecx 0.9.0 yet. ## Conducted EMI on a DC input `emi.conducted` (**Design › Automate › Conducted EMI**) never touches your circuit while it measures. It puts a LISN (50 µH, 0.1 µF, 50 Ω, after CISPR 16-1-2) on a copy, runs it until it settles, and reads the input current over a whole number of switching periods. The spectrum goes through a model of a CISPR 16-1-1 band B receiver (a 9 kHz bandwidth, quasi-peak with 1 ms charge and 160 ms discharge) with peak, quasi-peak and average detectors, and is held to CISPR 32 class A or B band by band. When the supply's return is not the ground node, both lines get a LISN and the result splits into differential mode and common mode, so you know which filter to build. When the margin is below `targetMarginDb` (6 dB by default), it sizes one or two damped LC stages and measures again with them. The damping follows Middlebrook's condition (R. D. Middlebrook, 1976; Erickson and Maksimovic, *Fundamentals of Power Electronics*, chapter 10): the filter's peak output impedance must stay 3 times (9.5 dB) below the converter's input impedance, or the filter destabilises the converter it was meant to quieten. `zinOhm` gives that impedance, such as Vin,min²/P at full load; without it the measured V/I is used. With `"apply": true` the filter goes into your circuit in one undo step. [Input filter stability](https://voltecx-web.nguyenvanqui291.workers.dev/blog/input-filter-middlebrook-stability). ## AC mains inputs *In the next release.* When the circuit has no DC source, its sine source is the input: an AC mains front end such as a diode bridge and a PFC stage. The LISN goes on L and on N, and the run settles for whole mains periods. The switching changes over the mains cycle, so one window is not enough: the estimate reads 8 windows of whole switching periods at equal phases of the next mains period and joins their receiver envelopes, with peak the largest, average the mean and quasi-peak the detector's value over the mains period. Each window must fit in an eighth of the mains period, 2.5 ms at 50 Hz. ## Limits that name their network and bandwidth *In the next release.* Each limit names its document, the artificial network it is measured with and the receiver bandwidth, each with its source, and the reply repeats them: | `limit` | Standard | Port | Network, receiver | |---|---|---|---| | `cispr32A`, `cispr32B` | CISPR 32:2015 Annex A | AC mains | 50 µH / 50 Ω, 9 kHz | | `cispr11A`, `cispr11B` | CISPR 11:2015+A2:2019, group 1 (class A up to 20 kVA) | AC mains | 50 µH / 50 Ω, 9 kHz | | `cispr25Class1` … `cispr25Class5` | CISPR 25 Ed. 5 (2021), voltage method | DC supply line | 5 µH + 1 Ω / 50 Ω, 9 kHz | The CISPR 11 and CISPR 25 values come from secondary sources, articles that reproduce the standards' tables, and were not checked against the standards' text. The reply marks them `"provenance": "secondary"` and names the articles: for CISPR 11 the EN 55011 Table 2 values as philipmcgaw.com and a Cadence article cite them; for CISPR 25 the peak and average values of an ST article (Gambino, Grasso, Scrimizzi, 2024) and the quasi-peak values of a Baltic Lab article (Westerhold, 2025), from that one source only. Check them against the standard before you rely on a margin. CISPR 25 is assessed only inside its broadcast bands, and its bands above 30 MHz are in the file but not assessed, because the conducted measurement ends at 30 MHz. CISPR 11 class A above 20 kVA and MIL-STD-461G CE102 are not included: their values were not available. A DC input held to a mains-port limit is a screen, and a note says so. ## A common-mode stage, sized from a catalogue *In the next release.* With two LISNs and a path to ground, a short common-mode margin gets a common-mode stage: a choke in both lines and a Y capacitor from each line to ground. The Y capacitance is set by your product's safety standard, through its touch-current limit, so Voltecx has no default for it: give `yCapMax` (farads per line), or `touchCurrent` with `mainsHz` and `mainsV`, which allows $$C_{Y,\text{max}} = \frac{I_{\text{touch}}}{2\pi \, f_{\text{mains}} \, V_{\text{mains}}}$$ per line. The choke is the catalogue part (57 TDK and Schaffner chokes, each row read from its data sheet) whose worst-case common-mode inductance reaches the corner frequency, and the Y capacitor the largest catalogue Y2 part under the limit. The choke's stray inductance stays in the differential path, and the reply gives the gain in each mode (`improvementCmDb`, `improvementDmDb`). Without a Y limit, or when no catalogue choke is large enough, a note says so and only the LC stages are sized. ## Parasitic elements, only from your data *In the next release.* With ideal parts the estimate is optimistic from about 5 to 30 MHz, where a real capacitor's ESL, an inductor's winding capacitance and a switch's Coss let noise through. Tick **Parasitic elements** on the form (`"parasitics": true`) to put them on the measured copies, never on your circuit. They come from your circuit's own `esr`, `esl` and `coss`, from **Parasitic values** you type by part name (`{"Cin": {"esl": "2n"}, "L1": {"srf": "30Meg"}}`), from the capacitor catalogue's ESR, or from the assigned device's Coss table at the input voltage (at the crest for a mains input). Nothing is assumed: a part with no value is listed as skipped, with what to give. The same window also runs with ideal parts, so the notes show what the parasitics cost in margin. ## Radiated EMI `emi.radiated` estimates the field from 30 MHz to 1 GHz at 3 m or 10 m against CISPR 32 class A or B, at every harmonic of the switching frequency, from two sources with C. R. Paul's formulas (*Introduction to Electromagnetic Compatibility*): the switch node driving its capacitance to the chassis and the cable as a common-mode antenna, and the hot loop as a small loop. It then tries three layout changes, halving the loop area, halving the switch node's capacitance and doubling the edge time, and says which one raises the worst margin most. *In the next release.* **Design › Automate › Radiated EMI** opens it as a form. A field left empty takes the circuit's value where there is one: the swing and the loop current come from the first hot loop of `layout.hints`, and the switch node's capacitance to the chassis is the capacitors drawn from the switch node to ground. Where nothing gives a value, a typical one stands in (1 cm² of loop area, 10 pF, a 1 m cable), and the result window lists each of them under **Assumed values** with a field: type your board's number and press **Run Again**. **Inputs** says where every number came from. *In the next release.* **A switch on a heat sink** counts too: a MOSFET, IGBT or diode whose tab (the drain, the collector or the cathode, as its data sheet draws it) is the switch node, mounted on a heat sink through an insulating pad, couples the switch node to the heat sink through the pad. Draw the thermal network with the pad's library `part`, or let `design.thermal {apply: true}` draw it, and the estimate adds the tab's capacitance, ε0·εr·A/d, from the pad's data sheet and the package's outline drawing; `commonMode` shows it as a row with `via: "tab"`. The heat sink is taken as earthed: if yours floats, give `cSw`. A grease, a pad the library does not hold, or a package with no tab size is named in a note and left out. ## Radiated EMI from the routed board *In the next release.* Give `emi.radiated` the routed board (`path` to a `.kicad_pcb`, or `board` for a Voltecx `.vxpcb`) and it reads the copper through `layout.extract` instead of typical values: - **Every power loop**, each with its own current: the loop's own peak from `layout.hints`, matched by name, and listed in `loops` with its area and its own field. The gate loops join the sum too: with `iGate`, the gate driver's peak current from its data sheet, or without it each switch's own peak gate current from the last run, when the switch's gate is modelled (a MOSFET at the dynamic level). Either way their share is an upper bound, since the gate pulse takes the power loop's duty and edge. When the last run recorded each loop's switch node, a loop whose leg switches slowly or not at all leaves the sum, and its row says so. The same run gives each loop its leg's phase and the way its current goes round the board, and the loops add as phasors, each loop's current pulse at its own leg's duty in the run (`legDuty`): mirrored legs in antiphase cancel at the even harmonics and complementary legs at every harmonic, less as the frequency rises with their spacing. When the run or the board cannot say, they add in amplitude, the worst case. - **The common-mode path from the copper**: the parallel-plate capacitance of every switch node's copper to a chassis or heat-sink fill, one row per node and fill in `commonMode`. When the last run recorded each switch node, every leg uses its own simulated frequency, phase and duty, so interleaved and complementary legs cancel where they should and a line-frequency leg adds nothing at the switching harmonics; without that run the legs add in phase, the worst case. - **Where the cables leave**: `cables` lists each connector, its role (input, load or other) and its distance to the switch node, nearest first. The cable length stays yours, since a board does not say it. - **In the result window** these are three tables: **Hot loops at** the worst line (area, peak current and field of each power and gate loop), **Common-mode paths** (each switch node's fill or tab, its capacitance, swing and field) and **Cables and connectors**. Rows are largest or nearest first, and a row the run left out of the sum says **Not in the sum**. ## Near-field map of the board *In the next release.* `emi.nearField` maps the magnetic near field over the routed board: each hot loop's copper path carrying its own current (a gate loop takes `iGate`, or without it its switch's peak gate current from the run, an upper bound), the quasi-static Biot–Savart field (Griffiths, example 5.5) on a plane 10 mm above the copper by default, at the first switching harmonic at or above 30 MHz, or the strongest of its lobe when that one falls in a null of the spectrum (every even harmonic at 50 % duty; with a run, the null is looked for at the duties the loops' legs actually have), with a note saying so. It returns the map in dB(µA/m), each cell's strongest loop and the hot spots, strongest first. The board window's **Near field** button draws it under the copper with the hot spots ringed and numbered, and draws it again after each board edit, so you see at once whether moving a capacitor shrank the loop. With a current run, the power loops whose leg phase and direction round the board the run resolves add as phasors, each at its own leg's duty, as in the radiated estimate; the other loops add in amplitude on top, an upper bound for them. `cables` gives the field over each cable connector of the board (the connectors `emi.radiated` lists), its strongest loop there and how far it is under the strongest cell, strongest first, since a cable plugged in where the field is strong carries it off the board; the overlay marks each connector with a square and a label such as "J1 97 dB", and its scale names the strongest one. It is an estimate to find which loop to fix, not a probe scan. ## Layout hints `layout.hints` (**Design › Automate › Layout Hints**) reads the circuit, and the last simulation when there is one, and says where the layout matters for EMI and for the switches: the commutation loops with the parts in each, an inductance budget for each loop (the largest loop inductance whose voltage spike still fits the switches' margin), the ring frequency with the switch capacitances, the gate loops, Kelvin source pairs, the switching nodes to keep small, the thermal resistance the copper under each device must stay below, and a split of the ground into power and control returns that `schematic.splitGrounds` can draw. Its checklist is a list of things to check on your board; it is not a board design. ## The example **File › Open Example › Power quality › Conducted EMI bench** (`emiInputFilter`) draws the measurement itself: a floating 24 V supply feeds a switching load through two LISN parts and a TDK B82724A2202N001 common-mode choke. The load draws 1 A pulses at 100 kHz, and its switch node jumps 24 V in 20 ns against a 100 pF capacitance to ground, as a heatsink would. On the scope, half the difference of `v(mp)` and `v(mn)` is the differential noise and half their sum the common-mode noise, and you can see the choke's full inductance stand in the common-mode path while the load current sees only its stray inductance. ## From a script ```sh powercraft-cli run --cmd file.openExample --params '{"name": "buck"}' \ --cmd emi.conducted --params '{"limit": "cispr25Class3", "targetMarginDb": 6, "parasitics": true}' \ --cmd emi.radiated --params '{"limit": "cispr32B", "distanceM": 3, "edgeTime": 5e-9}' \ --cmd layout.hints --params '{"edgeTime": 1e-8}' ``` `cispr25Class3` and `parasitics` need a version with the next release's limits and parasitics; on 0.9.0 use `cispr32A` or `cispr32B` without `parasitics`. ## What these numbers are An estimate from the circuit and the numbers you give. It knows the real board only as far as the routed board you give it, and nothing of the enclosure or the cable routing beyond the numbers you give, the filter parts are ideal apart from the values listed above, and no estimate has been compared with a chamber measurement yet. EMI results are not compliance results, layout hints are not a board design, and the CISPR 11 and CISPR 25 limits are unchecked against the standards' text. The EMI commands are in the EMI & Layout licence module; see [licences](https://voltecx-web.nguyenvanqui291.workers.dev/features/licences-and-protection). More in the manual: [conducted EMI and the input filter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/06-analyses/#conducted-emi-and-the-input-filter), [radiated EMI](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/06-analyses/#radiated-emi), the [near-field map](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/06-analyses/#near-field-map-of-the-board) and its [board overlay](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/22-board/#near-field), [parasitic elements](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/06-analyses/#parasitic-elements-in-the-conducted-emi-estimate), the [EMI and layout commands](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/16-automatic-design/#the-tools-one-by-one) and the [conducted EMI tutorial](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/09-conducted-emi/). Related pages: [design tools](https://voltecx-web.nguyenvanqui291.workers.dev/features/design-tools), [analyses](https://voltecx-web.nguyenvanqui291.workers.dev/features/analyses), [isolation and gate drive](https://voltecx-web.nguyenvanqui291.workers.dev/features/isolation-and-gate-drive). --- # Parts and the bill of materials, from simulated stress URL: https://voltecx-web.nguyenvanqui291.workers.dev/features/parts-and-bom/ A simulation tells you what each part has to carry. Voltecx turns that into the parts you buy: it rates every part on the voltage, current, power and temperature it saw in the run, proposes devices and passives that carry it with margin, tells you what to check on each data sheet, and writes a bill of materials and a KiCad project with the part numbers filled in. Every catalogue part it picks names the manufacturer data sheet it was read from. A line that no catalogue part fits, and none of your own parts either, gets no part and says why: Voltecx never makes one up. ## Rate every part on its stress `analysis.stress` reads the last run and gives one row per part: the measured peak and RMS voltage and current, the power and the junction temperature, the ratings the part needs after derating, and the margin of the assigned device over them. A part the device cannot carry is named. The default derating is 0.8 of the voltage rating, 0.7 of the RMS current, 0.8 of the peak current, 0.5 of the power and a junction at most 125 °C. These are common engineering practice, not a standard, and the reply says so. Pass `derating` to use your own factors, and `t0` and `t1` to rate the steady state rather than the whole run, start-up included. The same derating feeds `design.parts`, `device.recommend` and `bom.export`. To rate the parts against NASA EEE-INST-002 instead, use `design.reliability`. [Derating: how much margin do power components need?](https://voltecx-web.nguyenvanqui291.workers.dev/blog/derating-rules-power-components) works through both rule sets on a 48 V flyback. ## The Parts table `design.parts` (**Design › Design Steps › Parts**, **Design › Design Steps › Parts** in 0.9.0) picks the semiconductor for every switch and diode. It simulates if the result is missing or stale, rates each part with `analysis.stress`, ranks the library devices that carry it by estimated loss with `device.recommend`, and proposes the best one. It skips a device rated more than 2.5 times the part's worst-case voltage, or one whose gate plateau the switch's drive voltage does not clear, unless nothing else qualifies. With `corners` it also simulates the circuit at each input and load you list and keeps only devices that carry every corner. `buyable` proposes a vendor part over an illustrative one. *In the next release.* In the Design panel, the Parts table shows one row per switch and diode: the chosen device, the voltage the part saw (**Stress**), the device's rating (**Rated**), the **Margin** of that rating over the derated need (red when it falls short) and the estimated **Loss**. Hover the **?** at the end of a row to see what to check on the data sheet before you buy: for a MOSFET, Rds(on) at the hot junction, Qg and Qgd, Coss, body-diode recovery and the Vds overshoot at turn-off; for an IGBT, Vce(sat) hot, Eoff and the tail current, short-circuit withstand time and the diode's recovery; for a diode, reverse recovery, forward voltage hot, leakage and surge rating. Click a part's name to select it on the schematic. The Auto Design result window lists the same parts. From a script, `apply: true` assigns every proposal in one undo step. ## Capacitors and inductors with their margins *In the next release.* Under the semiconductors, **Capacitors and inductors** lists the catalogue part that `bom.export` picks for each one, how many, and the margin of the rating that limits it: voltage or ripple current for a capacitor, saturation or RMS current for an inductor (hover the margin to see which). A ceramic capacitor's count already allows for the capacitance it loses at its DC voltage. The **?** lists what to read on that part's data sheet, such as the ripple rating at your frequency and temperature, the DC-bias curve of a ceramic, the lifetime of an electrolytic or the saturation current when hot. From a script, this is `design.parts` with `passives: true`. ## Find a part - `library.search` filters the device library and the devices in the open circuit by type and ratings (`vdsMin`, `idMin`, `rdsonMax`, `vfMax`, `rthJcMax` and more), and sorts them. *In the next release:* `module` lists only power modules or only discrete parts. - `device.recommend` ranks the devices that carry one part's stress by estimated loss, says whether your gate drive clears each device's plateau, and with `apply` assigns the best one, or the one you `choose`. - `device.fromPartNumber` looks up a part number, part of one, or key specs such as `650 V < 20 mΩ TO-247` or `10u 50V 1206`. Type it in the **Part number** field in **Properties** and press Enter: a semiconductor gets its loss and thermal tables, a capacitor its capacitance and data-sheet ESR, an inductor its inductance, DCR and saturation current, and the log names the data sheet. - *In the next release:* **Library › Search Parts** (`parts.search`) searches every part source at once by part number, category and specs, one line per part with its key specs, package, price, stock and where the data came from. **Place** (`parts.place`) puts it on the schematic with its values filled, in one undo step. It works offline on the shipped catalogue. ## The vendor device library The built-in library holds 92 vendor semiconductors from 9 manufacturers: 74 MOSFETs (silicon, SiC and GaN), 3 IGBTs and 15 diodes. *In the next release:* 24 more Infineon IGBTs, 16 of them power modules, bring it to 116. 34 more MOSFETs follow them: 600–650 V silicon superjunction parts for power factor correction, 650 V GaN, 40–150 V silicon for 48 V stages and LLC rectifiers, and parts from Taiwanese makers. That makes 150 vendor devices from 20 manufacturers, 108 of them MOSFETs. Each cites its data sheet: the document, its revision and the figures and tables its values were read from. Next to it, `bom.export` picks passives from a catalogue of 577 capacitors, 96 inductors and 10 resistor families, each with its source. Six generic devices are marked illustrative: they are for exploring, and `buyable: true` keeps them out of the proposals whenever a vendor part qualifies. [Models and parts](https://voltecx-web.nguyenvanqui291.workers.dev/features/models-and-parts) covers the GaN devices, the IGBT modules and how to bring your own vendor SPICE model. ## Your own parts When no catalogue part fits a line, add your own. **Library › Your Parts** (`parts.check`) takes a part read off a data sheet: its kind, part number, manufacturer, source and ratings. It flags missing fields, values that are not numbers and values outside the range real parts have, which is usually a unit slip. It also shows which result each field changes. Paste the data sheet's text and it suggests the values it finds, quoting the line each came from. **Fill in from BOM line** starts from the empty template of an unmatched line. `parts.list` lists your library. It stays on your computer: the desktop app keeps it in a local file, and nothing is uploaded. `bom.export` then uses your part for a line no catalogue part fits, marked `user` with the source you gave. *In the next release:* the library is a small manager. Search it and group parts by category, edit a part in place (`parts.update`), and move a team's approved-parts list between machines as CSV or JSON (`parts.export`, `parts.import`); an import names every row it leaves out and keeps the good ones. *Also in the next release:* add a part from its data sheet with a review. Each value is read with its page and table, a field the sheet does not give stays empty, and nothing is saved until you check the values and press Save (`parts.fromDatasheet`). ## The bill of materials `bom.export` (**File › Export › Bill of materials**, also in Design › Manufacturing) picks a part for every component from the stress of the last run, with the same derating: capacitors, resistors and inductors from the passive catalogue, switches and diodes from the device library or the device already assigned, and a transformer or inductor designed by `magnetics.design` as a custom wound line. Each line says how it was filled (`matched`, `assigned`, `custom`, `user`, `illustrative` or `unmatched`) and lists alternates. A line without a part carries the template to fill in. The CSV has the KiCad BOM columns first, then the purchasing columns, each part's source, its lifecycle status, qualification and second sources. Prices come only from what you give (`prices`), from Nexar when `NEXAR_TOKEN` is set, or from the offline price list, which ships empty. A part without a price stays unpriced, and the totals say whether the list is complete. `prefer: "cost"` compares the price of the best candidates. *In the next release:* `boards` reads each price at the quantity break of a production run. `grade: "automotive"` and `lifecycle: "avoid"` or `"active"` filter on the supply records, and each line names the candidates they left out. [How to cut the cost of a power supply](https://voltecx-web.nguyenvanqui291.workers.dev/blog/power-supply-cost-optimisation) shows where those choices move the cost. *In the next release:* **View › Bill of Materials** shows the same list in the app as a table of designators, value, rating, part number, manufacturer, pieces and DNP. Click a line to select its parts on the schematic, or a header to sort by designator, value or quantity. Scripts read the rows with `bom.list`. ## Compare two BOMs `bom.diff` takes two `bom.export` replies, one per version of the circuit, and lists the lines added and removed and, per reference designator, a changed status, part number, manufacturer, value, quantity, footprint or unit price, with the change in total cost, pieces and board area. It runs nothing and changes nothing. ## Fitted or not: DNP A DNP (do not populate) part keeps its footprint on the board but is not fitted. `circuit.setDnp`, or the **DNP** box in **Properties**, marks it in one undo step. It is drawn dashed with a DNP mark, left out of the simulation, listed in the BOM's DNP section with the value it would have, and exported to KiCad with `dnp yes`. The debug aids of **Design › Automate › Debug Aids** use it for the snubber, gate-resistor and bulk-capacitor footprints you may fit at bring-up. ## On to KiCad and the assembly house `file.exportKicad` (**File › Export › KiCad project**) writes a KiCad 8 schematic with the Reference, Value, Footprint, Datasheet, MPN, Manufacturer and Source of every part taken from `bom.export`. It also writes a project with net classes sized for the voltage and current of each net, a design-rules file with clearances from IPC-2221B, and a pcbnew script that places the hot loop and the gate parts. Voltecx writes no board file: the layout is yours. Once you have routed the board, `file.manufacturingOutputs` (**Design › Manufacturing › Manufacturing Outputs**) runs kicad-cli (KiCad 10) for the design rules check with schematic parity, Gerbers, drill files, the position file, the BOM in a generic or JLCPCB format and an assembly drawing. It lists whatever still stands between the board and an order, such as unrouted nets, DRC errors or a part without an MPN. It needs KiCad installed on the desktop. `bom.export`, `bom.diff`, `design.parts` and `device.recommend` are in the Parts & ICs licence module; `file.exportKicad` and `file.manufacturingOutputs` are in EMI & Layout. See [licences](https://voltecx-web.nguyenvanqui291.workers.dev/features/licences-and-protection). ## From a script ```sh powercraft-cli run --root work --cmd file.openExample --param name=buck \ --cmd simulation.run \ --cmd design.parts --params '{"passives": true}' \ --cmd bom.export --params '{"priceSource": "offline", "csvPath": "buck-bom.csv"}' \ --cmd file.exportKicad --params '{"path": "buck.kicad_sch"}' ``` Each command prints one JSON line: the rated parts with their margins and watch lists, the bill of materials, and the KiCad files written under `work`. `passives` is in the next release; in 0.9.0 leave it out. More in the manual: [the Design panel](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/07-design-panel/), [`bom.export`, `file.exportKicad` and `file.manufacturingOutputs`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/16-automatic-design/) and [comparing two versions](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/09-import-export/). The whole flow from spec to hand-off is on [Design tools](https://voltecx-web.nguyenvanqui291.workers.dev/features/design-tools). --- # The workbench in a browser tab URL: https://voltecx-web.nguyenvanqui291.workers.dev/features/browser-version/ The browser version is the Voltecx workbench built for the web: the same simulation engine, menus and scope, in a browser tab, with nothing to install. It is meant for quick looks: open an example, run it, change a value, run it again. For real work, use the desktop app. Six things differ. ## 1. Files go through the browser A browser page has no file system, so **File › Open** and **File › Import** use the browser's file chooser, and everything Voltecx writes is downloaded instead: **Save** and **Save As** download the `.voltecx` file, and **Export Netlist**, **Export Waveforms** and the scope image download their file named after the circuit. Files over 64 MB are refused. ## 2. Limits for quick looks Each run stops at one million steps, and circuits are limited to 50 parts (the largest built-in example fits). A run that reaches a limit says so and names the desktop app. To stay inside the step limit, raise the maximum step or shorten the end time. ## 3. Drop a file to open it Drop a circuit, a SPICE netlist or another simulator's schematic anywhere on the page. A circuit opens; a netlist or schematic is imported. Voltecx recognises the file by its extension, and by its first bytes when the extension says nothing. ## 4. No cloud features The browser version has no assistant, so it never asks for an API key and keeps none. **Auto Design** runs on Voltecx Cloud and needs the desktop app; in the browser the command answers with that message instead of running. The assistant is in the desktop app and in the command-line tool (see [Use Voltecx with AI](https://voltecx-web.nguyenvanqui291.workers.dev/ai/)). ## 5. No terminal The integrated terminal opens a shell on your computer, which a browser page cannot do. Its menu items are not in the browser version. ## 6. Recovery copies stay in this browser Unsaved circuits are copied into the browser's storage a few seconds after each change, and when the tab is hidden or closed, so a reload brings them back. Each tab keeps its own copies, and circuits over 4 MB are not kept. Only **Save** keeps a file: clearing the browser's data removes the copies. --- # Power supply design — DC-DC and AC-DC URL: https://voltecx-web.nguyenvanqui291.workers.dev/use-cases/power-supply/ A power-supply spec is a table of corners: low line and high line, light load and full load, cold and hot. A design is done when every corner passes. Voltecx is built around that table. ## From spec to first design in one run Write the spec, `{"vin": [10.8, 13.2], "vout": 3.3, "iout": 5, "ripple": 0.05}` plus the load step, start-up, efficiency, temperature and margin limits you need, and run **Design › Auto Design**. Voltecx ranks topologies, sizes the stage and the magnetics, closes the voltage loop, runs every corner, picks devices from cited data sheets and writes a report with one row per requirement. Topologies it designs today: buck, synchronous buck, boost, synchronous boost, inverting buck-boost, SEPIC and flyback with closed loops; four-switch buck-boost, LLC and phase-shifted full bridge are drawn and sized with an open or template loop. ## For off-line flybacks - `magnetics.design` picks core, material, gap, turns and wire from the simulated magnetising current, and writes a winding build sheet. - The isolated feedback stage designs a TL431 and optocoupler network for a peak-current-mode controller, checked at the highest, lowest and end-of-life CTR of the opto bin. - Built-in examples show a TL431 and optocoupler loop and a TVS clamp. ## Check what a review will ask - **Loop margins** over the input and load range with `design.robustLoop` and `analysis.loopGain`. - **Efficiency and junction temperature** at your hottest ambient with `design.efficiency` and `design.thermal`. - **Tolerances:** worst case and seeded Monte Carlo yield. - **Conducted EMI** pre-compliance estimate against CISPR 32 class A or B with `emi.conducted`, and an input filter sized and checked against Middlebrook's stability condition. With a floating return it splits differential and common mode, and with your standard's Y-capacitor or touch-current limit it adds a catalogue common-mode choke and Y capacitors to the filter. - **Protection:** current-sense shunt, peak-current trip, blanking, OVP/UVLO thresholds and soft start with `design.protection`; the Test Bench runs OCP, OVP, UVLO, inrush and hold-up cases one at a time. - **Radiated EMI** estimate from 30 MHz to 1 GHz against CISPR 32 with `emi.radiated` (**Design › Automate › Radiated EMI**): the switch node's capacitance comes from the circuit when it is drawn, every value it had to assume is shown in its own box to replace with the board's, and it ranks the layout changes that help most. ## Hand off The run writes a bill of materials, the gate-driver and bootstrap parts, the sense network into an STM32G474 ADC, fixed-point firmware, layout hints with an inductance budget for each hot loop, and a KiCad schematic and project. ## Know the limits EMI, layout and price figures are estimates; a pass is not a compliance result. The conducted EMI estimate uses ideal parts unless you turn on parasitic elements, which take capacitor ESR and ESL, inductor winding capacitance and switch Coss from your circuit, your data-sheet values, the capacitor catalogue or the device's Coss table, and list every value that is missing instead of assuming it. PFC front ends are simulated (the `pfcBoost`, `interleavedPfc` and `totemPolePfc` examples), and `emi.conducted` measures their mains input with a LISN on L and N over a whole mains period, but `design.auto` does not design them yet. Low-voltage MOSFET data sheets give no switching energy, so those parts add no switching loss in the model. Nothing has been compared with a built board yet. Related: [Automatic design](https://voltecx-web.nguyenvanqui291.workers.dev/features/auto-design) · [Analyses](https://voltecx-web.nguyenvanqui291.workers.dev/features/analyses) · [Flyback transformer design steps](https://voltecx-web.nguyenvanqui291.workers.dev/blog/flyback-transformer-design-steps) --- # EV chargers and on-board chargers URL: https://voltecx-web.nguyenvanqui291.workers.dev/use-cases/ev-charger/ A charger is a chain of stages: a power-factor corrector or active front end, a DC link, and an isolated DC-DC stage that must keep soft switching over a wide output range. Voltecx has examples of each stage and the analyses to check them. ## Stages you can open today | Stage | Built-in example | |---|---| | Single-phase PFC | `pfcBoost` (1 kW, 230 V to 400 V) and `interleavedPfc` (2 kW, two phases) | | Three-phase front end | `viennaRectifier` (5 kW, 800 V link) and `afe3Phase` (5 kW, 700 V link) | | Resonant DC-DC | `llcHalfBridge` (400 V to 48 V, 100 kHz) | | Phase-shifted full bridge | `psfb` (400 V to 48 V, 1 kW, ZVS on both legs at full load) | | Bidirectional DC-DC | `dab` (about 4.4 kW from a 400 V to a 200 V bus) | | Battery charging | `batteryCharger` (constant current, then constant voltage) | All example values are illustrative, chosen to show the circuit working. ## SiC and soft switching - Vendor SiC MOSFETs and diodes from Wolfspeed, Infineon and ROHM, rated 600 V to 1200 V, each citing its data-sheet revision and figures. The `doublePulse` example switches a SiC MOSFET at 400 V and 20 A; the accuracy report compares simulated Eon and Eoff with two data sheets (within 6.9 % to 14.3 %, tolerance 30 %). - `analysis.softSwitching` classifies every turn-on as ZVS, partial or hard, measures the energy lost to hard turn-ons, checks each leg's dead time and, with a load sweep, shows where ZVS is lost. - `design.llc` sizes the resonant tank for your whole input range and checks it by simulation. ## Losses and heat `analysis.losses` splits conduction and switching loss per device. Thermal networks carry the heat from junction to heatsink, with a slower thermal step so long runs stay quick. `analysis.stress` compares each part's peak and RMS values with its derated rating. ## Control dq current control and DC-voltage loops are in the front-end examples. Generate C99 for the sampled control blocks, with set-up code for STM32G474 or TI F28379D. ## Know the limits PFC, LLC frequency control and dual active bridges are not designed automatically by `design.auto` yet; you size them with the Design panel tools and simulation. No result has been compared with a built charger or with another simulator. Related: [Simulation](https://voltecx-web.nguyenvanqui291.workers.dev/features/simulation) · [LLC resonant tank design](https://voltecx-web.nguyenvanqui291.workers.dev/blog/llc-resonant-tank-design) · [Dead-time effects](https://voltecx-web.nguyenvanqui291.workers.dev/blog/dead-time-effects) --- # Solar inverters and energy storage URL: https://voltecx-web.nguyenvanqui291.workers.dev/use-cases/solar-storage/ Solar and storage systems combine slow sources and fast switching: a PV array that moves with the sun, a battery with its state of charge, and a grid that sets the rules for the current you inject. Voltecx models both time scales in one circuit. ## Sources and storage - **Solar modules** with their I-V curve, in series and parallel strings. - **Batteries** with state of charge, **supercapacitors** and **fuel cells** that follow a polarisation curve. - **Three-phase grid** source, line impedance, breakers and faults. - **Wind turbines** with a doubly fed induction generator or a direct-drive PM generator. ## Examples to start from | What | Example | |---|---| | PV charger with perturb-and-observe MPPT, boost into a 104 V battery | `pvMppt` | | Single-phase grid-tie inverter: LCL filter, PLL, resonant current control | `gridTieInverter` | | Three-phase active front end, unity power factor, 700 V link | `afe3Phase` | | Three-level NPC inverter on an 800 V split link | `npcInverter` | | CC-CV charger for a four-cell lithium-ion pack | `batteryCharger` | | Four-cell pack with passive (bleed-resistor) balancing | `passiveBalancing4s` | | Four-cell pack with active (switched-capacitor) balancing | `activeBalancing4s` | | Four-cell pack with active (inductor) balancing | `inductorBalancing4s` | | Four-cell pack with a cell thermal model (core and can) | `packThermal4s` | | Four-cell aged pack: the weakest cell sets the usable charge | `agedPack4s` | | Wind turbines | `windDfig`, `windPmsg` | All example values are illustrative. ## What to check - **Harmonics and THD** of the injected current with `analysis.fft` and the scope's THD measurement; **power and power factor** on the scope. - **Losses** per device and **junction temperatures** through thermal networks, with a multi-rate thermal step for long runs. - **Long runs:** variable-step simulation lands exactly on switching events, and older results are parked on disk so memory stays bounded. - **Load traces:** replay a measured logger or PMBus trace as a load profile with `circuit.importLoadTrace`. ## Control to code Build PLLs, dq transforms, PI and resonant controllers from blocks, then generate C99 for the sampled ones, with set-up code for STM32G474 or TI F28379D. ## Know the limits Grid-code compliance is not checked, and `design.auto` does not design inverters or PFC stages yet. Battery, PV and fuel-cell parameters have no defaults that stand for a product: take them from your data sheet or measurement. No result has been compared with field data. Related: [Analyses](https://voltecx-web.nguyenvanqui291.workers.dev/features/analyses) · [Code generation](https://voltecx-web.nguyenvanqui291.workers.dev/features/code-generation) · [MOSFET loss and thermal estimation](https://voltecx-web.nguyenvanqui291.workers.dev/blog/mosfet-loss-and-thermal-estimation) --- # Motor drives — induction, PMSM, BLDC and DC URL: https://voltecx-web.nguyenvanqui291.workers.dev/use-cases/motor-drive/ A motor drive is an electrical machine, a mechanical load, an inverter and a controller running at a fixed sample rate. Voltecx models all four in one circuit, and generates C for the controller from the same blocks. ## Machines and loads - Induction machines (squirrel cage and wound rotor), synchronous and PM synchronous machines, brushless DC with Hall signals, and DC machines. - Mechanical loads and shafts, so torque, speed and inertia are part of the simulation. - Start from the numbers on a data sheet or name plate. The equations, pins and parameter tables are in the motor-drive documentation. ## Control schemes, as examples | Scheme | Example | |---|---| | Induction motor, V/f | `imVf` | | Induction motor, indirect field-oriented control | `imIfoc` | | Induction motor, direct torque control (hysteresis and switching table) | `imDtc` | | PMSM, field-oriented control | `pmsmFoc` | | PMSM, sensorless with a sliding-mode observer (`smo` block) | `pmsmSmo` | | BLDC, six-step commutation with a speed PI | `bldcSixStep` | | DC motor | `dcMotor` | | Robot joint servo: 48 V GaN inverter, encoder, cascaded position, speed and current loops, gear | `robotJointServo` | | Regenerative braking into a bus that cannot take it, with a brake chopper | `regenBrake` | Clarke, Park and dq transforms, SVPWM, PI and PID with anti-windup and the sample delay of a microcontroller (`mcu` block) are blocks you wire like any other. ## Inverter losses and heat `inverter3Thermal` adds dq current control and a thermal model for every device. `analysis.losses` splits conduction and switching loss per switch and diode; thermal networks give junction temperatures over a load cycle, with a slower thermal step so a one-second run stays quick. `analysis.softSwitching` checks the dead time of each leg against how long the switch node took to swing. ## From model to firmware **Tools › Code Generation** turns the sampled control blocks into C99 with no `malloc`, with set-up and interrupt code for STM32G474 (TIM1 and ADC1) or TI F28379D (ePWM1 and ADC-A, with a Code Composer Studio project). A UART logger in the generated code lets you compare what the real controller computed with the simulation. ## Know the limits Generated C was checked against the simulator's block evaluation, not compiled in the tests: build and verify it with your toolchain. `design.auto` designs DC-DC converters, not drives; drive control loops are designed with the Design panel's current and speed loop tools. No drive has been compared with a test bench yet. Related: [Code generation](https://voltecx-web.nguyenvanqui291.workers.dev/features/code-generation) · [Dead-time effects](https://voltecx-web.nguyenvanqui291.workers.dev/blog/dead-time-effects) · [Analyses](https://voltecx-web.nguyenvanqui291.workers.dev/features/analyses) --- # Server power supplies and 48 V racks URL: https://voltecx-web.nguyenvanqui291.workers.dev/use-cases/server-power/ Server and AI-rack power is judged by efficiency at every load point, by how the output holds through fast load steps, and by what happens when the mains drops. Voltecx gives you the stages, the loads and the checks for each of those questions. ## Stages - **Front end:** boost PFC and two-phase interleaved PFC examples. - **Isolated DC-DC:** LLC half bridge (400 V to 48 V), phase-shifted full bridge (400 V to 48 V, 1 kW) and dual active bridge examples; `design.llc` sizes an LLC tank for your input range. - **Point of load:** `design.auto` designs synchronous buck and multiphase buck stages from a spec, with the loop checked over every corner. ## Loads that behave like real ones - **Constant-power load** (`powerLoad`) with UVLO thresholds. Its negative incremental resistance shows whether an input filter rings. - **Load profiles:** pulses, steps, a voltage-regulator load step with slew in A/µs (`vrstep`), and an AI-training workload cycle (`workload`). An example takes its workload from Choukse et al., "Power Stabilization for AI Training Datacenters" (arXiv:2508.14318v2, 2025), on an OCP Open Rack V3 48 V shelf. - **Measured traces:** `circuit.importLoadTrace` reads a logger, PMBus or scope CSV and writes it as the load's profile, keeping its energy. - **Hold-up:** the Test Bench cuts the input and measures how long the bus stays above your minimum. ## Checks a power review asks for - Efficiency at up to 16 load points and junction temperatures at the hottest ambient. - Load-step droop and recovery, with `loadStep.slew` and a load-line check for voltage-regulator specs. - Loop margins over the input and load range, including firmware delay. - ZVS over load for resonant and phase-shifted stages with `analysis.softSwitching`. - Conducted-EMI pre-compliance estimate against CISPR 32. ## Know the limits PFC is not designed by `design.auto` yet, and the LLC frequency loop is not closed. EMI figures are estimates, not measurements. Load-profile numbers have no defaults: take them from your measurement or a cited source. Nothing has been compared with a built PSU. Related: [Power supply design](https://voltecx-web.nguyenvanqui291.workers.dev/use-cases/power-supply) · [LLC resonant tank design](https://voltecx-web.nguyenvanqui291.workers.dev/blog/llc-resonant-tank-design) · [Monte Carlo tolerance analysis](https://voltecx-web.nguyenvanqui291.workers.dev/blog/monte-carlo-tolerance-analysis-power-supply) --- # Teaching and research in power electronics URL: https://voltecx-web.nguyenvanqui291.workers.dev/use-cases/education-research/ A power-electronics course needs students to change circuits and see the result; a research lab needs results that someone else can reproduce. Voltecx supports both. ## In the classroom - **Install on any student laptop.** The free tier runs offline with no account and no licence key. A browser version opens the same examples for a quick look. - **55 examples with known answers**, from RC step responses to PFC, LLC, DAB, grid-tie inverters and field-oriented motor control. Each opens with its main signals on the scope and a list of things to try. - **See it move.** Circuit animation (Shift+F8) shows current flow, node voltages and switch states on the schematic, synchronised with the scope cursor. - **Two languages.** The interface, the user manual and the reference page for each of 137 parts are in English and Traditional Chinese. - **Exercises as scripts.** A lab sheet can be a list of commands: open an example, change a value, run, measure. The command-line tool's `sim --expect` check returns pass or fail with an exit code, which suits automated checking of assignments. ## In the lab - **Python and Jupyter** with NumPy and pandas; sweeps and Monte Carlo runs with a seed, so a figure can be regenerated. - **Plain-JSON circuit files** that diff in version control and keep numbers bit for bit. - **Figures:** scope plots as SVG, schematic figures as SVG or LaTeX `circuitikz` (beta), design reports as HTML or PDF. - **Models with references:** vendor devices cite the data-sheet revision and figure; the design equations follow Erickson and Maksimović. - **Your own blocks** as sandboxed WebAssembly; C99 export for STM32G474 and TI F28379D boards. - **The built-in assistant** runs the simulator with the same commands you use, with file access limited to the folders you allow, which makes Voltecx a test bed for research on AI-assisted design. ## Academic plan Terms are not set yet. See the [academic program](https://voltecx-web.nguyenvanqui291.workers.dev/academic) and tell us about your course. ## Know the limits No result has been compared with the waveforms of other simulators or with hardware. LaTeX figures have not been typeset in the tests: compile your first one and check it. The browser version limits each run to one million steps. Related: [Academic program](https://voltecx-web.nguyenvanqui291.workers.dev/academic) · [Automation](https://voltecx-web.nguyenvanqui291.workers.dev/features/automation) · [Loop gain and phase margin in simulation](https://voltecx-web.nguyenvanqui291.workers.dev/blog/loop-gain-phase-margin-simulation) --- # LED driver design — constant current and dimming URL: https://voltecx-web.nguyenvanqui291.workers.dev/use-cases/led-drivers/ An LED wants a current, not a voltage. A driver holds the string's current and lets its voltage fall where it will, and it has to dim: by lowering the current (analog dimming) or by switching it on and off (PWM dimming). Each way brings its own check. ## What the job needs checked - **The held current and its ripple.** The mean string current at full and at dimmed brightness, the peak the LEDs see, and the switching frequency the regulation settles at. - **Flicker.** PWM dimming makes the light go fully off between pulses. IEEE Std 1789-2015 sets a low-risk limit on percent flicker that rises with the dimming frequency and sets none above 1250 Hz, so a 1 kHz dimming that is fine to the eye can still fail. - **The shortest pulse.** A pulse needs time to rise from zero, so a very short dimming duty never reaches regulation. - **The loop on a boost.** A boost driver steps up onto a long string and has a right-half-plane zero, so its current loop needs phase margin against it. ## How Voltecx does it - **Design › Design Steps › LED Driver** (`design.ledDriver`) reads the open circuit, sizes a hysteretic buck or a PI-controlled boost, and reports the switching frequency, the mean and peak current, the shortest dimming duty, the percent flicker and the IEEE 1789 limit at your dimming frequency. With `verify` it simulates the circuit and checks the mean current; with `apply` it writes the parts in one undoable step. - Two examples ship ready to run: a buck from 48 V with 1 kHz PWM dimming, and a boost from 12 V onto ten LEDs with both analog and 200 Hz PWM dimming. - `scope.measure` reads the current held inside a pulse and its mean over a dimming period. ![The LED current of the boost driver example simulated in Voltecx over two 200 Hz dimming periods at half duty, with the analog level Adim at 0.6 and at 0.3. Inside each pulse the loop holds 0.307 A and 0.152 A; over a period the means are 0.150 A and 0.075 A.](https://voltecx-web.nguyenvanqui291.workers.dev/media/use-cases/led-drivers/dimming.svg) The figure is the boost example dimmed both ways at once. Halving `Adim` halves the current inside each pulse with no flicker added; the PWM duty sets how long the current flows. At 200 Hz the flicker limit is 16 %, and PWM dimming gives 100 %, so a design dimmed at 200 Hz should dim with the current and keep PWM above 1250 Hz. ## Try it [Tutorial 23](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/23-led-drivers/) opens both drivers, sizes the buck, shows why 1 kHz PWM dimming fails the flicker check and 2 kHz passes, and dims the boost both ways. About 15 minutes. ## Know the limits The LEDs in the examples are illustrative: each is a 3 V threshold and a 1 Ω straight line, not a part from a data sheet. Percent flicker is computed from the simulated current; the light output of a real LED, its colour shift with current and its temperature are not modelled. Nothing has been compared with a built driver yet. Related: [Design tools](https://voltecx-web.nguyenvanqui291.workers.dev/features/design-tools) · [Examples](https://voltecx-web.nguyenvanqui291.workers.dev/features/examples) · [Scope](https://voltecx-web.nguyenvanqui291.workers.dev/features/scope) --- # Battery charger design — CC-CV URL: https://voltecx-web.nguyenvanqui291.workers.dev/use-cases/battery-chargers/ A lithium-ion pack charges in two stages. While it is low the charger pushes a fixed current (CC); when the pack reaches its voltage limit the charger holds that voltage (CV) and the current tapers away. A charger design is a pair of nested loops and a limit between them, and the check is that the hand-over is clean. ## What the job needs checked - **The constant current.** That the inner loop holds the current at its limit while the pack is low. - **The hand-over.** When the outer voltage loop leaves its limit, and that the pack voltage does not overshoot the target as it does. - **The taper and the end.** That the voltage is held at the target while the current falls, and how far the charge has come by the end. - **The limit as a design choice.** A lower current charges more gently and takes longer to reach the same state. ## How Voltecx does it - The example **Battery charger, constant current then constant voltage** is a synchronous buck from 24 V onto four cells in series, with an inner current loop and an outer PI voltage loop whose output is limited between 0 and the CC current. - The battery model carries its state of charge, so the pack's rest voltage rises during the run and the taper follows from the physics, not from a script. - `scope.measure` reads the held current, the hand-over time and the end state; change `Icc` or the target `Vcv` under **Circuit › Variables**, or sweep them with `analysis.paramSweep`. ![The pack voltage, the battery current and the current reference of the charger example simulated in Voltecx over 0.6 s. The current is held at 5.00 A until the pack reaches 16.6 V at about 150 ms, then the voltage is held at 16.61 V while the current tapers towards zero.](https://voltecx-web.nguyenvanqui291.workers.dev/media/use-cases/battery-chargers/cc-cv.svg) ## Try it [Tutorial 25](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/25-battery-charger/) runs the charger, reads the hand-over on the scope and halves the current limit to move it from 150 ms to 330 ms. About 10 minutes. [Tutorial 22](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/22-long-battery-run/) charges a real pack for 1.5 hours in seconds of compute. ## Know the limits The example's pack has a capacity of 1 mAh, far smaller than any real pack, so the charge moves in a fraction of a second instead of hours; its parameters are illustrative, not a cell's data sheet. Pre-charge of a deeply discharged pack, termination by a current threshold and temperature-dependent limits are not in the example. Nothing has been compared with a built charger yet. Related: [Simulation](https://voltecx-web.nguyenvanqui291.workers.dev/features/simulation) · [Models and parts](https://voltecx-web.nguyenvanqui291.workers.dev/features/models-and-parts) · [Solar and storage](https://voltecx-web.nguyenvanqui291.workers.dev/use-cases/solar-storage) --- # Wireless power design — resonant inductive links URL: https://voltecx-web.nguyenvanqui291.workers.dev/use-cases/wireless-power/ Two coils a few centimetres apart pass power through the air. Each coil alone is a poor transformer, with a coupling factor `k` far below 1, so each is tuned by a series capacitor to the switching frequency. The pads will not always sit where they were designed to, and the tuning drifts, so a design has to be checked over coupling and detuning, not at one point. ## What the job needs checked - **Coupling.** A series-series link is a current source: the secondary current is the bridge voltage over `ω·M`. Halving the coupling roughly doubles the output into a fixed load and raises the primary current faster still, so misalignment changes the operating point a lot. - **Efficiency.** The coils' resistance is the loss, and it grows with the current the primary carries for each ampere delivered. - **Detuning.** A capacitor off its value leaves the output nearly where it was but reflects reactance into the primary: the bridge sees more current for the same power, a lower power factor and loses its zero-current turn-on. ## How Voltecx does it - The example **Wireless power transfer, series-series** is a full bridge at 85 kHz into two 120 µH coils coupled at `k` = 0.2, each with its tuning capacitor and winding resistance, then a diode bridge onto a 10 Ω load. The secondary sits on its own ground, joined to the primary only through a high-value tie, so the air gap is drawn as the barrier between the two halves of the schematic. - Change `k` or a tuning capacitor under **Circuit › Variables**, or sweep `k` in one call with `analysis.paramSweep`. - `scope.measure` with a product gives the power in and out and the link efficiency over whole periods. ![The bridge voltage and the primary and secondary coil currents of the wireless power example simulated in Voltecx over three 85 kHz periods at k = 0.2. The square wave drives near-sinusoidal coil currents; the link delivers 101 W at 96.4 % efficiency.](https://voltecx-web.nguyenvanqui291.workers.dev/media/use-cases/wireless-power/link.svg) At `k` = 0.2 the output is 31.1 V; with the pads moved apart to `k` = 0.1 it rises to 59.3 V into the same load, which is why a real charger regulates against coupling. ## Try it [Tutorial 24](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/24-wireless-power/) runs the link, misaligns the pads to `k` = 0.1 and 0.3, and detunes the secondary capacitor by 10 % to show the power factor fall. About 15 minutes. ## Know the limits The coils in the example are illustrative, 120 µH each with a quality factor of 300, not a product's pads, and `k` is a number you set: Voltecx does not compute it from the pad geometry in this example. The example has no regulation loop, no foreign-object detection and no field-exposure check. Nothing has been compared with a built link yet. Related: [Simulation](https://voltecx-web.nguyenvanqui291.workers.dev/features/simulation) · [Analyses](https://voltecx-web.nguyenvanqui291.workers.dev/features/analyses) · [Isolation and gate drive](https://voltecx-web.nguyenvanqui291.workers.dev/features/isolation-and-gate-drive) --- # Move an LTspice project to Voltecx URL: https://voltecx-web.nguyenvanqui291.workers.dev/guides/migrate-from-ltspice/ LTspice is where many power-supply designs start. You do not have to leave your files behind to try Voltecx. Voltecx reads LTspice `.asc` schematics and SPICE netlists, runs the analyses the file asks for, and writes your edits back into the original `.asc` file. This guide walks through a migration step by step and says plainly where the limits are. LTspice is a trademark of Analog Devices, Inc. Voltecx is an independent product. It is not affiliated with, sponsored by or endorsed by Analog Devices. Voltecx reads LTspice files only so that you can keep working with them. ## What to expect - **Import keeps the file.** The original schematic is stored inside the Voltecx circuit. A file you import and export again without edits comes back byte for byte. - **Edits touch only their own lines.** Change one resistor value and one line of the `.asc` file changes. Spacing, line endings and lines Voltecx does not understand stay as they were. - **Nothing is dropped silently.** A symbol, parameter or directive that Voltecx cannot map is listed in the warnings, and the rest of the file stays intact. - **What was measured.** In a run on 2026-10-15, all 332 public LTspice sample schematics in our test corpus wrote back byte for byte, with no crash. Most of them also import and run a short simulation; the files that do not run usually define variables in an include file or script that was not published with them. The samples are files their authors published on GitHub, never files that ship with LTspice. - **What was not tested.** No file written by Voltecx has been opened in LTspice itself. The guarantees come from the format rules and from tests on public files. ## Step 1: Convert the schematic In a terminal: ```sh powercraft-cli convert design.asc design.voltecx powercraft design.voltecx ``` Or, in the desktop app, choose **File > Import** and pick the file. **File > Open** also takes `.asc` files directly, as well as SPICE netlists (`.cir`, `.net`, `.sp`, `.spice`, `.ckt`). A new circuit opens with an automatic layout. From a script or an AI assistant, the same step is the `file.import` command: ```json {"path": "design.asc", "format": "auto"} ``` ## Step 2: Point Voltecx at your symbol files A symbol that LTspice does not build in is described by its own `.asy` file. Voltecx looks for it next to the schematic first, then in the folders you name: ```sh powercraft-cli convert design.asc design.voltecx --sym ~/my-lib/sym --sym ~/other-lib/sym ``` With `file.import`, pass `{"path": "design.asc", "symbolPaths": ["lib/sym"]}` (up to 32 folders). A symbol file whose prefix is a primitive (`R`, `C`, `L`, `D`, `V`, `I`, `MN`, `MP`) imports as that part. The control-library symbols (gain, integrator, delay, limiter and so on), logic gates and the blocks of the public LTspicePowerSim library are recognised by the pin names in their symbol files. The symbol files that were read are stored in the circuit, so writing back opens no extra file. A symbol whose file is not found is named in one warning. ## Step 3: Includes, parameters and models `.include`, `.inc` and `.lib` lines are followed when you import by path. Voltecx reads every `.param` in an included file and the `.model` and `.subckt` definitions the schematic uses. Paths are relative to the file that names them. Cycles, nesting deeper than 8 levels, more than 64 files and files over 8 MB are skipped with a warning. A missing include is named in a warning, and if variables stay undefined, the error says they probably live in that file. ## Step 4: Read the warnings Read the import warnings before you trust a result. The ones that matter most for power circuits: - **MOSFETs with vendor or VDMOS models** become an ideal switch driven by the gate-source voltage (on above 2 V, 10 mΩ). The vendor model is not read, and a warning says so. For switching loss, assign a device from the Voltecx library, which carries data-sheet values with their source. - **Named op-amps** such as an LT part number become a generic op-amp, with a warning that the part's own model is not used. - **Zener breakdown** is not modelled on import. - **Ratings and part data** in `SpiceLine` (`V=`, `Irms=`, `mfg=`) are reported, not used. `Rser`, `Lser` and `Rpar` on inductors and capacitors are used: they become winding resistance, ESR, ESL and leakage or core-loss resistance. - **Hierarchical sheets** are not read. Then check the topology. `circuit.explain` reads a circuit you did not draw and says, without simulating, what it is: the topology with a confidence, the role of each part (for example `S1: high-side switch`) and the main loops. ## Step 5: Run what the file asked for Voltecx keeps the analysis directives of the schematic instead of ignoring them: | Directive | In Voltecx | |---|---| | `.tran` | The end time and maximum step of the simulation. A `.tran` without a maximum step gets one that keeps the run between 50 and a million steps | | `.step` (`param`, `list`, `lin`, `oct`, `dec`) | A parameter step. `.step temp` and a step of a source give a precise warning | | `.ac dec`, `oct`, `lin` | An AC sweep. `lin` becomes a log sweep, with a warning | | `.op`, `.dc`, `.tf` | The DC operating point, a DC sweep of the first source, and the DC transfer function | | `.meas` (`TRAN`, `AC`, `OP`, `DC`) | Translated: `AVG`, `RMS`, `MAX`, `MIN`, `PP`, `INTEG` with `FROM`/`TO`, `FIND ... AT`, `FIND ... WHEN`, `WHEN`, `TRIG ... TARG` and `PARAM`. Functions such as `ph()` are refused with a warning | | `.options` | `reltol`, `abstol`, `vntol`, `maxstep` and `method` become simulation settings. Quoted `method="gear"` and `modtrap` are read. The rest is listed as ignored | | `.ic` | Initial conditions, including `I(L1)=` for an inductor current | To run them, call `analysis.runImported`. It never edits the circuit: ```json {"what": "all"} ``` `what` is `all`, `tran`, `step`, `ac`, `op`, `dc` or `tf`. Stepped runs go in parallel on your cores. Each `.meas` line is evaluated on its own, so an error in one does not stop the others. ## Step 6: Check the numbers twice Voltecx has two solvers. **fast** is the everyday solver for switching circuits. **reference** is a deliberately simple solver whose job is to check the fast one. When a result surprises you, run it again with the reference solver: ```sh powercraft-cli run --in design.voltecx \ --cmd simulation.run --params '{"solver": "reference"}' \ --cmd scope.measure --params '{"signals": ["v(out)"], "t0": "3m"}' ``` Both solvers are checked in the test suite against closed-form answers and against waveforms computed by ngspice for the same netlists. The current results are in the accuracy report. Then pin the numbers that matter with `powercraft-cli sim`. It runs a file, measures, and sets its exit code by whether your limits hold, so it fits a CI job. It takes the `.asc` file directly: ```sh powercraft-cli sim design.asc --tend 5m \ --expect 'mean(v(out), 4m, 5m) in 11.8..12.2' \ --expect 'pp(v(out), 4m, 5m) < 0.05' ``` The exit code is 0 when every limit holds and 3 when one does not. ## Step 7: Edit, then write back Edit the circuit in Voltecx, then export it into the original format: ```sh powercraft-cli convert design.voltecx design.asc ``` or run `file.exportNative` in the app. What gets written: | Change in Voltecx | Written to the `.asc` file | |---|---| | A value of a resistor, capacitor, inductor or source | Its `SYMATTR Value` line | | A variable (`.param`) | The number in its directive; a new variable gets a new directive | | End time or maximum step | The `.tran` directive | | A moved part | Its `SYMBOL` line, with new wire stubs so nothing disconnects | | An added resistor, capacitor, inductor, source or diode | A new `SYMBOL` with its name and value | | A deleted part | Its `SYMBOL` lines (wires and labels stay) | | A net label added, renamed or removed | `FLAG` lines, as described below | **Reported but not written:** rewiring an existing symbol, a new orientation, a changed component type, removed variables, and parameters that live in a model (a diode's forward drop, for example). ## Net labels LTspice `FLAG` names become net labels. Flags that name a supply rail (`VCC`, `VDD`, `VEE`, `VSS`, `V+`, `V-`, `+5V`, `-12V`, `3.3V` and similar) become rail labels. `0` and `GND` stay ground, and an `IOPIN` flag becomes a port. When you add, rename or remove a label in Voltecx and export, the change is written as `FLAG` lines; untouched flags keep their bytes. ## Text encodings LTspice often saves schematics in the Windows code page, so the micro sign and accented letters in comments are not UTF-8. Voltecx reads UTF-16 (little endian), UTF-8 and otherwise Windows-1252, and writes back in the same encoding, so an unedited file stays byte for byte. A character the code page cannot hold (the ohm sign, for example) makes the write-back UTF-8, with a warning. ## Sources given as points `PWL(...)` sources import as Voltecx PWL sources, and `r=0` sets repeat. A `PWL FILE=` source stays DC, with a warning. An edited point list is reported as not written back to the `.asc` file. ## Where to go next - [File compatibility](https://voltecx-web.nguyenvanqui291.workers.dev/features/file-compatibility): every format Voltecx reads and writes. - [Simulation](https://voltecx-web.nguyenvanqui291.workers.dev/features/simulation): the two solvers and the accuracy report. - [Automation](https://voltecx-web.nguyenvanqui291.workers.dev/features/automation): run the same steps from Python, the command line or an AI assistant. --- # Switching to Voltecx from another simulator URL: https://voltecx-web.nguyenvanqui291.workers.dev/guides/switching-from-another-simulator/ If you already simulate converters in a schematic-based simulator, most of what you know carries over to Voltecx. Switching circuits, control blocks, scopes, thermal networks and parameter sweeps are the same engineering ideas. This page maps the general ideas you already use to the place they live in Voltecx, so you can find your way in an afternoon. This is a concept map, not a feature comparison. It describes Voltecx from its own documentation. Voltecx was written clean-room: no code, model library, example file or manual text from another simulator was used. Voltecx has not been compared with the reference waveforms of other simulators, and we make no claim that results match theirs. LTspice is a trademark of Analog Devices, Inc. Other product names are trademarks of their owners. Voltecx is an independent product. It is not affiliated with, sponsored by or endorsed by these companies. ## The one idea that is new: everything is a command Every action in Voltecx is a named command, for example `circuit.addComponent`, `simulation.run` or `analysis.acSweep`. The menu, the command palette (Cmd+K), the command-line tool `powercraft-cli`, the Python package and the built-in assistant all call the same commands. So anything you click, you can script, and the user manual names the command next to each menu path. Run `powercraft-cli commands` for the full list. ## Concept map | If you think in terms of… | In Voltecx it is… | |---|---| | The simulation settings: time step and total time | **Simulation > Settings** (`simulation.settings`): `tEnd`, `maxStep`, `fixedStep`, `integration` (trapezoidal, backward Euler, or exact: piecewise-linear circuits solved in closed form between switching events), and the tolerances for variable step. Settings are saved with the circuit | | Fixed time step | `fixedStep: true` (the default). The step is `maxStep`, shortened only to land exactly on a switching edge. A good start for a converter is 200 steps per switching period | | Variable step | `fixedStep: false`. The solver controls the local error and still lands on every switching event | | Choosing a solver | Two solvers: **fast** for everyday work and **reference**, a deliberately simple solver that checks the fast one. Run the same circuit on both when a result surprises you | | Skipping the start-up transient | **Simulation > Steady-State Analysis** (`simulation.steadyState`) runs period after period until the waveform repeats, then shows the last period | | Voltage and current probes | The **probe tool** (key P): click a wire, pin or part and its voltage or current goes on the scope. Signals are named `v(out)` and `i(L1)` | | The scope window | The scope panel: tabs, cursors, logic lanes, measurements (mean, RMS, peak-to-peak, power, THD), comparison with earlier runs, export to CSV, PNG and SVG. It can be detached into its own window | | Subsystems | **Circuit > Subsystem > Create Subsystem** (Cmd+G) turns parts into a block with named pins. Double-click to edit inside (it opens at a readable zoom; Esc or the **‹ Back** button returns); every instance follows the definition | | Signal tags (goto and from) | **Net labels** (key L or N), with the kinds net, goto, from, rail and port. Goto and from labels join control pins by name, without wires | | Model variables and parameter expressions | **Circuit > Variables**. A parameter that names a variable follows it everywhere. Parameters accept expressions and SI suffixes (`4.7u`, `10k`) | | A parameter sweep | `analysis.paramSweep` (runs in parallel on your cores), `analysis.paramSweep2d` for two variables, `analysis.monteCarlo` for yield | | Frequency response and loop gain | `analysis.acSweep`, `analysis.impedance` and `analysis.loopGain` (with phase and gain margins) | | Switching and conduction losses | `analysis.losses` per switch and diode over a time window. Vendor devices carry loss tables read from their data sheets, with the source of every value | | Thermal networks and heatsinks | The **Thermal** library: Foster and Cauer chains, heatsinks and junction temperatures, read with `analysis.thermal`. A separate thermal step (`thermalStep`) lets the slow thermal network step at its own rate | | Writing your own block in C | Custom blocks run as sandboxed WebAssembly modules (`library.customBlock`), on the desktop and in the browser. C blocks in imported files are kept with the circuit (see below) | | Generating controller code | **Tools > Code Generation** (`tools.codeGeneration`): portable C99 from the sampled control blocks, with optional set-up code for the STM32G474 or TMS320F28379D | | Batch runs and scripts | **Tools > Parameter Sweep**, **Tools > Scripting**, `powercraft-cli script` and `powercraft-cli sim`, and the Python package `powercraft` | | Motor drives | The `machine` and `mechanical` parts with FOC blocks. Examples: induction motor V/f and indirect FOC, PMSM FOC, sensorless PMSM, DC motor, direct torque control, BLDC six-step | | Designing the converter before simulating it | The **Design** menu sizes inductors, capacitors and compensators from targets. **Design > Auto Design** (`design.auto`) goes from a spec to a checked circuit and a report | ## Opening your existing files | Your file | What Voltecx does | |---|---| | LTspice `.asc` and SPICE netlists | Read and written back. See [Move an LTspice project to Voltecx](https://voltecx-web.nguyenvanqui291.workers.dev/guides/migrate-from-ltspice) | | Files from other simulators | Read, and in several formats your edits are written back into the same file. An unedited file comes back byte for byte; an edit changes only the bytes it must. Blocks Voltecx does not map are kept untouched in the file or listed in **Problems**, the most important first. Where a format cannot be written, **File > Save** asks for a new `.voltecx` file. The wiring is rebuilt from the drawing. Control code in a C block is not run when the format cannot carry it across: the code is kept with the circuit (**Circuit > C Code**), with a comment listing the net each pin touched, so you can rebuild the controller. Import from other formats is a Pro feature | What was measured: in a run recorded on 2026-10-15, all 332 public LTspice sample files and all 122 public sample files in the other supported write-back format in our test corpus wrote back byte for byte, with no crash. The read-only importer was checked on 6 public sample files, which read back identically. No file was opened in the original tools to test. The guarantees come from the file format rules and from tests on public files. See [File compatibility](https://voltecx-web.nguyenvanqui291.workers.dev/features/file-compatibility). ## How Voltecx earns your trust You will want to know why a number is right before you rely on it. Three habits help: 1. **Use the second solver.** The reference solver is simple on purpose. If both solvers agree on your circuit, a solver bug is unlikely to be the cause of a surprise. 2. **Read the accuracy report.** The test suite compares both solvers with closed-form answers, with values from named data sheets and with waveforms computed by ngspice for the same netlists. The latest report lists 22 of 22 comparisons within tolerance, and each row names its reference. 3. **Read the not-checked list.** Reports from the design tools list the requirements they did not check, and mark estimates (EMI, layout, prices) as estimates. ## Where to go next - [Simulation](https://voltecx-web.nguyenvanqui291.workers.dev/features/simulation): the two solvers and what they have been checked against. - [Analyses](https://voltecx-web.nguyenvanqui291.workers.dev/features/analyses): sweeps, loop gain, losses, thermal and FFT. - [Code generation](https://voltecx-web.nguyenvanqui291.workers.dev/features/code-generation): C99 for your controller. - [File compatibility](https://voltecx-web.nguyenvanqui291.workers.dev/features/file-compatibility): every format, with its limits. --- # Use a manufacturer's SPICE MOSFET or diode model in Voltecx URL: https://voltecx-web.nguyenvanqui291.workers.dev/guides/use-vendor-spice-models/ To use a manufacturer's SPICE model in Voltecx, list the models in the file with `spice.listModels`, place the one you want with `spice.placeModel`, and wire its pins. Voltecx reads the `.lib`, `.mod` or `.sub` file from your disk, builds the model as a subsystem in your circuit, and returns a warning for every parameter it does not model. Most vendor power-MOSFET models are `VDMOS` cards or `.subckt` macro-models, and both are supported; encrypted models are refused. ## What kinds of model files work? | In the file | Placed as | Pins | |---|---|---| | `.subckt` (top level) | a subsystem with the subcircuit's elements | in the subcircuit's order | | `.model … VDMOS` | an `nmos` or `pmos` at `level: vdmos`, with its capacitances and body diode | `d g s` | | `.model … NMOS` / `PMOS` | level 1, or level 3 with `LEVEL=3`; other levels (BSIM among them) as level 1 with a warning | `d g s` | | `.model … D` | the exponential diode when the card gives stored charge (`CJO` or `TT`), else a piecewise-linear diode | `a k` | | `.model … NPN` / `PNP` | a bipolar transistor | `c b e` | Inside a subcircuit, R, L, C, coupled inductors, independent sources, linear and common behavioural E/G sources, switches, B sources and nested subcircuits are read the way `file.import` reads a SPICE netlist. `.include` and `.lib` lines inside the model are followed relative to the file. ## Step by step ### 1. List the models in the file ```sh powercraft-cli run --cmd file.openExample --params '{"name": "buck"}' \ --cmd spice.listModels --params '{"path": "models/vendor.lib"}' ``` The reply lists every top-level `.subckt` and every placeable `.model` card, with its kind and pins. ### 2. See what the import keeps ```sh powercraft-cli run --cmd spice.importReport --params '{"path": "models/vendor.lib", "name": "MYFET"}' ``` Before you place anything, the report lists each element and each `.model` parameter as mapped, approximated, dropped or unused (noise and information fields, which do nothing in SPICE either), with its line in the file and the reason. It ends with one line of fidelity, such as `MYFET: kept as written 5 of 6 elements and 30 of 34 model parameters; dropped: J1 TV.RTHJC`. In the app, the **Import vendor SPICE model** window (Library › Import Vendor SPICE Models) shows the same report under the model list, with the items that are not mapped as written; click another model's name to see its own. ### 3. Place the model ```sh powercraft-cli run --cmd file.openExample --params '{"name": "buck"}' \ --cmd spice.placeModel --params '{"path": "models/vendor.lib", "name": "MYFET", "instance": "Q2"}' ``` `name` is optional when the file has one model. The instance is placed with its pins unconnected and named as the model names them; wire them with `circuit.connect`. One undo removes the placement. From the AI assistant or the command line the same two commands run by id. ### 4. Read the warnings Every element or parameter that is not mapped exactly is returned in `warnings`; nothing is dropped silently. Typical ones: - **VDMOS**: quasi-saturation (`RQ`, `VQ`), the subthreshold shift `SUBSHIFT` and breakdown (`BV`, `IBV`, `NBV`) are modelled, and a part at another temperature than `TNOM` is moved there. The temperature coefficients `TEXP1` and `TKSUBTHRES1`/`2` and self-heating are not modelled. - **Diodes**: breakdown, `IKF`, `ISR`/`NR`, temperature dependence and the area factor are not modelled. - **Levels 2 and 3**: sheet resistance (`RSH`) and the body effect of a body off the source are not modelled. The instance's `AD`, `PD` and `AS` size the body junction from `CJ`, `CJSW` and `JS`, as in SPICE. A model evaluated at `TNOM` (usually 27 °C) does not show the rise of $R_{DS(on)}$ with temperature. For loss and thermal work at a hot junction, scale the conduction loss by the data sheet's normalised $R_{DS(on)}$ curve at your junction temperature. ### 5. Check it against the data sheet Before trusting a model in a design, run a double-pulse test at your voltage and current and compare the turn-on and turn-off waveforms, and the switching energies, with the data sheet's test conditions. Voltecx's own check of a VDMOS card against ngspice in a 400 V, 20 A double pulse is described in the manual. ## What does not work? - **Encrypted models** (PSpice/Cadence encrypted blocks, LTspice-encrypted files) are refused with a message saying so: they cannot be read, so they cannot be simulated. - **The vendor file is not shipped.** Voltecx keeps only the part it builds from the file, in your circuit file, and never copies or redistributes the vendor's file. Check the model's licence terms before sharing a circuit that contains it. ## When should I use a SPICE model instead of a library device? - **Use the SPICE model** to study switching waveforms, ringing, dv/dt and gate behaviour with the capacitances the vendor fitted. - **Use a data-sheet library device** for fast loss, efficiency and thermal estimates across many operating points; the library parts cite the data sheet each value comes from. See [models and parts](https://voltecx-web.nguyenvanqui291.workers.dev/features/models-and-parts). [File compatibility](https://voltecx-web.nguyenvanqui291.workers.dev/features/file-compatibility) covers whole netlists and schematics from other tools, and the [design tools overview](https://voltecx-web.nguyenvanqui291.workers.dev/features/design-tools) shows where part choice sits in the flow. ## Frequently asked questions ### Can Voltecx read LTspice or PSpice MOSFET models? It reads unencrypted SPICE `.model` and `.subckt` text in the common ngspice and LTspice syntax, including `VDMOS` cards and behavioural B sources. Encrypted models are refused. ### Why does my imported MOSFET model warn about temperature? The model is evaluated at its nominal temperature (`TNOM`); temperature coefficients and self-heating are not modelled. Warnings name each parameter the card gives that is not applied. ### Does Voltecx ship vendor SPICE models? No. You keep the vendor file; Voltecx stores only the part it built in your circuit file. The built-in library uses parts digitised from data sheets, each with its source. --- # Import a whole vendor SPICE model library into Voltecx URL: https://voltecx-web.nguyenvanqui291.workers.dev/guides/import-vendor-model-libraries/ To use a vendor's whole model library in Voltecx, download it from the vendor's own site, then click **Import Vendor Folder** (the import icon at the right of the library panel's title) (or run `library.importVendor {folder}`). Voltecx indexes every `.model` and `.subckt` in the folder's `.lib`, `.mod`, `.sub` and `.cir` files, checks each one through its SPICE import, and lists them in the library panel's **User Library** section. Voltecx never ships or downloads vendor files: the files stay on your disk, and only the index is kept, for you alone. ## Where do I download vendor models? From the vendors' own pages. **Where to Get Vendor Models**, at the bottom of the User Library section (or `library.vendorSources`), links them: | Vendor | Where the models are | |---|---| | Infineon | the simulation models page, or each product page | | Wolfspeed | the LTspice and PLECS models page ("All SPICE Models") | | Texas Instruments | each product page, simulation models (PSpice) | | onsemi | the documentation library, simulation / SPICE models | | Navitas | the downloads page, with note AN030 on using the models | | EPC | design support, device models | | ROHM | the design models page, or each product page | | STMicroelectronics | each product page, CAD resources | You accept each vendor's terms when you download. ## What does the import check? | Result | Meaning | |---|---| | **ok** | The model maps (VDMOS, level-1 and level-3 MOSFETs, diodes, bipolar transistors, B sources, nested subcircuits). Anything not modelled exactly is listed as a warning. | | **unsupported** | Voltecx cannot use it, and says why: a `.model` type it does not map (a JFET, say), or a subcircuit with nothing it can simulate. | | **failed** | The model could not be read. | | skipped | An encrypted file, or one over 32 MB. | Pins named like `D G S`, `drain gate source`, `C G E` or `A K`, with a Kelvin source or `Tj`/`Tcase` thermal pins, are matched to the MOSFET, IGBT or diode symbol. Models with numbered or unknown pins go on the **needs pin map** list; they still place, with the model's own pin names. ## From the command line ```sh powercraft-cli run --root ~/models \ --cmd library.importVendor --params '{"folder": "wolfspeed"}' \ --cmd library.vendorModels --params '{"status": "ok", "filter": "650"}' ``` `library.placeVendor {name}` places a model; `library.removeVendor {folder}` forgets a folder. ## Frequently asked questions ### Why doesn't Voltecx come with these models? The vendors' terms do not allow us to redistribute their model files. Downloading them yourself takes a minute, and you always have the vendor's latest version. ### Is my index shared or uploaded? No. It lives in your settings folder (`library/vendor-models.json`) and holds names, pins and results, not the models. ### Can I use encrypted models? No. Encrypted PSpice or LTspice models cannot be read; ask the vendor for an open model. --- # Look up a data sheet value with the assistant, with cited sources URL: https://voltecx-web.nguyenvanqui291.workers.dev/guides/look-up-data-sheet-values-with-the-assistant/ The Voltecx assistant never reaches the web on its own. Start the terminal chat with `--allow-web` (`powercraft-cli chat --allow-web`) and it may search and read pages when your circuit, the results, the catalogue and your files do not answer a question: a gate charge on a data sheet, an application note, a limit in a standard. Without the option, it never goes online. ## What leaves your computer Anthropic runs the search, so the computer still talks only to `api.anthropic.com`. The search queries and the addresses of the pages the assistant reads go there. Your circuit file does not. A message may search at most 8 times and read at most 8 pages. With a self-hosted model server, `--allow-web` is refused. ## How you see what it did Each search shows as a `→ web_search {"query":…}` line. The answer is followed by the pages it cites: ```text The total gate charge Qg is … nC at VGS = 10 V (data sheet, page 3). Sources from the web: 1. data sheet, page 3: https:///… ``` A line after the answer counts the searches and pages read. With `-p --json`, the result adds `webSearches`, `webFetches` and `sources`, each with `url`, `title`, `page` and the cited passage. ## Check before you keep a value The assistant does not write a value from the web into your circuit without naming its source. Open the cited page and confirm the number, the test conditions and the revision of the document before you keep it. Voltecx never invents a value: if no source answers the question, the value stays absent. --- # Lesson 1: Diodes and rectifiers URL: https://voltecx-web.nguyenvanqui291.workers.dev/course/diodes-and-rectifiers/ A rectifier is the first power converter most students meet, and it already holds the ideas the rest of the course needs: a switch that decides for itself when to conduct, an average that differs from the textbook shortcut, and a capacitor that trades ripple for peak current. In this lesson you predict each of those numbers by hand, then let Voltecx show you whether you were right. **Time:** about 30 minutes. **You need:** Voltecx on your computer ([how students install](https://voltecx-web.nguyenvanqui291.workers.dev/course/for-instructors#how-students-install)) and the idea of an RMS and an average value. ## Open it in Voltecx Click **Guided Lessons** in the activity bar on the left and choose **Course 1 · Diodes and rectifiers**. The lesson opens each circuit for you and checks every exercise against your own run: **Next** stays locked until the numbers are right. You can also open the two circuits yourself from **File › Open Example › Rectifiers**: **Half-wave rectifier** and **Bridge rectifier with a capacitor**. ## The half-wave rectifier ![The half-wave rectifier: a 10 V, 50 Hz source, diode D1 and a 100 Ω load](https://voltecx-web.nguyenvanqui291.workers.dev/media/course/diodes-and-rectifiers/half-wave-schematic.svg) A diode conducts when its anode is above its cathode by the forward drop $V_F$, here 0.7 V, and blocks otherwise. With a 10 V peak source the output follows the source, one drop lower, during the positive half cycle and sits at zero during the negative one. So the peak is $V_p - V_F = 9.3$ V. The quick estimate of the mean treats the output as a half sine of amplitude $V_p - V_F$: $$\bar v_{out} \approx \frac{V_p - V_F}{\pi} = 2.96\ \text{V}.$$ It is a little high. The diode only starts to conduct once the source reaches 0.7 V, at the angle $\alpha = \arcsin(V_F / V_p) = 4.0°$, and stops at $\pi - \alpha$. Averaging the real output over that conduction angle gives $$\bar v_{out} = \frac{1}{2\pi}\Big[2 V_p \cos\alpha - V_F\,(\pi - 2\alpha)\Big] = 2.84\ \text{V},$$ which is what the simulation reports. ![The source and the output of the half-wave rectifier over two cycles](https://voltecx-web.nguyenvanqui291.workers.dev/media/course/diodes-and-rectifiers/half-wave.svg) ## Adding a capacitor A capacitor across the load charges to the peak while the diode conducts and supplies the load while it does not. The output now sags between peaks by about $$\Delta V \approx \frac{I_{load}\,T}{C},$$ where $T$ is the time between charging pulses: one line period, 20 ms, for a half-wave rectifier. With $I_{load} \approx 9.3\ \text{V} / 100\ \Omega$ and 1000 µF this gives 1.86 V. The run gives 1.54 V around a mean of 8.53 V: the estimate is pessimistic because the output, and so the load current, falls during the sag, and because the capacitor recharges a little before the next peak. The price is the diode current. The capacitor is refilled in a short pulse near each crest: the diode carries 0.085 A on average, but peaks at 1.75 A, twenty times more. ![The capacitor-filtered output and the diode current over two cycles in steady state](https://voltecx-web.nguyenvanqui291.workers.dev/media/course/diodes-and-rectifiers/capacitor-filter.svg) ## The bridge rectifier ![The bridge rectifier: a 17 V peak winding with 0.5 Ω, four diodes, a 2200 µF capacitor and a 22 Ω load](https://voltecx-web.nguyenvanqui291.workers.dev/media/course/diodes-and-rectifiers/bridge.svg) Four diodes let both half cycles charge the capacitor. When the left end of the winding is positive, D1 and D4 conduct; on the other half, D2 and D3. Two drops are always in the path, so the output peaks at about $17 - 2 \times 0.7$ V less the drop in the winding's 0.5 Ω, 14.67 V in the run. The capacitor is now recharged twice per line period, so the ripple is at 100 Hz and the sag time halves: $$\Delta V \approx \frac{I_{load}}{2 f_{line} C}.$$ The run gives a mean of 13.66 V, 0.62 A into the 22 Ω load and 2.02 V of ripple. The winding delivers its current in pulses of 3.18 A, five times the DC current. A load like this draws a very non-sinusoidal current from the line: that is the problem power factor correction solves later in the course. ![The DC output and the winding current from switch-on: the inrush pulse, then the 100 Hz ripple and the current pulses](https://voltecx-web.nguyenvanqui291.workers.dev/media/course/diodes-and-rectifiers/bridge-waveforms.svg) Look at the first cycle too. The capacitor starts empty, so the first pulse is limited only by the winding resistance and the diodes: 8.6 A, almost three times the steady pulse. This inrush is why real rectifiers have a soft-start or an NTC thermistor in series. ## Exercises The in-app lesson checks each answer against your run. Work the number by hand before you run. 1. **Half-wave output.** Predict the peak and the mean of `v(out)` for the half-wave rectifier, first with the quick estimate, then with the conduction angle. Run it and compare. *(Checked: peak 9.2 to 9.4 V, mean 2.75 to 2.95 V.)* 2. **Filter capacitor.** Place a 1000 µF capacitor from `out` to ground, set the End time to 100 ms and predict the ripple with $I\,T/C$. Run it. Is your estimate high or low, and why? *(Checked over the last cycle: mean 8.3 to 8.8 V, ripple 1.3 to 1.8 V.)* 3. **Bridge rectifier.** For the bridge, predict the output peak, the ripple frequency and the ripple. Which two diodes conduct when the left end of the winding is positive? *(Checked: peak 14.4 to 14.9 V, ripple 1.8 to 2.3 V, winding pulses above 2.5 A.)* 4. **Halve the ripple.** Double C1 to 4.4 mF. Predict what happens to the ripple, the output peak and the current pulses, then run it. *(Checked: ripple 0.9 to 1.2 V.)* ## Answers 1. Peak 9.30 V. Mean: 2.96 V by the quick estimate, 2.84 V with the conduction angle; the run gives 2.84 V. 2. $I\,T/C$ = 1.86 V. The run gives 1.54 V around 8.53 V: the load current falls as the output sags, and the capacitor starts recharging before the crest, so the estimate is high. 3. Peak 14.67 V, ripple 2.02 V at 100 Hz, mean 13.66 V. D1 and D4 conduct when the left end is positive. 4. The ripple halves to 1.03 V. The peak falls to 14.34 V and the pulses rise to 3.26 A: the capacitor sags less, so it is refilled in a shorter, taller pulse, which drops more in the winding and the diodes. The first-cycle inrush rises from 8.6 A to 13.3 A. ## Lab handout **Objective.** Measure how the diode drop, the conduction angle and the filter capacitor set the output of a rectifier, and how the capacitor shapes the line current. **Before the lab.** For the half-wave rectifier (10 V peak, 0.7 V drop, 100 Ω) and the bridge (17 V peak, 0.5 Ω winding, 0.7 V drops, 22 Ω), compute the quantities in the table below. **Procedure.** 1. Open **Course 1 · Diodes and rectifiers** in Guided Lessons and complete its steps. 2. After each run, read the values in the table from the scope's measurements. 3. For the bridge, run once with 2200 µF and once with 4.4 mF, and export both scope views as SVG for your report. | Quantity | Predicted | Simulated | Difference | |---|---|---|---| | Half-wave peak, V | | | | | Half-wave mean, V | | | | | Ripple with 1000 µF, V | | | | | Bridge peak, V | | | | | Bridge ripple with 2200 µF, V | | | | | Bridge ripple with 4.4 mF, V | | | | | Winding current pulse with 2200 µF, A | | | | **Report questions.** 1. Why does a larger capacitor lower the output peak while it lowers the ripple? 2. Estimate the power factor of the bridge load from the RMS of the winding current and the DC power. What limits it? 3. Propose one way to limit the switch-on inrush, and say what it costs at full load. ## References The theory in this lesson is covered in any introductory power electronics text, for example the chapters on line-frequency diode rectifiers in N. Mohan, T. M. Undeland and W. P. Robbins, *Power Electronics: Converters, Applications, and Design*, 3rd ed., Wiley, 2003, and in D. W. Hart, *Power Electronics*, McGraw-Hill, 2011. The exercises and numbers here are Voltecx's own. **Next:** [Lesson 2: The buck converter](https://voltecx-web.nguyenvanqui291.workers.dev/course/buck-converter). --- # Lesson 2: The buck converter URL: https://voltecx-web.nguyenvanqui291.workers.dev/course/buck-converter/ The buck converter is the switching converter every other one is measured against. A switch chops the input, an inductor and a capacitor average the chopped voltage, and the duty cycle sets the output. This lesson derives the output and the ripples from two balance rules, shows where they stop holding, and ends with a small design task that the Voltecx Test Bench grades. **Time:** about 40 minutes. **You need:** [Lesson 1](https://voltecx-web.nguyenvanqui291.workers.dev/course/diodes-and-rectifiers), and the inductor law $v = L\,di/dt$. ## Open it in Voltecx In **Guided Lessons**, choose **Course 2 · The buck converter**. The circuit is also **File › Open Example › DC-DC › Buck converter, textbook**. ![The buck converter: 48 V source, switch S1, diode D1, L1 = 100 µH, C1 = 100 µF and a 2.4 Ω load, driven by a 100 kHz PWM at a duty of 0.25](https://voltecx-web.nguyenvanqui291.workers.dev/media/course/buck-converter/schematic.svg) ## Volt-second balance In steady state the inductor current ends each period where it started, so the inductor's average voltage is zero. While the switch is on, for $D\,T$, the inductor sees $V_{in} - V_{out}$; while the diode conducts, for $(1 - D)\,T$, it sees $-V_{out}$. Setting the two areas equal: $$(V_{in} - V_{out})\,D = V_{out}\,(1 - D) \quad\Rightarrow\quad V_{out} = D\,V_{in} = 12\ \text{V}.$$ The capacitor obeys the dual rule, charge balance: its average current is zero, so the inductor's average current equals the load current, 5 A. ## Ripple During the on-time the inductor current rises at $(V_{in} - V_{out})/L$, so its peak-to-peak ripple is $$\Delta I_L = \frac{(V_{in} - V_{out})\,D}{L\,f_{sw}} = \frac{36 \times 0.25}{100\ \mu\text{H} \times 100\ \text{kHz}} = 0.9\ \text{A}.$$ The capacitor takes the AC part of that triangle. The charge in one half of the triangle, $\Delta I_L\,T/8$, sets the output ripple: $$\Delta V_{out} = \frac{\Delta I_L}{8\,C\,f_{sw}} = 11.3\ \text{mV}.$$ The run gives 11.99 V, 0.90 A and 11.7 mV, within a few percent of the hand results. ![Switch node, inductor current and output over three periods in steady state](https://voltecx-web.nguyenvanqui291.workers.dev/media/course/buck-converter/steady-state.svg) ## Discontinuous conduction The ripple does not depend on the load, but the average current does. Once the load current falls below half the ripple, the inductor current would have to go negative at the end of each period; the diode will not let it, so the current stays at zero for part of the period. The converter is then in discontinuous conduction mode (DCM), and the output is no longer $D\,V_{in}$. The boundary is at $$R_{crit} = \frac{2L}{T\,(1 - D)} = 26.7\ \Omega.$$ Above it, the conversion ratio follows $$M = \frac{V_{out}}{V_{in}} = \frac{2}{1 + \sqrt{1 + 4K/D^2}}, \qquad K = \frac{2L}{R\,T}.$$ With 48 Ω, $K = 0.417$ and $M = 0.320$: 15.34 V instead of 12 V. The run agrees, 15.34 V. A closed loop would hide this by lowering the duty, but the plant it controls changes, which is why loop design (lesson 6) checks both modes. ![Inductor current in continuous conduction (2.4 Ω, top) and in discontinuous conduction (48 Ω, bottom)](https://voltecx-web.nguyenvanqui291.workers.dev/media/course/buck-converter/ccm-and-dcm.svg) ## A design task, graded by the Test Bench A smaller inductor is cheaper, so take L1 = 22 µH. The ripple current is now $36 \times 0.25 / (22\ \mu\text{H} \times 100\ \text{kHz}) = 4.09$ A, and the spec allows at most 50 mV of output ripple. The capacitor must be at least $$C \ge \frac{\Delta I_L}{8\,f_{sw}\,\Delta V_{max}} = 102\ \mu\text{F},$$ so the smallest E12 value that meets it is 120 µF. The Test Bench checks this the way a lab would: it reads the spec (48 V in, 12 V ± 2 % out at 5 A, ripple at most 50 mV), runs the converter from start-up until the output settles, and compares regulation and ripple with their limits. With 100 µF it reads 51.9 mV and fails; with 120 µF it reads 45.4 mV and passes. The same circuit is also worked in full, from the hand calculation to the run, in the [worked example](https://voltecx-web.nguyenvanqui291.workers.dev/worked-examples/buck-converter-48v-to-12v). ## Exercises 1. **Volt-second balance.** Predict the output, the load current and the inductor ripple, then run. *(Checked: 11.9 to 12.1 V, ripple 0.85 to 0.95 A.)* 2. **Halve the inductor.** Set L1 to 50 µH. Which numbers change? *(Checked: ripple 1.7 to 1.9 A, output still 11.9 to 12.1 V.)* 3. **Discontinuous conduction.** Put L1 back to 100 µH and R1 to 48 Ω. Find the boundary resistance and the DCM output, set the End time to 30 ms and run. *(Checked: 15.1 to 15.6 V, and the inductor current reaches zero.)* 4. **Size the capacitor.** With L1 = 22 µH and R1 = 2.4 Ω, find the smallest E12 capacitor that keeps the output ripple at or below 50 mV. *(Checked: inductor ripple near 4.1 A and output ripple between 41 and 50 mV, which only the right value gives.)* 5. **Grade it.** Press **List and run the case** in the lesson, or run it yourself with **Simulation › Test Bench › Run All and Report**. *(Checked: the case `corner-48V-5A` passes on the circuit as it is now.)* ## Answers 1. 12 V and 5 A; ΔI = 0.9 A. The run gives 11.99 V and 0.90 A. 2. The ripple doubles to 1.80 A; the output stays at 12 V, because it depends only on D and Vin. The output ripple doubles too. 3. $R_{crit}$ = 26.7 Ω; $M$ = 0.320, so 15.34 V. The run gives 15.34 V. 4. 102 µF is the minimum, so 120 µF. With it the run reads 43.4 mV over the last 0.1 ms; 100 µF reads 51.5 mV, and 150 µF passes but is not the smallest. 5. The Test Bench reads 45.4 mV of ripple with 120 µF and passes; with 100 µF it reads 51.9 mV and fails. ## Lab handout **Objective.** Verify volt-second and charge balance on a buck converter, find the edge of discontinuous conduction, and size an output capacitor against a written spec. **Before the lab.** Compute every "Predicted" entry below. For task 4, show the capacitor calculation and the E12 value you choose. **Procedure.** 1. Open **Course 2 · The buck converter** in Guided Lessons and complete its steps in order. 2. Record each value from the scope after its run. 3. For the design task, save your circuit (**File › Save As**) as `buck-.pcraft` and hand it in with this sheet. | Quantity | Predicted | Simulated | Difference | |---|---|---|---| | Output, V | | | | | Inductor ripple, L = 100 µH, A | | | | | Output ripple, mV | | | | | Inductor ripple, L = 50 µH, A | | | | | Boundary resistance, Ω | | — | | | DCM output at 48 Ω, V | | | | | C for 50 mV with L = 22 µH, µF | | — | | | Test Bench ripple with your C, mV | — | | | **Report questions.** 1. Why does the output ripple follow the inductor ripple, but the output voltage does not? 2. A data sheet's capacitor has an ESR of 10 mΩ. Add it (the capacitor's `esr` parameter) and explain the new ripple. 3. Why would a converter designed at full load enter DCM at light load, and what would its controller see? ## References Steady-state analysis by volt-second and charge balance, ripple and discontinuous conduction are treated in R. W. Erickson and D. Maksimović, *Fundamentals of Power Electronics*, 3rd ed., Springer, 2020 (chapters 2 and 5), and in Mohan, Undeland and Robbins, *Power Electronics*, 3rd ed., Wiley, 2003. The exercises and numbers here are Voltecx's own. **Next:** [Lesson 3: Boost and buck-boost](https://voltecx-web.nguyenvanqui291.workers.dev/course/boost-and-buck-boost). --- # Lesson 3: Boost and buck-boost URL: https://voltecx-web.nguyenvanqui291.workers.dev/course/boost-and-buck-boost/ Rearrange the buck's parts and the same two balance rules give a converter that steps the voltage up, or one that turns it negative. This lesson works both, shows why a boost's input current grows faster than its output voltage, why it settles slowly, and why the switch of a buck-boost must block more than either the input or the output. **Time:** about 35 minutes. **You need:** [Lesson 2](https://voltecx-web.nguyenvanqui291.workers.dev/course/buck-converter). ## Open it in Voltecx In **Guided Lessons**, choose **Course 3 · Boost and buck-boost**. The boost is also **File › Open Example › DC-DC › Boost converter**; the lesson builds the buck-boost for you from a template. ![The boost converter: 12 V source, L1 = 200 µH, switch S1, diode D1, C1 = 220 µF and a 24 Ω load, 50 kHz PWM at a duty of 0.5](https://voltecx-web.nguyenvanqui291.workers.dev/media/course/boost-and-buck-boost/boost.svg) ## The boost converter The inductor sits at the input. While the switch is on it sees $V_{in}$; while the diode conducts it sees $V_{in} - V_{out}$, which is negative. Volt-second balance: $$V_{in}\,D + (V_{in} - V_{out})(1 - D) = 0 \quad\Rightarrow\quad V_{out} = \frac{V_{in}}{1 - D} = 24\ \text{V}.$$ Every watt delivered comes through the inductor, so with no losses $V_{in}\,\bar I_L = V_{out}\,I_{out}$ and $$\bar I_L = \frac{I_{out}}{1 - D} = 2\ \text{A}, \qquad \Delta I_L = \frac{V_{in}\,D}{L\,f_{sw}} = 0.6\ \text{A}.$$ The capacitor alone feeds the load while the switch is on, so the output ripple is $I_{out}\,D/(C\,f_{sw}) = 45.5$ mV. The run gives 23.99 V, 2.00 A, 0.60 A and 45.6 mV. ### Why the boost settles slowly Read the output at the default 10 ms and it is 23.89 V, not 24. Seen from its output, a boost behaves like an LC filter whose inductance is $L/(1 - D)^2 = 800$ µH. With C1 it resonates at $$f_0 = \frac{1}{2\pi\sqrt{800\ \mu\text{H} \times 220\ \mu\text{F}}} = 379\ \text{Hz},$$ and the 24 Ω load damps it lightly, so it rings for tens of milliseconds. Run 60 ms before you read a steady state. ![The boost output over 60 ms: a slow, lightly damped ring around 24 V](https://voltecx-web.nguyenvanqui291.workers.dev/media/course/boost-and-buck-boost/boost-settling.svg) Raise the duty to 0.6 and the output should be $12/0.4 = 30$ V. The load now takes $30^2/24 = 37.5$ W, so the inductor must carry $37.5/12 = 3.125$ A: the output voltage went up by a quarter, the input current by more than half. The run gives 29.98 V and 3.13 A. That is why a boost at high gain is limited by its inductor and switch currents, not by its duty cycle. ## The inverting buck-boost ![The inverting buck-boost the template builds: switch S1 from the input to the switch node, L1 from the switch node to ground, D1 pointing into the switch node, C1 and the load on the negative output](https://voltecx-web.nguyenvanqui291.workers.dev/media/course/boost-and-buck-boost/buck-boost.svg) Now the switch connects the input to the inductor, and the diode connects the inductor to the output in the reverse direction. While the switch is on the inductor sees $V_{in}$; while the diode conducts it sees $V_{out}$, which is negative. Balance gives $$V_{out} = -\frac{D}{1 - D}\,V_{in},$$ so 24 V out of 12 V needs $D = 2/3$. The template sizes the inductor at 133.3 µH for a 20 % ripple. Its inductor carries $I_{out}/(1 - D) = 3$ A. The switch node swings from $+V_{in}$ while the switch is on to $V_{out}$ while the diode conducts. So both the switch and the diode must block $$V_{in} + |V_{out}| = 36\ \text{V},$$ more than either side of the converter. The run gives −23.72 V (the template's source has a 1 % resistive drop at full load), 2.96 A in the inductor, and a 35.8 V swing at the switch node. ![Switch node and inductor current of the buck-boost over three periods](https://voltecx-web.nguyenvanqui291.workers.dev/media/course/boost-and-buck-boost/buck-boost-waveforms.svg) The same circuit is also worked in full, from the hand calculation to the run, in the [worked example](https://voltecx-web.nguyenvanqui291.workers.dev/worked-examples/boost-converter-12v-to-24v). ## Exercises 1. **Boost output.** Predict $V_{out}$, $\bar I_L$ and $\Delta I_L$. Set the End time to 60 ms and run. *(Checked: 23.8 to 24.2 V, 1.95 to 2.05 A, ripple 0.55 to 0.65 A.)* 2. **Raise the duty.** Set the Duty block to 0.6. Predict the output and, from the power balance, the inductor current. *(Checked: 29.7 to 30.2 V, 3.05 to 3.2 A.)* 3. **Buck-boost.** Build it with the lesson's button. What duty does it need for −24 V from 12 V? 4. **Switch stress.** Predict the swing of the switch node, then run. *(Checked: −24.2 to −23.4 V out, at least 35 V of swing.)* ## Answers 1. 24 V, 2 A, 0.6 A; the run gives 23.99 V, 2.00 A and 0.60 A. At 10 ms it is still 23.89 V. 2. 30 V and 3.125 A; the run gives 29.98 V and 3.13 A. 3. $D = 2/3$; the template sets D = 0.667 and L1 = 133.3 µH. 4. $V_{in} + |V_{out}|$ = 36 V; the run gives −23.72 V and a 35.8 V swing. ## Lab handout **Objective.** Derive the boost and buck-boost conversion ratios from volt-second balance, check the input current from the power balance, and find the voltage the switch must block. **Before the lab.** Compute the "Predicted" column. For the boost, also compute the resonant frequency of $L/(1-D)^2$ with C1 and estimate how many milliseconds the output needs to settle. **Procedure.** 1. Open **Course 3 · Boost and buck-boost** in Guided Lessons and complete its steps. 2. For each run, read the values from the scope over the last periods. 3. Export the boost's 60 ms start-up as an SVG for your report. | Quantity | Predicted | Simulated | Difference | |---|---|---|---| | Boost output, D = 0.5, V | | | | | Boost inductor current, A | | | | | Boost inductor ripple, A | | | | | Boost output, D = 0.6, V | | | | | Boost inductor current, D = 0.6, A | | | | | Buck-boost duty for −24 V | | | | | Buck-boost switch-node swing, V | | | | **Report questions.** 1. Why does a boost's inductor current grow faster than its output voltage as the duty rises? 2. Why does the boost settle more slowly than the buck of lesson 2? 3. Choose a switch for the buck-boost: what voltage rating and what derating would you use, and why? ## References The boost and buck-boost, their conversion ratios and their steady-state waveforms are derived in R. W. Erickson and D. Maksimović, *Fundamentals of Power Electronics*, 3rd ed., Springer, 2020 (chapters 2 and 6), and in D. W. Hart, *Power Electronics*, McGraw-Hill, 2011. The exercises and numbers here are Voltecx's own. **Next:** [Lesson 4: The flyback converter](https://voltecx-web.nguyenvanqui291.workers.dev/course/flyback-converter). --- # Lesson 4: The flyback converter URL: https://voltecx-web.nguyenvanqui291.workers.dev/course/flyback-converter/ Split the buck-boost's inductor into two coupled windings and you have a flyback: the most common isolated converter below about 100 W, in every phone charger and auxiliary supply. It stores energy in the core while the switch is on and releases it to the output while the switch is off. This lesson derives its output, shows the voltage the switch sees, and shows what the imperfect coupling of a real transformer costs. **Time:** about 30 minutes. **You need:** [Lesson 3](https://voltecx-web.nguyenvanqui291.workers.dev/course/boost-and-buck-boost), and the idea of mutual inductance. ## Open it in Voltecx In **Guided Lessons**, choose **Course 4 · The flyback converter**. The circuit is also **File › Open Example › Isolated › Flyback converter**. ![The flyback: 12 V source, coupled inductor T1 (two 50 µH windings, k = 0.995), switch S1 with an RC snubber Csn and Rsn, output diode D1, C1 = 47 µF and a 20 Ω load, 100 kHz PWM at a duty of 0.4](https://voltecx-web.nguyenvanqui291.workers.dev/media/course/flyback-converter/schematic.svg) ## How it works T1 is a coupled inductor with two windings, $N_p : N_s$ = 1 : 1 here, and the dots placed so that the secondary voltage is reversed. While S1 is on, the primary sees $V_{in}$, its current ramps up, and D1 is reverse biased: no current flows to the output and C1 feeds the load. When S1 opens, the core's magnetising current has to continue; it moves to the secondary, forward biases D1 and flows into C1 and the load. Volt-second balance on the magnetising inductance, with the secondary voltage referred to the primary by $n = N_s/N_p$: $$V_{in}\,D = \frac{V_{out}}{n}(1 - D) \quad\Rightarrow\quad V_{out} = n\,\frac{D}{1 - D}\,V_{in} = 8\ \text{V}.$$ It is the buck-boost ratio, scaled by the turns ratio and with the sign set by the dots. The run gives 7.93 V. The primary current ramps by $V_{in}\,D/(L_m\,f_{sw}) = 0.96$ A during the on-time. The input power, about 3.1 W, means an average input current of 0.26 A, or 0.66 A averaged over the on-time; so the primary peaks near $0.66 + 0.96/2 = 1.14$ A. The run gives 1.15 A in the primary and 1.08 A in the secondary at turn-off. ## The drain voltage While the secondary conducts, it holds the primary at $-V_{out}/n$, so the drain of S1 sits at $$V_{in} + \frac{V_{out}}{n} = 20\ \text{V}.$$ That plateau is the minimum the switch must block. But the coupling is not perfect: a part of each winding's inductance, $(1 - k)\,L_p$ = 0.25 µH, is not linked to the other winding, and the primary sees both windings' share, a leakage inductance $L_{lk} = (1 - k^2)\,L_p \approx$ 0.5 µH. Its current cannot jump to the secondary. At the instant S1 opens, the whole primary current flows into the snubber, and the snubber capacitor is still empty, so the drain jumps to $$I_{pk}\,R_{sn} = 1.15\ \text{A} \times 50\ \Omega \approx 57.5\ \text{V}.$$ The run gives 57.5 V. The leakage current then falls into the secondary with the time constant $L_{lk}/R_{sn}$ = 10 ns, and the drain settles on the plateau. ![Drain voltage, primary current i(T1.1) and secondary current i(T1.2) over two periods](https://voltecx-web.nguyenvanqui291.workers.dev/media/course/flyback-converter/steady-state.svg) Raise the duty to 0.5 and the output becomes $V_{in}$ = 12 V with this 1 : 1 winding; the run gives 11.85 V. The plateau rises to 24 V and the spike to 89.8 V, because the primary now peaks at 1.8 A. ## Leakage inductance Make the transformer worse: set the coupling to $k$ = 0.98, which a winding made with less care can easily have. The leakage inductance grows fourfold, to about 2 µH. The spike's peak does not move: it is still the primary current times $R_{sn}$, 57.1 V in the run. What grows is how long it lasts, $L_{lk}/R_{sn}$ = 40 ns, and the energy the leakage holds at turn-off, $\tfrac12 L_{lk} I_{pk}^2$ = 1.3 µJ. None of it reaches the output: the snubber turns it into heat each period, 0.13 W at 100 kHz against 33 mW with $k$ = 0.995. The output falls to 7.76 V: the 20 Ω load receives 3.01 W instead of 3.14 W. ![The drain voltage with k = 0.995 and with k = 0.98: the same plateau and the same peak, a spike that lasts longer](https://voltecx-web.nguyenvanqui291.workers.dev/media/course/flyback-converter/leakage.svg) This is why a flyback's switch is rated well above its plateau, why an RC snubber's resistor is chosen with the peak current in mind, why its transformer is interleaved to keep the leakage small, and why a clamp (an RCD network or a TVS, see the **Flyback RCD + TVS clamp** example under **Power quality**) is sized for the leakage energy. The same circuit is also worked in full, from the hand calculation to the run, in the [worked example](https://voltecx-web.nguyenvanqui291.workers.dev/worked-examples/flyback-converter-12v-to-8v). ## Exercises 1. **Output and drain.** Predict $V_{out}$ and the drain plateau. Set the End time to 6 ms and run. *(Checked: 7.8 to 8.1 V out, drain spike 55 to 60 V.)* 2. **Raise the duty.** Set the Duty block to 0.5. Predict the output and the new plateau. *(Checked: 11.6 to 12.0 V.)* 3. **A looser winding.** Set the Duty back to 0.4 and the coupling k of T1 to 0.98. Predict what happens to the spike and to the output, and where the extra energy goes. *(Checked: drain spike still 55 to 60 V, output 7.6 to 7.9 V.)* ## Answers 1. 8 V, a 20 V plateau and a spike of $I_{pk}\,R_{sn}$ = 1.15 A × 50 Ω; the run gives 7.93 V, a 20 V plateau and a 57.5 V spike. 2. 12 V and a 24 V plateau; the run gives 11.85 V and an 89.8 V spike, the 1.8 A primary peak times 50 Ω. 3. The leakage grows about fourfold. The peak stays at the primary current times $R_{sn}$ (57.1 V), but the spike lasts four times longer and its energy, four times larger, goes into the snubber, so the output falls to 7.76 V. ## Lab handout **Objective.** Derive a flyback's output from volt-second balance, find the voltage its switch must block, and see what leakage inductance costs. **Before the lab.** Compute the "Predicted" column, including the leakage inductance for k = 0.995 and k = 0.98. **Procedure.** 1. Open **Course 4 · The flyback converter** in Guided Lessons and complete its steps. 2. Zoom the scope onto two switching periods at the end of each run and read the values. 3. Export the drain voltage for k = 0.995 and k = 0.98 as SVG for your report. | Quantity | Predicted | Simulated | Difference | |---|---|---|---| | Output, D = 0.4, V | | | | | Drain plateau, V | | | | | Drain spike, V | | | | | Primary peak current, A | | | | | Output, D = 0.5, V | | | | | Leakage inductance, k = 0.98, µH | | — | | | Drain spike, k = 0.98, V | | | | | Output, k = 0.98, V | | | | **Report questions.** 1. Change the secondary to 200 µH (a 1 : 2 winding). What duty gives 8 V now, and what happens to the drain plateau? 2. Why does a flyback need a snubber or clamp when a buck-boost with one inductor does not? 3. Open the **Flyback RCD + TVS clamp** example (**File › Open Example › Power quality**). What sets the clamp voltage, and what does a lower clamp voltage cost? ## References The flyback as an isolated buck-boost and the role of leakage inductance are covered in R. W. Erickson and D. Maksimović, *Fundamentals of Power Electronics*, 3rd ed., Springer, 2020 (chapter 6), and in Mohan, Undeland and Robbins, *Power Electronics*, 3rd ed., Wiley, 2003. The exercises and numbers here are Voltecx's own. **Next:** lesson 5, averaged models, is on the way. Meanwhile, see [how to use this course in a class](https://voltecx-web.nguyenvanqui291.workers.dev/course/for-instructors). --- # Lesson 7: The single-phase inverter and sine PWM URL: https://voltecx-web.nguyenvanqui291.workers.dev/course/single-phase-inverter/ An inverter makes an AC output from a DC link by switching fast and letting a filter keep only the slow part. This lesson builds the output of a full bridge from a sine reference and a carrier, predicts its size from the modulation index, and shows what a few hundred nanoseconds of dead time do to it. **Time:** about 45 minutes. **You need:** [Lesson 2](https://voltecx-web.nguyenvanqui291.workers.dev/course/buck-converter) (the LC average of a chopped voltage). ## Open it in Voltecx Use **File › Open Example › Inverters › Single-phase full-bridge inverter** (`file.openExample` with `{"name":"fullBridgeSpwm"}`). It has a 400 V link, two legs with 50 mΩ MOSFETs, 10 kHz carriers, 0.5 µs of dead time, a 1 mH + 1 mH and 10 µF filter and a 50 Ω load. ![The full bridge, its two modulators and the LC filter](https://voltecx-web.nguyenvanqui291.workers.dev/media/course/single-phase-inverter/schematic.svg) ## Unipolar sine PWM Each leg compares a duty reference with a carrier. Leg a follows $d_a = 0.5 + (M_i/2)\sin\omega t$ and leg b the same reference shifted by 180°. The leg midpoints then switch between 0 and $V_{dc}$, and the voltage between them averages, over one carrier period, to $$\bar v_{ab} = (d_a - d_b)\,V_{dc} = M_i\,V_{dc}\sin\omega t.$$ With $M_i = 0.8$ and $V_{dc} = 400$ V the peak is 320 V and the rms 226 V. The LC filter (corner near 1.1 kHz here, from the two 1 mH inductors and 10 µF) passes the 50 Hz part and removes the carrier. Because the two legs switch in opposition, the voltage between them has three levels and ripples at twice the carrier frequency, which is why the filter can be small. ## What the run gives Over the last 20 ms (one cycle) the output has a peak of 316.6 V and an rms of 222.73 V: 1.5 % below the ideal 320 V and 226 V. The filter inductor current peaks at 7.26 A, 6.3 A of load plus the ripple and the capacitor current. ![Output voltage and filter inductor current over the last cycle](https://voltecx-web.nguyenvanqui291.workers.dev/media/course/single-phase-inverter/steady-state.svg) ## Dead time The two switches of a leg must never conduct together, so each gate waits $t_d$ before turning on. During that time the current picks the leg's voltage, and the average output moves toward the wrong side, once per switching edge. The loss of output grows with $t_d\,f_{sw}$. Set $t_d$ to zero and the run gives exactly the hand result, 226.25 V rms and 320.1 V peak; with 0.5 µs the output is 222.73 V. ## Exercises 1. **Predict and run.** Predict the peak and rms output for $M_i = 0.8$. *Answer: 320 V and 226 V; the run (with dead time) gives 316.6 V and 222.73 V.* 2. **Halve the index.** Set the amplitude of both references (`Refa`, `Refb`) to 0.2. *Answer: $M_i = 0.4$ gives 160 V peak by hand; the run gives 156.7 V peak and 109.61 V rms.* 3. **Double the carrier.** Return the amplitudes to 0.4 and set the frequency of `PWMa` and `PWMb` to 20 kHz. *Answer: the output falls to 219.14 V rms, because there are twice as many dead-time edges.* 4. **Remove the dead time.** Set `td` of the four dead-time blocks to 0 (still at 20 kHz). *Answer: 226.25 V rms and 320.1 V peak. A real bridge cannot do this: it would shoot through.* Command chain for exercise 2: `file.openExample`, `circuit.setParam` on `Refa` and `Refb` (`amp`), `simulation.run`, `scope.measure` on `vo` between 0.04 s and 0.06 s. ## Quiz 1. What does the filter see: the 400 V pulses or their average? *The filter keeps the average; the pulses are what it removes.* 2. Why does the output stay at 50 Hz when the carrier doubles? *The reference sets the fundamental; the carrier only sets where the ripple is.* 3. A data sheet gives a driver dead time of 1 µs. Does the output rise or fall compared with 0.5 µs? *It falls further, since the loss follows $t_d\,f_{sw}$.* ## References Unipolar and bipolar sine PWM, the modulation index and dead-time effects are treated in N. Mohan, T. Undeland and W. Robbins, *Power Electronics*, 3rd ed., Wiley, 2003 (the chapter on switch-mode DC-AC inverters). The circuit values are illustrative; the numbers on this page are Voltecx's own runs. **Next:** back to the [course page](https://voltecx-web.nguyenvanqui291.workers.dev/course), or read [how to use this course in a class](https://voltecx-web.nguyenvanqui291.workers.dev/course/for-instructors). --- # For instructors: teaching with the Voltecx course URL: https://voltecx-web.nguyenvanqui291.workers.dev/course/for-instructors/ This course is built to drop into an existing undergraduate or graduate power electronics class. Each lesson is three things that agree with each other: a circuit that ships with Voltecx, a guided lesson in the app that checks every exercise against the student's own run, and a page here with the theory, the answers and a one-page lab handout. Every number on the pages is checked against a simulation by an automated test, so the pages cannot drift from the program. ## The course at a glance | # | Lesson | Status | |---|---|---| | 1 | [Diodes and rectifiers](https://voltecx-web.nguyenvanqui291.workers.dev/course/diodes-and-rectifiers) | Ready | | 2 | [The buck converter](https://voltecx-web.nguyenvanqui291.workers.dev/course/buck-converter) | Ready | | 3 | [Boost and buck-boost](https://voltecx-web.nguyenvanqui291.workers.dev/course/boost-and-buck-boost) | Ready | | 4 | [The flyback converter](https://voltecx-web.nguyenvanqui291.workers.dev/course/flyback-converter) | Ready | | 7 | [The single-phase inverter and sine PWM](https://voltecx-web.nguyenvanqui291.workers.dev/course/single-phase-inverter) | Ready (page and example; no guided lesson in the app yet) | | 5–6, 8–11 | Averaged models, loop design, three-phase inverters and SVPWM, magnetics, thermal, conducted EMI | Planned | | 12–16 | Graduate topics: resonant and soft-switching converters, power factor correction, motor drives, grid-tied inverters, digital control | Planned | The [course page](https://voltecx-web.nguyenvanqui291.workers.dev/course) lists them with what each one covers. Until a planned lesson is ready, the [tutorials](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials) and the built-in examples cover most of the same circuits, without the graded exercises. ## How students install 1. Download Voltecx for their platform from the [download page](https://voltecx-web.nguyenvanqui291.workers.dev/download): macOS, Windows or Linux. 2. Install it as the [installation chapter of the manual](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/01-install) describes. Beta builds are not yet notarised on macOS; the chapter shows the one-time step to open them. 3. Start it and click **Guided Lessons** in the activity bar on the left. The course lessons are listed as **Course 1** to **Course 4**. The free tier runs offline with no account and no licence key, so students can install it on their own laptops and work without the campus network. The terms of the academic plan are not published yet; see the [academic program](https://voltecx-web.nguyenvanqui291.workers.dev/academic) page. ## How a lesson runs in class - **Before class**, students read the lesson page up to the exercises and fill in the "Predicted" column of the lab handout. - **In the lab**, they open the guided lesson. Each step says what to change and what to predict; **Next** stays locked until the student's own run gives the right number, and a hint says what to look at when it does not. A step that asks for a design (the capacitor in lesson 2) only passes on the right answer, not on any answer that works. - **After the lab**, they hand in the handout and the saved circuit (`.pcraft`). The answers on each lesson page are for you; they are on the public page, so assign the report questions, or change the values, for marked work. ## Assignment template Copy this into your course page and fill in the brackets. ```text Lab [N]: [lesson title] Learning outcomes After this lab you can [derive / predict / size] [quantity] for [converter] and check it against a simulation. Before the lab (20 %) Read [lesson page]. Fill in the "Predicted" column of the lab handout, showing each calculation. In the lab (40 %) Complete "Course [N]" in Voltecx's Guided Lessons. Record the simulated values in the handout. Save your final circuit as [lab-N-studentid].pcraft. Report (40 %) Answer the report questions on the handout. Include the scope figures the procedure asks for, exported as SVG or PNG. Hand in The handout (PDF) and [lab-N-studentid].pcraft by [date]. Changed values for this term [e.g. Vin = 36 V, L1 = 68 µH: recompute every predicted value] ``` ## Grading the circuits automatically `powercraft-cli`, the command-line program that ships with Voltecx, runs the same checks as the guided lesson on a student's saved file. For example, to grade the capacitor step of lesson 2 (step index 4, counting from 0): ```sh powercraft-cli run --accept-terms --root submissions \ --cmd file.open --param path=lab-2-s1234567.pcraft \ --cmd simulation.run \ --cmd lesson.check --params '{"id":"course-buck","step":4}' ``` The last line it prints is a JSON object with `"passed": true` or `false`, and the reason for each check that failed. The Test Bench step is graded the same way, after listing and running its case: ```sh powercraft-cli run --accept-terms --root submissions \ --cmd file.open --param path=lab-2-s1234567.pcraft \ --cmd testbench.list --params '{"spec":{"vin":48,"vout":{"nom":12,"tolPct":2},"iout":{"min":5,"max":5},"ripple":{"maxPp":0.05}}}' \ --cmd testbench.run --param case=all \ --cmd lesson.check --params '{"id":"course-buck","step":5}' ``` A loop over the folder grades a whole class. `powercraft-cli run --cmd lesson.get --param id=course-buck` prints every step with its checks, so you can see what each one requires. If you change the values for your term, write your own pass bands with `scope.measure` or a Test Bench spec; the [Test Bench chapter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/18-test-bench) describes the specs it reads. ## Lab kit list The course runs on laptops alone. What each seat needs: - A computer that runs Voltecx (macOS, Windows or Linux) with the program installed. - A copy of the lesson's lab handout, on paper or as a PDF. - Optional: a mouse; the schematic editor is easier with one than with a trackpad. If your lab follows a simulation with the same circuit on a bench, the usual kit for these four lessons is a low-voltage AC source (a mains isolation transformer with a 12 V secondary for lesson 1), a current-limited DC bench supply, a two-channel oscilloscope with a current probe, a multimeter, and an evaluation board or breadboard for each converter. Choose the parts and their ratings from your own lab's safety rules; Voltecx does not supply kits. ## Questions and pilots We are looking for a few university labs to pilot the course and tell us what to change. Write to us through the [contact page](https://voltecx-web.nguyenvanqui291.workers.dev/contact) with your course, the topics you teach and the number of seats. --- # Worked example: a 48 V to 12 V buck converter URL: https://voltecx-web.nguyenvanqui291.workers.dev/worked-examples/buck-converter-48v-to-12v/ The `buckIdeal` example (the textbook buck: an ideal switch and diode) steps 48 V down to 12 V at a fixed duty cycle of 0.25 and 100 kHz, into a 2.4 Ω load (5 A). By hand, the output is 12 V, the inductor ripple 0.90 A and the output ripple 11.25 mV. The run gives 11.99 V, 0.90 A and 11.2 mV. ## Open it In the app: **File › Open Example › DC-DC › Buck converter, textbook**, then press **F5**. From the command line: ```sh powercraft-cli run --cmd file.openExample --params '{"name": "buckIdeal"}' \ --cmd simulation.run \ --cmd scope.measure --params '{"signals": ["v(out)", "i(L1)"], "t0": 0.0039, "t1": 0.004}' ``` ![The buck example: a 48 V source, switch S1, freewheeling diode D1, L1 = 100 µH, C1 = 100 µF and a 2.4 Ω load, with a constant duty of 0.25 driving a 100 kHz sawtooth PWM.](https://voltecx-web.nguyenvanqui291.workers.dev/media/worked-examples/buck-converter-48v-to-12v/schematic.svg) | Part | Value | | --- | --- | | Input $V_{in}$ | 48 V | | Duty cycle $D$ | 0.25 (open loop) | | Switching frequency $f_{sw}$ | 100 kHz | | Inductor $L_1$ | 100 µH | | Output capacitor $C_1$ | 100 µF, starts at 12 V | | Load $R_1$ | 2.4 Ω | ## The hand calculation In continuous conduction the switch node is $V_{in}$ for a fraction $D$ of each period and 0 V for the rest, and the inductor passes its average: $$V_{out} = D\,V_{in} = 0.25 \times 48 = 12\ \text{V}, \qquad I_{out} = \frac{12}{2.4} = 5\ \text{A}$$ While the switch is on, $V_{in} - V_{out}$ across the inductor ramps its current up by $$\Delta I = \frac{(V_{in} - V_{out})\,D}{f_{sw}\,L} = \frac{36 \times 0.25}{100\ \text{kHz} \times 100\ \mu\text{H}} = 0.90\ \text{A}$$ The capacitor takes the triangular part of that current. The charge in one half of the triangle gives the output ripple: $$\Delta V = \frac{\Delta I}{8\,f_{sw}\,C} = \frac{0.90}{8 \times 100\ \text{kHz} \times 100\ \mu\text{F}} = 11.25\ \text{mV}$$ ## The run The example runs for 4 ms. The capacitor starts at 12 V, so the start-up is short. Measure the last ten periods (3.9 to 4.0 ms): | Quantity | Hand | Run | | --- | --- | --- | | Mean output voltage | 12 V | 11.99 V | | Mean inductor current | 5 A | 5.00 A | | Inductor ripple (peak to peak) | 0.90 A | 0.90 A | | Output ripple (last two periods) | 11.25 mV | 11.2 mV | ![Two periods at the end of the run: the switch node v(sw) toggling between 48 V and 0 V, the inductor current i(L1) as a 0.90 A triangle around 5 A, and the output v(out) with its 11 mV ripple.](https://voltecx-web.nguyenvanqui291.workers.dev/media/worked-examples/buck-converter-48v-to-12v/steady-state.svg) The output sits 6 mV under 12 V: the switch and the diode each have 1 mΩ of on-resistance, and the formula has none. Over ten periods the output ripple reads about 0.4 mV more than over two, because the slow tail of the LC start-up is still in the window. ## Try next - Change `D` in the circuit variables to 0.5 and check $V_{out} = 24$ V. - Halve L1 to 50 µH: the inductor ripple doubles to 1.8 A and the output ripple to about 22 mV. - Raise R1 until the current triangle touches zero. Past that point the buck runs in discontinuous conduction and $V_{out} = D\,V_{in}$ no longer holds. - Close the loop: the [closed-loop buck](https://voltecx-web.nguyenvanqui291.workers.dev/worked-examples/buck-closed-loop-pi) holds 12 V with a PI controller. Every number on this page comes from a run that a test repeats (`auto::tests_worked_examples`), so the page changes when the simulator does. --- # Worked example: a buck converter with a PI voltage loop URL: https://voltecx-web.nguyenvanqui291.workers.dev/worked-examples/buck-closed-loop-pi/ The `buckClosedLoop` example is the 48 V to 12 V buck with a PI controller setting the duty cycle. By hand, the loop gain crosses 0 dB three times: it falls through it near 373 Hz, rises above it again on the output filter's resonance and falls through it last at 1758 Hz, where the phase margin is about 44°. The run starts from 0 V, settles inside ±1 % of 12 V at 3.3 ms without passing 12 V, and the loop gain measured on the switching circuit falls through 0 dB last at 1751 Hz with 45° of phase margin and 47 dB of gain margin. ## Open it In the app: **File › Open Example › DC-DC › Buck converter, closed loop**, press **F5**, then **Analysis › Loop Gain** with the signal `duty`. From the command line: ```sh powercraft-cli run --cmd file.openExample --params '{"name": "buckClosedLoop"}' \ --cmd simulation.run \ --cmd analysis.loopGain --params '{"signal": "duty", "fStart": 100, "fStop": "20k", "points": 80}' ``` ![The closed-loop buck: the power stage of the buck example, a voltmeter VM on the output, and the control chain Ref (12 V), Err (reference minus output), PI (Kp 0.01, Ki 40, duty limited to 0 to 0.9) and a 100 kHz PWM.](https://voltecx-web.nguyenvanqui291.workers.dev/media/worked-examples/buck-closed-loop-pi/schematic.svg) The power stage is the one of the [open-loop buck](https://voltecx-web.nguyenvanqui291.workers.dev/worked-examples/buck-converter-48v-to-12v): 48 V in, L1 = 100 µH, C1 = 100 µF, R1 = 2.4 Ω, 100 kHz. The capacitor now starts empty. ## The hand calculation The duty cycle drives the output through the LC filter. At low frequency the gain from duty to output is $V_{in} = 48$ V per unit of duty. The filter resonates at $$f_0 = \frac{1}{2\pi\sqrt{L C}} = \frac{1}{2\pi\sqrt{100\ \mu\text{H} \times 100\ \mu\text{F}}} = 1.59\ \text{kHz}, \qquad Q = R\sqrt{\frac{C}{L}} = 2.4$$ The PI controller is $K_p + K_i/s$ with $K_p = 0.01$ and $K_i = 40$, so the loop gain is $$T(s) = \left(0.01 + \frac{40}{s}\right) \frac{48}{L C s^2 + (L/R)\,s + 1}$$ Well below $f_0$ the filter is flat and $T(j\omega) \approx 48\,(0.01 + 40/(j\omega))$. Setting $|T| = 1$: $(0.48)^2 + (1920/\omega)^2 = 1$ gives $\omega = 2190$ rad/s, a first crossing near **350 Hz** (373 Hz with the filter's rise), where the phase margin is about 115°. That is not the crossing that matters. Above it the gain keeps falling toward 0.48 (−6.4 dB), but the filter's resonance lifts it by up to $Q = 2.4$: $|T|$ rises above 1 again at 1181 Hz, peaks at +2.1 dB near 1.51 kHz and falls through 1 for the last time at **1758 Hz**. There the filter has already turned the phase most of the way to −180°, so the phase margin is about **44°** (41° with the PWM's half-period delay). The last crossing sets the damping: the closed-loop poles are at $-1418 \pm j11925$ s⁻¹, ζ ≈ 0.12, so a load step rings at about 1.9 kHz. ## The run The example runs for 10 ms from an empty capacitor. ![Start-up over the 10 ms run: v(out) rises to the 12 V reference, ringing at the LC resonance on the way, while the duty climbs to 0.25.](https://voltecx-web.nguyenvanqui291.workers.dev/media/worked-examples/buck-closed-loop-pi/start-up.svg) | Quantity | Hand | Run | | --- | --- | --- | | Settled output (last ten periods) | 12 V | 12.00 V | | Settled duty cycle | 0.25 | 0.250 | | Time into ±1 % of 12 V | — | 3.3 ms | | Peak output | — | below 12.01 V | | 0 dB crossings | 3 | 3 | | Last fall through 0 dB | 1758 Hz | 1751 Hz | | Phase margin there | 44.5° | 45° | | Gain margin | — | 47 dB | ![The loop gain T measured by analysis.loopGain on the switching circuit: the magnitude falls through 0 dB near 375 Hz, rises above it on the LC resonance and falls through it last at 1751 Hz (the vertical line), where the phase is 45° from −180°.](https://voltecx-web.nguyenvanqui291.workers.dev/media/worked-examples/buck-closed-loop-pi/loop-gain.svg) `analysis.loopGain` reads the margins at the last fall through 0 dB and says how many crossings it found (`crossings`, and a warning). Sweep densely around the resonance: the phase turns by about 90° between 1.3 and 2 kHz, so the default 50-point sweep from 10 Hz to 100 kHz reads 52° there, and a 12-point sweep from 100 Hz to 20 kHz steps over the resonance and finds only the first crossing. The ringing at start-up is that same resonance, excited while the duty cycle climbs; the integrator is slow, so it lets the output ring and then pulls it in. `analysis.loopGain` injects a small perturbation into the `duty` signal of the switching circuit and measures the response at each frequency. It needs no averaged model, so the result includes the PWM and anything else the circuit holds. ## Try next - Halve Kp to 0.005: the resonance hump stays below 0 dB, and by hand the loop crosses once, near 330 Hz with about 100° of margin. Double it to 0.02: one crossing near 2.1 kHz with only about 27°. Run the loop gain again and compare. - Change the load R1 to 24 Ω (0.5 A): Q rises to 24 and the resonance peak grows. Check the gain margin. - Read [how to design the PI for a buck](https://voltecx-web.nguyenvanqui291.workers.dev/blog/buck-converter-pi-compensator-design) for the full procedure. Every number on this page comes from a run that a test repeats (`auto::tests_worked_examples`), so the page changes when the simulator does. --- # Worked example: a 12 V to 24 V boost converter URL: https://voltecx-web.nguyenvanqui291.workers.dev/worked-examples/boost-converter-12v-to-24v/ The `boost` example steps 12 V up to 24 V at a duty cycle of 0.5 and 50 kHz, into a 24 Ω load (1 A). By hand, the inductor carries 2 A with a 0.60 A ripple and the output ripple is 45.5 mV. A 60 ms run gives 23.99 V, 2.00 A, 0.60 A and 45 mV. The default 10 ms run ends at 23.89 V because the boost's LC resonance is lightly damped and still ringing. ## Open it In the app: **File › Open Example › DC-DC › Boost converter**, then press **F5**. From the command line, with the longer run: ```sh powercraft-cli run --cmd file.openExample --params '{"name": "boost"}' \ --cmd simulation.settings --params '{"tEnd": 0.06}' \ --cmd simulation.run \ --cmd scope.measure --params '{"signals": ["v(out)", "i(L1)"], "t0": 0.0599, "t1": 0.06}' ``` ![The boost example: a 12 V source, L1 = 200 µH, switch S1 to ground, diode D1, C1 = 220 µF and a 24 Ω load, with a constant duty of 0.5 driving a 50 kHz PWM.](https://voltecx-web.nguyenvanqui291.workers.dev/media/worked-examples/boost-converter-12v-to-24v/schematic.svg) | Part | Value | | --- | --- | | Input $V_{in}$ | 12 V | | Duty cycle $D$ | 0.5 (open loop) | | Switching frequency $f_{sw}$ | 50 kHz | | Inductor $L_1$ | 200 µH, starts at 2 A | | Output capacitor $C_1$ | 220 µF, starts at 24 V | | Load $R_1$ | 24 Ω | ## The hand calculation In continuous conduction the inductor's volt-seconds balance over a period, which gives $$V_{out} = \frac{V_{in}}{1 - D} = \frac{12}{0.5} = 24\ \text{V}, \qquad I_L = \frac{I_{out}}{1 - D} = \frac{1\ \text{A}}{0.5} = 2\ \text{A}$$ While the switch is on, the full input is across the inductor: $$\Delta I = \frac{V_{in}\,D}{f_{sw}\,L} = \frac{12 \times 0.5}{50\ \text{kHz} \times 200\ \mu\text{H}} = 0.60\ \text{A}$$ While the switch is on the diode is off, and the capacitor alone feeds the load: $$\Delta V = \frac{I_{out}\,D}{f_{sw}\,C} = \frac{1 \times 0.5}{50\ \text{kHz} \times 220\ \mu\text{F}} = 45.5\ \text{mV}$$ ## Why the default run has not settled To the duty cycle, a boost looks like an LC filter whose inductance is $L/(1-D)^2 = 800$ µH. With 220 µF and 24 Ω: $$f_0 = \frac{1}{2\pi\sqrt{800\ \mu\text{H} \times 220\ \mu\text{F}}} = 379\ \text{Hz}, \qquad Q = R\sqrt{\frac{C}{L/(1-D)^2}} = 12.6$$ A resonance with Q = 12.6 decays with a time constant of $2Q/(2\pi f_0) \approx 10.6$ ms. The capacitor and the inductor start at their average values, but the first switching period still disturbs them, and the ring that follows lasts tens of milliseconds. After the default 10 ms the output still reads 23.89 V; after 60 ms it has settled. ![The output over a 60 ms run: the ring at 379 Hz dies out over tens of milliseconds and v(out) settles at 24 V.](https://voltecx-web.nguyenvanqui291.workers.dev/media/worked-examples/boost-converter-12v-to-24v/settling.svg) ## The run | Quantity | Hand | Run | | --- | --- | --- | | Output after the default 10 ms | — | 23.89 V | | Output after 60 ms (last five periods) | 24 V | 23.99 V | | Mean inductor current | 2 A | 2.00 A | | Inductor ripple (peak to peak) | 0.60 A | 0.60 A | | Output ripple | 45.5 mV | 45 mV | ![Three periods at the end of the 60 ms run: the switch node v(sw) toggling between 0 V and 24 V, the inductor current i(L1) as a 0.60 A triangle around 2 A, and v(out) with its 45 mV ripple.](https://voltecx-web.nguyenvanqui291.workers.dev/media/worked-examples/boost-converter-12v-to-24v/steady-state.svg) ## Try next - Close the loop with the `boostClosedLoop` example. A boost's loop is limited by its right-half-plane zero; [the boost design article](https://voltecx-web.nguyenvanqui291.workers.dev/blog/boost-converter-design-rhp-zero) explains why. - Raise D to 0.6: $V_{out}$ = 30 V, $I_L$ = 2.5 A, and the resonance moves to $f_0 \propto (1 - D)$. - Compare with the [buck worked example](https://voltecx-web.nguyenvanqui291.workers.dev/worked-examples/buck-converter-48v-to-12v), which settles in a few milliseconds because its Q is 1. Every number on this page comes from a run that a test repeats (`auto::tests_worked_examples`), so the page changes when the simulator does. --- # Worked example: a 12 V to 8 V flyback converter URL: https://voltecx-web.nguyenvanqui291.workers.dev/worked-examples/flyback-converter-12v-to-8v/ The `flyback` example runs a 1:1 coupled inductor at a duty cycle of 0.4 and 100 kHz from 12 V into a 20 Ω load. By hand, the output is 8 V, the primary current peaks at 1.14 A and the converter stays in continuous conduction. The run gives 7.94 V, a 1.15 A peak and 0.19 A still flowing in the secondary when the switch turns on again. It also shows a 57.6 V spike on the drain, where the ideal plateau is 20 V: the leakage inductance. ## Open it In the app: **File › Open Example › Isolated › Flyback converter**, then press **F5**. From the command line: ```sh powercraft-cli run --cmd file.openExample --params '{"name": "flyback"}' \ --cmd simulation.run \ --cmd scope.measure --params '{"signals": ["v(out)", "i(T1.1)", "v(drain)"], "t0": 0.0029, "t1": 0.003}' ``` ![The flyback example: a 12 V source, the coupled inductor T1 (50 µH each side, coupling 0.995), switch S1 with an RC snubber (2 nF, 50 Ω) on its drain, diode D1, C1 = 47 µF and a 20 Ω load, driven at a constant duty of 0.4 and 100 kHz.](https://voltecx-web.nguyenvanqui291.workers.dev/media/worked-examples/flyback-converter-12v-to-8v/schematic.svg) | Part | Value | | --- | --- | | Input $V_{in}$ | 12 V | | Coupled inductor T1 | 50 µH : 50 µH ($n = 1$), $k = 0.995$ | | Duty cycle $D$ | 0.4 (open loop) | | Switching frequency $f_{sw}$ | 100 kHz | | Snubber | 2 nF in series with 50 Ω, drain to ground | | Output | C1 = 47 µF (starts at 8 V), R1 = 20 Ω | ## The hand calculation A flyback stores energy in the magnetising inductance while the switch is on and releases it to the output while the switch is off. In continuous conduction, the volt-second balance gives $$V_{out} = n\,V_{in}\,\frac{D}{1 - D} = 12 \times \frac{0.4}{0.6} = 8\ \text{V}$$ The magnetising inductance is about $k\,L_1 = 49.75$ µH. During the on-time it ramps by $$\Delta I = \frac{V_{in}\,D}{f_{sw}\,L_m} = \frac{12 \times 0.4}{100\ \text{kHz} \times 49.75\ \mu\text{H}} = 0.965\ \text{A}$$ All the output current passes through the secondary during the off-time, so the magnetising current (referred to the primary) averages $I_{out}/(1 - D)$. With the run's 7.94 V, $I_{out}$ = 0.397 A and that average is 0.661 A. The ramp then runs from $$0.661 - \frac{0.965}{2} = 0.18\ \text{A} \quad\text{to}\quad 0.661 + \frac{0.965}{2} = 1.14\ \text{A}$$ The valley is above zero, so the core never empties: continuous conduction. When the switch is off, the drain sits at $V_{in} + V_{out}/n = 20$ V. ## The run The example runs for 3 ms; the measurements are over the last ten periods. | Quantity | Hand | Run | | --- | --- | --- | | Mean output voltage | 8 V (ideal) | 7.94 V | | Peak primary current | 1.14 A | 1.15 A | | Secondary current when the switch turns on | 0.18 A | 0.19 A | | Drain voltage, off-time plateau | 20 V | 20 V | | Drain voltage, peak | — | 57.6 V | ![Three periods at the end of the run: the drain voltage v(drain) with a spike at each turn-off and a 20 V plateau, the primary current i(T1.1) ramping to 1.15 A while the switch is on, the secondary current i(D1) ramping down to 0.19 A while it is off, and the output v(out).](https://voltecx-web.nguyenvanqui291.workers.dev/media/worked-examples/flyback-converter-12v-to-8v/steady-state.svg) The output is 0.8 % below the ideal 8 V: the formula has no leakage inductance, no snubber and no on-resistance. The drain spike is the leakage inductance. With $k = 0.995$, a small part of the primary inductance is not coupled to the secondary. When the switch opens, the current in it has nowhere to go but the snubber capacitor, and at the edge the drain jumps to 57.6 V, the 1.15 A of the primary current times the 50 Ω snubber resistor, before the snubber capacitor takes over and the drain settles to the plateau. A real design sizes the switch's voltage rating for that spike, not for the 20 V plateau. ## Try next - Change k to 0.98 and run again: more of the primary is leakage. Compare the drain spike and the output with this run. - Raise R1 to 100 Ω. The average magnetising current falls below half the ripple, the secondary current reaches zero before the period ends, and the converter enters discontinuous conduction. - Read [the flyback transformer design steps](https://voltecx-web.nguyenvanqui291.workers.dev/blog/flyback-transformer-design-steps) to choose n, $L_m$ and the core for a real specification. Every number on this page comes from a run that a test repeats (`auto::tests_worked_examples`), so the page changes when the simulator does. --- # Worked example: a 1 kW boost power factor corrector on 230 V mains URL: https://voltecx-web.nguyenvanqui291.workers.dev/worked-examples/boost-pfc-230v-1kw/ The `pfcBoost` example takes 230 V, 50 Hz mains through a diode bridge and a boost stage into a 470 µF DC link at 400 V, and a 160 Ω load. By hand the load takes 1 kW, the line current is 4.35 A rms and the link carries a 16.9 V ripple at 100 Hz. The run takes 1.007 kW at a power factor of 0.994, with a line current of 4.40 A rms and 6.1 % THD, and the link ripples 17.3 V. Doubling the load makes the link dip to 343 V and recover, and the power factor stays at 0.996. ## Open it In the app: **File › Open Example › Power quality › Boost PFC**, then press **F5**. From the command line: ```sh powercraft-cli run --cmd file.openExample --params '{"name": "pfcBoost"}' \ --cmd simulation.run \ --cmd scope.power --params '{"v": "vac", "i": "iac", "t0": 0.16, "t1": 0.24}' ``` ![The boost PFC example: mains source, diode bridge, boost inductor L1, switch S1, diode D5, link capacitor C1 and load R1, with the voltage loop, multiplier, current loop and PWM above the power stage joined by net labels.](https://voltecx-web.nguyenvanqui291.workers.dev/media/worked-examples/boost-pfc-230v-1kw/schematic.svg) | Part | Value | | --- | --- | | Mains | 230 V rms, 50 Hz | | Boost inductor $L_1$ | 3 mH | | Switching frequency | 20 kHz | | Link capacitor $C_1$ | 470 µF | | Link voltage $V_o$ | 400 V | | Load $R_1$ | 160 Ω | ## The hand calculation The load power and the line current follow from the link voltage: $$P = \frac{V_o^2}{R} = \frac{400^2}{160} = 1\ \text{kW}, \qquad I_{rms} = \frac{P}{V_{rms}} = \frac{1000}{230} = 4.35\ \text{A}$$ The power drawn from a sine is not constant: it pulses at twice the line frequency, and the link capacitor absorbs the pulse. The ripple on the link is $$\Delta V = \frac{P}{2\pi f_{line}\,C\,V_o} = \frac{1000}{2\pi \times 50 \times 470\ \mu\text{F} \times 400} = 16.9\ \text{V}$$ peak to peak. This ripple is why the voltage loop is slow (it crosses over near 10 Hz): a faster loop would pass the 100 Hz ripple into the current reference and distort the line current. ## The run Measure over four whole line cycles after the start-up, 160 ms to 240 ms. | Quantity | Hand | Run | | --- | --- | --- | | Line power | 1 kW | 1.007 kW | | Line current (rms) | 4.35 A | 4.40 A | | Power factor | 1 | 0.994 | | Current THD | — | 6.1 % | | Mean DC link | 400 V | 398 V | | Link ripple (peak to peak) | 16.9 V | 17.3 V | The run takes a little more than the load's 1 kW because of the bridge, switch and diode losses, and the link sits 2 V under its set point. A bridge with a capacitor and no correction typically has a power factor of 0.5 to 0.7. ![Two line cycles at the end of the start-up: the line voltage vac, the line current iac in phase with it and the DC link vdc with its 100 Hz ripple.](https://voltecx-web.nguyenvanqui291.workers.dev/media/worked-examples/boost-pfc-230v-1kw/line.svg) ## Double the load At the end of the 0.25 s run, halve the load resistor and continue for another 0.25 s: ```sh powercraft-cli run --cmd simulation.tune --params '{"component": "R1", "key": "r", "value": 80}' \ --cmd simulation.continue --params '{"duration": 0.25}' ``` The load is now 2 kW. The slow voltage loop needs time to raise the current demand, so the capacitor supplies the difference and the link falls to 343.2 V, 0.022 s after the step. Over 0.4 s to 0.5 s the converter takes 1.984 kW at a power factor of 0.996, with a peak line current of 12.9 A. ## Try next - Run `Design › Design Steps › Current Loop` and `Voltage Loop` to replace the example's hand-set gains with designed ones. - Let `design.auto` size the converter from a mains spec (`vinAc`, `pout`, `pf`, `thd`) and compare the power factor with this page. - See the [boost worked example](https://voltecx-web.nguyenvanqui291.workers.dev/worked-examples/boost-converter-12v-to-24v) for the DC-DC stage on its own. Every number on this page comes from a run that a test repeats (`auto::tests_worked_examples`), so the page changes when the simulator does. --- # Worked example: a 250 W LLC half bridge from 400 V to 48 V URL: https://voltecx-web.nguyenvanqui291.workers.dev/worked-examples/llc-half-bridge-400v-to-48v-250w/ The `llcHalfBridge` example drives a resonant tank and a transformer from a half bridge at 400 V, with a diode bridge to 48 V. It ships with a tank for about 480 W. This page sizes a new tank for 250 W and an input of 360 to 420 V: a turns ratio of 4.04, a 97.2 µH resonant inductor, a 26.1 nF resonant capacitor and 486 µH of magnetising inductance. At 100 kHz the run gives 47.96 V out with a resonant current of 2.27 A peak, which matches the hand value. A frequency sweep finds zero-voltage switching from 60 kHz up, next to the 54.9 kHz the tank design predicts. ## Open it In the app: **File › Open Example › Isolated › LLC resonant half bridge**. Then choose **Design › Design Steps › LLC Tank** and enter the spec below. From the command line: ```sh powercraft-cli run --cmd file.openExample --params '{"name": "llcHalfBridge"}' \ --cmd design.llc --params '{"vin": 400, "vinMin": 360, "vinMax": 420, "vout": 48, "pout": 250, "fr": "100k", "apply": true}' \ --cmd simulation.run \ --cmd scope.measure --params '{"signals": ["v(out)", "ir"], "t0": "1.4m", "t1": "1.8m"}' ``` ![The LLC half bridge: the 400 V source, switches Q1 and Q2, the ammeter AmR, resonant capacitor Cr and inductor Lr, transformer T1, diode bridge D1 to D4, output capacitor Co and load R1, with the PWM, inverter and dead-time blocks above the power stage joined by the net labels g1 and g2.](https://voltecx-web.nguyenvanqui291.workers.dev/media/worked-examples/llc-half-bridge-400v-to-48v-250w/schematic.svg) | Spec | Value | | --- | --- | | Nominal input | 400 V | | Input range | 360 to 420 V | | Output | 48 V, 250 W (9.216 Ω) | | Resonant frequency $f_r$ | 100 kHz | | Dead time | 200 ns | ## The hand calculation A half bridge puts a square wave of half the input on the tank. At the resonant frequency the tank's gain is one, so the turns ratio sets the output. With the rectifier's 1.5 V drop at this current: $$n = \frac{V_{in}/2}{V_o + V_{drop}} = \frac{200}{49.5} = 4.04$$ The rectifier and load look like a resistor to the tank, seen through the transformer: $$R_{ac} = \frac{8 n^2}{\pi^2} R \cdot \frac{V_o + V_{drop}}{V_o} = 125.75\ \Omega$$ The design step picks the quality factor $Q$ = 0.4855 and $L_m/L_r$ = 5. These give a peak gain 10 % above the 1.11 that the 360 V input needs. Then: $$L_r = \frac{Q R_{ac}}{2\pi f_r} = 97.17\ \mu\text{H}, \qquad C_r = \frac{1}{2\pi f_r Q R_{ac}} = 26.07\ \text{nF}, \qquad L_m = 5 L_r = 485.8\ \mu\text{H}$$ | Result of LLC Tank | Value | | --- | --- | | Peak gain at full load | 1.222, at 54.88 kHz | | $f_{min}$ (gain 1.11, 360 V in) | 76.99 kHz | | $f_{max}$ (gain 0.95 at 10 % load, 420 V in) | 115.4 kHz | | Magnetising current at turn-off, at $f_{max}$ | 0.892 A | | Switch-node swing time | 188 ns | The gain curve depends only on $Q$ and $L_m/L_r$, so it is the same shape as the example's 480 W tank, only with new component values. ![The tank's gain against switching frequency at full load and at 10 % load, with the resonant frequency marked at 100 kHz.](https://voltecx-web.nguyenvanqui291.workers.dev/media/worked-examples/llc-half-bridge-400v-to-48v-250w/gain-curves.svg) Zero-voltage switching needs the magnetising current to move the switch node before the other switch turns on. The node has to move $2 C_{oss} V_{in,max}$ = 2 · 200 pF · 420 V = 168 nC. At 0.892 A that takes 188 ns, which is inside the 200 ns dead time but with little to spare. The design step reports 515.7 µH as the largest $L_m$ that still swings in time. ## The run Run with the new tank at 400 V and 100 kHz, then measure from 1.4 ms to 1.8 ms. At resonance the resonant current is the sum of two parts a quarter period apart: - the load's part, with a peak of $\pi I_o / (2n)$ = 2.03 A; - the magnetising current, with a peak of $(V_{in}/2) / (4 L_m f_r)$ = 1.03 A. Together they give $\sqrt{2.03^2 + 1.03^2}$ = 2.27 A. | Quantity | Hand | Run | | --- | --- | --- | | Mean output | 48 V | 47.96 V | | Output ripple (peak to peak) | — | 0.25 V | | Resonant current, peak | 2.27 A | 2.27 A | | Resonant current, rms | — | 1.60 A | ![Three switching cycles at 100 kHz: the switch node v(sw) from 0 to 400 V, the near-sine resonant current ir and the output v(out).](https://voltecx-web.nguyenvanqui291.workers.dev/media/worked-examples/llc-half-bridge-400v-to-48v-250w/tank-current.svg) ## Where zero-voltage switching starts Below the peak-gain frequency the tank turns capacitive, and the switches turn on hard. Sweep the PWM frequency `fr` with **Analysis › Soft Switching**: ```sh powercraft-cli run --cmd analysis.softSwitching \ --params '{"sweep": {"variable": "fr", "values": [40000, 50000, 55000, 60000, 70000, 80000, 100000, 115000]}}' ``` | fr | 40 kHz | 50 kHz | 55 kHz | 60 kHz | 70 to 115 kHz | | --- | --- | --- | --- | --- | --- | | Zero-voltage turn-on | no | no | no | yes | yes | Both switches gain zero-voltage switching between 55 and 60 kHz. The tank design put the peak at 54.88 kHz, so the first-harmonic model and the simulation agree to within the sweep's 5 kHz steps. The whole working range, 77 to 115 kHz, switches at zero voltage. ## Try next - Step the input to 360 V with `simulation.tune` and find the frequency that brings the output back to 48 V, as in the LLC tutorial. - Raise `T1`'s magnetising inductance above 515.7 µH and rerun the sweep: the swing no longer fits in the dead time. - See the [boost PFC worked example](https://voltecx-web.nguyenvanqui291.workers.dev/worked-examples/boost-pfc-230v-1kw) for the stage that usually feeds an LLC its 400 V. Every number on this page comes from a run that a test repeats (`auto::tests_worked_examples`), so the page changes when the simulator does. --- # Battery CC-CV charging: two loops, one limit and when to stop URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/battery-cc-cv-charging/ A lithium-ion charger has two jobs that look like one. It must not push more current into the cell than the cell is rated for, and it must not take the cell above its charge voltage. A constant-current, constant-voltage (CC-CV) charger does both with two control loops, one inside the other, and a single clamp between them. This article builds that controller on a buck converter, shows the moment it hands over from current to voltage, and then runs a real four-cell pack through a whole charge. ## The cell sets the two numbers Both numbers come from the cell's data sheet, not from the charger. For the Molicel INR-21700-P45B (E-One Moli Energy, *Product Data Sheet, Model INR-21700-P45B*, version 1.2, "Charge" rows): - charge voltage 4.2 V per cell, - standard charge current 4.5 A, with a standard charge time of 1.5 hours, - typical capacity 4500 mAh, and a typical DC impedance of 15 mΩ at 50 % charge. For four cells in series the charger therefore holds at most 4.5 A and at most 16.8 V. The sheet gives no termination current; the charger designer chooses one. C/10 (0.45 A for this cell) is a common choice and is used below. ## Two loops and a clamp The power stage is a synchronous buck from 24 V. The control has two PI loops: 1. **The inner current loop** makes the inductor current $i_L$ follow a reference $i_{ref}$. A feedforward duty $v_{bat}/V_{in}$ does most of the work, so the PI only corrects. The plant from duty to current is about $V_{in}/(sL)$, and the loop crosses over well below the switching frequency. 2. **The outer voltage loop** compares the filtered pack voltage with the target $V_{CV}$ and gives $i_{ref}$. The clamp is the whole trick: the output of the voltage PI is limited to $0 \le i_{ref} \le I_{CC}$. While the pack is below its target, the voltage error is large and positive, the PI sits on its upper limit, and $i_{ref} = I_{CC}$: the charger is a current source. As the pack voltage approaches $V_{CV}$, the error shrinks, the PI leaves the limit, and from then on it holds the voltage: the charger is a voltage source, and the current falls by itself. Two details matter in practice: - **Anti-windup.** While the voltage PI sits on its limit, its integrator must stop integrating. Otherwise it winds up during the whole CC phase and the pack overshoots $V_{CV}$ at the handover. Voltecx's `pi` block holds its integrator so that its output stays between `lo` and `hi`. - **Measure the voltage at the cell.** The current through the pack's internal resistance $R_0$ raises the terminal voltage by $I \cdot R_0$. Regulating the terminal voltage is right (it is what the cell's limit refers to), but it means the CV phase starts early, while the cell's rest voltage is still $I_{CC} R_0$ below the target. ![The batteryCharger example in Voltecx: a synchronous buck from 24 V into a four-cell pack, with the voltage PI giving iref and the current PI and feedforward giving the duty.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/battery-cc-cv-charging/charger.svg) ## The handover, simulated The `batteryCharger` example uses this controller with $I_{CC} = 5$ A and $V_{CV} = 16.6$ V (4.15 V a cell) at 10 kHz. Its pack has a capacity of only 1 mAh, so a fraction of a second of simulated time shows the whole charge with every switching cycle; the controller's behaviour does not depend on the capacity, only the time scale does. ![CC-CV charge of the batteryCharger example: the pack voltage (2 ms mean) rises to 16.6 V and holds; the pack current (2 ms mean) holds 5 A, then falls as the voltage loop leaves its limit; the state of charge rises from 70 % to about 96 %.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/battery-cc-cv-charging/cc-cv.svg) The simulation shows the three phases: - **CC.** The current holds 5.00 A while the pack voltage climbs. The current loop is fast enough that the 2 ms mean of $i_{bat}$ sits on $i_{ref}$. - **Handover.** At 149 ms the mean current falls below 4.9 A: the voltage PI has left its clamp. The current turns down smoothly, without a step, because the integrator did not wind up. The 2 ms mean of the pack voltage goes 45 mV above 16.6 V before it settles: the 300 Hz filter in the voltage feedback lets the pack run a little ahead of what the loop sees. That is about 11 mV a cell; a slower filter or a lower target would trade it against ripple. - **CV.** The pack voltage holds 16.61 V and the current tapers. It is below 0.5 A, a tenth of $I_{CC}$, at 233 ms, and under 10 mA at the end of the run, with the charge at 95.6 %. In CV the current is set by the gap between the target and the cell's rest voltage, divided by the internal resistance. That gap closes as the cell fills, so the current decays roughly exponentially and never quite reaches zero. ## A real pack over a real charge A switching simulation of 1.5 hours at a 2 µs step would take billions of steps. The `batteryChargerLongRun` example puts four P45B cells (the data sheet's 4.5 Ah, 16.8 V, 4.5 A and 60 mΩ for the pack) behind the same controller, and `simulation.batteryRun` runs it on the converter's averaged model: short bursts until the current settles, then jumps of seconds to minutes in which only the battery's charge moves. ![The four-cell Molicel P45B pack charged by the same controller over 90 minutes, on the averaged model: pack voltage, pack current with the 0.45 A (C/10) line, and state of charge.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/battery-cc-cv-charging/p45b-pack.svg) The current holds 4.5 A for 45 minutes. It reaches C/10 at 54 minutes with the pack at 99.6 %, and at the end of the data sheet's 1.5 hours the pack is at 100.0 %. The last half percent after C/10 takes nearly as long again as the CV phase before it, which is why chargers stop at a termination current rather than waiting for zero. The pack model keeps the battery part's default rest-voltage curve (illustrative, not from the data sheet) and no RC branch, because the sheet gives neither. The times above depend on that curve; the shape of the charge does not. ## Checklist - Take $V_{CV}$ and $I_{CC}$ from the cell's data sheet, per cell, and multiply by the number in series. Leave margin for the tolerance of your voltage measurement: an error of 1 % is 42 mV a cell. - Clamp the voltage PI's output at $I_{CC}$ and stop its integrator while it is clamped. - Make the current loop at least five times faster than the voltage loop, so the voltage loop sees a current source. - Choose a termination current and say where it comes from: the data sheet, if it gives one, otherwise your own trade between charge time and capacity. - Add the protections the loops do not provide: a charge timer, a temperature window (most cells must not be charged below 0 °C), and a pre-charge at low current for a deeply discharged cell, all per the cell's data sheet. ## Try it in Voltecx - Open the `batteryCharger` example and plot `vbat`, `ibat`, `iref` and `soc`. Change `Icc` or `Vcv` in the variables and run again. - Open `batteryChargerLongRun` and run `simulation.batteryRun` with `tEnd` 5400, or with `stopCurrent` 0.45 to stop at C/10. - The [battery charger tutorial](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/25-battery-charger/) builds the charger step by step, and [long battery runs](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/22-long-battery-run/) explains the averaged run. The [analyses](https://voltecx-web.nguyenvanqui291.workers.dev/features/analyses) page lists the measurements used here. --- # Designing the EMI input filter: corner, damping, one stage or two URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/emi-input-filter-design/ A pre-compliance estimate tells you how many decibels you are over the limit. The filter is what you build with that number. Three choices decide it: where its corner sits, how large its characteristic impedance is, and how it is damped. Each one comes from a different requirement, and getting one wrong breaks a different thing: the emission, the converter's loop, or the size of the board. This article designs the differential-mode filter of a 48 V to 12 V, 5 A, 200 kHz buck in one stage and in two, and compares them with Voltecx's `emi.conducted`. ## The requirement The converter and its estimate are those of the [conducted EMI pre-compliance](https://voltecx-web.nguyenvanqui291.workers.dev/blog/conducted-emi-pre-compliance) article: a buck with a 10 µF ceramic input capacitor and a LISN in the supply line. `emi.conducted` reads the fundamental at 200 kHz at 102.0 dBµV against a CISPR 32 class B average limit of 53.6 dBµV there (CISPR 32:2015, Edition 2.0, Annex A, the class B limits for conducted emission at the AC mains power port; on a DC input this is a screen, not a test against the standard). With a 6 dB design margin the filter must attenuate 54.4 dB at 200 kHz. The fundamental is the hardest frequency. Higher harmonics are lower, and the filter attenuates them more, so the frequency that sets the corner is almost always the switching frequency, or the first harmonic inside the band when $f_{sw}$ is below 150 kHz. ## Step 1: the corner Above its corner $f_0 = 1/(2\pi\sqrt{LC})$, one LC stage attenuates at 40 dB per decade and $k$ stages at $40k$ dB per decade. For an attenuation $A$ at $f_{sw}$: $$f_0 = f_{sw} \cdot 10^{-A / (40 k)}$$ For 54.4 dB at 200 kHz that is - one stage: $200\ \text{kHz} / 10^{54.4/40} = 8.73$ kHz, - two stages: $200\ \text{kHz} / 10^{54.4/80} = 41.8$ kHz. A corner five times higher means $LC$ is 23 times smaller per stage. That is the whole argument for two stages, before any part is chosen. ## Step 2: the characteristic impedance The corner fixes the product $LC$. The ratio, $R_0 = \sqrt{L/C}$, is fixed by the converter. A regulated converter draws constant power, so its input looks like a negative resistance of magnitude $$|Z_{in}| = \frac{V_{in}^2}{P_{in}} = \frac{48^2}{61\ \text{W}} = 37.8\ \Omega$$ Middlebrook's condition (R. D. Middlebrook, "Input filter considerations in design and application of switching regulators", IEEE IAS Annual Meeting, 1976) says the filter's output impedance must stay well below $|Z_{in}|$ at every frequency, or the filter changes the converter's loop gain and can make it oscillate. The [input filter stability](https://voltecx-web.nguyenvanqui291.workers.dev/blog/input-filter-middlebrook-stability) article shows that oscillation. Here we hold the peak to a third of $|Z_{in}|$, a 9.5 dB margin. An undamped LC has an infinite peak at $f_0$, so the filter needs damping, and the damping sets how high the peak is compared with $R_0$. With a resistor $R_d$ in series with a blocking capacitor $C_d = nC$ across the filter capacitor, the optimum of R. W. Erickson and D. Maksimović (*Fundamentals of Power Electronics*, chapter "Input Filter Design") gives $$|Z_o|_{peak} = R_0 \frac{\sqrt{2(2+n)}}{n}, \qquad R_d = R_0 \sqrt{\frac{(2+n)(4+3n)}{2n^2(4+n)}}$$ With $n = 4$ the peak is $0.866\,R_0$, so $R_0 = 37.8 / 3 / 0.866 = 14.5\ \Omega$. For the one-stage filter at 8.73 kHz: $$L = \frac{R_0}{2\pi f_0} = 265\ \mu\text{H}, \qquad C = \frac{1}{2\pi f_0 R_0} = 1.25\ \mu\text{F}, \qquad R_d = 0.61\,R_0 = 8.9\ \Omega, \quad C_d = 4C = 5\ \mu\text{F}$$ The order matters. If you pick $C$ first for low impedance, $L$ follows from the corner and $R_0$ may be far too high; the filter then meets the emission and fails Middlebrook. ## Step 3: real parts Voltecx's `emi.conducted` does the same three steps and then picks catalogue parts at or above each value: Coilcraft inductors with their DC resistance, ceramic capacitors at their capacitance under the 48 V DC bias, E96 damping resistors. It inserts the filter on a copy of the circuit and measures the spectrum again. | | One stage | Two stages | |---|---|---| | Corner of the parts drawn | 5.4 kHz | 27.6 kHz | | Inductance per stage | 330 µH | 66 µH | | Capacitance per stage, at 48 V | 2.67 µF | 0.50 µF | | Converter-side damping | 7.50 Ω, 18 µF | 4.75 Ω, 10 µF | | Output impedance peak | 9.42 Ω | 8.78 Ω | | Middlebrook margin to 37.8 Ω | 12.1 dB | 12.7 dB | | Worst margin to the limit, filtered | 16.7 dB | 20.1 dB | The one-stage filter needs a 330 µH inductor that carries the full 1.3 A input current: in practice a part much larger than the buck's own inductor. The two-stage filter uses 66 µH per stage (two 33 µH parts in series) and a fifth of the capacitance per stage, and it still has more margin. Both corners are below the hand values because every part is rounded up, which moves the corner down and adds margin. ![The two-stage filter emi.conducted inserted in front of the buck: each stage is a shunt capacitor and a series inductor, with a damping resistor and blocking capacitor on the inner node and across the converter's input capacitor.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/emi-input-filter-design/filtered-buck.svg) ![Average-detector spectrum from emi.conducted: without a filter, with the one-stage and with the two-stage filter, against the CISPR 32 class B average limit.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/emi-input-filter-design/spectrum.svg) ## Step 4: the parts above their resonance The 40 dB per decade holds only while the inductor is an inductor and the capacitor a capacitor. Every inductor has winding capacitance and every capacitor has ESL, so each part has a self-resonant frequency above which it turns into its opposite. `emi.conducted` reports the insertion loss of the stages with ideal parts and with the catalogue parts' data-sheet resonances: - One stage: 131 dB ideal at 10 MHz, but 97 dB with the parts; at 30 MHz 150 dB ideal and 76 dB with the parts. - Two stages: 205 dB against 192 dB at 10 MHz, 243 dB against 138 dB at 30 MHz. Here the buck's high harmonics are low enough that the margin is still set at 200 kHz. In a converter with fast edges, the band above 10 MHz is where real filters fall short, and the remedy is a part with a higher resonance (a smaller inductor, a small ceramic capacitor in parallel with the bulk one), not a larger value. The layout matters as much: a filter whose input and output tracks run side by side is bypassed by their mutual capacitance. ## Checklist 1. Take the attenuation needed at the frequency that sets it, including your design margin. 2. Choose the number of stages: one when the corner lands within a decade of $f_{sw}$, two when one stage would need a corner far below it. 3. Set $R_0$ from Middlebrook's condition at the lowest input voltage and full power, where $|Z_{in}|$ is smallest. 4. Damp every stage, and the converter-side one most: its peak is what the converter's loop sees. 5. Check the inductor's saturation current at the peak input current and its loss at the RMS current, and the capacitors' value at their DC bias. 6. Check the margin above 10 MHz with the parts' self-resonant frequencies, then with the layout. 7. Check the converter's loop gain with the filter in place. ## Try it in Voltecx - `emi.conducted` with `filter: "oneStage"` or `"twoStage"` sizes the filter and measures it; `parasitics: true` puts the parts' ESR, ESL and winding capacitance on the measured copy, and `apply: true` inserts the filter in one undoable step, refused when Middlebrook's check or the loop's phase margin fails. - The [conducted EMI tutorial](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/09-conducted-emi/) runs the whole flow on a buck, and the [EMI](https://voltecx-web.nguyenvanqui291.workers.dev/features/emi) page lists what the estimate covers and what it does not. --- # Three-phase inverter losses and junction temperature, by hand and simulated URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/three-phase-inverter-loss-and-junction-temperature/ In a DC-DC converter every switching period is the same, so one period gives the loss. In an inverter the current follows a sine at the output frequency: each device conducts for half of it, the current it switches changes from zero to the peak and back, and the IGBT and its diode share the work in a ratio set by the modulation index and the power factor. This article estimates the losses of one leg over the output period, turns them into temperatures through the thermal path, and compares both with a simulation. ## The inverter The `inverter3Thermal` example in Voltecx: a 600 V DC link, three IGBT legs at 10 kHz with space-vector modulation and a 1 µs dead time, a star-connected load of 0.8 Ω and 8 mH per phase at 50 Hz, and dq current control to a 30 A peak. Each IGBT and diode takes its losses from tables of on-state voltage and switching energy against current, voltage and junction temperature. The tables are illustrative values for a 1200 V, 50 A device class, not a real part; for a design, take them from the data sheet of the module you use. - IGBT on-state voltage at 25 °C: 1.24 V at 20 A, 1.68 V at 40 A. Diode: 1.2 V and 1.5 V. - Switching energy at 600 V and 25 °C: $E_{on} + E_{off}$ = 3.14 mJ at 20 A and 7.42 mJ at 40 A; diode reverse-recovery energy $E_{rr}$ = 0.92 mJ and 1.4 mJ. - Thermal path: IGBT junction to heat sink 0.4 K/W, diode 0.72 K/W (each a three-stage Foster chain from 0.5 ms to 50 ms), heat sink to air 0.15 K/W, air at 40 °C. ## The operating point The load impedance at 50 Hz is $|Z| = \sqrt{0.8^2 + (2\pi \cdot 50 \cdot 8\,\text{m})^2} = 2.64\ \Omega$, so $\cos\varphi = 0.8 / 2.64 = 0.303$. A 30 A peak needs 79.1 V peak per phase, a modulation index $M = 79.1 / 300 = 0.264$ referred to half the link voltage. This is a lightly loaded, low-power-factor point: 1.1 kW into the load from a 600 V link. ## Conduction loss over the sine Model each device's on-state curve as a line, $v = V_0 + r\,i$: the IGBT is 0.80 V and 22 mΩ, the diode 0.90 V and 15 mΩ (from the two points above). For sinusoidal PWM, averaging $v \cdot i$ over the output period gives (F. Casanellas, "Losses in PWM inverters using IGBTs", *IEE Proceedings - Electric Power Applications*, vol. 141, no. 5, 1994) $$P_{c,T} = V_{0}\hat I\left(\frac{1}{2\pi} + \frac{M\cos\varphi}{8}\right) + r\hat I^2\left(\frac{1}{8} + \frac{M\cos\varphi}{3\pi}\right)$$ $$P_{c,D} = V_{0}\hat I\left(\frac{1}{2\pi} - \frac{M\cos\varphi}{8}\right) + r\hat I^2\left(\frac{1}{8} - \frac{M\cos\varphi}{3\pi}\right)$$ The signs say who carries the current: with a high $M\cos\varphi$ (motoring at full voltage) the IGBT conducts most of the time; at a low one, as here, the diode carries almost as much. With $\hat I = 30$ A and $M\cos\varphi = 0.080$: $P_{c,T}$ = 6.7 W and $P_{c,D}$ = 5.6 W per device. Space-vector modulation changes the duty pattern a little, but the $M\cos\varphi$ terms are small at this point, so the formulas still apply. ## Switching loss over the sine Each device switches at $f_{sw}$ during its half of the output period, at the instantaneous current $\hat I \sin\theta$. If the switching energy grows linearly with current, the average over the half wave is $$P_{sw} = \frac{f_{sw}}{\pi} E(\hat I)\,\frac{V_{dc}}{V_{ref}}$$ At 30 A and 600 V, halfway between the table's 20 A and 40 A rows, $E_{on} + E_{off}$ = 5.28 mJ and $E_{rr}$ = 1.16 mJ, so $P_{sw,T}$ = 16.8 W and $P_{sw,D}$ = 3.7 W. In total, 23.5 W per IGBT and 9.3 W per diode, 197 W for the six of each. ## What the simulation gives ![Junction temperatures of the upper IGBT and diode of phase a and the heat-sink temperature over two output periods, from a Voltecx run started at its thermal steady state, with the phase current below.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/three-phase-inverter-loss-and-junction-temperature/junction-temperature.svg) The heat sink's time constant is 15 s, so a run that starts at 40 °C would need minutes of simulated time to warm up. Voltecx's `thermalStart: "steady"` instead runs a few line periods first, measures each device's average loss, and starts the thermal network at the DC steady state those losses give, with the losses read again at that temperature until it settles. Then `analysis.losses` over the last two line periods gives: - 24.3 W per IGBT, 71 % of it switching; - 10.8 W per diode, 49 % of it reverse recovery; - 210 W in all, at a phase current of 21.2 A RMS. The simulation is higher than the hand estimate, because it reads the tables at the junction's temperature, about 80 °C, not at 25 °C: the on-state voltage at 40 A rises from 1.68 V to 1.98 V at 150 °C, and the switching energies by 15 % to 60 %. Repeating the hand estimate with each table read at 80 °C gives 25.2 W per IGBT and 10.3 W per diode, 213 W in all, close to the simulation; this is the same iteration as in the [MOSFET loss and temperature](https://voltecx-web.nguyenvanqui291.workers.dev/blog/mosfet-loss-and-thermal-estimation) article. ## From loss to temperature Every device sits on one heat sink, so the heat sink carries the sum: $$T_{hs} = T_a + P_{total} R_{th,sa} = 40 + 210.4 \times 0.15 = 71.6\ ^\circ\text{C}$$ and each junction sits above it by its own loss times its own junction-to-sink resistance: $$T_{j,T} = T_{hs} + P_T R_{th,j\text{-}s,T} = 71.6 + 24.3 \times 0.4 = 81.3\ ^\circ\text{C}$$ $$T_{j,D} = 71.6 + 10.76 \times 0.72 = 79.3\ ^\circ\text{C}$$ The simulation's means are 71.4 °C, 81.0 °C and 79.1 °C. The mean is not the whole story. The figure shows the IGBT junction swinging between about 76 °C and 89.0 °C every 20 ms, and the diode up to 85.8 °C half a period later: each device heats while it conducts its half of the sine and cools during the other half, and the 0.5 ms and 5 ms stages of its thermal impedance are fast enough to follow. The peak is 8 K above the mean here; at a low output frequency, near standstill in a motor drive, one device carries the peak current for a long time and the ripple grows towards the full $P \cdot R_{th,j\text{-}s}$. The steady-state $R_{th}$ estimate gives the mean; the peak needs the transient thermal impedance $Z_{th}(t)$ at the output frequency, which is what a simulation with the Foster network computes directly. ## Checklist 1. Compute $M$ and $\cos\varphi$ at each operating point that matters: full torque at low speed, full power at full speed, regeneration (where $\cos\varphi < 0$ and the diodes carry more of the conduction loss). 2. Read conduction and switching data at the expected junction temperature, then iterate once with the temperature you find. 3. Scale switching energies to your link voltage and gate resistance with the data sheet's curves. 4. Sum the losses of every device on a shared heat sink before you compute any junction. 5. Hold the peak junction temperature, not the mean, to the data sheet's limit with your margin, and check the peak at the lowest output frequency. 6. For lifetime, the temperature swing $\Delta T_j$ per output period counts as well as its peak; module manufacturers give power-cycling curves against it. ## Try it in Voltecx - Open `inverter3Thermal`, set `thermalStart` to `steady` in the simulation settings, run, and plot `T(Sah.j)`, `T(Dah.j)` and `T(hs)`. - `analysis.losses` gives each device's average conduction and switching loss over a window, and `analysis.thermal` each thermal node's temperatures. - The [thermal and losses tutorial](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/08-thermal-losses/) builds the thermal path on a buck, and the [thermal](https://voltecx-web.nguyenvanqui291.workers.dev/features/thermal) page lists the thermal parts and analyses. --- # Commutation-loop inductance: how a few nanohenries set the turn-off overshoot URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/commutation-loop-inductance-overshoot/ When a fast transistor turns off, the current that flowed through it has to move to the other device of the half bridge within a few nanoseconds. Every nanohenry in the loop that carries this change (the DC-link capacitor, the two transistors and the copper between them, called the commutation loop) drops $L \cdot di/dt$ on top of the supply, so the drain overshoots. In Voltecx's `doublePulse` example, a Wolfspeed C3M0065090D SiC MOSFET switching 20 A at 400 V, the drain peaks at 412 V with the bench's own inductance. With 20 nH added it peaks at 443 V, with 50 nH at 479 V and with 100 nH at 557 V, ringing at 51 MHz. This article shows where the overshoot comes from, how to read the loop's inductance from the ring, and what the loop does to the switching energies: the turn-off loses more, the turn-on loses less, and why a lower total is no reason to welcome the inductance. Every number comes from a run of the example, and the runs are checked by a test in the Voltecx source. ## The bench ![The doublePulse example with the added loop inductance Lloop (here 50 nH) between the 400 V supply and the top of the half bridge. Q2 is the device under test; Q1 is held off and freewheels the 99 µH load on its body diode.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/commutation-loop-inductance-overshoot/bench.svg) The bench is the one of the [double-pulse post](https://voltecx-web.nguyenvanqui291.workers.dev/blog/double-pulse-test-switching-energy): a half bridge of two C3M0065090D, the 99 µH load across the upper one, which is held off, and two gate pulses on the lower one. The first pulse ramps the load to 20.2 A, the turn-off at 5.25 µs moves that current to Q1's body diode, and the second pulse takes it back at 6.25 µs. Each device has 5 nH in its source (the example's common-source inductance, chosen so the bench gives the data sheet's turn-off delay and fall time), and both of them lie in the commutation loop. To stand for the board, one inductor, `Lloop`, sits between the supply and the drain of Q1. On a real board this is the inductance of the path from the DC-link capacitor through both transistors and back. Where it sits in the loop does not matter for the overshoot: the whole loop changes its current at the same rate. ## Where the overshoot comes from ![The turn-off at 5.25 µs (0 ns) with 0, 20, 50 and 100 nH added: the drain voltage (top) and the drain current (bottom). The current falls at the same rate in every run; the voltage overshoots by more, and rings slower, the more inductance the loop has.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/commutation-loop-inductance-overshoot/turn-off.svg) At the turn-off the drain voltage of Q2 rises first, at constant current, until it passes the supply and Q1's body diode can take the current. Only then does Q2's current fall, and while it falls the loop's inductance holds the supply's voltage up: $$V_{peak} \approx V_{DC} + L_{loop} \cdot \left|\frac{di}{dt}\right|$$ On this bench the drain current falls at 1.02 A/ns between 80 % and 20 % of its value, with a steepest rate of 1.7 A/ns. The fall rate is set by the gate (the plateau, the gate resistor and the device's capacitances), not by the loop, so it is the same in every run. The overshoot then grows by about 1.33 V per added nanohenry, between the two rates, as the equation says. | Added loop inductance | Peak drain voltage | Eoff | Eon | Eon + Eoff | |---|---|---|---|---| | 0 nH | 412 V | 44.9 µJ | 272 µJ | 317 µJ | | 10 nH | 427 V | 46.7 µJ | 265 µJ | 311 µJ | | 20 nH | 443 V | 48.4 µJ | 260 µJ | 308 µJ | | 50 nH | 479 V | 54.6 µJ | 241 µJ | 295 µJ | | 100 nH | 557 V | 64.7 µJ | 202 µJ | 267 µJ | ![The peak drain voltage at the turn-off against the added loop inductance; the line marks the 400 V supply.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/commutation-loop-inductance-overshoot/overshoot-vs-l.svg) Even with nothing added the drain overshoots by 12 V: the two 5 nH source inductances are part of the loop. The C3M0065090D is a 900 V part, so 100 nH still leaves margin here. On a 650 V device at the same bus, the 557 V peak would already use 86 % of the rating, and a faster device or a larger current raises $di/dt$ and the overshoot with it. That is the real cost of a loop inductance: it decides how fast you may switch before the overshoot eats the voltage margin. ## Reading the loop from the ring After the peak the voltage rings: the loop's inductance against the output capacitance of the device that has just turned off. With 20, 50 and 100 nH added, the period is 10.8 ns, 14.5 ns and 19.7 ns. With 0 and 10 nH added, the ring dies out within three cycles. The period is $T = 2\pi\sqrt{L C}$, so $T^2$ is a straight line in the inductance: $$\left(\frac{T}{2\pi}\right)^2 = (L_{added} + L_{built\text{-}in})\, C$$ The slope of that line between the 50 nH and the 100 nH runs gives the ringing capacitance, 89 pF, and its intercept the inductance the bench already has, 10 nH: the two 5 nH source inductances. The same line predicts the 20 nH period within 10 %; the fit is not exact because the output capacitance of a MOSFET falls with its voltage, and a larger ring swings it over a wider range. On a real board you do this the other way round: measure the ring frequency, add a known inductance (or capacitance, as in the [snubber post](https://voltecx-web.nguyenvanqui291.workers.dev/blog/rc-snubber-design)), measure again, and solve the two equations for the loop. A ring at 51 MHz is also exactly where radiated emissions are hard to pass, so the ring frequency is worth knowing for EMI too. ## What the loop does to the switching energies ![The turn-on energy, the turn-off energy and their sum against the added loop inductance.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/commutation-loop-inductance-overshoot/energy-vs-l.svg) **Eoff grows.** At the turn-off the loop's inductance carries the test current and stores $\frac{1}{2} L I^2$. When the current moves to the body diode, that energy has nowhere to go but into the device under test and into the ring. With 100 nH added, $\frac{1}{2} \cdot 100\ \text{nH} \cdot (20.2\ \text{A})^2 = 20.4$ µJ, and Eoff grows from 44.9 µJ to 64.7 µJ: almost all of it. The Voltecx test checks this at every point of the sweep. **Eon falls.** At the turn-on the current rises at several amperes per nanosecond, and the loop's inductance takes $L \cdot di/dt$ of the supply while it does. The device's drain voltage is that much lower during the current rise, so the device dissipates less. The loop gives up about $\frac{1}{2} L I_{peak}^2$ of the turn-on energy, with the peak of 36.6 A that includes the diode's recovery: with 100 nH, about 67 µJ, and Eon falls from 272 µJ to 202 µJ. The sum falls, from 317 µJ to 267 µJ. That is a known effect, and it is why a slow, inductive layout can measure lower switching losses on a double-pulse bench than a tight one. But the energy has only moved: what the loop took from the turn-on comes back at the turn-off as overshoot and ringing, and the ringing ends in the device capacitances, the board's resistance and the radiated field. The voltage margin and the EMI decide the design, not the few microjoules. If you want lower turn-on loss, a faster gate or a diode with less recovery does it without the overshoot. ## What to do on the board - **Make the commutation loop small.** Put the DC-link (or decoupling) capacitors right next to the half bridge, so the high-frequency current flows in the shortest loop. The bulk capacitor may sit further away; a small ceramic capacitor across each leg carries the fast edge. - **Lay the loop over its own return.** A loop whose outgoing and returning currents run on adjacent layers has a small area and a small inductance; a loop that runs around the board does not. - **Count the package.** The source and drain inductances of the package are in the loop too. In this bench the two 5 nH source inductances alone give the 12 V overshoot with nothing else added. - **Measure it.** Read the overshoot and the ring frequency on a double-pulse test, and use $T^2$ against a known added inductance to get the loop's inductance and capacitance. - **Snub what remains.** When the loop cannot be made smaller, an RC snubber damps the ring (see the [snubber post](https://voltecx-web.nguyenvanqui291.workers.dev/blog/rc-snubber-design)); a slower turn-off (a larger turn-off gate resistor) lowers $di/dt$ and the overshoot, at the cost of Eoff. ## Try it Open the `doublePulse` example, add an inductor between the supply's positive terminal and the bus, and run it. Read the peak of `v(dd)` just after 5.25 µs, and the ring period on the scope's cursors, for a few values of the inductance. The command `device.doublePulse` also sweeps the power-loop inductance (`sweep: {"lStray": [...]}`) for any library MOSFET or GaN transistor that has gate data. ## References - Wolfspeed, C3M0065090D data sheet, Rev. 08, 2024: Fig. 30, clamped inductive switching test circuit. - N. Mohan, T. M. Undeland and W. P. Robbins, *Power Electronics: Converters, Applications, and Design*, 3rd ed., Wiley, 2003, chapter 2 (clamped inductive switching). - R. W. Erickson and D. Maksimović, *Fundamentals of Power Electronics*, 3rd ed., Springer, 2020, chapter 4 (switching loss). --- # Regenerative braking and the brake chopper: where the energy goes URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/regenerative-braking-brake-chopper/ When a motor drive slows its load, the motor becomes a generator and pushes energy back into the DC link. In a robot or an AMR the link is usually the battery, so the energy is welcome until the battery cannot take it. A full pack, a cold pack or a BMS charge-current limit opens the charge FET. From that moment the braking energy has two places to go: the link capacitor, which charges up fast, or a brake resistor that a chopper switches in. This article follows the energy through the `regenBrake` example in Voltecx and checks every joule against the simulation. ## The setup | Part | Value | |---|---| | Bus | 48 V battery. The BMS has opened its charge FET, so current only leaves the pack, through the FET's body diode (0.7 V). | | Link capacitor | 1 mF | | Inverter and motor | Three EPC2302 GaN half bridges at 40 kHz and a maxon EC 45 flat (48 V winding). Same as the [robot joint servo](https://voltecx-web.nguyenvanqui291.workers.dev/blog/robot-joint-servo-cascaded-loops). | | Load | A 10 kg share of an AMR on a 75 mm wheel, through a 20:1 gear, at 1 m/s | | Braking | A speed ramp to zero in 0.4 s (2.5 m/s²) | | Brake chopper | 10 Ω, switched by an EPC2302. On above 58 V, off below 56 V. | ## How much energy comes back The motor sees the wheel's mass through the gear: $$J_t = J_m + \frac{m\,r_w^2}{N^2} = 181 + \frac{10 \times 0.075^2}{20^2}\times 10^7 = 1587\ \text{g}\cdot\text{cm}^2$$ At 266.7 rad/s that is $E_k = \tfrac12 J_t\,\omega^2$ = 5.64 J. Not all of it reaches the link. The current that brakes the motor also heats its windings. Braking at 667 rad/s² takes 0.93 A of $i_q$, and with 3.4 Ω per phase the copper loss over the 0.4 s is $$E_{cu} = \tfrac32\,R\,i_q^2\,t \approx 1.8\ \text{J}$$ That leaves about 3.8 J for the link. A permanent-magnet motor feeds the link only while its back-EMF power exceeds its copper loss, $\tfrac32(\psi_f\,\omega_e\,i_q - R\,i_q^2) > 0$. Brake hard at low speed and the motor returns nothing; it only heats itself. For this winding, braking at 3 A gives no energy back below 136 rad/s. ## Without a chopper If the capacitor must take everything, its voltage rises to $$V = \sqrt{V_0^2 + \frac{2\,(E_k - E_{cu})}{C}} = \sqrt{47.3^2 + \frac{2 \times 3.84}{1\ \text{mF}}} \approx 99.6\ \text{V}$$ The simulation reaches 100.8 V. That is the rating of the GaN FETs, from a 48 V system braking a 10 kg load at walking pace. To hold the bus near 58 V instead, the capacitor would have to grow about tenfold. That is why every drive that can regenerate into a stiff-but-unwilling source carries a brake chopper. ## With the chopper A comparator on the measured link voltage turns the brake switch on above 58 V and off below 56 V. The thresholds sit above the pack's full charge (13S × 4.2 V = 54.6 V), so the chopper never fires while the battery is charging normally, and well below the switches' rating. The resistor only needs to take the peak regenerated power, about 24 W here ($\tfrac32(\psi_f\,\omega_e\,i_q - R\,i_q^2)$ at the start of braking), at a small duty. At 58 V, 10 Ω draws 5.8 A, 336 W while on, so it switches for a few percent of the time. In the simulation the link climbs to 58 V within 30 ms of the start of braking and then stays between 56.0 and 58.0 V until the wheel stops. The tests account for the energy: | | Joules | |---|---| | Kinetic energy released | 5.64 | | Copper loss (from the simulated phase currents) | −1.80 | | Kept by the link capacitor (47.3 V → 54.4 V) | −0.36 | | **Expected in the brake resistor** | **3.48** | | Simulated in the brake resistor | 3.47 | The 0.5 % that is left over goes into the switches and the dead-time conduction of the GaN FETs. ## Try it Open **File › Open Example › Motor drives › Regenerative braking, brake chopper**, or `file.openExample {"name": "regenBrake"}`. The schematic has three parts: - the power stage; - the drive controller module, `Ctrl`; - the chopper's comparator module, `Brake`. The two modules read the link voltage `vdc` from one voltmeter by label. Set the variable `Vch` to 1000 to switch the chopper off and watch the bus run up to 100 V. Change `Clk` or `Rb` to size your own link. These are simulation results. The example has not been compared with a test bench yet. --- # Robot joint servo: tuning cascaded current, speed and position loops URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/robot-joint-servo-cascaded-loops/ A robot joint is a small servo drive: a three-phase inverter, a permanent-magnet motor, an encoder, a gear and a link that carries a payload. A controller wraps three loops around the joint. The innermost loop sets the motor current, the next sets the speed, and the outer one sets the position. Each loop has to be several times faster than the one around it. Getting the three bandwidths right is most of the work of making a joint feel stiff without ringing. This article sizes the three loops by hand for a real motor and gear, then checks every number in the `robotJointServo` example in Voltecx. ## The joint | Part | Choice | Numbers used | |---|---|---| | Link | 48 V, the nominal level of a 13S lithium-ion robot battery | $V_{dc}$ = 48 V | | Inverter | Three half bridges of EPC2302 eGaN FETs (100 V) | 1.4 mΩ typical, 40 kHz PWM, 50 ns dead time | | Motor | maxon EC 45 flat, 48 V winding (402687) | 6.89 Ω and 5.85 mH phase to phase, 131 mN·m/A, 8 pole pairs, 181 g·cm² | | Gear | Strain-wave set, ratio 50 (Harmonic Drive CSG-14-50) | taken as rigid | | Load | Link and payload | 0.025 kg·m² at the joint | | Encoder | 18 bits on the motor shaft | 262 144 counts per turn | GaN switches let the PWM run at 40 kHz without a heat sink at this power level. A faster PWM means less current ripple and less delay inside the current loop, so that loop can be faster too. The catalogue gives terminal (phase-to-phase) values for block commutation. A star-connected sinusoidal model takes half of each per phase, $R$ = 3.445 Ω and $L$ = 2.925 mH. The magnet flux follows from the torque constant, $\psi_f = K_t/(\sqrt3\,p)$ = 9.48 mWb. In dq terms the torque is then $$T = \tfrac32\,p\,\psi_f\,i_q = 0.114\ \text{N}\cdot\text{m/A} \times i_q$$ The gear divides the load inertia by the square of its ratio. The motor sees $$J_t = J_m + \frac{J_L}{N^2} = 181 + \frac{250\,000}{2500} = 281\ \text{g}\cdot\text{cm}^2$$ ## Loop 1: current The plant of the current loop is the winding, $1/(R + Ls)$. Put the zero of a PI controller on the winding's pole ($K_i/K_p = R/L$) and the loop gain becomes a pure integrator: $$L_i(s) = \frac{K_p + K_i/s}{R + Ls} = \frac{\omega_c}{s} \quad\text{with}\quad K_p = L\,\omega_c,\ K_i = R\,\omega_c$$ The closed loop is a first-order lag with bandwidth $\omega_c$. The limit is the delay of the PWM and the current sampling, about one and a half PWM periods. A common rule keeps $\omega_c$ near a twentieth of the switching frequency: 2 kHz at 40 kHz, so $K_p$ = 36.8 V/A. A digital drive samples the phase currents once per PWM period, at the middle of the ripple. The example does the same with a zero-order hold at the carrier valley. Without it, the 0.1 A of switching ripple feeds straight back through a gain of 36.8 V/A into the modulator, and the small-signal gain of the loop shrinks. ## Loop 2: speed Seen from the speed loop, the closed current loop is almost instant, and the plant is the inertia, $K_t/(J_t s)$. A PI with $K_p = J_t\,\omega_s/K_t$ crosses over at $\omega_s$. Putting its zero a factor of 4 below that crossover ($K_i = K_p\,\omega_s/4$) keeps about 65° of phase margin. With $\omega_s = \omega_c/10$, a 200 Hz speed loop, $K_p$ = 0.311 A·s/rad. The speed comes from the encoder: the derivative of the angle, filtered at 2 kHz. The filter adds about 6° of lag at the crossover, and the current loop adds another 6°. ## Loop 3: position The position loop only needs a proportional gain. The speed loop's integrator already removes a steady error under a constant load, since the PI integrator holds the torque. With $\omega^* = K_{pp}(N\theta^* - \theta_m)$, the loop crosses over at $K_{pp}$. A tenth of the speed loop gives $K_{pp}$ = 126 1/s, a 20 Hz position loop. ## Measured in the simulation `analysis.loopGain` breaks a loop at a signal, injects a sine and measures what comes back around the loop. Here it runs on the switching circuit, with the GaN bridge, the PWM and the encoder's counts all in the loop. | Loop | Designed | Analytic, with the delays and the filter | Simulated (`analysis.loopGain`) | |---|---|---|---| | Current | 2 kHz | 2 kHz | 1.94 kHz, 90° margin | | Speed | 200 Hz | 204 Hz, 65° | 214 Hz, 62° | | Position | 20 Hz | 20.8 Hz | 20.9 Hz, 90° | Two details matter when you measure the current loop: - **Open the speed loop.** Otherwise the speed loop acts through the encoder in parallel with the current loop, and the reading mixes the two. - **Use a large enough perturbation.** At 0.1 A, the size of the ripple, the result is mostly ripple. At 1 A it reads within 3 % of the design. ## Step and disturbance The example then runs a test sequence: 1. The joint moves 0.2 rad, limited to a ramp at 2 rad/s (100 rad/s at the motor). 2. A 1 mrad fine step tests the loops in their linear range. 3. A 5 N·m load step lands on the joint, like a payload picked up. The tests compare the switching simulation with the linear cascade (first-order current loop, speed PI, filtered estimate, position gain): - **Fine step.** It follows the cascade within a tenth of the step at every sample from 1 ms to 30 ms. - **Load step.** It pushes the joint back by 112 µrad, as the cascade predicts. The speed integrator then brings the joint back and holds the load with $i_q = T_L/(N\,K_t)$ = 0.88 A. ## Try it Open the example with **File › Open Example › Motor drives › Robot joint servo, 48 V GaN**, or with `file.openExample {"name": "robotJointServo"}`. The whole controller is one module, `Ctrl`, connected to the power stage only by labels: the gate signals, the phase currents and the encoder count. The gains are circuit variables written as the formulas above, so changing `fsw`, `JL` or the gear ratio `N` re-tunes all three loops. These are simulation results. The example has not been compared with a test bench yet. --- # 5 things to check before you trust a power electronics simulation URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/five-things-to-check-in-power-electronics-simulation/ A simulator always gives you an answer. It plots a clean waveform, prints an efficiency with four digits and never says "I am not sure". That is the danger. A switching converter simulation can be wrong by a factor of two while looking perfectly reasonable, and nothing on the screen warns you. The good news: almost every bad result comes from one of five mistakes, and each one has a quick check. This article walks through them with real Voltecx runs. For each one you will see the wrong result next to the right one, the reason, and the fix. The five checks: 1. **Time step and solver.** Is the step small enough to see the fastest thing in the circuit? 2. **Steady state and initial conditions.** Are you measuring after the start-up transient has died out? 3. **Ideal versus real models.** What does an ideal switch hide? 4. **Parasitics that matter.** Which small R, L and C change the answer? 5. **How you measure.** Is your averaging window, RMS window and probe point right? Most examples use the textbook buck example that ships with Voltecx, `buckIdeal`: 48 V in, 12 V out, 100 kHz, a fixed duty cycle of 0.25, a 100 µH inductor, a 100 µF capacitor and a 2.4 Ω load (5 A). ## 1. Time step and solver: a big step misreads the ringing ### The intuition A simulator does not see a waveform continuously. It takes snapshots, one per time step, and draws straight lines between them. Think of a camera filming a spinning wheel: at a slow frame rate the wheel seems to stand still or turn backwards. If the circuit rings at 50 MHz and the simulator takes one snapshot every 50 ns, two and a half periods of the ring pass between two snapshots. The simulator cannot draw the ring as it is: depending on how it integrates, it either loses the ring or shows a slower, wrong one, like the wheel that seems to turn backwards. In a real converter the fastest events are at the switching edges. The loop inductance of the power stage (the traces, the capacitor leads, the package) rings with the capacitance at the switch node. The resonance frequency is $$f_{ring} = \frac{1}{2\pi\sqrt{L_{loop}\, C_{node}}}$$ ### A worked example Add 10 nH of loop inductance between the source and the switch of the buck, and 1 nF (with 0.5 Ω of damping) across the switch node. Then $$f_{ring} = \frac{1}{2\pi\sqrt{10\ \text{nH} \times 1\ \text{nF}}} = 50.3\ \text{MHz}, \qquad T_{ring} = 19.9\ \text{ns}$$ Now run the same circuit with different maximum steps (`simulation.settings`, `maxStep`, fixed step) and look at one turn-on edge. ![One turn-on edge of the buck's switch node v(sw) with 10 nH of loop inductance and 1 nF at the node, simulated in Voltecx with a fixed step of 50 ns, 5 ns and 0.5 ns. The 48 V line is the input.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/five-things-to-check-in-power-electronics-simulation/ring-time-step.svg) - At **50 ns** (the example's own setting, fine for a buck without parasitics) the edge rises slowly and rings at about 9 MHz instead of 50 MHz, peaking at 69.9 V. There is a ring, but it is the wrong one. - At **5 ns** the ring is a little slow (about 43 MHz), jagged, and peaks at 80.7 V. - At **0.5 ns** the ring is smooth and peaks at 85.9 V. The same circuit gives a peak anywhere from 62 V to 88 V depending on one setting (the table below). If you were choosing a 75 V MOSFET, the 50 ns run would tell you it is safe. It is not. Why a slow ring? Voltecx integrates with the trapezoidal rule and opens the step after each switching with two short backward-Euler sub-steps. The trapezoidal rule keeps a ring's energy at any step, but once the step is longer than the ring's period it bends the frequency down to $\frac{2}{h}\arctan\frac{\omega h}{2}$: 9.2 MHz at a 50 ns step. A solver that takes a whole backward-Euler step after each switching damps the ring away instead and draws a clean ramp to 48 V. Neither is the circuit. ### The fix: a convergence check Do not guess the step. Halve it until the number you care about stops moving: | maxStep | peak v(sw) | |---|---| | 50 ns | 69.9 V | | 20 ns | 87.7 V | | 10 ns | 62.4 V | | 5 ns | 80.7 V | | 2 ns | 83.8 V | | 1 ns | 85.6 V | | 0.5 ns | 85.9 V | | 0.2 ns | 85.8 V | ![Peak switch-node voltage against the maximum time step in Voltecx. The answer settles below about 1 ns, a twentieth of the 19.9 ns ring period; above that it scatters on both sides of the settled 85.8 V (horizontal line).](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/five-things-to-check-in-power-electronics-simulation/peak-vs-step.svg) The answer settles once the step is below about 1 ns, which is a twentieth of the ring period. Above that the numbers jump around, and at 20 ns the run even reads 87.7 V, above the settled value: a coarse run can be wrong in either direction, so it tells you nothing about the margin. That gives a practical rule: - **Rule of thumb:** use a step of at most 1/20 of the shortest period you want to see. For the switching ripple that is $T_{sw}/20$ or smaller; for edge ringing it is $T_{ring}/20$. - **Verify, don't trust the rule:** run once more at half the step. If the number you care about (peak, RMS, loss) changes by more than a few percent, you were not converged. - **Only resolve what you need.** If you only want the average output voltage, a 50 ns step is fine. Ringing matters for voltage stress, EMI and snubber design. ### Solver choice Voltecx has two solvers. `fast` is the production solver (event location, cached matrix factorisations, an optional error-controlled variable step). `reference` is deliberately simple and is used as an oracle to check the fast one. When a result surprises you, switch `solver` in `simulation.settings` and run again. If the two disagree, look harder before you believe either. A variable step does not remove the need for `maxStep`: the step can only shrink where the solver sees something happening, and the upper limit still caps how much it can miss between events. ## 2. Steady state and initial conditions: measure after the start-up ### The intuition When you switch on a converter, the output capacitor starts empty and the inductor carries no current. The LC filter is a spring and a mass: give it a sudden push and it bounces before it settles. Anything you measure while it is still bouncing describes the start-up, not the converter. The buck's output filter has $$f_0 = \frac{1}{2\pi\sqrt{LC}} = \frac{1}{2\pi\sqrt{100\ \mu\text{H} \times 100\ \mu\text{F}}} = 1.59\ \text{kHz}, \qquad Q = R\sqrt{\frac{C}{L}} = 2.4\sqrt{\frac{100\ \mu}{100\ \mu}} = 2.4$$ A Q of 2.4 means a slow decay: several cycles of a 0.63 ms period, so a couple of milliseconds before the output is quiet. That is 200 switching periods. ### What goes wrong ![The buck's output voltage v(out) and inductor current i(L1) in Voltecx, started from 0 (blue) and from the operating point, 12 V and 5 A (red). The marks are at 0.5 ms and at the last switching period.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/five-things-to-check-in-power-electronics-simulation/start-up.svg) Started from an empty capacitor (blue), the output overshoots to 18.1 V and the inductor current to 13.6 A before settling at 12 V and 5 A. Now suppose you measure efficiency with `scope.efficiency` over the first 0.5 ms: | Window | Efficiency | |---|---| | 0 to 0.5 ms (during start-up) | 83.6 % | | Last switching period (steady state) | 99.9 % | The start-up reading is wrong because part of the input energy is going into charging the capacitor and the inductor, not into the load. (The 99.9 % is high because the example's switch and diode are almost ideal; the point is the difference.) ### Initial conditions help, but check them too The fix many people reach for is to set initial conditions: start the capacitor at 12 V (`v0`) and the inductor at 5 A (`i0`). The red curve shows how much quieter that is. But it does not make the first milliseconds trustworthy either: over the same first 0.5 ms the efficiency now reads **101.3 %**. The preset values are slightly off the real operating point, so the filter still moves a little and gives back stored energy while it settles. More than 100 % is an obvious error; 98 % instead of 97 % would not be. ### The fix - **Measure late.** Set `t0` (and `t1`) on `scope.measure`, `scope.power` and `scope.efficiency` to a window near the end of the run, after everything has settled. - **Let the simulator find steady state.** `simulation.steadyState` runs a shooting method: it searches for the initial state that repeats itself after one switching period, instead of waiting for the transient to decay. On the buck example it converges in a few periods. - **Ask for a second opinion.** `analysis.diagnoseWaveforms` looks for common faults in the last result. On the cold start it reports that `v(out)` overshoots 51 % of its step and rings at about 1.56 kHz, which is the LC resonance above. (Its suggested cause mentions a control loop; this buck runs open loop, so here the cause is simply the undamped LC filter.) - **Watch slow states.** Thermal networks and large DC-link capacitors settle over seconds or minutes, so a run of a few milliseconds is not steady state for them. ## 3. Ideal versus real models: what an ideal switch hides ### The intuition An ideal switch is a perfect tap: fully open or fully closed, flipping in zero time, with no capacitance and no stored charge. It is the right model for learning topologies, checking control loops and estimating conduction loss. It is the wrong model for anything that happens during the switching edge, because in an ideal switch the edge does not exist. Real devices have: - **Output capacitance** ($C_{oss}$) that must be charged and discharged at every edge. - **Gate dynamics**: a delay and a finite slope set by the gate driver and the gate charge. - **Reverse recovery**: a diode (including a MOSFET's body diode) carrying forward current holds charge, and pulling it out makes a current spike when the opposite switch turns on. - **Dead time** behaviour: during the gap between two gate signals, the current flows through a diode, as explained in [Dead-time effects](https://voltecx-web.nguyenvanqui291.workers.dev/blog/dead-time-effects). ### The comparison The `doublePulse` example tests a SiC MOSFET at 400 V and 20 A with the gate and capacitance data of a real part from the device library, the way a data sheet measures switching energy. Voltecx can run the same circuit with every parasitic and loss removed, without editing it: `simulation.settings` with `"fidelity": "ideal"`. ![The turn-on edge of the double-pulse test in Voltecx with real device models and with fidelity set to ideal: the drain voltage v(dd) and drain current i(Id).](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/five-things-to-check-in-power-electronics-simulation/ideal-vs-real-turn-on.svg) | | Real models | Ideal | |---|---|---| | Peak current at turn-on | 36.7 A | below 21 A | | Peak voltage at turn-off | 412 V | 400 V | | Turn-on energy $E_{on}$ | 289 µJ | about 0 | | Turn-off energy $E_{off}$ | 38 µJ | about 0 | With real models the current overshoots to 36.7 A at turn-on: the 20 A load current plus the recovery charge of the other device's body diode and the charging current of its capacitance. The drain voltage falls later and more slowly than the gate command, and while voltage and current overlap, the device dissipates energy. Each edge costs energy, and at 100 kHz every microjoule per cycle is 0.1 W. The ideal run shows a perfect square and zero switching loss. If you estimated losses from it, you would miss most of the device's loss at high frequency. ### The fix - **Know what your model includes.** Use ideal switches for topology, control and averaged behaviour; use device models (with $C_{oss}$, gate data, recovery) for losses, stresses and EMI. - **Run both and compare.** The `fidelity` setting makes the comparison one setting away. If the result you care about changes a lot, you need the real model for that result. - **Check soft switching explicitly.** `analysis.softSwitching` reads every gate edge, classifies each turn-on as ZVS, partial or hard, and checks each leg's dead time against the measured transition. It needs capacitance on the switches (`coss`); with none, the switch node swings within one step and there is nothing to measure. ## 4. Parasitics that matter: loop inductance, ESR and ESL ### The intuition Every real part has small unwanted elements: a capacitor has series resistance (ESR) and series inductance (ESL); a PCB loop has inductance; an inductor's winding has resistance (DCR). Most of the time they are negligible. A few of them decide the answer. The trick is to know which ones, for the question you are asking. ### A worked example: ESR doubles the output ripple In the buck the inductor ripple current is $$\Delta I_L = \frac{(V_{in} - V_{out})\, D}{f_{sw}\, L} = \frac{(48 - 12) \times 0.25}{100\ \text{kHz} \times 100\ \mu\text{H}} = 0.9\ \text{A}$$ With an ideal capacitor the output ripple comes only from charging and discharging the capacitance: $$\Delta V_C = \frac{\Delta I_L}{8\, f_{sw}\, C} = \frac{0.9}{8 \times 100\ \text{k} \times 100\ \mu} = 11.25\ \text{mV}$$ Add 20 mΩ of ESR. The ripple current flowing through it makes a triangle of $$\Delta V_{ESR} = \Delta I_L \cdot ESR = 0.9 \times 0.02 = 18\ \text{mV}$$ ![The buck's inductor current i(L1) and its output voltage minus 12 V in Voltecx, with an ideal 100 µF capacitor and with 20 mΩ of ESR.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/five-things-to-check-in-power-electronics-simulation/esr-ripple.svg) The two parts are out of phase (the capacitive part lags by a quarter period), so they do not simply add: the simulated ripple is 11.25 mV with the ideal capacitor and 19.7 mV with the ESR, close to double. If the specification allows 15 mV, the ideal model passes and the real board fails. ### Which parasitics to include | Question | Parasitics that matter | |---|---| | Output ripple | Capacitor ESR (and ESL for ceramic or high-frequency ripple) | | Switch voltage stress, ringing, EMI | Power loop inductance, $C_{oss}$, diode capacitance | | Efficiency at full load | Inductor DCR, switch on-resistance, capacitor ESR (its RMS current) | | Light-load behaviour | Gate charge, $C_{oss}$, core loss | | Loop stability | Capacitor ESR (it adds a zero), DCR (damping) | Take values from the part's data sheet, not from habit. If you don't know a value yet, `circuit.makeRealistic` fills generic engineering typicals for the parasitics that are unset, so you can see whether they matter before you pick parts. Treat that as a sensitivity check; replace the typicals with data-sheet numbers before you sign off. Section 1 was the loop-inductance case: 10 nH turned a 48 V edge into 85 V. ## 5. How you measure: windows, RMS and the probe point ### The intuition Even with a perfect simulation, a measurement taken the wrong way gives the wrong number. Switching waveforms are periodic, and an average or RMS is only meaningful over **whole periods**. Measure over 1.5 periods of a pulsed current and you have counted one pulse in a window one and a half periods long. ### A worked example: the RMS of the switch current The buck's switch carries 5 A for a quarter of each period and nothing for the rest. Its RMS current is $$I_{rms} = \sqrt{D}\, I_o = \sqrt{0.25} \times 5\ \text{A} = 2.5\ \text{A}$$ (2.507 A with the 0.9 A ripple included). Now measure it with `scope.measure` over windows of different lengths that all end at the same instant: ![The RMS of the buck's switch current i(S1) in Voltecx, measured over windows from half a switching period to four periods, all ending at 4 ms. Only whole periods give the true 2.507 A.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/five-things-to-check-in-power-electronics-simulation/rms-window.svg) - Over 1, 2, 3 or 4 whole periods: 2.507 A every time. - Over 1.5 periods: 2.05 A, **18 % low**. - Over 1.75 periods: 1.89 A, 24 % low. - Over half a period (only the off-time): 0 A. Conduction loss goes with the square of the RMS current, so an 18 % RMS error is a 33 % loss error. ### The fix - **Use whole periods.** Set `t0` and `t1` so that $t_1 - t_0$ is an integer number of switching periods (`scope.power` says this in its help: use a window of whole periods for exact figures). For a mains-frequency converter, use whole line cycles, not switching periods. - **Use more periods for ripple and noise.** A peak-to-peak value from one period can miss a sub-harmonic oscillation that repeats every two or three periods. - **Measure at the right point.** The output voltage across the capacitor's terminals includes the ESR and ESL drops; the voltage across the ideal capacitance inside does not. Measure where your specification is defined (usually the load terminals) and compare like with like. - **Watch the sign.** A source's current is negative when it delivers power in the usual simulator convention. Measure input power at a point where the current flows into the converter, or check the sign before computing an efficiency. ## A quick checklist for every run Before you send a result to anyone: 1. Halve the time step. Did the number move more than a few percent? 2. Is the measurement window after the start-up, and whole periods long? 3. Did you use ideal switches for a loss or stress question? 4. Which parasitics decide this answer, and are they in the circuit with data-sheet values? 5. Would the other solver give the same answer? The formulas follow standard texts: R. W. Erickson and D. Maksimović, *Fundamentals of Power Electronics*, 3rd ed., for the buck's ripple and the LC filter, and N. Mohan, T. M. Undeland and W. P. Robbins, *Power Electronics*, for switching transitions. The double-pulse device data come from the Wolfspeed C3M0065090D data sheet, as the example cites. ## Try it in Voltecx - Open the `buckIdeal` example and change `maxStep` in `Simulation › Settings`; add a small inductor in series with the switch and a capacitor at the switch node to reproduce the ringing above. The `solver` setting switches between `fast` and `reference`. - Use `Simulation › Steady-State Analysis` (`simulation.steadyState`) before measuring, or set `t0` in the scope's measurements to skip the start-up. - Open the `doublePulse` example and run it twice, once with `"fidelity": "ideal"` in `simulation.settings`. `analysis.losses` lists the conduction and switching loss of each device; `analysis.softSwitching` classifies every turn-on. - Run `analysis.diagnoseWaveforms` after any run that looks suspicious. It reports ringing, inrush, sub-harmonic oscillation, overlapping gates and other faults, each with a plain-language cause. More on these tools on the [simulation](https://voltecx-web.nguyenvanqui291.workers.dev/features/simulation) and [debugging and scope](https://voltecx-web.nguyenvanqui291.workers.dev/features/debugging-and-scope) pages. --- # ADC sampling in a digitally controlled converter: when, how fast, how many bits URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/adc-sampling-power-converters/ A digital controller never sees the converter. It sees a list of numbers: one reading of the current or the voltage per sampling period, rounded to a whole number of ADC codes, and a little late. Everything the loop does, it does with those numbers. If the readings are wrong, the loop regulates the wrong thing, perfectly. This post walks through the three questions every firmware engineer meets when a converter goes digital: - **When** in the switching period to take the sample. - **How fast** to sample, and what happens when the sampling and the switching drift apart. - **How many bits** the ADC needs, and what the delay of the whole chain costs the loop. Every waveform below is a Voltecx run of a real converter: the 12 V to 3.3 V, 5 A, 200 kHz buck from the [PI compensator post](https://voltecx-web.nguyenvanqui291.workers.dev/blog/buck-converter-pi-compensator-design) (L = 8.2 µH, C = 100 µF), with zero-order holds and ADC blocks reading it. ## The picture to keep in mind: a camera with a slow shutter Think of the ADC as a camera that takes one photo per period. A **sample-and-hold** opens the shutter for a moment, freezes what it sees, and holds that picture until the next one. The converter keeps moving in between; the controller only knows the last photo. Two things follow from that picture: 1. **The moment you press the shutter matters.** The inductor current is a triangle. A photo at the bottom of the triangle and a photo in the middle of a ramp show two different currents, even though the converter is the same. 2. **The photos are a bit old.** By the time the controller has read the photo, computed a new duty cycle and the PWM timer has used it, the converter has moved on. That age is a delay, and a delay in a feedback loop eats phase margin. The ADC adds a third effect on top: it does not record the exact value but the nearest of $2^N$ levels. That is **quantisation**. ## Quantisation: the staircase An $N$-bit ADC over a full-scale range $V_{FS}$ divides the range into $2^N$ steps of $$\text{LSB} = \frac{V_{FS}}{2^N}$$ Every reading is the input rounded to the nearest step. The error is at most half a step either way, $\pm \tfrac{1}{2}\,\text{LSB}$, and for a signal that moves across many steps it behaves like noise with an RMS value of $\text{LSB}/\sqrt{12}$ (the classical quantisation-noise result, see for example Oppenheim and Schafer, *Discrete-Time Signal Processing*). To see the staircase, feed a slow ramp from 0 to 4 V into a deliberately coarse ADC: 4 bits over 4 V, so $\text{LSB} = 4/16 = 0.25$ V. ![A ramp from 0 to 4 V through a 4-bit ADC over 4 V in Voltecx: the output steps by 0.25 V and the error (lower panel) is a sawtooth within ±125 mV, until the input passes the top code of 3.75 V.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/adc-sampling-power-converters/staircase.svg) Three things to read from the figure: - Every step is exactly 0.25 V. - The error is a sawtooth between −125 mV and +125 mV: half an LSB. - The highest code is **3.75 V, not 4 V**. An $N$-bit ADC has codes $0 \dots 2^N - 1$, so its top reading is $V_{FS} - \text{LSB}$. Above that the ADC clips, and the error grows without limit. A sensor that runs into the top of the range looks like a converter whose current has stopped rising. ### How many bits do you need? Start from the regulation you have to meet, not from the ADC you happen to have. A practical rule: one LSB should be several times smaller than the error band you must hold, because the loop can only regulate to within about one code, and offset, gain error and noise take their share too. The buck's output is 3.3 V with 10.9 mV of ripple. Read it with two ADCs, both over 0 to 4 V: | ADC | LSB | LSB as % of 3.3 V | Ripple in codes | |---|---|---|---| | 8 bits | 15.6 mV | 0.47 % | less than 1 | | 12 bits | 0.98 mV | 0.03 % | about 11 | ![The buck output in Voltecx, v(out), and the same voltage through an 8-bit and a 12-bit ADC over 4 V. The 8-bit reading toggles between two codes, 3.281 V and 3.297 V; the 12-bit reading follows the ripple in 0.98 mV steps.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/adc-sampling-power-converters/quantised-output.svg) The 8-bit converter can see that the output is "about 3.29 V", nothing finer: it toggles between 3.281 V and 3.297 V. For a ±1 % regulation spec (±33 mV) that is already tight, because one code is half of the whole budget on each side. The 12-bit converter resolves 0.03 %: the bits are no longer the limit, the divider resistors and the voltage reference are. There is a second reason to want more bits than the regulation needs: the **digital PWM**. If one step of the duty cycle moves the output by more than one ADC code, the loop can never settle. It keeps jumping between two duty steps on either side of the target, a *limit cycle*. The usual condition (Peterchev and Sanders, IEEE Transactions on Power Electronics, 2003) is that the DPWM must be finer than the ADC, with an integrator in the loop. A buck with $V_{in} = 12$ V and a PWM timer of 1000 counts moves the output by $12 \times 0.1\,\% = 12$ mV per duty step: more than one code of the 12-bit ADC above. Either the timer needs more counts, or the PWM needs a high-resolution mode. ## When to sample: the middle of the on-time Now the timing. The inductor current of the buck is a triangle of $\Delta I = 1.46$ A peak to peak around its average of 4.99 A. For a current loop you nearly always want the **average** current, not whatever point of the ripple the ADC happens to land on. For a triangle, the average sits exactly halfway along each ramp. So if you sample in the **middle of the on-time** (or the middle of the off-time), you read the average directly, without any filtering. In a center-aligned (triangle carrier) PWM, the middle of the on-time is the peak or the valley of the carrier, which is why microcontrollers let you trigger the ADC there. ![Three switching periods of the buck in Voltecx: the inductor current iL, the sample taken at the middle of the on-time (i_mid) and the sample taken at the start of the period (i_valley).](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/adc-sampling-power-converters/synchronous-sampling.svg) The simulation shows the difference plainly: - **Sample at the middle of the on-time** (0.69 µs after the switch turns on, half of $D T_s = 0.275 \times 5$ µs): the reading is 4.99 A, equal to the true average within 0.1 %, and it does not move from one period to the next. - **Sample at the start of the period**, when the switch turns on: the reading is 4.26 A, the valley of the ripple. It is steady too, but it is **0.73 A low**, exactly $\Delta I / 2$. A current loop built on it would push the average 0.73 A above its reference. Both are *synchronous*: the sample happens at the same point of every period, so the reading is constant in steady state. That is what you want. A synchronised sample at the wrong point gives a steady offset; an unsynchronised sample gives something worse. ### Practical points about the sampling instant - **Avoid the edges.** Right after a switch turns on or off, the current and the sense signal ring. Sampling in the middle of a ramp keeps away from both edges. - **Account for the sense path delay.** An isolated amplifier or a filter shifts the signal by a microsecond or two. Move the trigger later by the same amount. - **Narrow pulses.** At very small or very large duty cycles the middle of the on-time is close to an edge. Many designs switch to sampling the middle of the off-time there. - **DCM and boost input current.** When the current waveform is not a symmetric triangle (discontinuous mode, or the input current of a boost with a large ripple), the midpoint is no longer the average. Averaging several samples over the period helps (see oversampling below). ## How fast: aliasing and the slow beat Suppose the ADC is triggered by its own timer at 195 kHz instead of by the PWM at 200 kHz. The two clocks are only 2.5 % apart. What does the controller see? Each sample lands a little later in the switching period than the one before. After 40 samples the sample point has walked through the whole triangle and comes back to where it started. The reading traces out the ripple in slow motion: $$f_{beat} = |f_{sw} - f_s| = |200\ \text{kHz} - 195\ \text{kHz}| = 5\ \text{kHz}$$ This is **aliasing**. The sampling theorem (Nyquist–Shannon) says a sampled signal can only represent frequencies below $f_s / 2$. The 200 kHz ripple is far above 97.5 kHz, so it does not disappear: it folds down and shows up at the difference frequency, 5 kHz. And 5 kHz is right where a voltage or current loop has its crossover. ![Upper panel: the inductor current sampled at 195 kHz (i_async) wanders from 4.26 A to 5.71 A and repeats every 200 µs, while the synchronous sample (i_mid) stays at 4.99 A. Lower panel: the same asynchronous sample taken behind a 20 kHz first-order filter.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/adc-sampling-power-converters/aliasing-beat.svg) The upper panel is the Voltecx run: the asynchronous reading sweeps the full ripple, 4.26 A to 5.71 A, and repeats every 200 µs. To the controller it looks like a real 5 kHz oscillation of 1.45 A in the current, and it will try to correct it, injecting a 5 kHz disturbance into the duty cycle. Nothing in the power stage is oscillating; the measurement made it up. This is why sampling is nearly always **synchronised to the PWM**: one sample per period (or two, at the carrier peak and valley), triggered by the PWM timer itself, so the ripple aliases to exactly zero frequency, a constant that the right sampling instant makes equal to the average. ## The anti-alias filter, and what it costs When the sampling cannot be synchronised (a voltage sensed by a slow ADC sequence, a second converter on its own clock, a noisy signal with spikes), the defence is an **anti-alias filter**: usually a resistor and a capacitor in front of the ADC pin. It attenuates the ripple before it reaches the sampler, so there is less to fold down. The lower panel above is the same 195 kHz sample behind a first-order low-pass at $f_p = 20$ kHz. The beat is still there, but it is **0.114 A** instead of 1.45 A, about 13 times smaller, and the average is still 4.99 A. A first-order filter attenuates the 200 kHz fundamental of the ripple by about $f_{sw}/f_p = 10$, and the triangle's harmonics by more. The cost is phase. A first-order pole at $f_p$ delays every signal in the loop, and at the crossover $f_c$ it takes $$\varphi_{RC} = \arctan\frac{f_c}{f_p}$$ For a loop crossing at 5.78 kHz, the 20 kHz pole costs $\arctan(5.78/20) = 16.1°$ of phase margin. So the filter corner is a compromise: - **High enough** above the crossover that its lag is small (a factor of 3 to 5 is common). - **Low enough** below $f_s / 2$ that it attenuates what would alias. With a crossover of $f_s/10$ the window between the two is narrow, and that is why synchronised sampling, which needs no filter for the ripple, is the default. Voltecx's `design.senseNetwork` puts the pole in the middle of that window on a log scale, $\sqrt{f_c \cdot f_s/2}$ by default, and reports its lag at the crossover so you can add it to the loop budget. The [sensing post](https://voltecx-web.nguyenvanqui291.workers.dev/blog/current-voltage-sensing-shunt-hall-divider) sizes one. ## Sampling delay and phase margin Even with perfect sampling, a digital loop is late. In the usual timing: 1. the ADC samples at the start of a period, 2. the interrupt computes the new duty during that period, 3. the PWM uses it from the next period on, 4. and the PWM itself, seen as a sampler, adds about half a period. That is about 1.5 sampling periods from sample to effect. A pure delay $T_d$ does not change the gain, but it shifts the phase by $$\varphi_d = 360° \cdot f_c \cdot T_d$$ at the crossover (see Corradini, Maksimović, Mattavelli and Zane, *Digital Control of High-Frequency Switched-Mode Power Converters*, for the full treatment). Every microsecond of delay costs more at a higher crossover. To put numbers on it, take the closed-loop buck example in Voltecx (48 V to 12 V, 100 kHz) with the Type III voltage loop that `design.voltageLoop` designs: crossover 5.78 kHz, 60° of phase margin, planned with half a sample (5 µs) of PWM delay. `design.digitalize` then recomputes the loop for each total delay. ![Phase margin and gain margin of the digitalised buck loop in Voltecx against the total delay from sample to duty, from the 5 µs the design planned for to 25 µs. The horizontal lines mark 45° and 6 dB.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/adc-sampling-power-converters/phase-margin-vs-delay.svg) | Total delay | Samples at 100 kHz | Phase margin | Gain margin | |---|---|---|---| | 5 µs | 0.5 | 60.0° | 12.2 dB | | 10 µs | 1.0 | 49.6° | 8.9 dB | | 15 µs | 1.5 | 39.2° | 6.4 dB | | 25 µs | 2.5 | 18.4° | 2.6 dB | Each extra 5 µs costs $360° \times 5.78\,\text{kHz} \times 5\,\mu\text{s} = 10.4°$, exactly as the formula says. The usual "sample, compute, update next period" timing (15 µs) leaves 39°: a loop that works but rings. The margin drops below 45° at 12.2 µs. Ways to win the phase back: - **Update the duty as soon as the computation ends**, not at the next period. If the interrupt takes 30 % of the period, the delay drops by most of a period. - **Sample later in the period**, as close as possible to the moment the result is needed, keeping the middle-of-ramp rule. - **Design the analog compensator with the delay in it** from the start, instead of discovering the loss afterwards. - **Lower the crossover.** It is the product $f_c T_d$ that matters. ## Oversampling and averaging Sometimes one sample per period is not enough: the waveform is not a symmetric triangle, or the signal is noisy. Then take several samples per period and average them. - **The average of $N$ samples spread evenly over one period** is the period's average current for any waveform shape, which fixes the DCM and boost-input cases above. - **Averaging reduces noise.** Uncorrelated noise falls by $\sqrt{N}$, so 16 samples gain a factor of 4, which is 2 bits. This only works when the noise is at least about one LSB (it *dithers* the input across codes); a perfectly clean signal averaged 16 times gives the same code 16 times. - **Averaging is a filter, and filters are late.** A moving average over one period behaves roughly like half a period of extra delay. Count it in the phase budget like any other delay. ## A checklist 1. Choose the full scale with headroom: the highest signal (including start-up overshoot and fault current) should stay below the top code. 2. Make one LSB several times smaller than the regulation band, and the DPWM step smaller than one LSB. 3. Trigger the ADC from the PWM timer, in the middle of the on-time or off-time, away from the edges. 4. If a signal cannot be sampled synchronously, filter it with a pole between the crossover and $f_s/2$ and count its lag. 5. Add up the delays (sense path, filter, conversion, computation, PWM) and check the phase margin with all of them. ## Try it in Voltecx - The **Zero-Order Hold** block (`zoh`) samples at `ts` with a start `offset`, so `offset = D/(2·fsw)` gives the middle of the on-time. The **Sample and Hold** block (`sampleHold`) can also be clocked from a signal. The **ADC** block (`adc`) rounds to `bits` over `range`, starting at `min`, and samples at `fs` when it is set. - Put an ammeter (a current meter) in series with the inductor to give these blocks a signal, as in the figures above. - `design.digitalize` takes the analog loop design, discretises the compensator, adds the compute delay, the ADC bits and the PWM resolution, and reports the phase margin lost and the limit-cycle check. The [digital control tutorial](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/07-digital-control/) walks through it on the closed-loop buck. - `design.senseNetwork` sizes the divider and the anti-alias capacitor in front of an STM32G474 ADC input, and `tools.codeGeneration` writes the C code of the control blocks. --- # Choosing capacitors for a power supply: MLCC, aluminium electrolytic, polymer and film URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/how-to-choose-capacitors-power-supply/ A switching power supply is full of capacitors, and they are not interchangeable. The 100 µF can at the input, the row of small ceramic chips under the controller, the blue film box across the mains and the tiny one in the snubber all do different jobs, and each job favours a different technology. This article is a beginner's map. It explains what each capacitor in a power supply is for, which data-sheet numbers matter (ESR, ESL, ripple current, lifetime, DC bias), how the main technologies compare, and then works through a real input bank that combines a hybrid electrolytic with ceramic capacitors. The figures come from Voltecx runs of a 36 V to 5 V, 3 A, 400 kHz buck and from the data sheets in the Voltecx parts catalogue, and a test checks the numbers you read here against them. The short version: - A real capacitor is a capacitor **plus a resistor (ESR) plus an inductor (ESL)** in series. Which of the three dominates depends on frequency. - **Ripple current** heats the capacitor through its ESR, and heat is what wears out electrolytics. - **Ceramic (MLCC)** capacitors have tiny ESR and ESL but, in X5R and X7R, lose much of their capacitance under DC voltage. - **Electrolytic, polymer and hybrid** capacitors give bulk capacitance; they differ in ESR and lifetime. - **Film** capacitors handle high voltage and AC; **X and Y** safety capacitors go across the mains. - Parallel capacitors share ripple current **by impedance**, so check the split, don't assume it. ## What the capacitors in a power supply do Think of a capacitor as a small local water tank. The supply far away delivers a steady flow; the tank next to the load covers the sudden gulps. In a power supply the "gulps" are the switching pulses, and they happen hundreds of thousands of times a second. | Role | Where | What it must do | Usual choice | |---|---|---|---| | Input (switching) | Next to the switch, across the input | Supply the pulsed input current; keep the hot loop small | MLCCs, plus bulk | | Bulk | At the input or a DC bus | Hold the voltage through load steps and line dips; damp the input filter | Electrolytic, hybrid, polymer, film | | Output | Across the output | Smooth the inductor ripple; hold the voltage through load steps | MLCC, polymer | | Bypass (decoupling) | At every IC supply pin | Supply fast current edges locally | Small MLCC (X7R, C0G) | | Snubber, clamp, resonant | Across a switch, diode or tank | Handle fast dv/dt and high voltage with stable value | C0G, film | | X and Y (safety) | Across the mains (X), mains to earth (Y) | Filter EMI; fail safely | Certified X2/Y2 film or ceramic | ## ESR and ESL: the parts of a capacitor you did not ask for A real capacitor behaves like a capacitance $C$ in series with a resistance (ESR) and an inductance (ESL): $$Z(f) = ESR + j\left(2\pi f\, ESL - \frac{1}{2\pi f\, C}\right)$$ - At **low frequency** the capacitance dominates and $|Z|$ falls as $1/f$. - At the **self-resonant frequency** $f_0 = 1/(2\pi\sqrt{ESL \cdot C})$ the two reactances cancel and $|Z| = ESR$. - **Above** $f_0$ the capacitor behaves like an inductor and $|Z|$ rises with $f$. ESR causes ripple voltage ($\Delta V = \Delta I \cdot ESR$) and heat ($P = I_{rms}^2 \cdot ESR$). ESL causes a step at every fast current edge ($\Delta V = ESL \cdot di/dt$), which is why the input MLCCs must sit right next to the switch. ### ESR in action: output ripple Here is the same buck output (12 µH, 0.898 A of ripple current) with three output capacitors from the catalogue: | Output capacitor | Data sheet | $C$ at 5 V | ESR at 100 kHz | Ripple | |---|---|---|---|---| | 4 × MLCC 47 µF 10 V X7R 1210 (Murata GRM32ER71A476ME15) | Murata data sheet, 2013/10/01 | 4 × 29.9 µF | 2.4 mΩ each | 2.40 mV | | Polymer 180 µF 16 V (Panasonic 16SVPF180M, OS-CON) | Panasonic SVPF parametric table | 180 µF | 22 mΩ max | 19.5 mV | | Aluminium electrolytic 270 µF 10 V (Panasonic EEUFR1A271) | Panasonic FR-A data sheet, 01-Sep-25 | 270 µF | 0.13 Ω (impedance) | 108 mV | ![Output ripple of the buck with three output capacitors, simulated in Voltecx: four 47 µF MLCCs, a 180 µF polymer and a 270 µF electrolytic.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/how-to-choose-capacitors-power-supply/output-ripple.svg) The shapes tell you which term dominates: - The **MLCC bank** gives a smooth curve: that is the capacitance charging and discharging, $\Delta V \approx \Delta I/(8 f_{sw} C) = 0.898/(8 \times 400\,\text{k} \times 119.8\,\mu) = 2.3$ mV. - The **polymer** and the **electrolytic** give a triangle in step with the inductor current: that is the ESR, $\Delta V \approx \Delta I \cdot ESR$. For the polymer that is $0.898 \times 22\,\text{m} = 19.8$ mV. For the electrolytic it would be 117 mV, but the load resistor carries part of the ripple, so the simulation gives 108 mV. The electrolytic has the most capacitance of the three and the worst ripple, by a factor of 45 over the ceramics. For high-frequency ripple, **ESR matters more than capacitance**. The FR data sheet gives an impedance at 100 kHz rather than an ESR; at 100 kHz the 270 µF reactance is only 6 mΩ, so the impedance is almost all ESR. ## Ripple current and lifetime Every capacitor data sheet gives a **rated ripple current**: the RMS current at a stated frequency and temperature that heats the part by the amount the maker allows. Exceed it and the part runs hotter than its rating. For a ceramic capacitor, heat just has to stay below its temperature limit. For an **aluminium electrolytic** capacitor, heat is the wear-out mechanism: the liquid electrolyte slowly evaporates through the seal, the capacitance falls and the ESR rises. Makers give a rated life at the upper category temperature (for example 6000 hours at 105 °C) and a formula to scale it. The Panasonic aluminium data sheets (FR-A and ZC series, 01-Sep-25, "Matters to Be Observed When Using This Product") use $$L = L_1 \cdot 2^{\,(T_1 - T_{core})/10}$$ so the life **doubles for every 10 °C cooler**, and they cap any estimate at 15 years because of the rubber seal. Polymer capacitors use a different law: Panasonic's OS-CON formula is $L_x = L_o \cdot 10^{(T_o - T_x)/20}$, ten times the life for every 20 °C cooler. The core temperature is the ambient plus the ripple heating, $T_{core} = T_a + I_{rms}^2 \cdot ESR \cdot R_{th}$. So the ripple current and the ambient temperature together set the life. ## Ceramic capacitors and DC bias Multilayer ceramic capacitors (MLCCs) come in two families: - **Class 1 (C0G, also called NP0)**: the capacitance hardly changes with voltage, temperature or time. Values are small (picofarads to tens of nanofarads in small cases). Use them for timing, snubbers, resonant tanks and sense filters. The KEMET C1003 sheet (2/20/2025) offers 100 pF to 22 nF at 50 V in 0805. - **Class 2 (X5R, X7R, X7S)**: high capacitance in a small case, but the capacitance falls with **DC bias voltage**, changes with temperature (X7R: ±15 % over −55 to 125 °C; X5R: −55 to 85 °C) and drifts slowly with age. DC bias is the one that surprises people. Here are four Murata parts, with the capacitance read from their DC-bias curves (Murata product search data, read 2026-10-18, and the GRM31CR61H106KA12 data sheet of 02/14/2024): ![Capacitance against DC bias voltage for four Murata MLCCs, from their data-sheet curves. The vertical line is the 36 V input of the example.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/how-to-choose-capacitors-power-supply/dc-bias.svg) | Part | Rating | Case | Nominal | Left at 36 V | |---|---|---|---|---| | GRM32EC72A106KE05 | 100 V X7S | 1210 | 10 µF | 3.76 µF (38 %) | | GRM55ER72A475KA01 | 100 V X7R | 2220 | 4.7 µF | 3.35 µF (71 %) | | GRM32ER72A225KA35 | 100 V X7R | 1210 | 2.2 µF | 1.43 µF (65 %) | | GRM31CR61H106KA12 | 50 V X5R | 1206 | 10 µF | 1.08 µF (11 %) | Two lessons: - **The voltage rating is not a derating.** A 50 V, 10 µF part at 36 V keeps 1.08 µF. The 100 V, 10 µF part in a bigger case keeps 3.76 µF. - **Case size matters as much as the label.** The 4.7 µF part in a 2220 case keeps almost as much as the 10 µF part in a 1210. Always read the DC-bias curve at your working voltage and count the parts from the capacitance that is left. Two smaller habits: lay MLCCs out away from board edges and connectors (they crack when the board flexes), and expect class-2 parts to "sing" audibly when the ripple falls in the audio band. ## Polymer, hybrid and film - **Polymer aluminium** (for example Panasonic OS-CON SVPF) replaces the liquid electrolyte with a conductive polymer. ESR is low (tens of milliohms) and stays low in the cold; there is no liquid to dry out. They suit low-voltage outputs and inputs up to a few tens of volts. - **Hybrid** (for example Panasonic EEH-ZC) combines a polymer with a liquid electrolyte: polymer-like ESR, with higher voltage ratings and the electrolyte's self-healing. The ZC series is rated 4000 hours at 125 °C. - **Film** capacitors (polypropylene) have very low losses, no DC-bias effect, high voltage ratings and a long life; they are big for their capacitance. Use them for DC links of hundreds of volts (TDK B32776G, 1100 V and 1300 V), AC filter capacitors (Vishay MKP1847C AC Filtering, Document 26077), and high-voltage snubbers (WIMA FKP 2, 630 V). ## X and Y safety capacitors Capacitors connected to the mains have their own safety classes, set by IEC 60384-14: - **X capacitors** go **across the line** (line to neutral). If one fails short, a fuse opens; nobody gets a shock. X2 is the usual class for equipment on the mains. - **Y capacitors** go **from line or neutral to protective earth** (or across an isolation barrier). If one failed short, the chassis could become live, so they must fail open, and their capacitance is limited by the allowed touch current. Never put an ordinary capacitor in an X or Y position, even one with a higher voltage rating; the certification covers surge and failure behaviour that the voltage rating does not. The Voltecx catalogue lists certified parts with their data sheets: KEMET R46 and Vishay MKP338 2 X2 film capacitors, and Vishay VY2 Y2 ceramic disc capacitors (Document 28535). ## A selection table | Technology | Capacitance | ESR | DC bias | Life | Best for | |---|---|---|---|---|---| | MLCC class 1 (C0G) | pF to tens of nF | Very low | None | Long | Snubber, resonant, timing, sense filters | | MLCC class 2 (X5R, X7R) | nF to tens of µF | Very low | Large | Long | Input, output, bypass | | Aluminium electrolytic | µF to mF | High | None | Limited by temperature | Bulk, low cost, damping | | Polymer aluminium | µF to mF | Low | None | Long when cool | Low-voltage bulk and output | | Hybrid | µF to hundreds of µF | Low | None | Long, rated at 125 °C | Bulk at tens of volts in hot places | | Film (polypropylene) | nF to tens of µF | Very low | None | Long | DC link, AC filter, high-voltage snubber | | X2 / Y2 safety | nF to µF (X), pF to nF (Y) | — | — | — | Mains EMI filter | ## Worked example: an input bank of a hybrid and MLCCs The input of our buck sees a pulsed current: 3 A while the switch is on, zero while it is off. The input capacitors must supply its AC part, whose RMS value is $$I_{C,rms} = I_o \sqrt{D(1 - D)} = 3 \times \sqrt{0.139 \times 0.861} = 1.04\ \text{A}$$ (a pulse of height $I_o$ for a fraction $D$ of the period has a mean of $D I_o$ and an RMS of $\sqrt{D}\,I_o$; take the mean out and $I_o\sqrt{D - D^2}$ is left). We try a common combination: one bulk hybrid capacitor for capacitance and damping, plus MLCCs for the high-frequency current. - **Bulk**: Panasonic EEHZC1H101P, 100 µF, 50 V, ESR 28 mΩ max at 100 kHz, rated ripple 1.6 A at 100 kHz (EEH-ZC parametric table). - **MLCCs**: Murata GRM32EC72A106KE05, 10 µF, 100 V X7S, 1210, which keeps 3.76 µF at 36 V; ESR 3.2 mΩ at 100 kHz; ripple rating 3.79 A for a 20 K self-heating rise (80 kHz curve). ![The input bank in Voltecx: Vin with the supply's resistance, the MLCC bank Cin (four 10 µF parts at 36 V: 15.03 µF) and the hybrid Cb next to it.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/how-to-choose-capacitors-power-supply/input-bank.svg) ### Step 1: the hybrid alone With no MLCCs, the hybrid carries 1.00 A RMS (the supply's leads take a little), within its 1.6 A rating. The input voltage ripple is 101 mV peak to peak, mostly the ESR times the 3 A pulse ($0.028 \times 3 = 84$ mV). ### Step 2: add MLCCs How does the current split once the MLCCs are in? **By impedance**, not by capacitance. At the 400 kHz switching frequency the four MLCCs (15 µF after DC bias) and the hybrid have about the same impedance, so they share: ![Two switching periods with four MLCCs: current in the hybrid i(Cb) and in the MLCC bank i(Cin), and the input voltage v(in).](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/how-to-choose-capacitors-power-supply/input-ripple-split.svg) The MLCCs take the fast edges (the steps in i(Cin)), and the hybrid takes the slower part. With four MLCCs, the hybrid carries 0.437 A and the MLCC bank 0.871 A (the RMS values do not add because the two currents are out of phase). The input ripple falls to 47.1 mV. ![RMS current in the hybrid and the input voltage ripple against the number of MLCCs in parallel with it.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/how-to-choose-capacitors-power-supply/bulk-current-vs-mlcc-count.svg) More MLCCs keep helping, but with diminishing returns: with eight, the hybrid carries 0.264 A and the ripple is 27.7 mV. Notice that even with eight MLCCs the hybrid still carries a quarter of an ampere. Its 28 mΩ ESR is low enough to compete with the MLCCs at 400 kHz. **Don't assume the ceramics take everything; simulate or calculate the split.** ### Step 3: the impedance of the bank The impedance plot shows why. Below about 400 kHz the hybrid has the lower impedance; above, the MLCCs do; together the bank stays low across the whole range. The catalogue has no ESL for these parts, so this plot uses what-if values of 1 nH per MLCC and 5 nH for the can (read the real ones from your parts' impedance curves, $ESL = 1/((2\pi f_0)^2 C)$). ![Impedance magnitude (dBΩ: 0 dB is 1 Ω, −40 dB is 10 mΩ) of the hybrid alone, the four MLCCs alone and both in parallel, from 1 kHz to 100 MHz, with what-if ESL values.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/how-to-choose-capacitors-power-supply/impedance.svg) | | 100 kHz | 400 kHz | 1 MHz | |---|---|---|---| | Hybrid 100 µF | 31 mΩ | 29 mΩ | 41 mΩ | | 4 × MLCC (15 µF) | 106 mΩ | 26 mΩ | 9.0 mΩ | | Both | 27 mΩ | 23 mΩ | 10.4 mΩ | With these ESL values the hybrid resonates near 225 kHz and the MLCC bank near 2.6 MHz. Above its resonance the hybrid is an inductor, which is why a big can alone cannot handle fast edges. ### Step 4: how long will the bulk capacitor last? `design.reliability` reads the simulated ripple in each capacitor, checks it against the part's rated ripple current, and applies its series' life formula. Panasonic prints no core temperature rise for the rated ripple of these series, so a part within its ripple rating is taken at the ambient temperature; with four MLCCs beside it, the bulk capacitor is well within its rating, and the life is set by the ambient temperature and the series' rating. For the hybrid the formula's T1 is then its 125 °C category temperature, without the rated ripple's rise, so its life is not overstated. We compare the hybrid with a standard electrolytic of the same 100 µF and 50 V, the Panasonic EEUFR1H101 (FR-A, 0.061 Ω at 100 kHz, 6000 hours at 105 °C, 0.87 A rated ripple): ![Estimated life of the bulk capacitor against the ambient temperature, with four MLCCs beside it: the EEHZC1H101P hybrid (top) and the EEUFR1H101 electrolytic (bottom). Both are capped at 15 years by Panasonic's seal limit.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/how-to-choose-capacitors-power-supply/life-vs-ambient.svg) | Ambient | Hybrid EEHZC1H101P | Electrolytic EEUFR1H101 | |---|---|---| | 55 °C | 15 years (cap) | 15 years (cap) | | 65 °C | 15 years (cap) | 11.0 years | | 85 °C | 7.31 years | 2.74 years | | 95 °C | 3.65 years | 1.37 years | | 105 °C | 1.83 years | 0.685 years | Inside a sealed enclosure at 85 °C, the ordinary electrolytic lasts under three years; the hybrid, rated 20 °C higher, lasts more than seven. That is what you pay the hybrid's higher price for. ### The resulting bank One EEHZC1H101P plus four GRM32EC72A106KE05: 47 mV of input ripple, every part well within its ripple rating, and a bulk capacitor whose life estimate reaches the 15-year cap up to a 70 °C ambient and is still over seven years at 85 °C. Place the MLCCs right at the switch and diode, so the loop that carries the fast edges is as small as the board allows. ## A step-by-step checklist 1. **Name the role** of each capacitor (input, bulk, output, bypass, snubber, safety). 2. **Voltage**: rated above the highest working voltage plus spikes, with your derating rule. 3. **Capacitance at the working point**: after DC bias (class 2), temperature and tolerance. 4. **ESR and ESL** at your switching frequency: they set the ripple voltage and the edge spikes. 5. **Ripple current**: find the RMS current in each part (simulate the split) and compare with its rating at your frequency and temperature. 6. **Lifetime** for electrolytics, polymers and hybrids: core temperature, then the maker's formula. 7. **Safety class** for anything on the mains: X or Y, certified. 8. **Mechanics**: size, height, board-flex cracking for large MLCCs, audible noise. ## Try it in Voltecx - Every capacitor takes `esr` and `esl`, and `esrTemp` and `cTemp` tables for the data sheet's temperature curves. Set `c` to the capacitance left at your DC bias. - `analysis.impedance` sweeps the impedance at any node, as in the bank plot above. - `scope.measure` gives the RMS current in each capacitor, so you can see the ripple split directly. - `bom.export` picks catalogue capacitors (Murata, KEMET, Panasonic, TDK, Vishay and WIMA parts, each with its data sheet) and counts how many pieces are needed for the capacitance left at the DC voltage, checks ripple current and voltage, and warns when a sheet gives no ripple rating. **Design › Design Steps › Parts** (`design.parts` with `passives`) shows the same choices with the margin that limits each one. - **Design › Design Steps › Reliability** (`design.reliability`) gives the core temperature and life of every electrolytic, polymer and hybrid capacitor from the last simulation, using the series' published formula, and a derating table for every part. **Design › Design Steps › Trade-offs** (`design.tradeoff`) compares capacitor alternatives on efficiency, board area, cost and life. For the output side of the same buck, see [how to choose the output capacitor of a buck converter](https://voltecx-web.nguyenvanqui291.workers.dev/blog/buck-output-capacitor-selection). For the inductor, see [how to choose an inductor](https://voltecx-web.nguyenvanqui291.workers.dev/blog/how-to-choose-an-inductor). ## Frequently asked questions ### Why does my 10 µF ceramic capacitor measure much less in the circuit? Class 2 ceramics (X5R, X7R) lose capacitance under DC bias. A 50 V, 10 µF X5R part in a 1206 case keeps only 1.08 µF at 36 V. Read the DC-bias curve and use a higher-voltage or larger-case part. ### Is a bigger electrolytic capacitor always better? Not for ripple. At the switching frequency an electrolytic's impedance is mostly its ESR, so a larger can with the same ESR gives the same ripple. Choose for ESR and ripple-current rating, then for capacitance. ### How do I estimate an electrolytic capacitor's life? Find the core temperature (ambient plus $I_{rms}^2 \cdot ESR$ heating), then use the maker's formula, usually doubling the rated life for every 10 °C below the rated temperature, and respect any cap the maker puts on the result. ### Can I put MLCCs in parallel with an electrolytic? Yes, and it is the usual input bank: MLCCs for the fast edges, the electrolytic for bulk capacitance and damping. The current splits by impedance, so check that the electrolytic's share stays within its ripple rating. ### Can I use a normal film capacitor across the mains? No. Use a certified X capacitor across the line and a certified Y capacitor to earth. --- # CMTI and fiber: isolating gate signals when SiC edges pass 100 V/ns URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/cmti-fiber-gate-drive-isolation/ A high-side gate signal starts on the controller's ground and ends on the switch node, which swings the whole bus voltage every cycle. The part that carries it across, an optocoupler, a digital isolator, an isolated gate driver or a fiber, sees that swing between its two sides. If the slope is too steep, charge pushed through the barrier capacitance flips its output: a false turn-on, a shoot-through. The data sheet number for this is the **common-mode transient immunity (CMTI)**, in kV/µs, which is the same number in V/ns. ## The numbers - A phototransistor optocoupler is a slow analog part. The TCET1100 in the Voltecx library has a 110 kHz pole: fine for the feedback of a flyback, far too slow for PWM. - A digital isolator such as the ISO7710: 100 V/ns typical (SLLSER9E, §5.9). - An isolated SiC gate driver such as the UCC21750: 150 V/ns minimum (SLUSD78C, Table 6.8). - An 800 V SiC leg switching in 5 ns: **160 V/ns**. That is above both. A fiber link has no galvanic path at all, so it has no CMTI limit, and its barrier voltage is set by the length of the fiber. That is why medium-voltage converters and modular multilevel converters drive their gates over fiber. ## What Voltecx checks - **During the run.** Every isolating IC model (`optocoupler`, `highSpeedOpto`, `digitalIsolator`, `gateDriverIso`) measures the slope across its own barrier over a 1 ns window. Above its `cmti` rating its output glitches, and the Problems list says so: `CMTI exceeded: 160 V/ns > 150 V/ns rating on U1`. A part whose rating Voltecx does not hold is measured, never trusted. - **The fiber link.** `fiberTx` and `fiberRx` model the delay, the time of flight, a seeded jitter, the minimum pulse width and the sensitivity. `fiber.linkBudget` adds up launched power, fiber attenuation and connector loss against the receiver's sensitivity. Their defaults are typical values: set your parts' numbers. - **The choice.** `design.gateDrive` weighs speed, bus voltage and CMTI against the switch node's dv/dt, picks the first element that passes, and says why in plain words. In the 800 V example at a 5 ns edge, it passes over the 150 V/ns driver and picks the fiber. Try it: open `File › Open Example › Isolated › SiC half bridge with fiber-optic gate drive`, or follow the tutorial in the documentation. --- # Derating: how much margin do power components need? URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/derating-rules-power-components/ A 100 V MOSFET on a 48 V bus. A 63 V capacitor on the same bus. A 10 W resistor that dissipates 3 W. Every power engineer runs parts below their ratings, and every company has a rule for how far below. That practice is called **derating**, and it is one of the cheapest ways to buy reliability. It is also easy to get wrong in both directions. Too little margin, and a start-up spike or a hot summer day takes the part past its limit. Too much margin, and the bill of materials fills with parts a class bigger than they need to be. This article explains what derating protects against, how the usual rules work for each kind of part, and then checks a real 48 V to 12 V flyback in Voltecx against two rule sets. Along the way it shows two things that catch people out: the peak at start-up, and what an over-strict rule does to the parts you buy. ## The intuition: a rope bridge Think of a rope bridge rated for 1000 kg. You could march 999 kg across it every day, and on most days nothing would happen. But the rating was measured on a new rope, on a dry day, with the load in the middle. Your rope is getting older, it rains, and sometimes people jump. So you post a sign saying 600 kg. A component rating is the same kind of number. It is the most the part takes under the conditions of the data sheet, not a level it can live at for years. Running below it buys three things: - **Room for the unexpected.** Spikes, surges, start-up overshoot, a hotter enclosure than planned, part-to-part spread. - **Slower wear-out.** Most failure mechanisms speed up with voltage, current density and above all temperature. An aluminium electrolytic capacitor's life roughly halves for every 10 K (the formula in Panasonic's EEU-FR data sheet), and semiconductor failure rates rise steeply with junction temperature. - **Margin for what you did not model.** Layout parasitics, ageing of other parts, the tolerance of the measurement itself. The derated limit is the rating times a **derating factor**: $$\text{limit} = k \times \text{rating}, \qquad \text{stress ratio} = \frac{\text{measured stress}}{\text{limit}} \le 1$$ A stress ratio of 0.9 means the part uses 90 % of what the rule allows. Above 1 the part fails the rule. It will probably not fail on the bench, but it gives away the margin the rule was written to keep. ## Which stresses, for which parts Each kind of part fails in its own way, so each is derated on its own stress. The figures below are from NASA's EEE-INST-002, "Instructions for EEE Parts Selection, Screening, Qualification, and Derating" (NASA/TP-2003-212242, May 2003, with Addendum 1 of April 2008), Table 4 of each part section. It is a strict rule set written for space flight, and it is the one Voltecx applies by default. | Part | Stress | EEE-INST-002 limit | |---|---|---| | MOSFET, IGBT, transistor | peak voltage | 0.75 of the rating | | | RMS current | 0.75 of the rating | | | junction temperature | 125 °C, or 40 °C below the maximum, whichever is lower | | Diode | peak reverse voltage | 0.7 of the rating | | | average forward current | 0.5 of the rating | | Ceramic and film capacitor | DC plus peak ripple voltage | 0.6 of the rating | | Resistor, film chip (style RM) | power | 0.6 of the rating to 70 °C, falling to zero at 118 °C | | Resistor, wirewound power (style RWR) | power | 0.6 of the rating to 25 °C, falling to zero at 160 °C | | Resistor | voltage | 0.8 of the rating | | Inductor, transformer | hot-spot temperature | 0.75 of the maximum operating temperature | Notice what is not in the table. EEE-INST-002 has no row for aluminium electrolytic, polymer or hybrid capacitors, so those are held to their manufacturer's voltage and ripple rating, and their life is checked separately from their core temperature. A second, common rule set is a single factor for everything: 0.8 of the voltage rating, 0.7 of the RMS current, 0.8 of the peak current, 0.5 of the power and a junction at most 125 °C. Those are common engineering practice, not a standard, and Voltecx says so in every row it writes with them (`design.reliability` with `"rules": "stress"`). Voltecx's `analysis.stress` used them by default when this article was written; it now follows EEE-INST-002 per part class too. ### Why voltage is derated more than you might think Voltage stress is about the **peak**, not the average. In a flyback, the MOSFET sees the input voltage plus the reflected output voltage plus the leakage-inductance spike, and in a ceramic capacitor the dielectric sees DC plus the ripple peak. A part that is fine at the steady-state peak can be over the limit for a few milliseconds at start-up, and that is often when it fails. ### Why temperature changes the power limit A resistor's power rating is given at a reference temperature. Above it, the allowed power falls in a straight line to zero at the highest temperature the part survives. The derating rule follows the same shape, so **the same resistor gets a smaller limit in a hotter box**. ## A worked example: a 48 V to 12 V flyback The circuit is the Voltecx flyback template: 48 V in, 12 V and 5.4 A nominal out, 100 kHz, a transformer with 0.995 coupling, an RCD clamp (Dsn, Csn, Rsn) to catch the leakage spike, and a Schottky output diode. It runs open loop at the template's duty cycle and settles at 11.19 V and 5.03 A. ![The flyback in Voltecx (circuit.template, 48 V to 12 V, 100 kHz): switch S1, transformer T1, RCD clamp Dsn, Csn and Rsn, output diode D1, capacitors Cin and C1.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/derating-rules-power-components/flyback.svg) After a 4 ms simulation from rest, `bom.export` picks a catalogue part for each component from the stress it measured, and `design.reliability` compares every part's stress with its rating under a rule set. The parts are an EPC EPC2207 (200 V) as S1, a Nexperia PNE20030EP (200 V) as the clamp diode, a Murata GCM31CR72A105KA03 (100 V) as Csn, a Vishay NS wirewound resistor as Rsn, a Nexperia PMEG045V100EPD (45 V, 10 A) as D1, two Panasonic 20SVPF120M polymer capacitors as C1 and two Panasonic EEHZC1J330P hybrids as Cin. ### Step 1: read the table | Part | Stress | Measured | Rating | EEE-INST-002 ratio | `stress` ratio | |---|---|---|---|---|---| | S1 EPC2207 | voltage | 121.0 V | 200 V | 0.81 | 0.76 | | Dsn PNE20030EP | voltage | 119.4 V | 200 V | 0.85 | 0.75 | | Csn GCM31CR72A105KA03 | voltage | 73.8 V | 100 V | **1.23** | 0.92 | | D1 PMEG045V100EPD | voltage | 30.0 V | 45 V | 0.95 | 0.83 | | D1 PMEG045V100EPD | current | 4.96 A | 10 A | 0.99 | 0.71 | | C1 20SVPF120M | ripple current | 2.14 A | 3.2 A | 0.67 | 0.95 | | Cin EEHZC1J330P | voltage | 48.0 V | 63 V | 0.76 | 0.95 | | Cin EEHZC1J330P | ripple current | 0.759 A | 1.1 A | 0.69 | 0.99 | Under the common-practice factors every part passes. Under EEE-INST-002 one fails: **the clamp capacitor Csn**. It sees 73.8 V on a 100 V ceramic, and the rule allows 0.6 × 100 = 60 V. The two rule sets also disagree on which parts are tight. EEE-INST-002 is hard on diodes (0.5 of the average current puts D1 at 0.99) and soft on electrolytic and polymer capacitors (no row, so the manufacturer's rating). The common-practice set is the other way round: it puts both capacitors at 0.95 or more of their limits. **The rule set decides which parts look critical.** Choose it from your reliability target before you read the table, not after. ### Step 2: look at the waveforms against the limits The table gives one number per part. The waveforms show where in the period that number comes from. ![Steady-state stress of S1 (drain voltage), Csn (clamp voltage) and D1 (reverse voltage) in the Voltecx flyback over two switching periods, with each part's rating, the 0.8 stress limit and the EEE-INST-002 limit.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/derating-rules-power-components/stress-waveforms.svg) - **S1** peaks at the clamp level when it turns off, then rings around the input plus the reflected output voltage while the leakage inductance and the switch capacitance exchange energy. In steady state the peak is 109.1 V, well inside both limits. - **Csn** holds about 60 V above the input and charges a little more each time the leakage energy arrives. Its steady-state peak is 61.7 V, just over the EEE-INST-002 limit of 60 V even without the start-up. - **D1** blocks 29.0 V while the switch is on. Its voltage limit under EEE-INST-002 is 31.5 V. A 45 V Schottky is a tight choice for a 12 V output. ### Step 3: start-up is the worst case The table above came from the whole run, from rest. The highest drain voltage is not the steady-state 109.1 V but **121.0 V**, reached 0.55 ms after start, during the start-up transient, before the clamp and output voltages settle. ![The highest drain voltage of S1 in every 50 µs of the Voltecx run from rest, with the 200 V rating, the 0.8 stress limit and the EEE-INST-002 limit.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/derating-rules-power-components/drain-peak-startup.svg) That is 11 % above the steady-state value. Here it is still inside the limits, but in a design with less margin, the start-up peak is the one that crosses. Two practical rules: - **Derate against the worst case of the whole operating envelope**: start-up, load steps, the highest input, the hottest ambient. A soft start that ramps the duty cycle lowers the start-up peak and is often cheaper than a higher-rated part. - **Know which window your tool measures.** Voltecx rates over the whole run by default. Pass `t0` to `design.reliability` or `analysis.stress` to rate steady state only, as we did for the 109.1 V above, and decide consciously which number the rule should see. ### Step 4: temperature moves the resistor limit The clamp resistor Rsn dissipates 3.45 W. Its Vishay NS data sheet rates it at 10 W at 25 °C (8 W at 70 °C), falling in a straight line to zero at 250 °C. EEE-INST-002 allows 0.6 of the rating up to 25 °C for this wirewound style, falling to zero at 160 °C. ![The power the clamp resistor Rsn may dissipate against the ambient: EEE-INST-002 style RWR in Voltecx and a flat 0.5 of the 8 W rating, with Rsn's 3.45 W dissipation.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/derating-rules-power-components/resistor-derating.svg) At 40 °C the rule allows 5.33 W and Rsn uses 0.65 of it. The limit falls to 3.45 W at **82.3 °C**: in an enclosure hotter than that, the same resistor fails the rule. A flat "half the rating" rule never catches this, because it ignores the temperature. If your product sits in a hot cabinet, read the derating curve at the ambient it really sees. The resistor is also the clue to a cost-effective fix. Its 3.4 W is leakage energy being burnt. A transformer with tighter coupling, or a clamp that recovers the energy, makes the resistor, the capacitor and the heat smaller at the same time. ### Step 5: what over-derating costs So what if we simply derate everything harder? Ask `bom.export` to pick parts with 0.6 of the voltage rating and 0.5 of the current rating for every part (a uniform choice for this comparison, roughly EEE-INST-002's strictest rows, not a standard): | Part | Usual factors (0.8 V, 0.7 I) | 0.6 V, 0.5 I for every part | |---|---|---| | S1 | EPC EPC2207, 200 V | Infineon BSC600N25NS3G, 250 V | | D1 | Nexperia PMEG045V100EPD, 45 V Schottky | onsemi MBR40H100WTG, 100 V dual Schottky in TO-247 | | Csn | Murata GCM31CR72A105KA03 | KEMET R75PI3220AA30J, 630 V film | | C1 | 2 × Panasonic 20SVPF120M | 2 × Panasonic 25SVPF180M | | Cin | 2 × Panasonic EEHZC1J330P | 3 × Panasonic EEHZC1K220P | | Part area (known lines) | 643 mm² | 931 mm² (+45 %) | Every line moved up a class, and three got absurd. D1 blocks 29 V and carries 5 A, and the strict rule pushed it into a TO-247 power rectifier: the strict rule asks for about 10 A, the library's surface-mount 100 V Schottky (CFP15) is rated for 8 A, so the next part that qualifies is a through-hole dual Schottky rated for 20 A per diode, in a package made to sit on a heatsink. Csn leaves the ceramic family altogether for a 630 V film box capacitor (18 × 10 mm) to cover a 74 V peak, and that one part adds 180 mm². Little of this buys reliability that a 56 W converter needs; the board just got bigger and more expensive. That is the trap of derating "to be safe". **The right amount of derating is the amount your reliability target needs, applied to the real worst case, and no more.** For a consumer adapter that may be the common-practice factors. For a telecom rectifier with a 15-year life, something closer to EEE-INST-002. For a satellite, EEE-INST-002 itself. ## How to fix the failing part Back to Csn, which fails EEE-INST-002 at 73.8 V on a 100 V rating. The options, in order of cost: 1. **Lower the stress.** A soft start removes most of the start-up overshoot. A transformer with less leakage lowers the clamp voltage in steady state too. 2. **Raise the rating where it is cheap.** A ceramic capacitor with a higher voltage rating is often available in the same package, and it often loses less capacitance under DC bias too. Check its DC-bias curve on the data sheet. 3. **Change the rule only for a reason you can write down.** If the product's reliability target does not call for EEE-INST-002, use the rule set it does call for, and give the name of that rule set in the report. Voltecx takes your own factors with a name: `rules: {"name": "...", "voltage": ..., "current": ..., "power": ..., "tjMax": ...}`. ## Practical pitfalls - **Derating against typical values.** Use the measured peak, at the highest input and the hottest ambient, against the minimum rating. - **Forgetting transients.** Start-up, short circuit, load dump and line surge all produce peaks the steady state never shows. Simulate them, or derate with them in mind. - **Ignoring temperature curves.** Resistor power, capacitor ripple current and semiconductor current ratings all fall with temperature. A flat factor at 25 °C is not a derating rule. - **Mixing rule sets.** Pick one rule set per product and name it. "We used 0.8 here and 0.6 there because it looked right" cannot be reviewed. - **Derating parts you could redesign instead.** A clamp resistor that burns 3.4 W, a diode at 0.99 of its current limit: often the cheaper fix is to change the circuit, not to buy a bigger part. - **Trusting a derating table with holes.** Voltecx marks a row *missing* when it lacks a number. Here, the resistor's voltage rating is not on its data sheet and the transformer has no catalogue part. A missing row is work to do, not a pass. ## Try it in Voltecx 1. Open the flyback template with the `circuit.template` command: `{"topology":"flyback","vin":48,"vout":12,"iout":5.4}`, set the simulation end to 4 ms and run it. 2. Run `design.reliability` with `{"bom": {"exclude": ["R1"], "parallel": 3, "capacitorEsr": "known"}}` for the EEE-INST-002 table, then with `"rules": "stress"` for the common-practice factors, and compare the ratios. 3. Add `"t0": 3.8e-3` to rate steady state only, and `"ambient": 85` to see the resistor limit move. 4. Run `bom.export` (**Design → Manufacturing → Export BOM**) with your own `derating` factors and watch which lines change. Every number and figure above comes from those commands, and a regression test re-runs them and checks each value against the text. --- # Double-pulse test: how to measure switching energy Eon and Eoff URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/double-pulse-test-switching-energy/ A double-pulse test measures a transistor's switching energy by switching it twice into an inductive load: the first gate pulse ramps the inductor to the test current, the device turns off there (Eoff), the current freewheels for a moment, and the second pulse turns it on at the same current (Eon). Each energy is $\int v_{DS}\, i_D\, dt$ over the edge. In Voltecx's `doublePulse` example, a Wolfspeed C3M0065090D SiC MOSFET at 400 V and 20 A gives Eoff = 44.9 µJ and Eon = 273 µJ, against 44.2 µJ and 239.8 µJ on the data sheet's Fig. 24; the turn-on is 14 % high because it includes the upper body diode's reverse recovery, modelled with the data sheet's 150 °C charge. This article explains the test from the circuit up: why it looks the way it does, how to pick the inductance and the pulse widths, where to start and stop the integrals, what Eon really contains, and why a few nanohenries of common-source inductance move the result more than the gate resistor does. Every number comes from a run of the example, and the runs are checked by a test in the Voltecx source. ## Why switching energy needs its own test A transistor in a hard-switched converter loses energy every time it turns on or off, because for a few tens of nanoseconds it carries current and blocks voltage at the same time. The power is $$P_{sw} = (E_{on} + E_{off})\, f_{sw}$$ and at 100 kHz the 273 µJ and 44.9 µJ above are already 31.8 W, more than the conduction loss of the same part at 20 A. So the switching energy at the operating point matters, and the data sheet only gives it at one set of conditions: one voltage, one gate resistor, one gate voltage, one freewheeling diode, one layout. You cannot get these energies from a running converter easily: the edges come every period, the heatsink warms, and you cannot separate the turn-on from the turn-off. The double-pulse test switches the device twice, at a known voltage and current, in a few microseconds, so the junction stays at the temperature it started at. The textbook picture is the clamped inductive switching of Mohan, Undeland and Robbins (*Power Electronics: Converters, Applications, and Design*, 3rd ed., chapter 2): with linear voltage and current ramps the energy per transition is about $\frac{1}{2} V_d I_o t_c$, where $t_c$ is the crossover time. Erickson and Maksimović (*Fundamentals of Power Electronics*, 3rd ed., chapter 4) add the two pieces that this picture leaves out: the reverse-recovery charge of the diode and the energy stored in the device capacitances, both of which the transistor pays for at turn-on. ## The bench ![The doublePulse example in Voltecx: the 400 V supply, the upper C3M0065090D (Q1) held off with the 99 µH load inductor across it, the ammeter Id and the device under test Q2. Gate commands reach the transistors by the labels gh and gl.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/double-pulse-test-switching-energy/bench.svg) The circuit is a half bridge with the load inductor across the upper device (Wolfspeed C3M0065090D data sheet, Rev. 08, Fig. 30, "Clamped Inductive Switching Waveform Test Circuit"): - **Q2**, the device under test, is the lower switch. Its gate gets the two pulses. - **Q1**, the same part, is held off at −4 V. Its body diode carries the inductor current while Q2 is off, exactly as the free-wheeling diode in a real half bridge would. - **L1** is the load. It is large enough that its current hardly changes during an edge, so each edge switches a constant current, which is what "clamped inductive" means. - **Id** measures the drain current at the drain terminal, and `v(dd)` is the drain-source voltage. These two are what the data sheet integrates. The example uses the dynamic MOSFET level with the gate charge, threshold, plateau and capacitance curves from the device library (data sheet Fig. 12, 17 and 18 and the Electrical Characteristics table), at the data sheet's test conditions: 400 V, 20 A, $V_{GS}$ = −4 V/15 V, $R_{G(ext)}$ = 2.5 Ω, L = 99 µH. The body diode's recovery charge (185 nC) and time (28 ns) are the data sheet's, which gives them only at 150 °C. The 5 nH of common-source inductance is not a data-sheet value: it was chosen so the bench reproduces the data sheet's turn-off delay and fall time (Fig. 27). ## Choosing L and the pulse widths The first pulse decides the test current. With the supply $V$ across the inductor for $t_1$: $$I_{test} = \frac{V\, t_1}{L} \quad\Rightarrow\quad t_1 = \frac{L\, I_{test}}{V} = \frac{99\,\mu\text{H} \times 20\ \text{A}}{400\ \text{V}} = 4.95\ \mu\text{s}$$ That is the example's first pulse, from 0.3 µs to 5.25 µs. The simulation reaches 20.2 A at the turn-off. The inductance is a compromise: - **Large enough** that the current is flat during each edge and during the second pulse. The second pulse lasts 0.5 µs and adds $V t_2 / L = 400 \times 0.5\,\mu / 99\,\mu = 2.02$ A, so the turn-on and the next turn-off are 10 % apart in current. That is fine for a turn-on measurement; a much smaller inductor would make the second pulse too short to settle. - **Small enough** that the first pulse is short (a few microseconds), so the device does not heat during it, and the inductor does not need to store more energy than necessary. - **Low capacitance**: an inductor's winding capacitance sits across the device under test and adds to its output capacitance. A single-layer air-core coil is the usual bench choice. The gap between the pulses (1 µs here) must be long enough for the turn-off ringing to die out, and short enough that the freewheeling current does not decay. During the gap the inductor sees only the body-diode drop, 5.18 V at 20 A (the device library's 25 °C body-diode curve, read from data sheet Fig. 9 and 10 at −4 V), so it loses $5.18 \times 1\,\mu / 99\,\mu = 0.05$ A. To test at another current, change $t_1$ or $L$. The Voltecx test sweeps $L$ at the same gate pattern ($L = V t_1 / I$) to test from 5.5 A to 30 A. ![The whole double-pulse run: the drain voltage v(dd), the drain current i(Id) and the inductor current i(L1), and the gate command gl. The first pulse ramps the current to 20 A, the turn-off at 5.25 µs hands it to Q1's body diode, and the second pulse at 6.25 µs takes it back.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/double-pulse-test-switching-energy/double-pulse.svg) ## The turn-off: Eoff At 5.25 µs the gate command falls. Nothing happens for about 14 ns (the turn-off delay, while the gate discharges to the plateau), then the drain voltage rises at constant current until it passes the supply and Q1's body diode takes the current, and only then does Q2's current fall. The drain overshoots to 412 V: the current's fall rate times the loop inductance. Integrated from the gate command until the drain current is below 2 % of the test current, the energy is **Eoff = 44.9 µJ**, collected in 33 ns. The data sheet's Fig. 24 gives 44.2 µJ at 20 A and 25 °C: 1.5 % apart. Part of Eoff is not lost in the channel at all. The output capacitance charges to 400 V during the turn-off and keeps that energy until the next turn-on, where the channel discharges it. A data-sheet Eoff measured at the terminals includes the energy put into $C_{oss}$; that energy reappears in Eon. This is why Eoff of a fast SiC device is so small: the channel turns off before the voltage has risen much, and the rest of the edge is the load current charging the capacitance. ## The turn-on: Eon, and what it contains At 6.25 µs the gate rises again. After the turn-on delay the drain current rises, and it overshoots the load current: it goes up to **36.7 A** before the voltage falls. The extra 16.7 A is the reverse-recovery current of Q1's body diode plus the current that charges Q1's output capacitance and discharges Q2's own. Only when the diode has recovered can the drain voltage fall. ![The turn-on at 6.25 µs (0 ns): the drain voltage, the drain current and their product. The integral runs from the gate command to the moment the drain is below 2 % of the supply (the second marker, 35 ns). The current overshoot is the body diode's recovery and the output capacitances.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/double-pulse-test-switching-energy/turn-on.svg) Integrated from the gate command until the drain voltage is below 2 % of the supply, **Eon = 273 µJ**, in 35 ns. Fig. 24 gives 239.8 µJ at 20 A; the Electrical Characteristics table gives 250 µJ at 150 °C. The simulation is 14 % above the 25 °C curve. The difference is the recovery. The example gives the body diode the data sheet's recovery charge, 185 nC, which the data sheet lists only at 150 °C. A silicon carbide body diode has little stored charge at 25 °C; much of what is measured is capacitive and grows with temperature. A rough upper bound for what the recovery adds is $Q_{rr} V = 185\ \text{nC} \times 400\ \text{V} = 74$ µJ. The test confirms it: with the recovery charge set to zero, Eon falls to 148 µJ at 20 A, and the data sheet's 239.8 µJ lies between the two runs. **Eon is a property of the pair**, the transistor and the diode it commutates against. A data sheet that measures with the body diode of the same part gives you a number for that pairing; with a separate SiC Schottky diode, or a silicon diode, the same transistor has a different Eon. ## The integration window The energy is an integral, so its limits matter. Typical limits start at the gate edge (10 % of the gate voltage, or the gate command in a simulation) and end when the edge is over: for Eon when the drain voltage is down to a few percent of the supply, for Eoff when the drain current is down to a few percent of the test current. The IGBT standard IEC 60747-9 uses 2 % end points of this kind, and many MOSFET data sheets follow similar rules; read the definition in the data sheet you compare with. The bench shows how much the window moves the number: - Ending the turn-on at 10 % of the supply instead of 2 % gives 272.4 µJ instead of 273 µJ. The tail is small here because the SiC device's voltage falls fast. - A fixed 300 ns window over the energy signal `E(Q2)` gives 289 µJ: it adds the conduction loss of the next 265 ns, $I^2 R_{DS(on)}$ for every nanosecond after the edge. So a fixed window too long counts conduction as switching, and a window too short misses the tail. Use the same limits as the data sheet when you compare, and in a loss budget make sure the conduction loss is not counted twice. ## Eon and Eoff against the test current Sweeping the test current with the inductance and comparing with Fig. 24 at 400 V: | Test current | Eon, Voltecx | Eon, Fig. 24 | Eoff, Voltecx | Eoff, Fig. 24 | |---|---|---|---|---| | 5.5 A | 115.3 µJ | 62.0 µJ | 9.42 µJ | 8.7 µJ | | 10 A | 153.5 µJ | 102.0 µJ | 11.66 µJ | 10.9 µJ | | 15 A | 205.9 µJ | 162.0 µJ | 26.2 µJ | 22.0 µJ | | 20 A | 273.1 µJ | 239.8 µJ | 44.9 µJ | 44.2 µJ | | 30 A | 467.4 µJ | 444.3 µJ | 91.1 µJ | 124.2 µJ | ![Eon and Eoff against the test current: the C3M0065090D data sheet's Fig. 24 at 400 V and 25 °C, and Voltecx runs of the doublePulse example at the same gate pattern with L set for each current.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/double-pulse-test-switching-energy/energy-vs-current.svg) The shape is right, but the agreement is not uniform, and it is worth saying why: - **Eon at low current is too high**: 86 % at 5.5 A, 14 % at 20 A, 5 % at 30 A. The recovery charge is a fixed 185 nC in the model, so the energy it adds is the same at every current and weighs most at low current. Without it Eon at 5.5 A is 42.1 µJ, below the data sheet's 62.0 µJ; again the data sheet lies between. - **Eoff at 30 A is 27 % low.** The gate model's channel turns off faster at high current than the real device does. Up to 20 A, Eoff is within 20 %. This is the honest state of a device model built from a data sheet: it reproduces the conditions it was fitted at, and the further you go from them, the more you should check it against the data sheet's curves, as this sweep does. ## Gate resistance and common-source inductance The test's main use in design is to see what the gate drive and the layout do to the losses. The bench makes both easy to sweep. **Gate resistance.** Raising the external gate resistor of Q2 slows both edges: | $R_{G(ext)}$ | Eon | Eoff | |---|---|---| | 2.5 Ω | 273.1 µJ | 44.9 µJ | | 5 Ω | 285.6 µJ | 55.3 µJ | | 10 Ω | 303.6 µJ | 76.4 µJ | | 20 Ω | 343.7 µJ | 119.4 µJ | ![Eon and Eoff of the doublePulse example against the external gate resistance of Q2 (on and off), at 400 V and 20 A.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/double-pulse-test-switching-energy/energy-vs-rg.svg) Eoff nearly triples from 2.5 Ω to 20 Ω; Eon rises 26 %. Eon depends less on the gate resistor because much of it is the recovery and the capacitance energy, which the gate does not control. A larger resistor buys a slower dv/dt (less EMI and less overshoot) at the cost of loss, which is the usual reason for separate turn-on and turn-off resistors. **Common-source inductance.** The source lead of a TO-247-3 package carries both the power current and the gate return. When the drain current rises at turn-on, $L_{cs}\, di/dt$ appears in the gate loop and subtracts from the gate drive; at turn-off it does the opposite and keeps the gate up. Both slow the edge. The sweep: | $L_{cs}$ | Eon | Eoff | |---|---|---| | 0 nH | 184.8 µJ | 15.7 µJ | | 2 nH | 221.3 µJ | 26.5 µJ | | 5 nH (the example) | 273.1 µJ | 44.9 µJ | | 10 nH | 356.2 µJ | 78.0 µJ | ![Eon and Eoff against the common-source inductance of Q2, at 400 V, 20 A and 2.5 Ω.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/double-pulse-test-switching-energy/energy-vs-lcs.svg) Five nanohenries, roughly the source lead of a through-hole package, costs more than going from a 2.5 Ω to a 10 Ω gate resistor: Eon rises from 184.8 µJ to 273.1 µJ and Eoff almost triples. This is why fast SiC and GaN parts come in packages with a separate Kelvin source pin for the gate return, and why the gate return must be routed to that pin. JEDEC JEP187 (JC-70.2, 2021) describes how this and other parts of the measurement setup change the measured losses of SiC MOSFETs. ## Common mistakes - **Comparing energies measured with different windows.** A fixed long window counts conduction loss; a window that ends at 10 % misses the tail of a slow device. - **Ignoring the freewheeling diode.** Eon is the transistor and the diode together. Change the diode and you change Eon. - **Probing the voltage across more than the device.** A probe that includes the source lead or a shunt adds $L\,di/dt$ to the voltage and bends the energy. Voltecx's `v(dd)` is the device's own terminal voltage. - **Using the 25 °C curve at 125 °C, or the reverse.** The recovery charge of a body diode grows with temperature; so does Eon. - **Forgetting the layout.** The data sheet's numbers come from its own board. Your common-source inductance and loop inductance are different. ## How to do it in Voltecx 1. Open **File › Open Example › doublePulse** (Basics) (`file.openExample`, `{"name":"doublePulse"}`) and run it (**Simulation › Run Simulation**, `simulation.run`). The run takes 6.8 µs on a variable step (at most 10 ns, at least 1 ps), which shortens itself through every edge; the solver is the fast one. 2. Put `v(dd)`, `i(Id)` and `E(Q2)` on the scope. **Scope › Measurements** (`scope.measure`) with `t0` and `t1` around an edge gives the energy as the rise of `E(Q2)`; for a data-sheet window, export the two traces (`waveform.get`) and integrate $v \cdot i$ between your limits, as the test behind this article does. 3. Change the test current with `L1`'s inductance, the gate resistor with `Q2`'s `rgon` (and `rgoff`), the common-source inductance with `lcs`, and the recovery with `Q1`'s `qrr` and `trr` (**Circuit › Parameters**, `circuit.setParam`). 4. Sweep any of them with **Analysis › Parameter Sweep** (`analysis.paramSweep`), measuring `E(Q2)` with `max` and `min` in a window. 5. Set **Simulation › Settings** (`simulation.settings`) `fidelity` to `ideal` to see the same bench with ideal switches: no recovery, no overshoot and no switching energy, which is what [an ideal switch hides](https://voltecx-web.nguyenvanqui291.workers.dev/blog/five-things-to-check-in-power-electronics-simulation). The numbers here are checked by the tests `the_double_pulse_post_energies_and_windows_match_the_simulation`, `the_double_pulse_post_energy_against_current_follows_the_data_sheet_curve` and `the_double_pulse_post_gate_resistance_and_source_inductance_move_the_energies` in `crates/engine/src/auto/tests_blog.rs`. For what to do with the energies once you have them, see [MOSFET loss and junction temperature estimation](https://voltecx-web.nguyenvanqui291.workers.dev/blog/mosfet-loss-and-thermal-estimation). ## Frequently asked questions ### Why two pulses and not one? The first pulse only builds up the current; its turn-on happens at zero current and says nothing. The turn-off at the end of the first pulse and the turn-on at the start of the second are the two edges at the test current. Two pulses are the shortest sequence that gives both, and they are short enough that the junction does not heat. ### How do I choose the inductance for a double-pulse test? Pick the first pulse length you want (a few microseconds) and set $L = V t_1 / I_{test}$. Check that the second pulse adds only a few percent to the current ($V t_2 / L$), and use a coil with little winding capacitance. The example uses 99 µH and 4.95 µs for 20 A at 400 V. ### Does Eon include the diode's reverse recovery? Yes. The recovery current flows through the transistor while it still blocks most of the voltage, so the transistor dissipates the energy. In this bench, removing the recovery charge lowers Eon at 20 A from 273 µJ to 148 µJ. That is why the data sheet names the diode it tested with. ### Why is my measured Eon higher than the data sheet's? Common causes: a longer integration window, a different freewheeling diode, a higher temperature, a higher gate resistance, or more common-source inductance. In the example, 5 nH of common-source inductance alone adds 88 µJ to Eon compared with a Kelvin connection. ### Can I use the double-pulse result for a converter's loss? Yes, at the same voltage, current, gate drive, temperature and diode: $P_{sw} = (E_{on} + E_{off}) f_{sw}$. Scale the energy with voltage and current only near the test point, and prefer a measurement or a simulation at your own conditions. --- # Dual active bridge: power, current and ZVS against phase shift URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/dual-active-bridge-phase-shift/ A dual active bridge (DAB) moves power between two DC buses through a transformer by shifting the square wave of one full bridge against the other. With single-phase-shift modulation, both bridges run at a fixed 50 % duty and the only control variable is the phase shift $\varphi$. The power is $P = n V_1 V_2\, \varphi(\pi - \varphi) / (2\pi^2 f_s L)$, it flows from the leading bridge to the lagging one, and it reverses with the sign of $\varphi$. This article works through the formula on a 400 V to 200 V, 4.4 kW example, then shows what the phase shift does to the inductor current and to zero-voltage switching (ZVS), and why the converter is happiest when the two voltages match the turns ratio. ## The circuit Each side has a full bridge. The primary bridge drives the transformer through a series inductance $L$, which is usually the transformer's leakage inductance plus an external inductor. With a turns ratio $n = N_1/N_2$, the secondary bridge puts $\pm n V_2$ on the primary side of the transformer. The inductor sees the difference of two square waves: - the primary bridge output $v_1 = \pm V_1$; - the secondary bridge output referred to the primary, $v_2' = \pm n V_2$, delayed by $\varphi$ (in radians of the switching period, $\varphi = 2\pi f_s t_\varphi$). The ratio $d = n V_2 / V_1$ is the voltage gain referred to the primary. It is 1 when the two buses match the turns ratio. Eight switches, two transformer windings and an inductor sound like a lot, but each bridge only ever does one thing: it makes a square wave of its own bus voltage. Everything interesting happens in the inductor between the two square waves. ## The intuition: two voltage sources and a reactance If you have met power flow on the grid, you already know the DAB. Two AC sources $V_1$ and $V_2$ joined by a reactance $X$ exchange $$P = \frac{V_1 V_2 \sin\delta}{X}$$ where $\delta$ is the angle between them. Power flows from the leading source to the lagging one, it is largest at 90°, and when the two amplitudes are equal almost no reactive current flows at small angles. A synchronous generator on the grid works this way, and so does the DAB: the two bridges are the two sources, the series inductance is the reactance $X = \omega L$, and the phase shift is the load angle. The square waves only change the numbers. A square wave of amplitude $V$ has a fundamental of $4V/\pi$, so the fundamentals alone give $$P_1 = \frac{8}{\pi^2}\,\frac{n V_1 V_2 \sin\varphi}{\omega L}$$ For the example below at 30° that is 4.13 kW, 93 % of the exact 4.44 kW; the harmonics carry the rest. This first-harmonic picture is good for intuition (and for an LLC-style analysis), but the exact square-wave formula is just as easy, so the rest of the article uses it. Three consequences follow straight from the analogy: - **Direction.** Swap which bridge leads, and the power reverses. No relay, no second converter: the DAB is bidirectional by construction, which is why it is used between batteries and DC links. - **Control.** At a fixed frequency, power is set by one number, the phase shift. A digital controller only moves the timing of one PWM carrier against the other. - **Matching.** When the two amplitudes differ ($d \ne 1$), reactive current flows even when little power does, exactly like a generator with the wrong excitation. This is the root of the DAB's main weakness, covered below. ## The power formula Over one half period, from the primary edge at $\theta = 0$ to the next one at $\theta = \pi$ (with $\theta = 2\pi f_s t$ and $\omega = 2\pi f_s$): - for $0 < \theta < \varphi$, the primary is at $+V_1$ and the secondary is still at $-nV_2$, so the inductor voltage is $V_1(1+d)$; - for $\varphi < \theta < \pi$, both are positive and the inductor voltage is $V_1(1-d)$. The current has half-wave symmetry, $i(\pi) = -i(0)$, which fixes the two corner currents: $$i(0) = -\frac{V_1}{2\omega L}\left[\pi(1-d) + 2d\varphi\right], \qquad i(\varphi) = \frac{V_1}{2\omega L}\left[2\varphi - \pi(1-d)\right]$$ The power is $V_1$ times the average of the current while the primary is positive. Integrating the two segments gives the familiar result: $$P = \frac{n V_1 V_2}{2\pi^2 f_s L}\,\varphi(\pi - \varphi)$$ It peaks at $\varphi = \pi/2$ (90°), where $P_{max} = n V_1 V_2 / (8 f_s L)$. Beyond 90° the power falls again while the current keeps rising, so practical designs stay well below it: the formula is symmetric, the circulating current is not. ### A worked example The `dab` example in Voltecx: $V_1 = 400$ V, $V_2 = 200$ V, $n = 2$, $f_s = 50$ kHz, $L = 50$ µH. The gain is $d = 2 \times 200 / 400 = 1$. $$P_{max} = \frac{2 \times 400 \times 200}{8 \times 50\,\text{k} \times 50\,\mu} = 8.0\ \text{kW}$$ At $\varphi = 30° = \pi/6$: $$P = 8.0\ \text{kW} \times \frac{4\varphi(\pi-\varphi)}{\pi^2} = 8.0\ \text{kW} \times \frac{5}{9} = 4.44\ \text{kW}$$ Simulated in Voltecx, the `dab` example at 30° delivers 4.43 kW into the 200 V bus and draws 4.46 kW from the 400 V bus; the 30 W between them is the conduction loss of the eight 20 mΩ switches. From 10° to 90° the simulated power stays within 2 % of the formula, the dead time and the switch resistance taking the rest. ![Power into the 200 V bus against the phase shift: the formula (line) and Voltecx runs of the dab example (points).](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/dual-active-bridge-phase-shift/power-vs-phase.svg) ## The inductor current With $d = 1$ the inductor voltage is zero for $\varphi < \theta < \pi$: the current ramps from $i(0)$ to $i(\varphi)$ and then stays flat. The corners are $$i(\varphi) = -i(0) = \frac{V_1 \varphi}{\omega L} = \frac{400 \times 0.524}{2\pi \times 50\,\text{k} \times 50\,\mu} = 13.3\ \text{A}$$ The waveform is a trapezoid, so its RMS value is $$I_{rms} = i(\varphi)\sqrt{1 - \frac{2\varphi}{3\pi}} = 13.3 \times \sqrt{1 - \frac{1}{9}} = 12.6\ \text{A}$$ The simulation gives 12.6 A RMS, the same as the formula, and a 13.6 A peak, 2 % above it: the formula leaves out the dead time and the drops across the switches. How to read the waveform below: the top panel shows the two bridge voltages. While they have opposite signs (the short interval after each primary edge), the full $V_1 + nV_2 = 800$ V sits across the inductor and the current ramps fast, at 16 A/µs. While they have the same sign, the inductor sees nothing and the current stays flat. The flat part is where the power is delivered; the ramp is the price of reversing the current every half period. ![One switching period of the dab example at a 30° shift: the bridge voltages v(a,b) and v(c,d) and the inductor current iL.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/dual-active-bridge-phase-shift/waveforms.svg) The RMS current sets the conduction loss in all eight switches, the transformer and the inductor, so a useful figure of merit is $I_{rms} V_1 / P$. Here it is $12.6 \times 400 / 4440 = 1.13$. It rises with the phase shift: at 60° the power is 7.1 kW, 1.6 times as much, but the RMS current is 23.5 A, 1.9 times as much, and near 90° much of the current only circulates. ![Peak and RMS inductor current against the phase shift at d = 1: the trapezoid formulas and Voltecx runs of the dab example, within 3 % of each other.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/dual-active-bridge-phase-shift/current-vs-phase.svg) The current grows linearly with the phase shift, while the power bends over towards its maximum. That is why a DAB is designed to run at a moderate shift at full load: the last 30 % of the power range costs far more current than the first 70 %. ## Zero-voltage switching A switch turns on at zero voltage when, during the dead time, the current flows in the direction that discharges its output capacitance and then forward-biases its body diode. For the DAB with single phase shift: - the **primary** bridge switches at $\theta = 0$; its switches turn on softly when $i(0) < 0$, which holds whenever $\pi(1-d) + 2d\varphi > 0$, so always for $d \le 1$; - the **secondary** bridge switches at $\theta = \varphi$; its switches turn on softly when $i(\varphi) > 0$, that is when $$\varphi > \frac{\pi(1-d)}{2}$$ For $d = 1$ both conditions hold at any phase shift, in the ideal waveform. In practice the current at the edge must also stay in the right direction through the whole dead time $t_d$, while it ramps at $V_1(1+d)/L$ towards zero. Setting $|i(0)| > V_1(1+d)\,t_d/L$ gives the primary limit with dead time, $$\varphi > \frac{\pi(d-1) + 2(1+d)\,\omega\, t_d}{2d}$$ which at $d = 1$ is $2\,\omega\, t_d = 2 \times 2\pi \times 50\,\text{k} \times 100\,\text{n} = 0.063$ rad, or 3.6°, in the example. In the Voltecx simulation every switch turns on at zero voltage from 4° up; at 3° the 1.3 A at the primary edge reverses inside the dead time (the current ramps at 16 A/µs) and the primary bridge switches hard. The output capacitance of real switches, which must be swung before the dead time ends, raises this light-load limit further. For $d \ne 1$ one bridge loses ZVS below a minimum phase shift, that is below a minimum power: the secondary when $d < 1$, the primary when $d > 1$. The map below puts both limits on one chart. It is V-shaped with its tip at $d = 1$, and the dead time lifts the right-hand branch by about 3° and lowers the left-hand branch by about 2°, because the secondary's current only has to reverse within the dead time: its limit is $\pi(1-d)/2 - \omega\, t_d$. The simulated points come from `analysis.softSwitching` sweeps of the `dab` example at five secondary voltages (160 V to 240 V): each is the smallest whole-degree shift at which every one of the eight switches turns on softly, and each lies on the whole degree at or above the curve with dead time (16° for the 16.2° of $d = 0.8$). ![The smallest phase shift with ZVS on both bridges against d: ideal (td = 0), with the example's 100 ns dead time, and from Voltecx sweeps of the dab example.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/dual-active-bridge-phase-shift/zvs-boundary.svg) Read the map as a design tool: pick the range of $d$ your buses will cover, read the smallest phase shift, and turn it into a power with the power formula. Below that power the converter switches hard, and the switching loss and EMI go up. ## The cost of a voltage mismatch Keep the same converter and the same 4.44 kW, but let the 200 V bus sag to 180 V, a battery at a low state of charge. Now $d = 0.9$ and $P_{max} = 7.2$ kW. - The phase shift that gives 4.44 kW solves $4\varphi(\pi-\varphi)/\pi^2 = 4.44/7.2$: $\varphi = 34.3°$. - The corner currents become $i(0) = -17.7$ A and $i(\varphi) = 11.3$ A. The peak rises from 13.3 A to 17.7 A, about a third more, for the same power. - ZVS of the secondary needs $\varphi > \pi(1-0.9)/2 = 9°$ in the ideal waveform (7.2° with the 100 ns dead time), that is $P > 7.2\ \text{kW} \times 4 \times 0.05 \times 0.95 = 1.37$ kW. Below about 31 % of the 4.44 kW load the secondary bridge switches hard. Simulated, the converter at 180 V and 34.3° delivers 4.43 kW with a 17.5 A peak and 13.7 A RMS, against 12.6 A at 200 V: 9 % more RMS current and about 19 % more conduction loss for the same power. A sweep of the phase shift with `analysis.softSwitching` finds the four secondary switches losing ZVS between 7° and 8°, 1.8° below the ideal 9° by $\omega\, t_d$. ![The same converter with the secondary bus at 180 V and a 34.3° shift: the inductor current is no longer flat between the edges.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/dual-active-bridge-phase-shift/mismatch.svg) This is the main design trade-off of the DAB. Choose the turns ratio for the voltage where the converter spends most of its time, and expect higher current and a narrower ZVS range away from it. Wide-range applications (battery chargers, solid-state transformers) add degrees of freedom: extended phase shift, dual phase shift or triple phase shift modulation shift the two legs inside each bridge as well, so that each bridge also controls its own effective duty. ## Choosing the inductance Rearranging the power formula for a target power $P$ at a chosen phase shift $\varphi_{nom}$ gives $$L = \frac{n V_1 V_2\, \varphi_{nom}(\pi - \varphi_{nom})}{2\pi^2 f_s P}$$ A small $\varphi_{nom}$ (a large $L$ for the power) keeps the circulating current low but leaves little control range and a small ZVS margin when $d \ne 1$; a large $\varphi_{nom}$ does the opposite. A common starting point is a full-load phase shift between 30° and 45°, then a check of the RMS current and the ZVS boundary at the voltage extremes. Remember that the leakage of the transformer is part of $L$, and that the dead time removes a little volt-seconds at each edge, which the closed loop absorbs. ### A design walk-through Putting the pieces together for a new DAB: 1. **Turns ratio.** Set $n = V_1 / V_2$ at the operating point where the converter spends most of its time, so that $d = 1$ there. 2. **Frequency.** Pick $f_s$ from the switch technology and the transformer size (a few tens of kHz for IGBTs and silicon at high power, hundreds of kHz for SiC and GaN). 3. **Inductance.** Choose the full-load phase shift (30° to 45°) and compute $L$ from the formula above, at the lowest input and output voltage, where the most shift is needed for the power. 4. **Current.** Compute $i(0)$, $i(\varphi)$ and the RMS current at the corners of the voltage range. These size the switches, the transformer windings and the inductor. 5. **ZVS range.** Read the map above at the extreme values of $d$, turn the minimum phase shift into a minimum power, and decide whether hard switching below it is acceptable or whether a richer modulation is needed. 6. **Simulate the corners.** Run the switching model at each corner and at light load, with the real dead time and output capacitances, and check the soft-switching report rather than the ideal conditions. ## Common mistakes - **Leaving the leakage inductance out.** A transformer with 10 µH of leakage and a 40 µH external inductor is a 50 µH DAB. Measure or estimate the leakage before choosing the external part. - **Designing at the nominal voltage only.** The worst current and the narrowest ZVS range are at the corners of the voltage range, not at the nominal point. - **Running near 90° at full load.** The power curve is flat there: the loop gain collapses and the current is far higher than the power needs. - **Trusting the ideal ZVS condition at light load.** Dead time and output capacitance both need current; the simulation above loses ZVS at 3° even with $d = 1$. - **Forgetting the DC offset at start-up.** A step in phase shift leaves a DC component in the inductor current that only the circuit resistance removes, over many switching periods. Soft-start the phase shift, or the transformer can saturate. The analysis follows R. W. De Doncker, D. M. Divan and M. H. Kheraluwala, "A three-phase soft-switched high-power-density DC/DC converter for high-power applications", *IEEE Transactions on Industry Applications*, vol. 27, no. 1, 1991, and B. Zhao, Q. Song, W. Liu and Y. Sun, "Overview of dual-active-bridge isolated bidirectional DC-DC converter for high-frequency-link power-conversion system", *IEEE Transactions on Power Electronics*, vol. 29, no. 8, 2014. ## Try it in Voltecx - Open the `dab` example (`File › Open Example`, Isolated). The variables `V1`, `V2`, `Nt`, `fsw`, `Lk`, `Phs` and `td` hold the numbers above; change `Phs` in `Circuit › Variables` and run again. - `analysis.paramSweep` over `Phs` with `i(V2)` as the measure draws the power curve; set `V2` to 180 to see the mismatch. - `analysis.softSwitching` classifies every turn-on of the eight switches as ZVS, partial or hard, and its `sweep` option over `Phs` reports where each switch loses ZVS. - `analysis.losses` splits the conduction loss by switch, so you can see what the RMS current costs at each operating point. --- # Flyback RCD clamp design: clamp voltage, resistor and capacitor URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/flyback-rcd-clamp-design/ Size a flyback's RCD clamp by choosing the clamp voltage $V_c$ above the reflected voltage $V_{or}$ (typically 1.5 to 2.5 times it), then the resistor dissipates $P = \frac{1}{2} L_k I_{pk}^2 f_{sw}\, V_c/(V_c - V_{or})$, so $R_c = V_c^2/P$, and the capacitor sets the ripple, $\Delta V_c \approx V_c/(R_c C_c f_{sw})$. For a 48 V to 12 V, 24 W, 100 kHz flyback with 7.7 µH of leakage and a 1.375 A peak, a 64 V clamp gives 1.46 W, 2.81 kΩ and 71 nF; simulated, the clamp settles at 59.9 V and the resistor takes 1.28 W, and the formula stays within 2 % of the simulation when it is given the simulated peak current and reflected voltage. This article explains why the clamp is needed, how to choose its voltage, where the formula comes from and where it stops being accurate, what the capacitor does, and when a TVS diode is the better clamp. The numbers come from Voltecx runs, checked by a test in the Voltecx source. ## Why a flyback needs a clamp A flyback transformer is a coupled inductor: while the switch is on, the primary stores energy in the magnetising inductance; when it turns off, the secondary diode conducts and the energy goes to the output. The coupling is never perfect. A part of the primary inductance, the leakage inductance $L_k$, is not coupled to the secondary, and its current $I_{pk}$ at turn-off has nowhere to go: it cannot jump to the secondary. Without a clamp, the leakage current charges the switch's output capacitance and the drain rises until the switch avalanches. With an RCD clamp, the drain rises only until the clamp diode conducts at $V_{in} + V_c$; the leakage current then flows into the clamp capacitor and falls at the rate $(V_c - V_{or})/L_k$, while the secondary current rises. The clamp capacitor holds $V_c$ and the resistor bleeds the energy off between pulses. Erickson and Maksimović (*Fundamentals of Power Electronics*, 3rd ed., chapter 6) derive the flyback; C. Basso, *Switch-Mode Power Supplies: SPICE Simulations and Practical Designs*, 2nd ed., chapter 7, covers the clamp in practice; and Fairchild Semiconductor's application note AN-4147, *Design Guidelines for RCD Snubber of Flyback Converters*, gives the formulas used below (its equations 3 to 5). ## The circuit The example is the flyback template of Voltecx (`circuit.template` with `{"topology":"flyback","vin":48,"vout":12,"iout":2,"fsw":100e3}`): 48 V to 12 V at 2 A, 100 kHz, duty cycle 0.4, continuous conduction. The template computes: - the turns ratio $n = N_s/N_p = V_{out}(1-D)/(V_{in} D) = 0.375$, so the reflected voltage is $V_{or} = V_{out}/n = 32$ V; - the magnetising current $I_{Lm} = n I_{out}/(1-D) = 1.25$ A with a 20 % ripple of 0.25 A, so the primary peak is $I_{pk} = 1.375$ A; - the primary inductance $L_1$ = 771.9 µH and a coupling of $k$ = 0.995, so the leakage is $L_k = (1-k^2) L_1 = 7.70$ µH; - an ideal switch with 340 pF across it, a 10 mΩ clamp diode, and the clamp $R_{sn}$ and $C_{sn}$ from the clamp voltage $V_c = 2 V_{or} = 64$ V. ![The flyback template at 48 V to 12 V, 2 A: the RCD clamp Dsn, Csn and Rsn from the drain to the input, the coupled inductor T1, the switch S1 driven by the label g, and the output rectifier D1.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/flyback-rcd-clamp-design/flyback-rcd.svg) The runs last 8 ms on the template's fixed 50 ns step, long enough for the clamp to settle (its time constant is at most 1.6 ms in the sweeps), and the measurements use the last 0.2 ms. ## Choosing the clamp voltage The clamp voltage is a trade-off between the switch's voltage rating and the clamp's loss: - The switch sees $V_{in,max} + V_c$ plus a small overshoot. Here $48 + 64 = 112$ V, so a 150 V MOSFET has margin. - The clamp must stay above the reflected voltage, or it would conduct the magnetising energy that belongs to the output. As $V_c$ approaches $V_{or}$, the leakage current falls slowly (its rate is $(V_c - V_{or})/L_k$), the secondary takes over slowly, and the clamp takes energy from the input as well as the leakage. That is the factor $V_c/(V_c - V_{or})$ in the loss formula. At $V_c = 2V_{or}$ the clamp dissipates twice the leakage energy; at $V_c = 1.5 V_{or}$, three times; at $V_c = 3 V_{or}$, 1.5 times. Most designs settle between 1.5 and 2.5 times $V_{or}$, and the template uses 2. ## The formula During the clamp interval the leakage current falls linearly from $I_{pk}$ to zero in $$t_s = \frac{L_k I_{pk}}{V_c - V_{or}}$$ and the clamp receives $V_c \cdot \frac{1}{2} I_{pk} t_s$ per period. Per second: $$P = \frac{1}{2} L_k I_{pk}^2 f_{sw} \cdot \frac{V_c}{V_c - V_{or}}$$ For the example: $$\frac{1}{2} L_k I_{pk}^2 f_{sw} = \frac{1}{2} \times 7.70\,\mu\text{H} \times (1.375\ \text{A})^2 \times 100\ \text{kHz} = 0.728\ \text{W}$$ $$P = 0.728 \times \frac{64}{64 - 32} = 1.456\ \text{W}, \qquad R_{sn} = \frac{V_c^2}{P} = \frac{64^2}{1.456} = 2.81\ \text{k}\Omega$$ The capacitor is chosen for the ripple of the clamp voltage. It is charged once per period and discharges through $R_{sn}$ for nearly a whole period: $$\Delta V_c \approx \frac{V_c}{R_{sn} C_{sn} f_{sw}} \quad\Rightarrow\quad C_{sn} = \frac{V_c}{\Delta V_c R_{sn} f_{sw}}$$ For a 5 % ripple, $\Delta V_c = 3.2$ V and $C_{sn} = 1/(0.05 \times 2.81\,\text{k} \times 100\,\text{k}) = 71.1$ nF. ## What the simulation shows ![Two periods in steady state: the drain voltage, the primary current i(T1.1) and the clamp diode's current i(Dsn), and the clamp voltage (Rsn's current times Rsn). The clamp diode takes the leakage current at each turn-off; the clamp voltage jumps by its ripple and decays until the next one.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/flyback-rcd-clamp-design/waveforms.svg) At the designed values the clamp settles at **59.9 V** and its resistor takes **1.28 W**, both below the design's 64 V and 1.456 W. The drain peaks at **108.7 V**. After the clamp diode stops, the drain rings around $V_{in} + V_{or}$: the leakage inductance against the switch's 340 pF. Two things in the simulation differ from the design's assumptions: - the primary current peaks at **1.32 A**, not 1.375 A, and - the output sits at **11.2 V**, not 12 V: the template runs open loop at D = 0.4, and its source has 0.96 Ω, so the reflected voltage is $11.22/0.375 = 29.9$ V. Given those two, the formula gives 60.9 V, 1.7 % above the simulated 59.9 V. The design formula is on the safe side: it overestimates the loss and the clamp voltage, which is what you want for choosing the resistor's rating and the switch's. The ripple is 2.91 V against the formula's 3.00 V, 3 % below it. ## Sweeping the resistor Changing $R_{sn}$ moves the clamp voltage: with more resistance the capacitor must charge higher before the resistor bleeds off the energy. Solving the formula for $V_c$: $$\frac{V_c^2}{R} = W \frac{V_c}{V_c - V_{or}} \quad\Rightarrow\quad V_c = \frac{V_{or}}{2} + \sqrt{\frac{V_{or}^2}{4} + R W}$$ with $W = \frac{1}{2} L_k I_{pk}^2 f_{sw}$. Against the simulation (the formula with the simulated peak and reflected voltage at each point): | $R_{sn}$ | $V_c$, Voltecx | Loss, Voltecx | Formula below simulation by | |---|---|---|---| | 0.7 kΩ | 41.9 V | 2.51 W | 0.9 % | | 1.4 kΩ | 49.6 V | 1.76 W | 1.0 % | | 2.81 kΩ | 59.9 V | 1.28 W | 1.7 % | | 5.6 kΩ | 76.5 V | 1.05 W | 3.2 % | | 11.2 kΩ | 95.5 V | 0.82 W | 8.4 % | | 22.4 kΩ | 118.1 V | 0.62 W | 14.9 % | (The last column is how far the simulated clamp voltage is below the formula's.) ![The clamp voltage and the clamp resistor's loss against Rsn: the formula with the simulated peak current and reflected voltage, and the Voltecx runs. The marker is the design's 2.81 kΩ; the line at 32 V is the reflected voltage.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/flyback-rcd-clamp-design/sweep-rsn.svg) Up to about twice the reflected voltage, the formula is within 2 %. At higher clamp voltages it overestimates more and more: at 118.1 V the simulated clamp is 15 % below it and the resistor takes 0.62 W, less than the leakage energy alone (0.67 W at the simulated peak). The formula assumes all the leakage energy reaches the clamp. In the circuit, the switch's output capacitance takes part of it on the way: the drain must charge from $V_{in} + V_{or}$ to $V_{in} + V_c$ before the clamp diode conducts, and that capacitive energy grows with $V_c$; it later rings back. Cutting the switch's capacitance from 340 pF to 20 pF at 22.4 kΩ reduces the gap from 15 % to 4 %. The remaining 4 % comes from the formula's other simplifications, such as the secondary current that starts to flow while the drain is still rising. For design this is good news: at the usual 1.5 to 2.5 times $V_{or}$ the formula is accurate, and above that it errs on the safe side. ## Sweeping the capacitor At 2.81 kΩ, changing $C_{sn}$ hardly moves the mean clamp voltage but sets its ripple: | $C_{sn}$ | Ripple, Voltecx | $V_c/(R C f_{sw})$ | |---|---|---| | 10 nF | 20.5 V | 21.2 V | | 22 nF | 9.37 V | 9.66 V | | 71.1 nF | 2.91 V | 3.00 V | | 220 nF | 0.94 V | 0.97 V | ![The ripple of the clamp voltage against Csn at Rsn = 2.81 kΩ: the formula and the Voltecx runs, 3 % apart.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/flyback-rcd-clamp-design/sweep-csn.svg) The ripple matters because the drain peak follows the top of it: with 10 nF the drain reaches 117.6 V instead of 108.7 V. A capacitor too small wastes the switch's voltage margin; one too large only costs board area and slows the clamp's response at start-up and in load steps. The clamp capacitor carries the leakage current pulses, so use a part rated for pulse current (film or C0G ceramic). ## A TVS clamp A TVS diode (or a Zener) clamps at a fixed voltage instead of one set by a resistor and the leakage energy. Voltecx's `flybackTvsClamp` example shows it on a small flyback: 12 V in, a 1:1 coupled inductor of 50 µH with $k$ = 0.95 (so $L_k = (1-k^2) L_1 = 4.9$ µH), 100 kHz at D = 0.4, an RCD clamp with a deliberately large 100 kΩ resistor, and a Vishay SMBJ24A across the resistor (document 88392, revision 09-Jan-2024: stand-off 24 V, breakdown 26.7 to 29.5 V, 38.9 V at 15.4 A). - **With the TVS**, the clamp stays between 27.6 V and 32.2 V (mean 28.4 V), the drain peaks at 44.2 V ($12 + 32.2$ V), the TVS carries 0.80 A pulses and takes 0.40 W. - **Without it**, the 100 kΩ resistor cannot bleed the energy until the clamp has climbed to 178 V, most of the way within a millisecond and all of it by about 2 ms, and the drain peaks at 191 V. ![The clamp voltage of the flybackTvsClamp example from start-up, with the TVS (held at about 28 V) and without it (climbing to 178 V with 100 kΩ alone).](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/flyback-rcd-clamp-design/tvs-clamp-voltage.svg) A TVS clamp holds the drain at a known voltage regardless of the load and the leakage, which an RCD cannot, so it is common in low-power supplies and as the upper limit in parallel with an RCD. Its losses are the same leakage energy times the same $V_c/(V_c - V_{or})$ factor, only at a fixed $V_c$, and they heat a small package: check the TVS's average power rating, not only its pulse rating. Its clamping voltage also moves with current and temperature, so the switch's margin must cover the upper end of its range. ## Common mistakes - **A clamp voltage too close to $V_{or}$.** The clamp then takes magnetising energy as well, the loss grows steeply, and the efficiency falls. - **Forgetting the input voltage.** The switch sees $V_{in} + V_c$; at high line it is the input that sets the switch's rating. - **Sizing at the nominal point only.** The leakage energy grows with the square of the peak current; size the clamp where the peak is highest. Voltecx's design flow sizes it at the highest input and full load. - **A slow clamp diode.** Use an ultrafast diode: during its reverse recovery the clamp capacitor discharges back into the leakage. - **Using the formula far above $2V_{or}$.** It overestimates there; at high clamp voltages simulate it. ## How to do it in Voltecx 1. Build the flyback with `circuit.template` and `{"topology":"flyback","vin":48,"vout":12,"iout":2,"fsw":100e3}`; its reply lists the design values with their formulas, among them `Llk`, `Vsn`, `Psn`, `Rsn` and `Csn`. 2. Set **Simulation › Settings** (`simulation.settings`) `tEnd` to 8 ms and run (**Simulation › Run Simulation**, `simulation.run`). 3. Measure over the last 0.2 ms with **Scope › Measurements** (`scope.measure`): the mean of `i(Rsn)` times $R_{sn}$ is the clamp voltage, its RMS squared times $R_{sn}$ is the loss, and the maximum of `i(T1.1)` is the primary peak. 4. Sweep `Rsn.r` or `Csn.c` with **Analysis › Parameter Sweep** (`analysis.paramSweep`). 5. Open **File › Open Example › flybackTvsClamp** (Power quality) for the TVS clamp. 6. The automatic design (`design.auto`) re-sizes the clamp with the designed transformer's own leakage at the highest input and full load. The numbers are checked by `the_rcd_post_clamp_voltage_and_loss_match_the_formula` and `the_rcd_post_tvs_caps_the_clamp_voltage` in `crates/engine/src/auto/tests_blog.rs`. The transformer side of the same design is in [flyback transformer design, step by step](https://voltecx-web.nguyenvanqui291.workers.dev/blog/flyback-transformer-design-steps). ## Frequently asked questions ### What clamp voltage should a flyback RCD clamp have? Between about 1.5 and 2.5 times the reflected voltage $V_{or} = V_{out} N_p/N_s$, and low enough that $V_{in,max} + V_c$ plus an overshoot stays inside the switch's rating. At $2V_{or}$ the clamp dissipates twice the leakage energy. ### How do I calculate the RCD clamp resistor? Compute the clamp power $P = \frac{1}{2} L_k I_{pk}^2 f_{sw} V_c/(V_c - V_{or})$ at the highest peak current, then $R = V_c^2/P$. In the example, 1.456 W at 64 V gives 2.81 kΩ. ### How do I size the clamp capacitor? For the ripple you accept: $C = V_c/(\Delta V_c R f_{sw})$. A 5 % ripple on 64 V with 2.81 kΩ at 100 kHz needs 71 nF. The simulated ripple is 3 % below the formula. ### Why is my clamp voltage lower than calculated? The formula assumes the whole leakage energy reaches the clamp. Part of it charges the switch's capacitance, and part goes to the secondary while the drain is still rising, so the clamp settles lower, increasingly so at high clamp voltages. In the example the clamp is 1.7 % below the formula at the design point and 15 % below it at 22.4 kΩ. ### RCD or TVS clamp? An RCD clamp's voltage floats with the load and the leakage; a TVS holds a fixed voltage. A TVS gives a predictable switch stress and suits low power; an RCD spreads the loss over a resistor and suits higher power. Many designs use an RCD with a TVS as the upper limit. --- # Gate signal timing: propagation delay, rise and fall times, dead time and blanking URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/gate-signal-timing-propagation-delay-blanking/ The PWM peripheral of a microcontroller produces clean edges at exactly the right time. The MOSFET does not see those edges. Between the pin and the switch there is an isolator or a level shifter, a gate driver, a gate resistor and the gate charge of the transistor itself. Each one adds delay, and none of them adds the same delay twice. This post follows a gate signal from the controller pin to the drain, with real numbers from driver data sheets and a 100 V MOSFET simulated in Voltecx with its gate charge and capacitances. You will see why the dead time you programmed is not the dead time the switches get, how the gate resistor sets the edge speed, why a current-sense comparator needs leading-edge blanking, and where the minimum on-time comes from. For what dead time costs in loss and output voltage, see [dead-time effects](https://voltecx-web.nguyenvanqui291.workers.dev/blog/dead-time-effects). Here the angle is **timing**: when each edge really happens, and in what order. ## The path from the pin to the switch Think of the gate as a bucket that has to be filled through a pipe before the switch turns on. - The **controller pin** opens the tap. - The **isolator and driver** are a long hose: water arrives only after a delay, the *propagation delay*. - The **gate resistor** is the width of the pipe: the narrower it is, the slower the bucket fills. - The **gate capacitance** is the bucket. The switch starts to conduct when the level passes the *threshold*. - On the way up, the level stops rising for a while: this is the **Miller plateau**, when the water goes into a side tank (the gate-drain capacitance) as the drain voltage swings. In order, a turn-on looks like this: 1. The controller's PWM output goes high. 2. An isolator or level shifter carries the signal to the driver (tens of nanoseconds). 3. The driver's input stage and output stage switch: the driver's propagation delay. 4. The driver output charges the gate through the gate resistor. 5. The gate reaches the threshold: the drain current starts to rise. 6. The gate sits on the Miller plateau while the drain voltage falls. 7. The gate rises to the full drive voltage: the channel is fully on. Turn-off runs the same steps backwards: the gate falls to the plateau, sits there while the drain voltage rises, and then falls below the threshold as the current stops. ## Step 1: propagation delay and how much it varies Every driver data sheet gives a propagation delay with a minimum, a typical and a maximum value, and for two-channel drivers a *delay matching* (how much the two channels can differ). From the Voltecx gate-driver catalogue: | Driver | Kind | Delay min / typ / max | Delay matching (max) | Data sheet | |---|---|---|---|---| | TI UCC27211 | Half bridge, bootstrap | 10 / 20 / 40 ns | 17 ns | SLUSAT7H, §5.6 | | TI UCC27282 | Half bridge, bootstrap | – / 16 / 30 ns | 7 ns | SNVSAQ5B, §6.6 | | TI UCC21520 | Isolated, two channels | 26 / 33 / 45 ns | 6.5 ns | SLUSCJ9F, §6.10 | | Infineon IR2110 | Half bridge | – / 120 / 150 ns | 10 ns | PD60147 rev. V | The typical delay barely matters, because the controller can correct for any fixed delay. What hurts is the **difference between the two switches of a leg**, because it changes the dead time. Three numbers set it: - **Delay matching** inside one package: 17 ns for the UCC27211. - **Turn-on against turn-off delay**: the IR2110 turns on after 120 ns typical but turns off after 94 ns (the same data sheet). A difference between turn-on and turn-off delay adds or removes the same amount of dead time. - **Part-to-part spread** when the two switches have separate drivers: if the data sheet gives no part-to-part skew, assume the whole spread between minimum and maximum. For the UCC21520 that would be 45 − 26 = 19 ns. ### Isolator delay An isolated driver such as the UCC21520 is two drivers and an isolation barrier in one package: 33 ns typical, 45 ns maximum, with 6.5 ns of matching between the channels. If you use a separate digital isolator in front of a non-isolated driver, its delay and its own channel-to-channel skew add to the driver's. The rule is the same: add up the worst-case differences, not the typical delays. ## Step 2: rise and fall times, set by the gate resistor Once the driver output switches, the gate charges through the total resistance in the loop: the external gate resistor, the driver's own output resistance and the resistance inside the MOSFET, $R = R_{g,ext} + R_{drv} + R_{g,int}$. While the drain voltage swings, the gate sits at the plateau voltage $V_{pl}$, so the gate current is roughly constant, and the drain swing needs the gate-drain charge $Q_{gd}$. That gives the classic estimates (TI SLUP169, *Fundamentals of MOSFET and IGBT gate driver circuits*): $$t_{rise,V} \approx \frac{Q_{gd}\, R}{V_{drv} - V_{pl}}, \qquad t_{fall,V} \approx \frac{Q_{gd}\, R}{V_{pl}}$$ The delays before the swing are the RC charge of the input capacitance $C_{iss}$ from one voltage to another, with $\tau = R \cdot C_{iss}$: $$t_{d,on} \approx \tau \ln\frac{V_{drv}}{V_{drv} - V_{th}}, \qquad t_{d,off} \approx \tau \ln\frac{V_{drv}}{V_{pl}}$$ Note the asymmetry: the turn-on is driven by $V_{drv} - V_{pl}$ and the turn-off by $V_{pl}$ alone. With a 10 V drive and a 4.8 V plateau they are similar; with a 15 V drive the turn-on edge is about twice as fast as the turn-off edge. ### Worked example: Infineon BSC070N10NS5 The BSC070N10NS5 is a 100 V MOSFET with 6 mΩ typical on-resistance. Its data sheet (Rev. 2.3) gives, at 50 V and 40 A: $Q_{gd}$ = 6 nC, a plateau of 4.8 V, $V_{th}$ = 3 V, $R_{g,int}$ = 1 Ω and $C_{iss}$ = 2.12 nF at 50 V (its capacitance curve, Diagram 11). Its switching times are measured with $R_{g,ext}$ = 3 Ω and a 0 to 10 V drive. With $R = 3 + 1 = 4$ Ω (no driver resistance) and $\tau = 4 \times 2.12\,\text{n} = 8.5$ ns: | Quantity | Hand estimate | Voltecx simulation | Data sheet (Table 5) | |---|---|---|---| | $t_{d,off}$ | 6.2 ns | 9.6 ns | 24 ns | | $t_f$ (drain voltage rising) | 5.0 ns | 5.5 ns | 6 ns | | $t_{d,on}$ | 3.0 ns | 6.8 ns | 13 ns | | $t_r$ (drain voltage falling) | 4.6 ns | 2.8 ns | 5 ns | The simulation is the `doublePulse` example with this MOSFET at the dynamic switching level, at 50 V and 40 A, with the delays and edges read by the usual 10 % and 90 % points (from 90 % or 10 % of the gate voltage to 10 % or 90 % of the drain voltage). The edge times agree within a nanosecond or two. The delays are shorter than the data sheet's. The bench has an ideal driver and no inductance in the gate or source path, while the data sheet's figures come from Infineon's own test fixture, so the two are not measured the same way. For a timing budget, use the data sheet's numbers, or your own measured ones. ![Turn-off of the BSC070N10NS5 in Voltecx at 50 V and 40 A with 3 Ω: the gate command, the gate-source voltage vgs falling to the Miller plateau while the drain voltage vds rises, and the drain current id.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/gate-signal-timing-propagation-delay-blanking/turn-off-edge.svg) At turn-off the plateau is plain to see: the gate stops near 4.6 V while the drain voltage rises from 0 to 50 V, and the current only falls once the drain has reached the supply. The drain voltage rises slowly at first and then fast, because the output capacitance is large at low voltage and small at high voltage. ![Turn-on of the BSC070N10NS5 in Voltecx: the gate rises past the threshold, the drain current overshoots to 124 A while the upper body diode recovers and the upper device's output capacitance charges, and the drain voltage falls during the plateau.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/gate-signal-timing-propagation-delay-blanking/turn-on-edge.svg) ### The gate resistor sets the edge Sweep the gate resistor and the edges follow almost a straight line. The simulated fall time lies within 10 % of $Q_{gd} R / V_{pl}$ from 3 Ω up; the rise time is shorter than its formula, which makes the formula a safe upper bound for the turn-on. ![Fall time tf and rise time tr of the BSC070N10NS5 in Voltecx against the external gate resistor, with the estimates Qgd·R/Vpl and Qgd·R/(Vdrv − Vpl).](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/gate-signal-timing-propagation-delay-blanking/edge-time-vs-rg.svg) At 10 Ω the simulation gives 13.9 ns for the fall and 9.3 ns for the rise. A larger resistor gives slower edges, less ringing and less EMI, at the cost of switching loss and a longer delay, which the dead time then has to cover. ## Step 3: the effective dead time The dead time is programmed in the PWM peripheral as a delay between one gate turning off and the other turning on. The switches see something else: $$t_{dead,eff} = t_{dead} + t_{pd,on}^{HS} - t_{pd,off}^{LS} + t_{0 \to V_{th}}^{HS} - t_{V_{drv} \to V_{th}}^{LS}$$ In words: the programmed dead time, plus the high side's turn-on delay, minus the low side's turn-off delay, plus the time the high side's gate needs to reach the threshold, minus the time the low side's gate needs to fall to it. The last term is the big one: the low side is not off until its gate has fallen below the threshold. ### Worked example: a 48 V half bridge Two BSC070N10NS5 in the `buckSync` example at 48 V and 20 A, driven 0 to 10 V through 3 Ω, with the UCC27211's typical 20 ns delay on every edge and 30 ns of programmed dead time. At the high side's turn-on, simulated: - The low side's gate takes 12.8 ns to fall from 10 V to its 3 V threshold. - The high side's gate reaches its threshold about 3 ns after its 30 ns dead time and 20 ns delay end. - The effective dead time is **20.3 ns**, not 30 ns. Now let the low side's turn-off be 17 ns late, the UCC27211's full delay matching: - The effective dead time drops to **3.3 ns**. - With 20 ns programmed, the switches **overlap by 13 ns**: shoot-through. The high side's current peaks at 140 A instead of 77 A. ![The gate-source voltages of the low and the high side and the switch node in Voltecx at the high side's turn-on, with matched driver delays and with the low side's turn-off 17 ns late; the line is the 3 V threshold.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/gate-signal-timing-propagation-delay-blanking/effective-dead-time.svg) The figure shows a second effect. When the switch node rises, the low side's gate is pulled back up through its gate-drain capacitance: to 2.9 V with matched delays, just below its 3 V threshold, and to 4.3 V, above it, when the gate was still on its way down. This *Miller turn-on* is why fast half bridges use a negative turn-off voltage, a low turn-off resistance or an active Miller clamp. Swept over the programmed dead time, the picture is simple: the matched bridge needs about 10 ns before the switches stop overlapping; with the 17 ns mismatch it needs 26.5 ns. ![Effective dead time and peak high-side current in Voltecx against the programmed dead time, with matched driver delays and with a 17 ns mismatch.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/gate-signal-timing-propagation-delay-blanking/dead-time-sweep.svg) `design.gateDrive` makes the same check from the data sheets alone: for this bridge with the UCC27211 it requires at least 17 ns of matching plus the 5.1 ns turn-off edge, 22.1 ns, and reports 7.9 ns of margin for the programmed 30 ns. ## Step 4: leading-edge blanking A peak-current-mode controller or an over-current comparator watches the switch current. The trouble is that every hard turn-on starts with a current spike: the switch has to charge the output capacitance of the other switch and sweep out the reverse-recovery charge of its body diode. In the double-pulse bench the BSC070N10NS5 turns on into 40 A with the upper body diode recovering (trr 53 ns and Qrr 89 nC in the data sheet), and the drain current peaks at **124 A** for a few nanoseconds. The bench has no stray inductance, so in a real layout the spike is lower, wider and rings. A comparator set at 43 A sees that spike and trips, even though the real current is 40 A. **Leading-edge blanking** (LEB) ignores the comparator for a fixed time after each turn-on command. In the figure the blanking is a 100 ns pulse started by the gate command, and the trip is the comparator AND NOT the blanking. ![Leading-edge blanking in Voltecx: the drain current id with its turn-on spike and the 43 A threshold, the comparator without blanking, the 100 ns blanking pulse, and the blanked trip signal.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/gate-signal-timing-propagation-delay-blanking/leading-edge-blanking.svg) Without blanking, the comparator trips a few nanoseconds after the turn-on. With it, the false trip disappears, and the comparator still trips when the current really reaches 43 A, about 0.39 µs after the turn-on, as the inductor ramps at 50 V / 6.19 µH = 8.1 A/µs. How long should the blanking be? Long enough to cover the spike and its ringing (look at your own waveform), and no longer, because during the blanking the protection is blind. An RC filter in the sense line does the same job but delays *every* reading, the real fault included. ## Step 5: minimum on-time and off-time All of this sets a floor on the shortest pulse the converter can make. In a peak-current loop the switch cannot turn off before the blanking ends, so roughly $$t_{on,min} \approx t_{LEB} + t_{pd} + t_{d,on} + t_r = 100 + 20 + 6.8 + 2.8 \approx 130\ \text{ns}$$ At 500 kHz that is 6.5 % of the period. A 48 V to 3.3 V buck needs $D = 3.3/48 = 6.9$ %: it just fits. At 1 MHz the minimum is 13 %, so the controller cannot make the pulse it needs and starts skipping pulses or loses regulation. The **minimum off-time** has the same kind of floor: two dead times, the edges, and in a bootstrapped high side the time the low side needs to stay on to recharge the bootstrap capacitor. It limits the maximum duty cycle. ## The timing budget of the example | Item | Value | Source | |---|---|---| | Driver delay, typical | 20 ns | UCC27211 data sheet | | Driver delay matching, max | 17 ns | UCC27211 data sheet | | Low-side gate fall from 10 V to 3 V | 12.8 ns | Voltecx simulation | | Turn-off edge | 5.1 ns | `design.gateDrive` | | Dead time needed (matching + edge) | 22.1 ns | `design.gateDrive` | | Programmed dead time | 30 ns | design choice | | Effective dead time, matched / worst case | 20.3 / 3.3 ns | Voltecx simulation | | Turn-on current spike | 124 A for a few ns | Voltecx simulation | | Leading-edge blanking | 100 ns | design choice | | Minimum on-time | about 130 ns | sum above | ## Common mistakes - **Using the typical propagation delay for the dead time.** The dead time must cover the worst-case *difference*: matching, turn-on against turn-off, and part-to-part spread. - **Forgetting the gate's own fall time.** The low side is not off when the driver output switches; it is off when its gate falls below the threshold, 12.8 ns later in the example. - **Raising the gate resistor late in the project.** It slows the edges for EMI, but it also lengthens the delays, and the dead time that was fine is now too short. - **Ignoring the Miller turn-on.** A fast-rising switch node can turn the "off" switch back on through its gate-drain capacitance. Check the off-state gate voltage at the other switch's edge. - **Blanking too long, or filtering instead.** A long blanking or a heavy RC filter blinds the protection during every turn-on, and a short circuit at turn-on is the case it most needs to catch. - **Forgetting the minimum on-time at high step-down ratios.** Check $D_{min} = t_{on,min} f_{sw}$ against the lowest duty your converter needs, at the highest input voltage. ## A step-by-step timing budget 1. List every block from the controller pin to the gate: isolator, driver, gate resistor. 2. For each, take the minimum and maximum delay from its data sheet, plus the channel matching. 3. Estimate the gate edges with $Q_{gd} R/(V_{drv} - V_{pl})$ and $Q_{gd} R/V_{pl}$, and the delays with $\tau \ln(\cdot)$. 4. Compute the effective dead time in the worst case and keep it positive with margin. 5. Simulate one edge with the device's gate charge and capacitances and look at the off-switch's gate. 6. Set the blanking from the turn-on spike, then compute the minimum on-time and check it against the lowest duty. ## Try it in Voltecx - A MOSFET at **`level` `dynamic`** follows its gate drive, gate charge and capacitances. Give it a library `device` (such as `infineon/bsc070n10ns5`, with its threshold, plateau, Qgd and capacitance curves from the data sheet), the drive voltages `von` and `voff`, the resistors `rgon` and `rgoff`, and the source inductance `lcs`. The `tdon` and `tdoff` parameters add a turn-on and a turn-off delay, which is how the driver delays and their mismatch are modelled here. - The **`doublePulse`** example is the clamped inductive bench the data sheets measure switching with; `buckSync` is a half bridge with `deadtime` blocks. - **`design.gateDrive`** picks a driver from the catalogue for every switch, sizes the gate resistors, the bootstrap capacitor and the drive power, and checks the dead time against the driver's delay matching plus the turn-off edge. - **`analysis.softSwitching`** classifies every turn-on and checks the dead time against the measured switch-node swing; **`analysis.losses`** gives the switching loss per device. - Leading-edge blanking is three blocks: a `comparator` on the current, a `monostable` triggered by the gate command, and an `and` with the blanking inverted by a `not`. See [design tools](https://voltecx-web.nguyenvanqui291.workers.dev/features/design-tools) and [models and parts](https://voltecx-web.nguyenvanqui291.workers.dev/features/models-and-parts). --- # Heatsink selection: thermal resistance budget, interface pads and Zth URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/heatsink-selection-thermal-design/ To choose a heatsink, work backwards from the junction: the heatsink may have at most $R_{th(s-a)} = (T_{j,max} - T_a)/P - R_{th(j-c)} - R_{th(c-s)}$, and when several devices share it, the hottest junction sets the limit with the total heat on the sink. For the 400 V to 200 V, 1.6 kW buck of this article, a SiC MOSFET losing 5.08 W and a SiC Schottky diode losing 4.91 W on one heatsink at 40 °C may use at most 6.59 K/W to stay at 125 °C; an Ohmite RA-T2X-64E at 4.07 K/W keeps both junctions near 100 °C in still air. A 20 ms overload that would cook the parts if it lasted (190 °C) only lifts them by 10 K and 24 K, because the transient thermal impedance $Z_{th}$ at 20 ms is a fraction of the steady-state resistance. ## Heat flows like current The steady-state thermal model is Ohm's law with temperature for voltage and watts for current. Each interface between the die and the air is a thermal resistance in kelvin per watt: - $R_{th(j-c)}$, junction to case: inside the package, from the device data sheet; - $R_{th(c-s)}$, case to sink: the thermal interface material (TIM) between the tab and the heatsink, a pad, grease or a phase-change film; - $R_{th(s-a)}$, sink to ambient: the heatsink itself, from its data sheet, for your airflow. With the power $P$ flowing through the chain, the junction sits at $$T_j = T_a + P\,\big(R_{th(j-c)} + R_{th(c-s)} + R_{th(s-a)}\big)$$ and the heatsink you need is the resistance left over when the junction is at its limit: $$R_{th(s-a)} \le \frac{T_{j,max} - T_a}{P} - R_{th(j-c)} - R_{th(c-s)}$$ This is the form found in N. Mohan, T. M. Undeland and W. P. Robbins, *Power Electronics: Converters, Applications and Design*, 3rd ed., chapter 29 (component temperature control and heat sinks). Three choices hide in it, and each one moves the answer a lot: - **$T_{j,max}$ is your design limit, not the absolute maximum rating.** Both parts below are rated to 175 °C; this article designs for 125 °C, the junction limit the derating checks of Voltecx use by default. The 50 K between them is the margin for a hot day, a dusty filter and the part-to-part spread of the losses. - **$T_a$ is the air at the heatsink**, inside the enclosure, not the room. 40 °C is a common figure for a closed box in an office. - **$P$ is the loss at the hot operating point.** The on-resistance of a MOSFET rises with temperature, so the loss at 100 °C is larger than at 25 °C. Use the loss at the temperature you expect, or let the simulation iterate. ## Several devices on one heatsink When two or more devices sit on the same heatsink, each has its own junction-to-case and case-to-sink drop, but they all share the heatsink's rise, which carries the sum of the losses: $$T_{j,k} = T_a + R_{th(s-a)} \sum_i P_i + P_k\,\big(R_{th(j-c),k} + R_{th(c-s),k}\big)$$ The limit for the heatsink is the smallest of the per-device answers: $$R_{th(s-a)} \le \min_k \frac{T_{j,max} - T_a - P_k\,(R_{th(j-c),k} + R_{th(c-s),k})}{\sum_i P_i}$$ Picture a water tank (the heatsink) with one drain (the air) and several taps filling it (the devices). Each tap has its own narrow pipe into the tank (its $R_{th(j-c)} + R_{th(c-s)}$); the level in the tank depends on all the taps together, and the pressure at each tap is the tank level plus its own pipe drop. ## The worked example The circuit is an open-loop buck from 400 V to 200 V at 8 A (1.6 kW, 25 Ω load), 50 kHz at a duty cycle of 0.5, with a 1 mH inductor and a 20 µF output capacitor. Both semiconductors are TO-247 parts from the Voltecx device library, each with its data sheet cited: - **Q1: Wolfspeed C3M0060065D**, a 650 V, 60 mΩ SiC MOSFET (data sheet Rev. 07, September 2024). Its conduction curves come from Fig. 5, its switching energies at 400 V from Fig. 23, and its junction-to-case Foster chain from the transient thermal impedance of Fig. 21, which sums to 0.99 K/W. - **D1: Infineon IDW20G65C5**, a 650 V, 20 A SiC Schottky diode (data sheet Rev. 2.2, 2013-01-15). Its forward curves come from Table 8 and its chain from the single-pulse curve of Table 10, which sums to 1.29 K/W against the 1.3 K/W maximum of Table 4. ![The buck of this article in Voltecx. Top: the power stage, with the load step R2 and S2 on the right and the PWM and the overload timer above it. Bottom: the thermal network. Each device puts its losses into its own case net (cq, cd) through its junction-to-case chain from the device library; a Sil Pad joins each case to the heatsink HS1, whose heat capacity is Chs, and HS1 goes to the 40 °C ambient.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/heatsink-selection-thermal-design/buck-heatsink.svg) ### Step 1: the losses The simulation starts at the thermal steady state (`thermalStart` set to `steady`: a short pre-run measures each device's average loss, the thermal network is solved for its DC operating point, and the two are iterated until they agree), then runs 4 ms at a fixed 100 ns step. Averaged over the last 2 ms: | | Loss | |---|---| | Q1, conduction and switching | 5.08 W | | D1, conduction | 4.91 W | | On the heatsink | 9.99 W | A SiC Schottky diode has no reverse recovery, so D1 loses only its forward drop; Q1's switching energies come from the data sheet's curves at its current. ### Step 2: the interface pad The case-to-sink resistance depends on the material, its thickness and how hard the device is pressed onto it. The Henkel Bergquist Sil Pad TSP 3500 (TDS, November 2018) lists a TO-220 tab at 2.61 K/W at 10 psi and 1.37 K/W at 200 psi. The sheet gives no TO-247 value, so this example uses the TO-220 figure at the lowest pressure: pessimistic for the larger TO-247 tab, and a clip or screw that really delivers 200 psi will do better. Note the size of it. At 10 psi the pad is 2.61 K/W, more than the junction-to-case resistance of either part. An insulating pad is often the largest single resistance in the chain, and it is the cheapest one to improve: a thinner pad, more pressure, or grease where isolation is not needed. ### Step 3: the budget With $T_{j,max} = 125$ °C and $T_a = 40$ °C: $$R_{th(s-a)} \le \frac{125 - 40 - 5.08 \times (0.99 + 2.61)}{9.99} = 6.68\ \text{K/W} \quad\text{(Q1)}$$ $$R_{th(s-a)} \le \frac{125 - 40 - 4.91 \times (1.29 + 2.61)}{9.99} = 6.59\ \text{K/W} \quad\text{(D1)}$$ The diode sets the limit: the heatsink may have at most 6.59 K/W. ### Step 4: read the heatsink data sheet at your power A heatsink data sheet usually gives a curve of temperature rise against dissipated power, and a one-line "thermal resistance" taken from it. In still air the curve is not a straight line: a hotter heatsink convects and radiates better, so its resistance falls as the power rises. The Ohmite RA-T2X-64E (F and R Series catalogue, page 176; 63 g, for TO-220, TO-218 and TO-247) is listed at 3.1 °C/W, but its rise curve reads 5.06 K/W at 5 W, 4.07 K/W at 10 W and 3.04 K/W at 19 W. Read it at the heat it will carry: 4.07 K/W at 10 W. ![The sink-to-ambient resistance read off the data sheets' rise curves by thermal.placeHeatsink: the Ohmite RA-T2X-64E in still air, and the Same Sky HSE17-252525P (20 g) in still air and at 1 m/s (200 LFM).](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/heatsink-selection-thermal-design/heatsink-rth-vs-power.svg) Airflow changes everything. The smaller Same Sky HSE17-252525P (data sheet rev. 1.01, 2025-11-17, 20 g) is 10.9 K/W at 10 W in still air, but 4.25 K/W at 200 LFM (1 m/s). ### Step 5: check the junctions With the RA-T2X-64E at 4.07 K/W: $$T_s = 40 + 9.99 \times 4.07 = 80.7\ ^\circ\text{C}$$ $$T_{j,Q1} = 80.7 + 5.08 \times (0.99 + 2.61) = 98.9\ ^\circ\text{C}, \qquad T_{j,D1} = 80.7 + 4.91 \times (1.29 + 2.61) = 99.8\ ^\circ\text{C}$$ The simulation agrees within 0.1 K: the heatsink at 80.7 °C, the cases at 94.0 °C and 93.5 °C, and the junctions at 99.0 °C and 99.9 °C. That leaves 25 K to the 125 °C design limit, and 75 K to the 175 °C rating. The alternatives, from the same formulas and the same losses: - **One HSE17-252525P for both parts in still air:** 10.87 K/W at 10 W puts D1 at 168 °C. It fails. - **The same HSE17 at 1 m/s:** 4.25 K/W, D1 at 101.6 °C. A 20 g heatsink with a fan does what the 63 g one does in still air. - **One HSE17 per part in still air:** each reads 11.8 K/W at its own 5 W, and the junctions reach 118.3 °C (Q1) and 117.4 °C (D1). Two 20 g heatsinks pass where one does not, because each one carries only half the heat and the rise curve is read at that half. - **The pad at 200 psi instead of 10 psi:** the simulation gives 92.5 °C and 93.6 °C, 6.5 K and 6.3 K cooler, for the price of a better clip. ### Step 6: sweep the heatsink The budget treats the losses as fixed. The simulation does not: as the heatsink gets worse, the junction gets hotter, the MOSFET's on-resistance rises and so does its loss. Sweeping the heatsink resistance from 1 to 8 K/W shows both. ![The junction temperatures against the heatsink resistance: the formula with the losses of the 4.07 K/W point held fixed (lines), and Voltecx runs from the thermal steady state (points), with the 125 °C design limit and the chosen heatsink marked.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/heatsink-selection-thermal-design/tj-vs-heatsink.svg) At 1 K/W the run is 0.7 K cooler than the formula (Q1 at 67.6 °C against 68.3 °C), because the losses are lower at that temperature; at 8 K/W it is 3 K hotter (141.3 °C against 138.2 °C). The simulated junctions cross 125 °C at 6.44 K/W (D1) and 6.51 K/W (Q1), a little below the 6.59 K/W of the hand budget. The difference is small here because SiC MOSFETs have a mild temperature coefficient, but it is in the unsafe direction, so a heatsink chosen right at the hand-calculated limit runs slightly hotter than planned. ## Transient thermal impedance: why a short overload is gentler A data sheet gives $R_{th(j-c)}$ as one number, and also a curve: the transient thermal impedance $Z_{th(j-c)}(t)$, the junction's rise per watt a time $t$ after a step of power, with the case held at a fixed temperature. It starts near zero (the die has heat capacity and needs time to warm) and climbs to $R_{th(j-c)}$ after the slowest time constant of the package. JEDEC JESD51-14 (the transient dual interface method) standardises how $R_{th(j-c)}$ is read from such transient measurements. Manufacturers fit the curve with a **Foster** network, a series of parallel RC pairs: $$Z_{th}(t) = \sum_i R_i\,\big(1 - e^{-t/\tau_i}\big)$$ For the C3M0060065D the library's four stages are 0.419 K/W at 17.8 ms, 0.493 K/W at 1.78 ms, 0.062 K/W at 56 µs and 0.016 K/W at 1.8 µs. That gives $Z_{th} = 0.313$ K/W at 1 ms, 0.749 K/W at 10 ms, 0.854 K/W at 20 ms and 0.988 K/W at 100 ms, against 0.99 K/W in steady state. A Foster network is a curve fit: its inner nodes have no physical meaning, and it only describes the device with its case held at a fixed temperature. Chained to a heatsink that itself stores heat, it would deliver heat to the heatsink instantly, which is wrong. The physical form is the **Cauer** ladder, a chain of resistances with a heat capacity from each node to the reference, which can be connected in series with the case, the pad and the heatsink. Infineon's application note AN2008-03, *Thermal equivalent circuit models*, explains both. Voltecx keeps a device's chain as Foster when its other side has no heat capacity (as in the Zth test below) and converts it to the equivalent Cauer ladder when it does (as in the buck, where the case connects through the pad to a heatsink with mass). ![The C3M0060065D's junction-to-case Zth from its Foster chain (line), and a Voltecx run of a 10 W step into that chain with the case held at 25 °C (points), within 1 % from 10 µs on. The 20 ms of the overload below is marked.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/heatsink-selection-thermal-design/zth.svg) ### The overload in the simulation From the steady state at 8 A, the load doubles to 16 A for 20 ms (R2 switches in at 10 ms and out at 30 ms). The losses jump: Q1 from 5.08 W to 14.84 W, D1 from 4.92 W to 13.11 W. ![A 20 ms overload, simulated from the thermal steady state: the junctions T(Q1.j) and T(D1.j), the cases T(cq) and T(cd), and the heatsink T(hs). The heatsink does not move; the diode's case does.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/heatsink-selection-thermal-design/overload.svg) - **Q1's junction** rises from 98.9 °C to 108.8 °C. A hand estimate of the die alone, $\Delta P \cdot Z_{th(j-c)}(20\ \text{ms}) = 9.76\ \text{W} \times 0.854\ \text{K/W} = 8.3$ K, assumes the case holds still; here the case warms by 3.0 K during the pulse, and the run, with heat flowing into the pad, gives 9.9 K. - **D1's junction** rises from 100.1 °C to 124.1 °C. Its chain is fast (its largest time constant is 3.2 ms), so after 20 ms the diode is already at its full junction-to-case rise, and its case climbs 15.0 K because the pad holds no heat of its own. - **The heatsink** moves by less than 0.01 K. With 57 J/K of aluminium (63 g at about 0.9 J/(g·K), Incropera, DeWitt, Bergman and Lavine, *Fundamentals of Heat and Mass Transfer*, 7th ed., Table A.1) and 4.07 K/W, its time constant is $C \cdot R = 232$ s, about four minutes. If the overload were held, the steady-state formula would apply: with the 12.5 Ω load from the start, the run settles with 16.0 W in Q1 and 14.1 W in D1, the heatsink at 131 °C (it reads its rise curve at that heat, so it is cooler than 4.07 K/W would give) and both junctions near 190 °C (188.9 °C and 186.3 °C), far past the 175 °C rating, and Voltecx reports an over-temperature for both. The same parts that ride through 20 ms with 50 K to spare would pass their rating within minutes if the overload stayed. That is the rule for pulses: for a pulse shorter than the heatsink's time constant, only the impedances that have time to respond count. A 20 ms surge is a junction-and-package problem; a 10 minute overload is a heatsink problem. Size the heatsink for the continuous load (and for the longest overload that lasts minutes), and check short pulses against $Z_{th}$. ## Common mistakes - **Using the room temperature for $T_a$.** The air at the heatsink inside a closed box is warmer than the room; measure it or take it from the product's specification. - **Reading the heatsink at the wrong power.** A natural-convection heatsink is worse at low power than its one-line rating; read its curve at the heat it will carry. - **Forgetting the pad.** An insulating pad at low pressure can be larger than $R_{th(j-c)}$. Check the pressure your clip or screw actually delivers. - **Adding the losses of shared devices only once.** On a shared heatsink, every device's junction sees the heatsink rise from all of them. - **Designing to the absolute maximum $T_j$.** Leave margin for the spread of the losses, the ambient and ageing. - **Chaining Foster networks.** Connect a data sheet's Foster chain only to a fixed temperature; for a full stack-up, use Cauer form. ## How to do it in Voltecx 1. Give each switch and diode its device: select the part and set `device` (**Circuit › Parameters**, `circuit.setParam`), for example `wolfspeed/c3m0060065d`. Its losses then follow the data-sheet curves and its junction-to-case chain comes with it. Set the part's `thermal` parameter to the net of its case (`cq`). 2. Draw the rest of the thermal path with thermal parts (**Circuit › Add Component**, `circuit.addComponent`): `rth` for the pad, `cth` for a heat capacity, `ambient` for the air, and `foster`, `cauer` or `zth` for a chain of your own. 3. Place a catalogue heatsink with **Design › Design Steps › Place Heatsink** (`thermal.placeHeatsink`): give the part number, the heat and the airflow, and it reads the data sheet's rise curve and cites it. 4. In **Simulation › Settings** (`simulation.settings`), set `thermalStart` to `steady` to start at the thermal operating point, so a short run shows the steady temperatures; `stopOnOverTemperature` ends a run at the first junction past its limit. 5. Run (**Simulation › Run Simulation**), then read **Analysis › Thermal** (`analysis.thermal`) for every temperature with its limit and margin, and **Analysis › Losses** (`analysis.losses`) for the loss of each device. 6. **Analysis › Parameter Sweep** (`analysis.paramSweep`) over a variable used as the `rth` of a plain heatsink (one without the rise table, which `thermal.placeHeatsink` writes and which the run reads instead of `rth`) gives the curve above. 7. **Design › Design Steps › Thermal** (`design.thermal`) works the budget for every device and proposes a catalogue heatsink and pad for each TO-220 or TO-247 part, or the copper area for an SMD part. ## Frequently asked questions ### What is a good heatsink thermal resistance? There is no single good value: it is whatever is left of $(T_{j,max} - T_a)/P$ after the junction-to-case and interface resistances. For the 10 W of two TO-247 parts here, at 40 °C ambient and a 125 °C limit, it was 6.6 K/W. More heat or a worse pad shrinks it quickly, and below a few kelvin per watt in still air the heatsink gets large; that is where a fan pays. ### Can two devices share one heatsink? Yes, if they can share its potential: an insulating pad (or an isolated package) for each device whose tab is not at the heatsink's voltage. The heatsink must then take the sum of the losses, and each junction adds its own drop on top of the shared rise. ### Why is my junction cooler than the formula after a short overload? Because the formula is the steady state. For a pulse much shorter than the slowest thermal time constant, the junction rise is $\Delta P \cdot Z_{th}(t_{pulse})$, which is smaller than $\Delta P \cdot R_{th}$. In this example a 20 ms overload added 10 K to the MOSFET, where holding it would have taken the junction past 200 °C. ### Is thermal grease better than a pad? Usually it has a lower resistance, but it does not insulate. Where the tab is at a high voltage, use an insulating pad or film and press it hard, or choose a package with an isolated tab. --- # How a power converter starts up, step by step: inrush, precharge, UVLO, soft start and pre-bias URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/power-converter-startup-sequence/ A converter spends almost all of its life in steady state, and that is where most design effort goes: ripple, losses, loop gain. But the few milliseconds after you plug it in are where many converters fail. In that time the capacitors are empty, the controller has no supply yet, and the feedback loop has nothing to regulate. A converter that is fine at full load can still blow its fuse, weld its relay, overshoot its output or switch itself off and on again during start-up. This article walks through the start-up as a numbered timeline, from the plug to "power good". Each step has the reason it exists, the numbers that size it, and a Voltecx simulation that shows what happens with and without it. The examples use a 12 V to 5 V, 2 A synchronous buck built around an LM5145-class controller, a 400 V DC-link precharge, and the PLL of a grid-tied inverter. ## The intuition: starting a car, not just driving it Think of starting a car on a cold morning. You don't turn the key and floor the pedal. The battery first has to crank the engine, the engine needs a moment to run on its own, you wait until the oil pressure light goes out, and only then do you pull away gently. If you skip a step, nothing explodes at once, but you wear out something expensive. A converter is the same: - the **input capacitors** are like the engine: they need a controlled push to get going (inrush and precharge); - the **controller** must have a healthy supply before it does anything (bias supply and UVLO); - the **output** must be brought up gently (soft start), without disturbing anything that is already there (pre-bias); - and the rest of the system waits for a signal that all is well (power good, PLL lock) before it draws power. ## The timeline at a glance 1. **Plug in: inrush.** The input capacitors charge from the source. Something must limit that current. 2. **Precharge and bypass.** On a large DC link, a resistor charges the capacitor, then a relay or contactor shorts the resistor. 3. **Bias supply.** The controller and gate drivers get their own low-voltage supply. 4. **UVLO.** The controller waits until the input is high enough, with hysteresis, so a sagging input does not make it chatter. 5. **Enable the gate drivers.** Switching starts at zero duty. 6. **Soft start.** The reference ramps from zero, so the output and the inductor current rise in a controlled way. 7. **Pre-bias check.** If the output already holds a voltage, the converter must not pull it down. 8. **Closed-loop takeover.** At the end of the ramp the loop regulates against the fixed reference. 9. **Power good.** Once the output is inside its window, a flag tells the downstream circuits they may start. 10. **For grid-tied and AC converters:** the PLL locks to the grid and the DC link is precharged before the PFC or the inverter switches. Shutdown runs the same list backwards: power good drops first, the load is told to stop, the switching stops, and the capacitors are discharged. The first figure shows steps 4 to 9 in one Voltecx run of the 12 V to 5 V buck while its input ramps up from 0 to 12 V in 3 ms. ![The 12 V to 5 V LM5145-class buck in Voltecx while its input ramps up: the input v(vin) and output v(out), the EN pin with its 1.2 V threshold, the soft-start capacitor v(ss) with the 0.8 V reference, and PGOOD.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/power-converter-startup-sequence/timeline.svg) Read it from top to bottom and left to right: - The input rises at 4 V/ms. The EN pin sees the input through a 65 kΩ over 10 kΩ divider, so it reaches the controller's 1.2 V threshold when the input is at $1.2 \times 75/10 = 9.0$ V. In the run that happens at 2.25 ms. - The small step on EN right after it crosses is the hysteresis current switching on (more on that below). - The soft-start pin then charges at $10\ \mu\text{A} / 12.5\ \text{nF} = 0.8$ V/ms. The error amplifier regulates to the lower of SS and the 0.8 V reference, so the output follows the ramp and arrives 1.06 ms later, without overshoot. - PGOOD goes high at 3.25 ms, when the output is at 4.71 V: the feedback pin has passed 94 % of the reference and the 25 µs filter has run. The controller values (1.2 V EN threshold, 10 µA hysteresis current, 10 µA soft-start current, 0.8 V reference, the 92 % and 94 % power-good thresholds and the 25 µs filter) are the typical values of the TI LM5145 data sheet, SNVSAI4B, section 7.5, which is where the Voltecx model takes them from. ## Step 1: plugging in, and the inrush current At the moment you connect the source, the input capacitor is empty. An empty capacitor behaves like a short circuit, so the only things limiting the current are the resistances in the path: the source, the cable, the connector, the capacitor's ESR. Those add up to tenths of an ohm, sometimes less. $$I_{peak} = \frac{V_{in}}{R_{path}}$$ For an off-line supply that is hundreds of amperes; the [inrush current and NTC sizing](https://voltecx-web.nguyenvanqui291.workers.dev/blog/inrush-current-ntc-sizing) article works through that case and shows how an NTC thermistor limits it. For a DC input with a large link capacitor (a battery feeding a motor inverter, a 400 V bus) the usual answer is a precharge circuit. ## Step 2: precharging a DC link A precharge circuit puts a resistor $R_{pre}$ in series with the link capacitor $C$ during start-up and shorts it with a relay or contactor once the capacitor is nearly charged. The capacitor charges with the time constant $$\tau = R_{pre}\, C$$ and reaches 95 % after $3\tau$. ### A worked example A 400 V source with 0.1 Ω of wiring charges a 470 µF link through $R_{pre} = 47$ Ω: - **Peak current:** $400 / 47.1 = 8.49$ A, instead of $400 / 0.15 = 2.67$ kA if the link were connected through the contact alone (0.1 Ω of wiring plus the contact's 50 mΩ). - **Time constant:** $47 \times 470\,\mu\text{F} = 22.1$ ms, so 95 % (380 V) is reached after 66.3 ms. - **Energy in the resistor:** charging a capacitor through a resistor always wastes as much energy as it stores, $\tfrac{1}{2} C V^2 = \tfrac{1}{2} \times 470\,\mu \times 400^2 = 37.6$ J, in about 70 ms. - **Peak power in the resistor:** $400^2 / 47 = 3.4$ kW at the first instant. The last two lines are why precharge resistors are chosen from their pulse-energy rating, not their continuous power rating. A 5 W resistor can be fine if its data sheet allows 40 J in a single pulse; a 50 W resistor without a pulse rating may not be. ![Precharge of a 470 µF link from 400 V through 47 Ω in Voltecx: the link voltage v(bus) with the 380 V threshold, the input current, and the relay's close command and contact. The comparator energises the coil at 66.3 ms; the contact closes 10.7 ms later.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/power-converter-startup-sequence/precharge.svg) In the run, a comparator energises the relay coil when the link passes 380 V, at 66.3 ms. The relay in this example is assumed to close 10 ms after its coil is energised; take the real operate time from your relay's data sheet. Counting the coil's own L/R rise, the contact closes at 77.0 ms, with the link at 387.7 V. The last 12.3 V then drop across only 0.15 Ω of wiring and contact, and the input current jumps to 82 A for a fraction of a millisecond. That pulse is the one the relay contacts must survive every time. Waiting longer before closing makes it smaller, at the cost of a longer start-up. The simulated resistor energy is 37.5 J, the formula's 37.6 J less the bit left uncharged when the contact closes. The order matters too: the load (the inverter, the downstream converter) must not start until the bypass has closed. Started earlier, its current flows through the precharge resistor, the link sags and the resistor overheats. ## Step 3: the bias supply The controller, the gate drivers and the sensing amplifiers need a stable low-voltage supply, typically 5 V to 15 V. In a small DC-DC converter this is a linear regulator inside the controller. In an off-line supply it is often a start-up resistor that slowly charges the controller's supply capacitor from the bulk voltage, until an auxiliary winding takes over once the converter switches. In larger systems it is a separate auxiliary converter. Whatever it is, two rules hold: - The gate drivers must hold the switches **off** until their own supply is valid. A gate driver with half its supply voltage drives a MOSFET into its linear region, where it heats up fast. - The bias supply must start before the power stage and stop after it. That is why gate drivers have their own UVLO, separate from the controller's. ## Step 4: UVLO, and why it needs hysteresis An undervoltage lockout (UVLO) keeps the converter off until the input is high enough to run it properly. Below that the duty cycle would saturate, the input current would be too large, and the output would not regulate. The catch is that a converter that starts draws current from its source, and every real source has some resistance. When the converter starts, the input voltage drops. If the turn-off threshold is the same as the turn-on threshold, that drop switches the converter off again, the input recovers, the converter starts again, and so on. This is called chattering or motorboating, and it can go on for as long as the input stays near the threshold. The fix is hysteresis: the converter starts at $V_{on}$ and only stops below a lower $V_{off}$. On the LM5145 the EN pin does both jobs. A divider $R_1$ (top) and $R_2$ (bottom) sets the start, and a 10 µA current that flows out of EN once the controller is on sets the hysteresis: $$V_{on} = 1.2\ \text{V} \times \left(1 + \frac{R_1}{R_2}\right), \qquad V_{off} = V_{on} - I_{hys}\, R_1$$ The hysteresis is set by $R_1$ alone, so a larger divider gives a wider window for the same start voltage: | Divider | $V_{on}$ | Hysteresis $I_{hys} R_1$ | $V_{off}$ | |---|---|---|---| | 65 kΩ / 10 kΩ | 9.0 V | 0.65 V | 8.35 V | | 250 kΩ / 38.3 kΩ | 9.03 V | 2.5 V | 6.53 V | ### The run The source rises slowly, at 0.5 V/ms, behind 1.5 Ω (a long cable or a weak supply). The converter delivers 10 W into its load once it is up. ![The same buck fed from a slowly rising source behind 1.5 Ω, with two EN dividers that both start at 9 V. With 0.65 V of hysteresis the input dips below 8.35 V at each start and the converter restarts four times; with 2.5 V it starts once.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/power-converter-startup-sequence/uvlo-hysteresis.svg) - **0.65 V of hysteresis:** each start pulls the input below 8.35 V, the controller stops, its soft-start capacitor is discharged, the input recovers above 9 V and it starts again. The run counts four soft starts; the output only stays up at 5.74 ms, when the source has risen far enough to carry the load. - **2.5 V of hysteresis:** one start. The input sags to 7.2 V while the output comes up, still above the 6.53 V turn-off point, and the output is regulating at 3.16 ms. How much hysteresis you need follows from the source: at least the drop $I_{in} R_{source}$ at full load and the lowest start voltage, plus margin for the input ripple. ## Step 5: enabling the gate drivers Once UVLO releases, the controller starts switching, but at zero duty and with the soft-start capacitor empty. Two details matter here: - **Bootstrap capacitors.** A high-side driver fed from a bootstrap capacitor needs the low-side switch to turn on first to charge it. Many controllers do this with a few low-side pulses before the first high-side pulse. - **Digital controllers.** In firmware, the PWM outputs must be configured as off (or high-impedance with pull-downs on the gates) before the timers start, and the duty must start at zero, not at the last value the code computed. ## Step 6: soft start Why not just let the loop run against the full reference from the start? Because the output capacitor is empty and the loop asks for full output voltage at once. The error amplifier saturates, the duty goes to its maximum, and the inductor current rises until something stops it. During a linear soft start of length $t_{ss}$, the output capacitor needs a charging current on top of the load: $$I_{charge} = C_{out} \frac{V_{out}}{t_{ss}}$$ For the 100 µF output at 5 V and $t_{ss} = 1$ ms, that is 0.5 A. The run measures 0.49 A halfway up. The inductor peaks at 2.71 A (the load, the 0.5 A charging current and half the ripple) and the input current at 1.01 A. ![The buck started with a 1 ms soft start and with a 10 µs one (in effect none): the output, the inductor current and the input current averaged over each switching period.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/power-converter-startup-sequence/soft-start.svg) With the soft start shortened to 10 µs, in effect none: - The valley current limit (3 A, 1.5 times the load current) holds the inductor current, which still peaks at 5.35 A because the limit only acts at the valley of each cycle. - While the limit holds the current, the integrator of the compensator winds up. When the output reaches 5 V the loop is far from where it should be, and the output **overshoots to 6.43 V**, 29 % above its setpoint. - The input current averaged over each period reaches 3.06 A, three times the 1 ms case. That is the "input current hump" a weak source or an input filter sees. With the current limit raised to 20 A the overshoot is smaller (5.34 V), but the inductor current reaches 16.4 A and the input current 13.0 A: enough to saturate an inductor sized for this converter's 3 A limit and to trip the upstream supply. The lesson: **a current limit is not a soft start.** The current limit protects the parts; the soft start is what keeps the output and the input well-behaved. A good soft start time is long enough that $C_{out} V_{out} / t_{ss}$ is a fraction of the load current, and short enough to meet the start-up time in your specification. If the load draws its full current from the start, add it: the inductor carries $I_{load} + I_{charge}$. ## Step 7: pre-biased outputs Sometimes the output is not at zero when the converter starts. A rail may be held up through the ESD diodes of a chip powered from another rail, or the converter may restart after a short interruption before its output capacitor has discharged. This is called a pre-biased output. A synchronous buck has a problem with that. At the start of the soft start the reference is near zero, so the loop asks for a duty near zero, and the low-side switch is on for almost the whole period. It connects the output to ground through the inductor, and current flows **backwards**, out of the output capacitor. ![A start into an output held at 3 V, at a light 0.1 A load: synchronous from the start (blue), and with the low-side switch held off so only its body diode conducts (red).](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/power-converter-startup-sequence/pre-bias.svg) In the run, the output starts at 3 V at a light 0.1 A load: - **Synchronous from the first cycle:** the inductor current goes to −7.4 A and the output collapses to 0.32 V before the soft start brings it back. A processor on that rail would see a brown-out; a battery or a supercapacitor on the output would be discharged into the converter; and the reverse current can trip the converter's own limit. - **Low-side switch held off:** only its body diode can conduct, so no current can flow backwards. The output sags only through its own load, to 2.66 V, until the soft-start ramp reaches it at about 0.6 ms, and then rises smoothly. Controllers with pre-bias support do the second: they keep the low-side switch off (or run it in diode emulation) until the soft-start reference has caught up with the output. The LM5145 is one of them; the Voltecx model leaves this feature out, which is why the first run shows what a controller without it would do. In the second run the low-side MOSFET is disabled and a diode stands in for its body diode for the whole run. ## Step 8: closed-loop takeover At the end of the ramp, the soft-start voltage keeps rising past the reference, and the error amplifier now regulates to the fixed reference. If the ramp was slow compared with the loop's bandwidth, the loop was regulating all along, and the handover is invisible: in the timeline figure, the output simply stops at 5 V. If the loop is slow or the compensator was saturated during the ramp, the takeover shows up as an overshoot or a small dip at the end of the ramp. A digital controller should start its integrator from the value that matches the present output, or hold it until the ramp ends, rather than from zero or from a stale value. ## Step 9: power good Power good (PGOOD, PG) is an open-drain output that is released when the output is inside its window. On the LM5145 it is released when the feedback pin rises past 94 % of the reference, and pulled low again below 92 % or above 108 %, each after a 25 µs filter. Downstream circuits use it: - as the enable of the next regulator (the [rail sequencing](https://voltecx-web.nguyenvanqui291.workers.dev/blog/power-rail-sequencing) article builds a chain of them); - as the reset of a processor, which must not run code on a rail that is still rising; - as a "ready" input of a system controller, which only then enables the load. The filter time matters: without it, a load step that dips the output for a few microseconds would reset the whole system. ## Step 10: grid-tied and AC converters A converter connected to the grid has two extra steps before its power stage may switch: 1. **DC-link precharge.** The DC link of a PFC stage or an inverter is precharged as in step 2, through a resistor or an NTC, and the bypass closes before the stage starts. In a boost PFC, the link charges to the peak of the line through the boost diode even before the PFC switches; the PFC then boosts it to its regulated voltage under soft start. 2. **PLL lock.** An inverter that feeds current into the grid must know the grid's phase. A phase-locked loop (PLL) measures it, and the inverter's gates stay off until the PLL reports lock. A grid-forming or PFC stage that synchronises to the line works the same way. ![The PLL of the gridTieInverter example in Voltecx: its frequency estimate settling at 50 Hz, and the locked flag rising after 107 ms.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/power-converter-startup-sequence/pll-lock.svg) In the `gridTieInverter` example the PLL starts at 50 Hz, swings to 54.7 Hz while it pulls in the phase, and reports lock (a phase error below 0.02 rad) after 107 ms, about five and a half line cycles. The example lets the inverter run from the first instant; in a product, the gate drivers would be enabled only after that flag. ## Shutdown: the same list, backwards Shutting down is start-up in reverse, and it deserves the same care: 1. Power good goes low as soon as a fault or a turn-off command is seen, so the loads stop first. 2. The converter stops switching, or ramps its reference down if the output must not drop abruptly. 3. Relays open with no current flowing (opening a contactor under DC load draws an arc). 4. The capacitors are discharged, by a bleeder resistor or by an active discharge, so that nobody touches a charged 400 V link. ## Common mistakes - **Choosing the precharge resistor by its continuous power.** It sees $\tfrac{1}{2} C V^2$ in one pulse at every start, and kilowatts at the first instant. Check its pulse-energy rating, and what happens if the bypass relay never closes and the load starts anyway. - **Closing the bypass too early.** In the example, closing at 95 % still drove an 82 A pulse through the contacts. The pulse is the remaining voltage over milliohms. - **UVLO without enough hysteresis.** The hysteresis must exceed the input drop when the converter starts at full load, or the converter chatters on a weak source. - **Relying on the current limit as a soft start.** The run above overshoots by 29 % with the current limit active, and draws three times the input current. - **Forgetting the load in the soft-start current.** The inductor carries the load current plus $C V / t_{ss}$; at full load that sum, not the charging current alone, must stay below the current limit. - **Ignoring pre-bias.** A synchronous converter without pre-bias support discharges whatever sits on its output. - **Starting a digital loop from a stale integrator.** Reset the integrator and start the reference ramp from the measured output, or from zero with the output known to be empty. - **Enabling the inverter before the PLL locks.** The first current pulses go into the grid at the wrong phase. For the lab side of start-up (how to power a new board for the first time, current-limited supplies, what to probe first), see the companion article on [bench-testing tips](https://voltecx-web.nguyenvanqui291.workers.dev/blog/bench-testing-power-converter-tips). The converter analysis follows R. W. Erickson and D. Maksimović, *Fundamentals of Power Electronics*, 3rd ed., and Mohan, Undeland and Robbins, *Power Electronics*. Controller thresholds and currents are from the TI LM5145 data sheet (SNVSAI4B), section 7.5. ## Try it in Voltecx - **The buck in this article** is the LM5145-class synchronous buck application circuit: `circuit.applicationCircuit` with `ic` = `syncBuckController` and `topology` = `syncBuck`. Its `tSs` sets the soft-start capacitor, `vinOn` the EN divider, and `iLimit` the valley current limit. Change `Ren1` and `Ren2` to try the hysteresis table above, and set the source's `pwl` to ramp the input. - **Check a start-up against a spec.** `spec.verify` with `startup: {maxTime, maxOvershootPct}` measures the start-up time into the output band and the overshoot. **Simulation › Test Bench** lists a start-up case, an inrush case (the peak input current into a discharged input) and an under-voltage start case from your spec, and draws the limits on the scope. - **Size the protection.** `design.protection` (**Design › Design Steps › Protection**) takes `startup.maxTime` as the soft-start time and adds the charging current $C V_{out} / t_{ss}$ to the current trip; it also sets the UVLO start and over-voltage trip thresholds from the input and output range, allowing for the tolerance of the divider resistors. `design.inputProtection` (**Design › Design Steps › Input Protection**) sizes the inrush limiter, the fuse and the hold-up capacitance. - **Automatic design.** For a flyback, `design.auto` simulates the power-on at the highest input and full load, with the soft start sized from `startup.maxTime`, and rates every switch and diode over that start-up as well as over the steady state. - **Precharge and PLL.** The relay is a part of its own, with operate and release times, and the `pll` control block has a `locked` output you can wire to the enable of your gate logic. See also the [design tools](https://voltecx-web.nguyenvanqui291.workers.dev/features/design-tools) and [analyses](https://voltecx-web.nguyenvanqui291.workers.dev/features/analyses) pages. --- # How a power supply gets designed, from spec to production URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/power-supply-product-design-flow/ A power supply on a datasheet looks like a few numbers: 12 V in, 3.3 V out, 5 A, 93 % efficient. Behind those numbers sit a dozen design steps, each with its own decisions and its own classic mistakes. Skip one and it comes back later, on the bench, in the EMI chamber or on the production line, where it costs far more to fix. This article walks through the whole flow in order. For each step it says what you decide, the mistake people usually make, and the Voltecx command that does the step. To keep it concrete, every number comes from one automatic design run (`design.auto`) of a real spec, so you can see what each step produced. ## The intuition: building a house Designing a power supply is like building a house: - The **spec** is the client's brief: how many rooms, what climate, what budget. - The **topology** is the floor plan. - **Sizing, magnetics and parts** are the structure: beams, walls and wiring, sized for the loads. - The **control loop** is the heating thermostat: it must react quickly without oscillating. - **Losses, thermal, protection and EMI** are the building codes: fire safety, insulation and noise. - **Tolerances, test plan, layout, prototypes and compliance** are inspections, before and after the walls go up. A change on paper costs an eraser. The same change after the walls are up costs a wrecking crew. That is why the flow front-loads checks: every hour spent simulating corners saves a board spin. ## The example spec Every number below comes from one run of this spec, a 12 V to 3.3 V point-of-load converter: | Requirement | Value | |---|---| | Input | 10.8 to 13.2 V (12 V ± 10 %) | | Output | 3.3 V ± 2 % | | Load | 0.5 to 5 A | | Output ripple | at most 33 mV peak to peak | | Efficiency | at least 90 % at 5 A | | Junction temperature | at most 125 °C | In Voltecx the spec is a small JSON object that `spec.verify`, `spec.feasibility` and `design.auto` all read: ```json { "vin": { "min": 10.8, "nom": 12, "max": 13.2 }, "vout": { "nom": 3.3, "tolPct": 2 }, "iout": { "min": 0.5, "max": 5 }, "ripple": 0.033, "efficiency": 90, "tjMax": 125, "loadStep": false } ``` The run took 77 simulations and passed all its gates. It passed in Voltecx's models: that is a starting point for a prototype, not a safety or compliance result. ## Step 1: requirements **What you decide.** Every number the product must meet, at every corner: input range, output tolerance, load range, ripple, load steps, start-up, efficiency points, ambient temperature, and the standards it must pass. **The typical mistake.** A spec with only the nominal point. A converter that works at 12 V and 5 A may fail at 13.2 V and 0.5 A, or at 50 °C. A missing requirement is never checked. **In Voltecx.** `spec.feasibility` checks the spec against physics bounds before anything is sized. For this spec it found every requirement within reach. At the end of the run, the report lists everything it did *not* check, with the reason. Here that list included start-up, load and line steps, the ambient range and Monte Carlo, all because the spec did not ask for them. Read that list: it is the to-do list for the spec's next revision. ## Step 2: topology **What you decide.** The power stage: buck, boost, flyback, LLC and so on. **The typical mistake.** Picking the topology you used last time, or the one with the fewest parts, without checking stress and efficiency at your numbers. **In Voltecx.** `topology.suggest` ranks the candidates and `design.compare` tabulates their efficiency, stress and part count. For 12 V to 3.3 V at 5 A both pick the synchronous buck. [Which converter topology for my spec?](https://voltecx-web.nguyenvanqui291.workers.dev/blog/which-converter-topology-for-my-spec) covers this step in detail. ## Step 3: power-stage sizing **What you decide.** The switching frequency, the inductor and the capacitors. The inductor follows from the ripple current you allow. With a ripple of 20 % of the 5 A load, $\Delta I = 1$ A: $$L = \frac{(V_{in} - V_{out})\,D}{f_{sw}\,\Delta I} = \frac{(12 - 3.3) \times 0.275}{100\ \text{kHz} \times 1\ \text{A}} = 23.9\ \mu\text{H}$$ The output capacitor follows from the ripple voltage. `design.auto` aims at 70 % of the spec's 33 mV, $\Delta V = 23.1$ mV, to keep margin: $$C = \frac{\Delta I}{8\,f_{sw}\,\Delta V} = \frac{1\ \text{A}}{8 \times 100\ \text{kHz} \times 23.1\ \text{mV}} = 54.1\ \mu\text{F}$$ **The typical mistake.** Sizing for the nominal input. The inductor ripple is largest at the highest input, so the output ripple is too. Here the verification measured 24.7 mV at 13.2 V and full load, inside the 33 mV limit. **In Voltecx.** `design.converter` (**Design › Design Steps › Converter**) computes these values from the template equations and can write them into the circuit. ![The designed converter at 12 V and 5 A in steady state: output voltage with 23.7 mV of ripple, the inductor current with 1.03 A of ripple, and the switch node.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/power-supply-product-design-flow/steady-state.svg) The dips below 0 V on the switch node are the dead time: for 18 ns at each edge the low-side MOSFET's body diode carries the current. The run sizes it from the gate drive: the driver's delay matching and the turn-off edge need 14.2 ns, plus 25 % margin. ## Step 4: magnetics **What you decide.** A catalogue inductor or a custom one, the core, the turns and the wire. **The typical mistake.** Checking the inductance and forgetting the rest: saturation at the worst-case peak current, and the winding resistance (DCR), which sets the copper loss. **In Voltecx.** `magnetics.design` designs a custom inductor from a core catalogue; the run then looks for a catalogue part that meets the same ratings. Here it chose two Coilcraft XAL8080-123MEC (12 µH each) in series for 24 µH, saturating at 8.6 A, and kept a custom ETD 39/20/13 design, wound on its coil former, as the alternative. That choice has a cost the loss breakdown shows at once: the two parts together have 36.4 mΩ of DCR, and at 5 A their copper loses 0.91 W of the converter's 1.10 W. If you need more efficiency, the inductor is the first place to look, not the MOSFETs. ## Step 5: semiconductors and gate drive **What you decide.** The MOSFETs (or diodes), the gate driver, the gate resistors and the bootstrap capacitor. **The typical mistake.** Choosing a switch by its on-resistance alone. A part far over-rated in voltage has more capacitance and switches slower; a part with too little margin fails on the first input surge. **In Voltecx.** `design.parts` (**Design › Design Steps › Parts**) rates every switch and diode against its simulated stress at the input and load corners and proposes the lowest-loss library device that carries it. The run chose an Infineon BSC0906NS for the high side and a BSC0902NS for the low side, with no part beyond its derated rating. The ranking counts each part's gate-drive loss with its conduction and switching loss, so a part with a large gate charge does not win on its on-resistance alone. `design.gateDrive` then picked a UCC27282 half-bridge driver and sized the gate resistors and the bootstrap capacitor. With these MOSFETs the driver's output and each part's own gate resistance already keep the gate current inside the driver's peak rating, so the external gate resistors are 0 Ω. It also reports the gate-drive power, 0.037 W, which `design.efficiency` counts as a fixed loss, so it is in the efficiency figures below. The controller's own supply is not. ## Step 6: the control loop **What you decide.** The control method, the compensator and its crossover frequency and margins. **The typical mistake.** Designing the loop at one operating point and never checking the others, or chasing phase margin while the gain near the LC resonance is barely above 0 dB. **In Voltecx.** `design.voltageLoop` (**Design › Design Steps › Voltage Loop**) designs a PI, Type II or Type III compensator for the power stage in the circuit. The run designs it at the nominal input and full load first, then reads that loop at 13.2 V and 0.5 A, where the light load leaves the output filter least damped: the LC resonance at 4.42 kHz has a Q of 9.9 there, and the loop designed at 12 V and 5 A loses its margins. So the run designs the loop at that corner instead. A PI cannot cross above the resonance with 60° of margin there, so it uses a Type III, and the highest crossover that keeps 60° of phase margin and 6 dB of gain margin is 222 Hz. The loop crosses over at 222 Hz with 90.5° of phase margin and 6.1 dB of gain margin. ![Bode plot of the designed loop at 13.2 V and 0.5 A: the plant Gvd peaks at the 4.42 kHz resonance, and the loop gain T crosses 0 dB at 222 Hz with 90.5° of phase margin.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/power-supply-product-design-flow/loop-bode.svg) Look at the shape of $T$, not just the margins: above the crossover it stays under 0 dB, and at the resonance, where the plant peaks, it is still more than 6 dB under. Crossing far below the resonance is what keeps the light-load corner from ringing. The price is speed: with the crossover at 222 Hz, far below the resonance, the output capacitor, not the loop, has to absorb fast disturbances. The report flags what was not checked: the loop was designed at one point, and the check over every corner was not run, because the spec switched the load step off (`"loadStep": false`; without that field a run checks a default 50 to 100 % step). Add a load step to the spec (2.5 to 5 A, at most 5 % droop) and the run changes course. The PI cannot hold the droop, so `design.robustLoop` takes over: it raises the switching frequency to 315 kHz and the output capacitor to 470 µF, and closes a Type III loop at 6.93 kHz, designed for 70° of phase margin and checked at every input, load and tolerance corner. The faster switching costs efficiency, 92.8 % instead of 93.7 %. The spec drives the design: a requirement you leave out is a cost you never see. ## Step 7: losses and efficiency **What you decide.** Whether the efficiency target is met over the load range, and where the losses go. **The typical mistake.** Quoting the full-load efficiency only. Many products spend most of their life at light load. **In Voltecx.** `design.efficiency` (**Design › Design Steps › Efficiency**) sweeps the load, one simulation per point, and splits the full-load loss by component. ![Efficiency of the designed converter at 12 V against load current, from 95.9 % at 0.5 A to a peak of 96.6 % at 1.5 A and 93.7 % at 5 A.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/power-supply-product-design-flow/efficiency-vs-load.svg) The curve starts at 95.9 % at 0.5 A, peaks at 96.6 % near 1.5 A and falls to 93.7 % at 5 A. At light load the fixed gate-drive loss (0.037 W) weighs most; at heavy load the copper loss, which grows as $I^2$, does. The figure covers the power stage and the gate drive: switches, inductor, capacitors and gate power. The controller's supply and the board copper come on top, and they weigh most at light load, so a real board measures lower there. ## Step 8: thermal **What you decide.** How each hot part gets rid of its heat: board copper, a heatsink or airflow. **The typical mistake.** Checking the junction temperature at 25 °C ambient, or assuming a heatsink that is not on the board. **In Voltecx.** `design.thermal` (**Design › Design Steps › Thermal**) turns each device's simulated loss into a junction temperature and picks the cooling from cited catalogues: for an SMD part, the copper area its data sheet rates it on. At 40 °C ambient, both MOSFETs reach 44 °C, on the copper area each data sheet specifies. Both are far below 125 °C, but the spec gave no ambient range, so 40 °C is a default, not your enclosure. ## Step 9: protection **What you decide.** Current limit, over-voltage and under-voltage thresholds, and how they are sensed. **The typical mistake.** A current limit set from the nominal inductor current. With the inductor 20 % low and the input at its maximum, the normal peak is higher, and a limit set too close trips in normal operation. **In Voltecx.** `design.protection` (**Design › Design Steps › Protection**) sizes the sense shunt and amplifier and the thresholds with their tolerances. Here: a 5.69 A peak-current trip, an over-voltage trip at 3.80 V (set above a 10 % start-up overshoot, the default allowance; the start-up simulation overshot 5.5 % at most) and an input under-voltage start at 10.38 V (below the 10.58 V the converter's input sags to at 10.8 V and full load). ![Peak inductor current against input voltage with the nominal inductance and with the inductance 20 % low, and the current-limit trip at 5.69 A.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/power-supply-product-design-flow/current-limit.svg) The trip sits on the highest normal peak, reached at 13.2 V with the inductance 20 % low: no false trip at any normal corner, and no more headroom than that. For the input side, `design.inputProtection` sizes the fuse, inrush limiting, the surge TVS and reverse-polarity protection, and `design.fmea` injects open, short and drift faults into every part and records which ones the protection catches. ## Step 10: EMI **What you decide.** The input filter, so that conducted emission stays under the limit of the standard your product must meet. **The typical mistake.** Leaving the filter for the end, then finding it resonates with the converter's negative input impedance and makes the loop unstable. **In Voltecx.** `emi.conducted` estimates the conducted spectrum at the input against the CISPR 32 class B limit, sizes a damped LC filter when the margin is short and measures again. ![Estimated conducted emission (average detector) without and with the input filter, and the CISPR 32 class B average limit.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/power-supply-product-design-flow/emi-before-after.svg) Without a filter the second harmonic, at 200 kHz, is 26.7 dB over the average limit (the 100 kHz fundamental is below the 150 kHz start of the band). With the damped filter the run added from catalogue parts (a 15 µH inductor, a 10 µF ceramic capacitor that keeps 8.2 µF at 12 V, and an RC damping branch), the worst point is 19 dB under it, and the filter passes the Middlebrook impedance check. This is an estimate for planning; only a measurement on the real board in a test lab counts for compliance. [Conducted EMI pre-compliance](https://voltecx-web.nguyenvanqui291.workers.dev/blog/conducted-emi-pre-compliance) and [Input filter stability](https://voltecx-web.nguyenvanqui291.workers.dev/blog/input-filter-middlebrook-stability) go deeper. ## Step 11: tolerances **What you decide.** Whether the design still meets the spec when every part is at the edge of its tolerance. **The typical mistake.** Signing off the nominal design. **In Voltecx.** The worst-case stage of `design.auto` runs the corners of a ±20 % tolerance box on the inductor and capacitor at the input extremes. Here it found something: with the output capacitor 20 % low and the inductor 20 % low at 13.2 V, the ripple reaches 38.6 mV, over the 33 mV limit. The nominal design passes, the worst case does not, and the report lists it as an open item: raise the capacitor or buy tighter parts. `analysis.monteCarlo` turns the same question into a yield; see [Monte Carlo tolerance analysis](https://voltecx-web.nguyenvanqui291.workers.dev/blog/monte-carlo-tolerance-analysis-power-supply). ## Step 12: test plan **What you decide.** How each requirement will be measured on the bench and on the production line, with which limit. **The typical mistake.** Writing the test plan after the prototype arrives, so the board has no test points and the limits have no source. **In Voltecx.** `design.testPlan` (**Design › Design Steps › Test Plan**) writes the procedure from the spec and the protection design, each limit with its source. For this design it has 18 steps: 2 inspections, 1 input test (reverse polarity), 10 power tests (output at each input and load corner, ripple, efficiency) and 5 protection tests (current limit, over-voltage trip and release, under-voltage start and stop). ## Step 13: layout, KiCad and BOM **What you decide.** The board: placement, the hot loop, ground, track widths and clearances, and the parts list. **The typical mistake.** A long hot loop. In a buck, the loop of the input capacitor and the two MOSFETs carries current that switches in nanoseconds; every nanohenry in it becomes a voltage spike and radiated noise. **In Voltecx.** The layout stage gives a checklist with numbers. Here it asks to keep the hot loop of Cin, Q1 and Q2 under 15.6 nH. `bom.export` picks a catalogue part for every component, each line citing its data sheet; this design has 18 lines, including the gate driver and its parts, one line per part. `file.exportKicad` (**File › Export › KiCad project**) writes a KiCad 8 project with the parts, footprints where known, and net classes sized for the current: 2.77 mm tracks on outer layers for the 5 A nets. Layout hints are not a board design; you still route the board. ## Step 14: prototypes and bring-up **What you decide.** How you will power up the first board safely and measure what the simulation predicted. **The typical mistake.** A board with no way to break the loop, no way to measure the inductor current and no way to power the stages one at a time. **In Voltecx.** `design.debugAids` (**Design › Automate › Debug Aids**) adds to the schematic what bring-up needs: 0 Ω links between the source and the input and between the output and the load, a loop-injection resistor with test points for a bench loop-gain measurement, and test points; all as DNP parts or links that leave the simulation unchanged. After routing, `layout.extract` reads the board, computes the inductance of each power loop and can put those parasitics back into the circuit, so you can simulate the spikes before the first board is built. ## Step 15: compliance **What you decide.** Which standards apply: safety (insulation, clearance and creepage), EMC (conducted and radiated emission, immunity) and, for an external power supply, efficiency regulations. **The typical mistake.** Treating a simulation as a certificate. **In Voltecx.** `design.safety` computes the clearance and creepage IEC 62368-1 asks for across each isolation barrier. `design.compliance` (**Design › Design Steps › Compliance**) builds one row per requirement for the US or EU market, each with its clause, and marks it pass, fail or not checked from what was simulated. Our 12 V module has no mains input, so all eight EU rows (efficiency, harmonics, EMC and safety for mains equipment) come back not checked, which is correct: they apply to the system it goes into. Either way, only an accredited lab can say a product complies. ## Step 16: production test **What you decide.** What every unit off the line is tested for, and the limits. **The typical mistake.** Production limits copied from the spec, with no guard band for the tester's own accuracy, or a test that needs equipment the factory does not have. **In Voltecx.** The `design.testPlan` procedure lists the equipment and fixtures each step needs, and exports as CSV for a test station. `file.manufacturingOutputs` runs KiCad's own command-line tool on your routed board to make the design-rule report, Gerbers, drill files, the placement file, the BOM and an assembly drawing. ## The whole flow on one page | Step | What you decide | Typical mistake | Voltecx | |---|---|---|---| | Requirements | every number at every corner | nominal point only | `spec.verify`, `spec.feasibility` | | Topology | the power stage | habit instead of numbers | `topology.suggest`, `design.compare` | | Sizing | fsw, L, C | sized at nominal input | `design.converter` | | Magnetics | core, turns, part | ignoring DCR and saturation | `magnetics.design` | | Semiconductors | switches, driver | on-resistance only | `design.parts`, `design.gateDrive` | | Control | compensator, crossover | one operating point | `design.voltageLoop`, `design.robustLoop` | | Losses | efficiency over load | full load only | `design.efficiency` | | Thermal | cooling | 25 °C ambient | `design.thermal` | | Protection | trips and sensing | limit from nominal current | `design.protection`, `design.inputProtection`, `design.fmea` | | EMI | input filter | filter added last | `emi.conducted` | | Tolerances | worst case, yield | nominal sign-off | worst-case stage, `analysis.monteCarlo` | | Test plan | measurements and limits | written after the prototype | `design.testPlan` | | Layout and BOM | board, parts list | long hot loop | layout checklist, `bom.export`, `file.exportKicad` | | Bring-up | debug access | no way to measure | `design.debugAids`, `layout.extract` | | Compliance | standards | simulation as certificate | `design.safety`, `design.compliance` | | Production | unit test, outputs | no guard band | `design.testPlan`, `file.manufacturingOutputs` | How the converter is controlled (a controller IC, an analog compensator or firmware on a microcontroller) is a decision of its own; [Digital, analog or controller IC](https://voltecx-web.nguyenvanqui291.workers.dev/blog/digital-vs-analog-vs-controller-ic-control) covers it. ## Try it in Voltecx - **Design › Auto Design** runs `design.auto` on your spec: it chains the steps above, checks each one by simulation, leaves a checkpoint after every stage and writes a report with the open items and everything it did not check. `report.export` writes that report as a PDF or HTML page. See [Automatic design](https://voltecx-web.nguyenvanqui291.workers.dev/features/auto-design). - Each step is also its own command under **Design**, so you can run one step on a circuit you drew yourself. - Paste the spec above, run it, then replace `"loadStep": false` with `"loadStep": { "from": 2.5, "to": 5, "maxDroopPct": 5 }` and run it again to watch the switching frequency, the capacitor and the loop change. The sizing equations follow R. W. Erickson and D. Maksimović, *Fundamentals of Power Electronics*, 3rd ed., ch. 2 and 9; the input-filter check follows R. D. Middlebrook, "Input filter considerations in design and application of switching regulators", IEEE IAS Annual Meeting, 1976. --- # How a totem-pole bridgeless PFC works, and how to design one URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/totem-pole-pfc-explained/ A totem-pole bridgeless PFC replaces the diode bridge and the boost switch with two half bridges. A fast leg of GaN or SiC transistors switches at tens of kilohertz and swaps roles each half cycle, and a slow leg follows the line polarity at 50 or 60 Hz. The line current then passes one slow-leg device and one fast-leg transistor instead of two bridge diodes plus a switch or diode. In continuous conduction the fast leg needs devices without reverse recovery, which is why it is built with GaN or SiC. Size the inductor for the ripple at the crest, $\Delta I = V_{pk}(1 - V_{pk}/V_o)/(f_{sw} L)$, and the output capacitor for hold-up and the twice-line ripple, $\Delta V = P/(2\pi f_{line} C V_o)$. For 3 kW from 207–253 V to 400 V at 65 kHz, that gives 200 µH, a 23.9 A peak, 1360 µF and 17.6 V of ripple. The slow leg saves 14 W over a diode bridge. The boost PFC itself (power factor, the slow voltage loop, the bulk capacitor) is covered in [boost PFC basics](https://voltecx-web.nguyenvanqui291.workers.dev/blog/boost-pfc-basics). This article is about what changes when the bridge goes away. ## How does a totem-pole PFC work? The line goes through the boost inductor to the midpoint of the fast leg (Q1 on top, Q2 below). The neutral goes to the midpoint of the slow leg. Both legs sit across the output capacitor. - **Positive half cycle.** The slow leg's lower device connects the neutral to the negative rail. Q2 is the boost switch: while it is on, the line charges the inductor. Q1 is the synchronous rectifier: while it is on, the inductor discharges into the output. - **Negative half cycle.** The slow leg's upper device connects the neutral to the positive rail, and Q1 and Q2 swap roles. Q1 is now the boost switch, Q2 the rectifier. Seen from the inductor, each half cycle is an ordinary synchronous boost converter. The slow leg does the job of the bridge, but it switches only twice per line cycle, so it can be a pair of slow rectifiers or, for the lowest loss, two silicon MOSFETs driven at the line frequency. ## Why does it remove the bridge's conduction loss? In a classic boost PFC, two bridge diodes always carry the line current. On top of them comes the boost switch during the on-time or the boost diode during the off-time. In the totem-pole the current passes **one** slow-leg device and **one** fast-leg transistor at every instant. One diode drop disappears, and the boost diode's drop becomes the on-state resistance of a transistor. A diode modelled as $V_{F0} + r_F\, i$ that conducts the whole rectified line current loses $$P_D = V_{F0}\, I_{avg} + r_F\, I_{rms}^2, \qquad I_{avg} = \frac{2\sqrt{2}}{\pi} I_{rms}$$ A bridge loses $2P_D$ and a diode slow leg $P_D$. Replacing the slow diodes with MOSFETs takes most of the rest away. ## Why does a CCM totem-pole need GaN or SiC? Look at the moment the boost switch turns on in continuous conduction mode (CCM). The synchronous rectifier was carrying the inductor current, through its channel and, during the dead time, through its body diode. The boost switch must now pull that current out. A silicon superjunction MOSFET's body diode has a large reverse-recovery charge. The boost switch has to sweep it out at full bus voltage on every period, which costs a large turn-on loss and a current spike. With silicon MOSFETs on the fast leg, the totem-pole is therefore run in critical or discontinuous conduction, where the current falls to zero before the boost switch turns on and there is nothing to recover. GaN transistors have no body diode, and they conduct in reverse through the channel with no stored charge to recover. SiC MOSFETs have a body diode with a much smaller recovery charge than silicon superjunction parts. Either makes the CCM totem-pole practical, and CCM is what keeps the ripple and the RMS currents low at kilowatt power. ## How do I size the boost inductor? At the crest of the line, the boost switch is on for $d = 1 - V_{pk}/V_o$ of each period. The line voltage across the inductor gives the ripple: $$\Delta I = \frac{V_{pk}\, d}{f_{sw}\, L} = \frac{V_{pk}\left(1 - V_{pk}/V_o\right)}{f_{sw}\, L}$$ Pick $L$ for a ripple of 20 to 40 % of the crest current at low line. The worst ripple over the line comes where $|v_{in}| = V_o/2$: $\Delta I_{max} = V_o/(4 f_{sw} L)$, as in [boost PFC basics](https://voltecx-web.nguyenvanqui291.workers.dev/blog/boost-pfc-basics). **How far does CCM reach?** The current $I_{pk}\sin\theta$ and the ripple $V_{pk}\sin\theta\,(1 - V_{pk}\sin\theta/V_o)/(f_{sw}L)$ both shrink towards the zero crossing. Their ratio is worst right at the crossing. The current stays continuous over the whole half cycle when $I_{pk} \ge V_{pk}/(2 f_{sw} L)$. With $I_{pk} = 2P_{in}/V_{pk}$, that is $$L \ge \frac{V_{rms}^2}{2\, f_{sw}\, P_{in}}$$ This is a full-load condition, and the highest line voltage is the hardest case. At lighter load the current loses continuity first near the zero crossings. With complementary gating, the synchronous switch lets the current reverse instead of resting at zero. Either way the current shape there is no longer what the loop assumes. ## How do I size the output capacitor? As for any PFC, by hold-up first, then check the ripple: $$C \ge \frac{2 P\, t_{hold}}{V_o^2 - V_{min}^2}, \qquad \Delta V_{pp} = \frac{P}{2\pi f_{line}\, C\, V_o}$$ The capacitor RMS current follows from the rectifier current. When the synchronous switch conducts, it carries the inductor current for a fraction $1 - d = |v_{in}|/V_o$ of each period. Averaged over the line, with the switching ripple neglected: $$I_{C,rms} = \sqrt{\frac{16\, P^2}{3\pi\, V_{pk}\, V_o} - \left(\frac{P}{V_o}\right)^2}$$ Of this, the twice-line part is $P/(\sqrt{2}\,V_o)$; the rest is at the switching frequency, where an electrolytic's rating is higher by its frequency factor. ## What goes wrong at the zero crossing? Two things change at once when the line voltage passes zero. The slow leg hands the neutral from one rail to the other, so its midpoint swings by the full output voltage. And the fast leg swaps its boost switch and its rectifier. Just before the crossing, the boost duty is close to 1 (the line voltage is near zero). So immediately after the swap, the new boost switch also starts near full duty. The slow-leg midpoint has capacitance (device junctions, the heatsink, the layout), and the line and the inductor must charge it through the full output voltage. If the fast leg applies its new duty before that swing is over, nearly the whole output voltage appears across the inductor for a moment. The result is a current spike at every crossing, which shows up as distortion and as conducted noise. The usual remedies: - **Blank both fast-leg switches** for a short window around the crossing, and let the slow leg commutate first. - **Soft-start the new boost switch**: ramp its duty up from zero over a few switching periods to the feedforward value, then enable the synchronous rectifier. - **Detect the polarity with hysteresis**, so noise near zero does not toggle the legs back and forth. ## How is the current loop designed? The control is average-current mode, as in a classic PFC, with two additions: the polarity logic and a duty feedforward. - **The plant** from duty to inductor current is $V_o/(sL)$ in both half cycles. A PI with crossover $\omega_c$ needs $K_p = \omega_c L / V_o$; put its zero a few times below $\omega_c$. - **Feedforward.** Add the steady-state duty $1 - |v_{in}|/V_o$ to the PI output, so the PI only corrects the error. This matters most near the crossings, where the needed duty changes fastest. - **Reference.** The voltage loop sets the peak current $I_{pk}$, and the reference $I_{pk}\,|v_{in}|/V_{pk}$ follows the rectified line. Keep the voltage loop slow, as in [boost PFC basics](https://voltecx-web.nguyenvanqui291.workers.dev/blog/boost-pfc-basics). - **Polarity.** A comparator on the line voltage chooses which fast-leg switch receives the PWM and which gets its complement. ## Does it meet IEC 61000-3-2? IEC 61000-3-2, *Electromagnetic compatibility (EMC) – Part 3-2: Limits – Limits for harmonic current emissions (equipment input current ≤ 16 A per phase)*, sets the harmonic limits. For class A equipment, Table 1 allows 2.30 A of 3rd harmonic and 1.14 A of 5th. A CCM totem-pole with a working current loop is far below these at full load. The places to check are light load (where the current loses continuity near the crossings) and the zero-crossing spikes. Note that a 3 kW single-phase stage at 230 V draws more than 13 A, close to the standard's 16 A boundary. Above 16 A, IEC 61000-3-12 applies instead. ## Worked example: 3 kW, 230 V ±10 %, 50 Hz, 400 V out, 65 kHz Assumptions: unity power factor, 98 % efficiency ($P_{in} = 3061$ W), 10 ms hold-up down to 330 V (the lowest voltage the downstream converter accepts in this example), and 30 % crest ripple at low line. Device models from the Voltecx `totemPolePfc` example: slow-leg rectifier 0.89 V + 10 mΩ (the straight-line fit of the Vishay VS-20ETS08FP 25 °C forward curve), fast-leg GaN 50 mΩ (GaN Systems GS66508T, typical at 25 °C). | Quantity | Formula | Value | |---|---|---| | Input current at 207 V | $P_{in}/V_{rms}$ | 14.79 A RMS, 20.91 A peak | | Crest duty at 207 V | $1 - V_{pk}/V_o$ | 0.268 | | Inductance for 30 % ripple | $V_{pk} d / (0.3\, I_{pk} f_{sw})$ | 192 µH, use 200 µH | | Crest ripple at 207 V | $V_{pk}(1 - V_{pk}/V_o)/(f_{sw} L)$ | 6.04 A | | Peak inductor current | $I_{pk} + \Delta I/2$ | 23.9 A | | Largest ripple (at 200 V) | $V_o/(4 f_{sw} L)$ | 7.69 A | | Inductance for CCM to the crossing at 253 V | $V_{rms}^2/(2 f_{sw} P_{in})$ | 161 µH (met) | | Full-line CCM lost below | $V_{rms}^2/(2 f_{sw} L)$ | 2.46 kW at 253 V, 2.03 kW at 230 V, 1.65 kW at 207 V | | Bridge loss, two diodes | $2(V_{F0} I_{avg} + r_F I_{rms}^2)$ | 28.1 W | | Slow-leg loss, one diode | $V_{F0} I_{avg} + r_F I_{rms}^2$ | 14.0 W | | Fast-leg conduction loss | $R_{DS(on)}\, I_{rms}^2$ | 10.9 W | | Hold-up capacitance | $2 P t_{hold}/(V_o^2 - V_{min}^2)$ | 1174 µF, use 2 × 680 µF | | Twice-line ripple | $P/(2\pi f_{line} C V_o)$ | 17.6 V peak to peak | | Capacitor RMS current at 207 V | formula above | 8.62 A (5.30 A of it at 100 Hz) | | Current-loop crossover | $f_{sw}/20$ | 3.25 kHz | | Current-loop PI | $K_p = \omega_c L/V_o$, zero at $\omega_c/4$ | $K_p = 0.0102$ per A, $K_i = 52.1$ per A·s | The slow leg saves 14 W, about 0.47 % of the output, before any MOSFET slow leg or the boost diode is counted. The fast-leg loss uses the 25 °C typical $R_{DS(on)}$; it is higher at a hot junction, so read the data sheet's curve. At this current you would choose a lower-resistance GaN part than the 650 V, 25 A GS66508T, whose rating the 23.9 A peak almost reaches. For the capacitors, two TDK B43544E5687M060 (680 µF, 450 V) are rated 3.29 A each at 100 Hz and 105 °C (TDK B43544 data sheet, December 2019). That covers the 5.30 A at 100 Hz; the 6.79 A at the switching frequency must fit their high-frequency rating, which may call for a third can. ## Try it in Voltecx 1. Open **File › Open Example › totemPolePfc**. It is a 1 kW totem-pole from 230 V, 50 Hz to 400 V, with a GS66508T GaN fast leg at 65 kHz (50 ns dead time, gate driven to +6 V and −3 V), a VS-20ETS08FP rectifier pair as the slow leg, 680 µH and 470 µF. The control is average-current mode with the duty feedforward and a comparator plus exclusive-or that picks the boost switch of each half cycle, wrapped as the `Ctrl` module. The slow leg is a rectifier pair because the device library has no 600 V silicon MOSFET to take its data from. The output starts at the line peak, so the run shows the boost from 325 V to 400 V. 2. Run it (`simulation.run`), then **Scope › Measurements** (`scope.measure`) from 0.21 s with `power` set to `vac` and `iac`. In our run: 1005 W, 4.41 A RMS, power factor 0.991, and `vdc` at 399 V with 17.6 V of ripple. The formula above gives 16.9 V for 470 µF. The capacitor `C1` carried 2.65 A RMS, where the formula gives 2.61 A. 3. **Analysis › FFT** (`analysis.fft`) on `iac` from 0.21 s with `fundamental` 50 gave a THD of 5.1 % and a 3rd harmonic of 0.31 A peak (0.22 A RMS), a tenth of the class A limit. 4. The example's devices have no capacitance, so the current passes through zero cleanly. To see the zero-crossing spike, give the slow leg a junction capacitance with `circuit.setParam` and run again. Use the value from your data sheet; the run below uses 1 nF only to make the effect obvious. ```sh powercraft-cli run --cmd file.openExample --params '{"name":"totemPolePfc"}' \ --cmd circuit.setParam --params '{"components":["D3","D4"],"key":"cj","value":"1n"}' \ --cmd simulation.run \ --cmd waveform.get --params '{"signals":["iac","vac","v(acn)"],"t0":"0.2196","t1":"0.2204"}' ``` The [examples](https://voltecx-web.nguyenvanqui291.workers.dev/features/examples) page lists the other PFC circuits, and the [server power](https://voltecx-web.nguyenvanqui291.workers.dev/use-cases/server-power) page shows where the stage sits in a supply. ## Frequently asked questions ### Can I build a totem-pole PFC with silicon MOSFETs? On the slow leg, yes: it switches at the line frequency, and silicon MOSFETs there remove the last diode drop. On the fast leg, only in critical or discontinuous conduction. In CCM the reverse recovery of a silicon body diode makes the turn-on loss and spikes too large. ### Why is the zero crossing the hard part? The slow leg's midpoint swings by the full output voltage, and at the same moment the boost duty is near 1. If the fast leg starts before the swing is over, the inductor briefly sees the output voltage and the current spikes. Blanking and a duty soft start after the crossing prevent it. ### How much efficiency does the totem-pole gain over a bridge plus boost? It removes one diode drop from the current path and turns the boost diode's drop into an on-resistance loss. In the 3 kW example above, the slow leg alone saves 14 W, about half a percent, and MOSFETs on the slow leg gain more. ### Is the voltage loop different from a classic boost PFC? No. It still sets the peak of the current reference and must stay well below twice the line frequency. See [boost PFC basics](https://voltecx-web.nguyenvanqui291.workers.dev/blog/boost-pfc-basics). ## Sources - L. Huber, Y. Jang and M. M. Jovanović, "Performance evaluation of bridgeless PFC boost rectifiers", *IEEE Transactions on Power Electronics*, 2008: a comparison of bridgeless boost PFC rectifiers. - IEC 61000-3-2, *Electromagnetic compatibility (EMC) – Part 3-2: Limits – Limits for harmonic current emissions (equipment input current ≤ 16 A per phase)*, Table 1 (class A). - GaN Systems GS66508T data sheet, Rev 200402; Vishay VS-20ETS08FP-M3 data sheet (Figure 7), as used by the Voltecx device library. - TDK Electronics, *Aluminum electrolytic capacitors, Snap-in capacitors, Series/Type B43544*, December 2019. --- # How to choose an inductor for a power supply: reading the data sheet URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/how-to-choose-an-inductor/ You have done the arithmetic and your buck converter "needs 12 µH". Now you open a distributor's site and find hundreds of 12 µH inductors, from a 3 mm chip to a part the size of a sugar cube. Which one do you buy? This article is about that step. [How to size a buck inductor](https://voltecx-web.nguyenvanqui291.workers.dev/blog/buck-inductor-sizing) works out the value; here we read the data sheet. We go through what each line on an inductor data sheet means, which ratings limit your design, and what goes wrong when you pick the wrong one. Every figure comes from a Voltecx run or from the data sheets in the Voltecx parts catalogue, and a test checks the numbers you read here against those runs. The short version: - **Inductance** sets the ripple current. Check it at the low end of its tolerance. - **Saturation current (Isat)** must be above the highest peak current the converter can ever make, including at its current limit, at your hottest temperature. - **RMS current (Irms)** sets how hot the part gets. It is a heating rating, not a saturation rating. - **DCR** and **core loss** are the two losses. DCR dominates at low frequency, core loss at high frequency. - **Shielding, size and height** decide whether it fits and whether it disturbs its neighbours. ## What an inductor does in a power supply Think of an inductor as a flywheel for current. A flywheel resists changes in speed; an inductor resists changes in current. Push on it with a voltage and its current changes, but only gradually: $$v = L\,\frac{di}{dt}$$ In a buck converter the switch connects the inductor to the input for a short time, then lets it freewheel through the diode. The inductor turns those chopped voltage pulses into a steady current with a small triangular ripple on top. While it does this, it stores energy in its magnetic field, $E = \tfrac{1}{2} L I^2$, and gives it back every cycle. ![The 36 V to 5 V, 3 A, 400 kHz buck used in this article, as Voltecx draws it: S1, D1, the inductor L1 and the output capacitor C1 with the load R1.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/how-to-choose-an-inductor/buck.svg) Two things follow from this picture, and they are the two halves of choosing a part: 1. **The value** (inductance) decides how big the ripple is. 2. **The construction** (core material, size, wire) decides how much current the part can carry before it stops being an inductor, how hot it gets and how much power it wastes. ## Inductance sets the ripple During the off-time the inductor sees $-V_{out}$, so its current falls by $$\Delta I = \frac{V_{out}\,(1 - D)}{f_{sw}\,L}, \qquad D = \frac{V_{out}}{V_{in}}$$ (R. W. Erickson and D. Maksimović, *Fundamentals of Power Electronics*, the chapter on steady-state converter analysis). Our example converts 36 V to 5 V at 3 A and 400 kHz, so $D = 0.139$. Simulated in Voltecx with three values from the Coilcraft XAL7070 series: | Inductance | Ripple $\Delta I$ | Peak current | |---|---|---| | 4.7 µH | 2.30 A | 4.15 A | | 12 µH | 0.898 A | 3.45 A | | 22 µH | 0.490 A | 3.24 A | ![Inductor current over two switching periods for 4.7, 12 and 22 µH: the average stays at 3 A, the ripple shrinks as the inductance grows.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/how-to-choose-an-inductor/ripple-vs-inductance.svg) The average current is the load current in all three cases. The inductance only changes the triangle on top. A larger inductance gives less ripple, a lower peak and less ripple voltage at the output, but it is physically bigger and slows the converter's response to a load step. A ripple of about 30 % of the load current, here 12 µH, is the usual compromise. ### Do not forget the tolerance A power inductor is typically ±20 % (the XAL parts in our catalogue all are). At the low end, 12 µH becomes 9.6 µH, and the simulation gives a ripple of 1.12 A and a peak of 3.56 A instead of 0.898 A and 3.45 A. Check every current rating at the low end of the tolerance. ## The data sheet, line by line Here is what a typical power-inductor data sheet gives you, and what each item means for your design. | Data-sheet item | What it means | What it limits | |---|---|---| | Inductance $L$ and its test frequency | The value at zero current, small signal | Ripple current | | Tolerance | Spread from part to part | Worst-case ripple and peak | | DCR (typ and max) | Resistance of the wire at DC, 20–25 °C | Copper loss | | $I_{sat}$ | DC current where $L$ has dropped by a stated amount | Peak current | | $I_{rms}$ | DC current for a stated temperature rise | Heating | | Shielded or not | Whether the magnetic field leaks outside | Noise in nearby circuits | | Size, height, footprint | Mechanical | Board space | | Operating temperature range | Including self-heating | Ambient plus rise | The two current ratings are the ones beginners mix up, so we take them one at a time. ## Saturation current: when the inductor stops being an inductor A magnetic core can only hold so much magnetic flux. Push more current through the winding and the core's permeability falls, so the inductance falls too. $I_{sat}$ is the current at which the inductance has dropped by a stated percentage. **Read the footnote**: one maker uses 10 %, another 20 or 30 %. The Coilcraft XAL sheets in the Voltecx catalogue define $I_{sat}$ as the DC current at 25 °C that drops the inductance by 30 % (typical). How the inductance falls depends on the core material: - **Gapped ferrite** has a *hard* knee. The inductance stays almost constant up to saturation, then collapses. - **Powder cores** (iron powder, MPP, High Flux, Kool Mµ) have the gap spread through the material. The inductance *rolls off* gradually as the current rises. To see the difference, we asked `magnetics.design` for the same 12 µH inductor for our buck in two materials from its catalogue. The best N87 ferrite design is an EFD 20/10/7 core with 13 turns and a 0.83 mm gap: 12 µH up to 15.7 A, then only 0.21 µH. The best Kool Mµ 60 design is an ungapped T 21/12/7.1 ring with 16 turns: 11.7 µH at our 3.45 A peak, 8.5 µH at 14.5 A and 6.9 µH at 20 A, from the material's DC-bias curve fit. ![Inductance against DC current for the two designs: the gapped N87 ferrite stays at 12 µH and drops to 0.21 µH at 15.7 A; the Kool Mµ 60 powder ring rolls off gradually. The vertical line is the 3.45 A peak of the buck.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/how-to-choose-an-inductor/inductance-vs-current.svg) Neither is better in general: - A gapped ferrite gives you the full inductance right up to its rating and low core loss, but you must never exceed $I_{sat}$. - A powder core forgives an overload, but you get less inductance at full load than at no load, and its core loss is usually higher. ### What saturation looks like Why does exceeding $I_{sat}$ matter so much? With a hard-saturating core, the current slope is $di/dt = v/L$, and $L$ has just fallen by a factor of 70. Here is our buck with a short across the output, with no controller to stop it: ![Inductor current after a short across the output, open loop. Both currents climb about 1 A per period; the N87 ferrite jumps to 34 A and then 75 A as soon as its peak passes the 15.7 A knee (horizontal line), while the powder core's current climbs faster and faster as its inductance falls.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/how-to-choose-an-inductor/saturation.svg) The current climbs about 1 A per period in both. The ferrite reaches 15.2 A in the 13th period; in the next period its peak passes the knee and jumps to 33.8 A, then 74.9 A in the one after. The powder core has no cliff: 14.7 A in the 11th period, 15.9 A in the 12th, and 34.2 A after 24 periods, rising faster each time as its inductance falls. That jump is what destroys MOSFETs. A current-limit circuit needs some time to react (blanking, comparator delay, driver delay), typically a few hundred nanoseconds. With 0.21 µH and 31 V across it, the current rises by 148 A every microsecond. So the rule is: > Choose $I_{sat}$ above the **current limit** of your controller, at your **hottest** operating temperature, not just above the full-load peak. Ferrite saturation flux falls as the core heats, so a ferrite part's $I_{sat}$ at 100 °C is lower than at 25 °C; good data sheets show a curve or a second column. ## RMS current: how hot it gets $I_{rms}$ has nothing to do with saturation. It is the DC current that heats the part by a stated amount above ambient, often 20 K or 40 K. The XAL sheets give both, called $I_{rms}$ for 20 K and for 40 K here. The heat comes mainly from the winding resistance: $$P_{DCR} = I_{rms}^2 \cdot DCR, \qquad I_{L,rms} = I_o\sqrt{1 + \frac{r^2}{12}}$$ with $r = \Delta I / I_o$. For our 12 µH buck the simulation gives 3.01 A RMS: at a 30 % ripple ratio, the RMS current is only 0.4 % above the DC current. Since the rise is roughly proportional to the loss, and the loss to $I^2$, you can read the data sheet's two points as a curve. Here we draw a power law through each part's 20 K and 40 K points (a reading of the data sheet, not a measurement), for three Coilcraft XAL candidates: ![Estimated temperature rise against DC current for XAL6060-103, XAL7070-123 and XAL8080-123, through each data sheet's 20 K and 40 K points and drawn only up to the 40 K point. The vertical line is the 3.01 A RMS current of the buck.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/how-to-choose-an-inductor/temperature-rise.svg) At 3.01 A the three parts rise by about 7.0, 4.3 and 2.7 K. Add the core loss (below), the heat of nearby parts and your ambient, and check the total against the part's maximum operating temperature. **Which current rating limits?** Usually saturation. In most buck designs the part's $I_{rms}$ is close to its $I_{sat}$ or below it, but your RMS current is close to the load current while your peak at the current limit can be twice that. Check both; the one with the smaller margin decides. ## DCR and core loss An inductor wastes power in two places: - **Copper (winding) loss**: $I_{rms}^2$ times the winding resistance. At high frequency the ripple current also crowds to the wire surface (skin and proximity effects), so the AC resistance is higher than the DCR. - **Core loss**: every cycle the ripple drives the core's flux up and down, and the core material turns part of that into heat. It grows with frequency and with the flux swing, so with the ripple current, not with the DC current. Use the maximum DCR, not the typical, for your loss budget. For the core loss, look for the maker's loss curves or calculator at your frequency and ripple; the XAL data sheets list the DCR but no core loss, so the Voltecx catalogue has no core-loss figure for them either. How do the two trade against frequency? We asked `magnetics.design` for the same job (3 A, 0.897 A ripple) at frequencies from 100 kHz to 1.6 MHz, with the inductance scaled as $1/f$ so the ripple stays the same. With the material set to Kool Mµ 60, it chose the same ring at every frequency and only changed the turns: ![Winding loss, core loss and their total against switching frequency for the same Kool Mµ 60 ring, wound for the same 0.897 A ripple at each frequency (the inductance falls as 1/f).](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/how-to-choose-an-inductor/loss-vs-frequency.svg) | Frequency | Inductance | Turns | Winding loss | Core loss | |---|---|---|---|---| | 100 kHz | 48 µH | 33 | 0.184 W | 0.046 W | | 400 kHz | 12 µH | 16 | 0.039 W | 0.105 W | | 1.6 MHz | 3 µH | 8 | 0.013 W | 0.224 W | At a low frequency you need many turns, and the copper dominates. At a high frequency you need few turns, but the core is cycled four or sixteen times as often, and the core loss dominates. In between there is a flat region where the total is lowest. The losses come from the iGSE core-loss model and Dowell's winding model, which `magnetics.design` uses (both approximations). ## Shielded or unshielded? An unshielded drum-core inductor lets its magnetic field loop through the air around it. That field can couple into a nearby sense trace, a feedback divider or an audio input, and it radiates. A shielded part (a ferrite sleeve, or a moulded part like the XAL series, where the winding is buried in the core material) keeps most of the field inside. Shielded parts are slightly bigger or slightly lower in inductance for the same size, and they cost a little more. For a switching supply on a mixed-signal board, choose shielded unless you have a reason not to. ## Size against frequency The energy an inductor must store per cycle is $\tfrac{1}{2} L I_{pk}^2$. For the same ripple ratio, $L$ falls as $1/f_{sw}$, so a higher switching frequency lets you use a smaller part. The loss table above shows the limit: past some frequency, the core loss grows faster than the copper loss shrinks, and the part runs hotter even though it is smaller. [Choosing the switching frequency](https://voltecx-web.nguyenvanqui291.workers.dev/blog/choosing-switching-frequency) covers this trade-off for the whole converter. ## Worked example: choosing the part for the 36 V to 5 V buck The requirements, from the sizing article and the simulation: - $L$ = 12 µH (±20 % allowed, check at 9.6 µH) - Peak current at full load: 3.45 A (3.56 A at the low end of the tolerance) - RMS current: 3.01 A - Suppose the controller's current limit is 5 A: then $I_{sat}$ must exceed 5 A at the hottest operating temperature. Three candidates from the Voltecx catalogue, all read from the Coilcraft data sheets (XAL60xx: Document 887-1, revised 02/25/26; XAL7070: Document 856-1, revised 02/25/26; XAL8080: Document 839-1, revised 05/01/26): | Part | $L$ | $I_{sat}$ (−30 %) | $I_{rms}$ 20 K | $I_{rms}$ 40 K | DCR max | $I^2 R$ at 3.01 A | Est. rise | |---|---|---|---|---|---|---|---| | XAL6060-103MEC | 10 µH | 7.6 A | 5.0 A | 7.0 A | 29.8 mΩ | 0.270 W | 7.0 K | | XAL7070-123MEC | 12 µH | 7.4 A | 6.0 A | 8.2 A | 22.2 mΩ | 0.201 W | 4.3 K | | XAL8080-123MEC | 12 µH | 8.6 A | 7.6 A | 10.5 A | 18.2 mΩ | 0.165 W | 2.7 K | Going through the checklist: 1. **Inductance.** XAL6060-103 is 10 µH, below the 12 µH target, so it raises the ripple; at the low end of its tolerance it is 8 µH. Keep it only if board space is the hard constraint. The other two are 12 µH. 2. **Saturation.** All three are above the 5 A current limit at 25 °C with a margin. The catalogue holds the 25 °C value only, so read the data sheet's temperature curve before you rely on the margin at 85 °C. 3. **Heating.** All three carry 3.01 A with less than 10 K of rise from the DCR alone. 4. **Loss.** 0.20 W or 0.17 W out of 15 W output is 1.3 % or 1.1 % of the output power, before core loss. XAL7070-123 is the smallest part that meets every requirement with margin. XAL8080-123 is larger but runs cooler and wastes 36 mW less. Voltecx's `bom.export`, which picks the catalogue part with the lowest DCR among those whose $I_{sat}$ and 40 K $I_{rms}$ cover the simulated currents with a derating, chooses XAL8080-123MEC and reports 0.165 W in its maximum DCR. If you care more about area, pick XAL7070-123 yourself; both are valid answers. ## A step-by-step checklist 1. **Find the inductance** for a 20–40 % ripple at the highest input voltage ([how to size a buck inductor](https://voltecx-web.nguyenvanqui291.workers.dev/blog/buck-inductor-sizing)). 2. **Find the worst-case peak current**: full-load peak at the low end of the tolerance, and the controller's current limit. Take the larger. 3. **Pick $I_{sat}$** above that peak, at your hottest temperature, knowing which percentage drop the data sheet uses. 4. **Find the RMS current** and pick $I_{rms}$ for the temperature rise you can afford. 5. **Add up the losses**: $I_{rms}^2 \cdot DCR_{max}$ plus the maker's core loss at your frequency and ripple. 6. **Check the temperature**: ambient plus rise below the part's maximum. 7. **Check shielding, size, height and footprint**, and any qualification your product needs. 8. **Simulate with the real part**: its inductance, DCR and saturation, and look at the current at start-up, at a load step and at the current limit. ## Common mistakes - **Choosing by $I_{rms}$ alone.** A part rated 8 A RMS may saturate at 5 A. - **Comparing $I_{sat}$ between makers** without reading the footnote (10 %, 20 % or 30 % drop). - **Ignoring the current limit.** The full-load peak is not the highest current; start-up and a short are. - **Using the typical DCR** in a loss budget. Use the maximum. - **Forgetting temperature.** Ferrite $I_{sat}$ falls with temperature, and the part heats itself. - **Putting an unshielded part** next to the feedback divider. ## Try it in Voltecx - `circuit.template` with `{"topology": "buck", "vin": 36, "vout": 5, "iout": 3, "fsw": 400e3}` builds the converter of this article. Set `l` and `dcr` on the inductor to your part's values (`dcr` is the winding resistance). - Each inductor takes `isat` and `lsat`: the inductance drops to `lsat` above `isat`. Use them to see what a short or a start-up does to a hard-saturating part. - `magnetics.design` designs a wound inductor from its catalogue cores (ferrites, MPP, High Flux and Kool Mµ) for your circuit's currents, and ranks the candidates by size or by loss. With `apply` it writes `l`, `dcr`, `isat`, `lsat` and the core-loss resistance `rcore` into the part; with `link` the simulation follows the core's inductance curve, with iGSE core loss and Dowell winding loss evaluated each switching period (approximations). - `bom.export` picks a catalogue inductor from the Coilcraft data sheets for each inductor in the circuit, checks its $I_{sat}$ against the simulated peak and its RMS rating against the simulated RMS current, and reports the DCR loss and the margins. **Design › Design Steps › Parts** (`design.parts` with `passives`) lists the same inductor and capacitor choices with the rating that limits each one. For the output capacitor that goes with this inductor, see [how to choose the output capacitor of a buck converter](https://voltecx-web.nguyenvanqui291.workers.dev/blog/buck-output-capacitor-selection) and [choosing capacitors for a power supply](https://voltecx-web.nguyenvanqui291.workers.dev/blog/how-to-choose-capacitors-power-supply). ## Frequently asked questions ### What is the difference between Isat and Irms on an inductor data sheet? $I_{sat}$ is the current at which the inductance has dropped by a stated percentage, because the core saturates. $I_{rms}$ is the current that heats the part by a stated amount, because of the winding resistance. The first limits your peak current, the second your RMS current. ### Can I use an inductor above its Isat? A powder or composite core loses inductance gradually, so a short excursion may be acceptable if the higher ripple is. A gapped ferrite collapses, and the current can then rise by tens of amperes within one switching period. Design so the peak at the current limit stays below $I_{sat}$. ### Why is a higher inductance not always better? It lowers the ripple, but it means more turns or a bigger core, so more DCR, more size and a slower response to load steps. ### Does the inductor's tolerance matter? Yes. At −20 %, our 12 µH part becomes 9.6 µH and the ripple rises from 0.898 A to 1.12 A. Check the ripple, the peak and the output ripple voltage at the low end. --- # How to cut the cost of a power supply without losing reliability URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/power-supply-cost-optimisation/ Every power-supply project eventually gets the same request: "Can you take some cost out?" The usual answers are to buy a cheaper MOSFET, drop a capacitor or shrink the heatsink. Sometimes that works. Often it moves the cost somewhere else, such as a hotter part, a shorter life, a failed EMI scan or a field return that costs far more than the parts saved. This article is about cutting cost on purpose rather than by accident. We start with where the money goes, then look at the four trade-offs that decide most of it, and then work through a 48 V to 12 V, 5 A buck in Voltecx, where a Pareto search shows what each saving really costs in watts and cubic centimetres. The headline result is a little surprising: in this design the expensive-looking choices (the lowest-RDS(on) MOSFET, the biggest inductor) make it *worse* or barely better, and the part that decides the efficiency is the cheapest one on the board. ## The intuition: cost is a budget you spend on loss Think of a power supply as a budget with two currencies: money and watts. Every watt of loss has to leave the box as heat, and you pay for that heat in copper, aluminium, airflow, board area and temperature margin. Every dollar you spend on better parts buys back some watts. So "cheaper" is never one number. It is a point on a curve: for a given efficiency there is a cheapest design, and for a given cost there is a most efficient one. Designs on that curve are called **Pareto-optimal**: you cannot improve one objective without paying in the other. Designs off the curve waste money, because some other design is both cheaper and better. The job of cost optimisation is therefore two things: 1. Get onto the curve, so that no money is wasted. 2. Choose where on the curve to sit, which is a business decision about how much a watt is worth to you. ## Where the money goes The bill of materials is only part of the cost of a power supply. A useful checklist: - **Semiconductors.** MOSFETs, diodes, the controller and the gate driver. Their price scales roughly with die area, and a lower RDS(on) at the same voltage means a larger die. - **Magnetics.** Inductors and transformers. Their cost scales with core size, copper and, for custom parts, the winding labour. Lower switching frequency means more energy stored per cycle and a bigger core. - **Capacitors.** Bulk input and output capacitance. Electrolytic and polymer parts wear out, so a cheap capacitor that runs hot can set the life of the whole product. - **PCB area.** Every square centimetre of board costs money, and the large parts (magnetics, bulk capacitors, heatsinks) decide the area. - **Thermal management.** Heatsinks, thermal pads, fans and the enclosure's airflow. A fan is cheap to buy but adds noise, a wear-out part and a failure mode. - **Assembly.** Part count, through-hole parts that need a second soldering step, and anything placed or screwed by hand. - **Test and yield.** Calibration, burn-in, and the cost of boards that fail at the end of the line. Notice how many of these depend on **loss**. Loss sets the heatsink, the heatsink sets the area and assembly, and the temperature sets the capacitor life. That is why the trade-offs below always come back to watts. Voltecx does not guess prices. Its parts catalogue cites a data sheet for every part, and data sheets do not publish prices, so the shipped price list is empty on purpose. You give your own quotes with the `prices` parameter of `bom.export`, `design.tradeoff` or `analysis.pareto`, or connect an online price lookup. Until then a line is marked *unpriced* and never filled in with a made-up number. In this article we therefore compare designs by what Voltecx can compute from data sheets (watts, inductor volume, board area, heatsink mass) and leave the dollars to your purchasing team. ## The four trade-offs that decide most of the cost ### 1. Switching frequency against magnetics against loss The inductor of a buck is sized for a ripple ratio $r$, the peak-to-peak ripple current over the load current (Erickson and Maksimović, *Fundamentals of Power Electronics*, ch. 2): $$L = \frac{(V_{in} - V_{out})\,D}{r\, I_{out}\, f_{sw}}$$ Double the frequency and the inductance halves. The energy the core must store, $\tfrac{1}{2} L I_{pk}^2$, halves too, and the core can be smaller. That is the cost saving. The price is switching loss, which grows in proportion to frequency: $$P_{sw} \approx \tfrac{1}{2}\, V_{in}\, I_{out}\, (t_r + t_f)\, f_{sw}$$ and core loss, which grows with frequency for a given flux swing. Somewhere there is a frequency where the sum is lowest, and a range around it where the magnetics are small enough and the loss is still acceptable. The [switching-frequency article](https://voltecx-web.nguyenvanqui291.workers.dev/blog/choosing-switching-frequency) covers this in detail. ### 2. MOSFET RDS(on) against price A lower RDS(on) cuts conduction loss, $P_{cond} = I_{rms}^2 R_{DS(on)}$. But within one technology, a lower RDS(on) at the same voltage usually comes from a bigger die, which has more gate charge and more capacitance, so it switches more slowly and loses more energy on every edge. It also costs more. Past a certain point you pay more money for more loss. ### 3. Thermal: heatsink against airflow against loss A heatsink is rated by its sink-to-air thermal resistance $R_{th,sa}$. The junction temperature is $$T_j = T_a + P\,(R_{th,jc} + R_{th,cs} + R_{th,sa})$$ Halving $R_{th,sa}$ in still air does not take twice the aluminium. It takes much more, because a bigger fin area also cools less efficiently per square centimetre. A little airflow changes the picture completely. Every watt you avoid upstream is a smaller heatsink downstream. ### 4. Derating: enough, not excessive Derating means running a part below its rating: a 100 V MOSFET on a 48 V bus, a capacitor at 70 % of its ripple rating. Derating buys reliability, and too little of it is a classic false economy. But derating is not "the more the better". Every extra step of margin costs a bigger part, and stacked margins (a 1.5× voltage margin on top of a worst-case input, on top of a 125 °C ambient that never happens) quickly double the cost of a part without making the product more reliable. The rule is to derate against a **named rule set** and the **real worst case**, not against fear. The [derating article](https://voltecx-web.nguyenvanqui291.workers.dev/blog/derating-rules-power-components) goes through the rules part by part. ## A worked example: 48 V to 12 V, 5 A The example is an asynchronous buck: 44 to 52 V in (48 V nominal), 12 V out, 0.5 to 5 A, at most 0.12 V of output ripple. That is 60 W, the kind of intermediate rail you find in telecom and industrial equipment. ![The buck in Voltecx (circuit.template, 48 V to 12 V, 5 A, 100 kHz): switch S1, diode D1, inductor L1, output capacitor C1, input capacitor Cin, with the PWM on the gate label g.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/power-supply-cost-optimisation/buck.svg) ### Step 1: let a search find the curve Rather than guessing, we ask `analysis.pareto` to search the design space: switching frequency from 20 to 500 kHz, ripple ratio from 0.1 to 0.6, every diode in the vendor library rated for the voltage (each from its manufacturer's data sheet), four EPC GaN transistors (the EPC2619, EPC2204, EPC2045 and EPC2207: the switches a search over the whole vendor library kept on its front, given as `switches` so that the figures here do not move each time the library gains a part), and every core in the magnetics catalogue. It minimises two objectives at once: total loss and the boxed volume of the inductor. The volume is our stand-in for the cost of the magnetics. The search (a genetic algorithm, NSGA-II) evaluates 504 designs and returns a front of fourteen designs: - The most efficient one switches at 27 kHz on an E 42/21/15 core: **2.36 W** of loss with a 37.1 cm³ inductor. - The smallest one switches at 373 kHz on an EFD 20/10/7 core: **2.97 W** with a 3.54 cm³ inductor. - The **knee**, the point where the curve bends and further savings get expensive, is the EFD 25/13/9 at 116 kHz: **2.54 W** (95.94 % estimated efficiency) with a 7.06 cm³ inductor. The most efficient design saves only 0.18 W more for five times the inductor volume. The knee is the natural starting point. The smallest design saves half of the knee's inductor volume for 0.43 W more loss. Voltecx also re-simulated the knee in the switching circuit: the simulation gives 95.67 % against the estimate's 95.94 %, so the estimate is 0.3 points optimistic. That is close enough to rank designs, and a reminder to check the final pick in simulation. The core loss of a buck inductor depends on the DC current through it as well as on the ripple. For the TDK N87 and Ferroxcube 3C90 ferrites, Voltecx corrects the loss with measured DC-bias data (the Princeton MagNet database), so those cores no longer look cheaper than they are. No 3C90 or N87 core is on this front: all its cores are Ferroxcube 3C95 but one TDK N97, and neither material has such data yet, so their core loss is the data-sheet loss without it. Every design on the front uses the same diode, the Vishay VX60202PW-M3, and a small EPC GaN transistor: the EPC2204, and the EPC2207 at the smallest end. That is the first lesson: searched over the whole library, the front kept only small GaN transistors, not the biggest, lowest-resistance MOSFET. We will see why in step 3. The diode is the second lesson, and a warning. The VX60202PW-M3 is a 200 V, 2 × 30 A Schottky in a TO-247 package, on a 5 A output. The search picks it because its forward drop at 5 A is lower. Part of that lead is the data: its data sheet gives typical forward voltages only, where the other Schottky rectifiers in the library are modelled on maximum values. And the search counts only loss and inductor volume: nothing tells it what the part costs or how much board it takes. Give it your `prices` and the `cost` objective, and it weighs that saving against the price. The rest of this article keeps the part that `bom.export` picks for the diode, the Nexperia PMEG100V080ELPD (step 6), so that each step changes one thing. ### Step 2: frequency and magnetics To see the frequency trade on its own, we fix the switch, the diode and a ripple ratio of 0.3, and search only the core at three frequencies. The inductance follows the formula above: 240 µH at 25 kHz, 60 µH at 100 kHz and 15 µH at 400 kHz. ![Loss against inductor box volume on the Pareto front at 25 kHz, 100 kHz and 400 kHz (EPC2214, PMEG100V080ELPD, ripple ratio 0.3), from analysis.pareto in Voltecx.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/power-supply-cost-optimisation/pareto-fronts.svg) Read the figure from left to right: each curve is the lowest loss you can buy with a given inductor volume. - **At 25 kHz** (blue) the 240 µH inductor needs a big core. Getting under 3 W takes 26 cm³ of inductor. - **At 100 kHz** (red) the same 3 W is reached with 6.7 cm³ (2.94 W). Beyond that the curve is nearly flat: the largest core, 36.6 cm³, gets to 2.82 W. That is **5.5 times the volume to save 0.12 W**, a bad deal for almost any product. - **At 400 kHz** (green) the inductor can be tiny (3.6 cm³ for 3.08 W), but the curve never gets below 2.97 W. Switching loss sets a floor that no amount of copper can remove. The cheapest good design lives at the bend of the 100 kHz curve. A bigger core is money spent on almost nothing. Now hold the core fixed (a PQ 26/25 in 3C95 ferrite) and sweep the frequency from 25 to 400 kHz: ![Loss by part (switch conduction, switch switching, inductor) and efficiency against switching frequency, one PQ 26/25 3C95 core, from analysis.pareto in Voltecx. The diode's 2.60 W is the same at every frequency and is left off the top panel.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/power-supply-cost-optimisation/loss-vs-fsw.svg) - At 25 kHz the inductor loses 0.85 W, because the large inductance needs many turns of thin wire on a core of this size. Efficiency is 94.39 %. - At 100 kHz the inductor loss has fallen to 0.085 W and the switching loss is only 0.046 W. Efficiency peaks at **95.48 %**. - At 400 kHz the switching loss has grown to 0.185 W, and efficiency drops back to 95.26 %. The efficiency curve is flat around its peak: anywhere from about 70 to 200 kHz costs less than 0.15 points. Inside that band, choose the frequency that gives the cheapest magnetics, the easiest EMI filter (see [conducted EMI pre-compliance](https://voltecx-web.nguyenvanqui291.workers.dev/blog/conducted-emi-pre-compliance)) and a controller you can buy. ### Step 3: the expensive MOSFET is the worse one Next we swap the switch at 100 kHz, keeping everything else the same. Four candidates from the vendor library, with their typical RDS(on) at 25 °C from their data sheets: | Switch | RDS(on), typ. | Conduction | Switching | Total loss of the buck | |---|---|---|---|---| | EPC EPC2214 | 15 mΩ | 0.106 W | 0.046 W | 2.84 W | | Infineon BSC070N10NS5 | 6.0 mΩ | 0.042 W | 0.356 W | 3.09 W | | Infineon BSC040N10NS5 | 3.4 mΩ | 0.024 W | 0.667 W | 3.38 W | | Infineon ISC022N10NM6 | 1.8 mΩ | 0.013 W | 1.00 W | 3.70 W | ![Conduction, switching and total switch loss against the switch's typical RDS(on) at 100 kHz and 5 A, for the four switches of the table, from analysis.pareto in Voltecx.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/power-supply-cost-optimisation/switch-rdson.svg) Going from 15 mΩ to 1.8 mΩ cuts conduction loss by 0.09 W and adds almost 1 W of switching loss. At 5 A and a duty cycle of 0.25, the RMS current through the switch is only about $5\sqrt{0.25} = 2.5$ A, so conduction loss is small to begin with, while the big die's gate charge is paid at every edge. The part with the lowest RDS(on) makes the converter less efficient and hotter, and you would pay extra for the privilege. Two caveats. First, these switching losses are estimates: the data sheets give no switching energies, so Voltecx derives them from the gate charges with the gate-charge method (Graovac, Pürschel and Kiep, Infineon application note, 2006), and says so in its notes. Second, the comparison flips at higher current, where $I^2R$ grows quickly. The point is not "small MOSFETs are better". The point is that the right RDS(on) depends on the current and the frequency, and the most expensive part is often not the right one. ### Step 4: find the part that actually matters Look at the loss budget at 100 kHz: 2.84 W in total, of which the diode takes **2.60 W, 91 %**. The switch and the inductor together are less than a tenth. The diode's loss is roughly $(1-D)\,I_{out}\,V_F$: it conducts 75 % of the time at 5 A with an effective drop of about 0.69 V. This is the most useful result of the whole exercise. Every hour spent shaving the inductor or choosing a MOSFET moves the total by a few percent at most. The one decision that moves it a lot is the rectifier: a second switch in place of the diode (a synchronous buck) cuts most of those 2.6 W, at the cost of a second transistor and a driver that can drive it. Whether that pays depends on what a watt is worth to you; the [synchronous or diode buck](https://voltecx-web.nguyenvanqui291.workers.dev/blog/synchronous-vs-diode-buck) article works through that decision. **Find the biggest loss before you optimise anything.** ### Step 5: what a watt costs in heatsink If a part needs a heatsink, every watt you save upstream shrinks it. The Voltecx thermal catalogue lists heatsinks from their manufacturers' data sheets, each with its temperature-rise table and weight. Taking the sink-to-air resistance at 5 W, the lightest heatsinks for each resistance are: ![The lightest heatsinks in the Voltecx catalogue for each sink-to-air resistance at 5 W, in natural convection and at 200 LFM, from each heatsink's data-sheet rise table and weight.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/power-supply-cost-optimisation/heatsink-mass.svg) - In still air, a Same Sky HSS29-302513P (5.2 g) gives 17.4 K/W, and an HSE16-384225P-CP (14.2 g) gives 9.16 K/W. - To reach 5.06 K/W in still air you need an Ohmite RA-T2X-64E at 63 g, **4.4 times the mass** for less than half the resistance. - With 200 LFM of airflow, the same 14.2 g HSE16-384225P-CP gives 2.92 K/W, better than any heatsink in the catalogue in still air. So the cheapest ways to handle heat, in order: do not make it (step 4), spread it over the copper of the board, use the airflow the product already has, and only then buy aluminium. `design.thermal` does this pick for you: for each TO-220 or TO-247 device it chooses the lightest catalogue heatsink that keeps the junction at or below its limit. ### Step 6: the bill of materials and the derating check Finally, `bom.export` picks a catalogue part for every component from the stresses in the simulation. For the buck at 100 kHz: | Line | Part | Pieces | Body area | |---|---|---|---| | L1 | Coilcraft XAL1510-333MEC | 3 in series | 739 mm² | | Cin | Murata GRM32EC72A106KE05 | 8 | 64 mm² | | C1 | Murata GCM32ER71E106KA57 | 2 | 16 mm² | | S1 | EPC EPC2214 | 1 | not in the catalogue | | D1 | Nexperia PMEG100V080ELPD | 1 | not in the catalogue | The inductor takes **90 %** of the known part area (739 of 819 mm²), which is one more reason to get the frequency right. All 5 lines are unpriced: Voltecx tells you that the cost is incomplete instead of inventing it. Then `design.reliability` compares every part's measured stress with its rating times the derating factor of a named rule set. By default that is NASA EEE-INST-002 (the derating tables of its capacitor, magnetics, resistor and semiconductor sections): - S1 sees 47.8 V against a limit of 60 V (0.75 of its 80 V rating). - D1 must block at most 70 V (0.7 of its 100 V rating). - D1 carries an average of 3.74 A against a limit of 4.0 A (0.5 of its 8 A rating), a ratio of **0.93**. That is the tightest margin on the board, and still a pass. That tells you where you can save and where you cannot. The diode has no room to shrink. The switch has room on voltage, but not enough for a lower rating: a 60 V part would be allowed only 45 V under the same rule, less than the 47.8 V it sees. EEE-INST-002 is a space-grade rule set and stricter than most commercial practice. Voltecx also offers `stress`, its own common-practice factors (not a standard), or your company's rules. Pick the rule set your product's reliability target actually calls for, and derate against it, not beyond it. ## Practical pitfalls - **Optimising the wrong part.** In the example, 91 % of the loss is in one diode. Measure, or simulate, before you optimise. - **Comparing parts at the wrong operating point.** RDS(on) at 25 °C is not RDS(on) at 100 °C, and a part that wins at 20 A can lose at 5 A. Compare at your worst-case current, temperature and frequency. - **Trusting typical values for margins.** Use maximum RDS(on), maximum $V_F$ and minimum capacitance for the worst case. Typical values are for estimates like the ones above. - **Removing "unnecessary" parts.** Snubbers, bleeders, test points and TVS diodes look like cost until the first EMI scan or surge test. Check the reason a part is there before you delete it. - **Choosing non-standard values.** A 6.8 µH inductor from a standard series is cheaper and easier to second-source than a custom 6.2 µH one. Design to the values you can buy. - **Forgetting capacitor life.** A smaller electrolytic or polymer capacitor carrying the same ripple runs hotter. An aluminium electrolytic's life halves for every 10 K (the formula of Panasonic's EEU-FR data sheet), and a polymer's falls by ten for every 20 K (Panasonic OS-CON). Check the life at your real ambient before you downsize a capacitor. - **Cost-reducing after the layout.** By then the topology, the frequency and the magnetics are fixed, and they decide most of the cost. Design to cost from the start: write the cost target down next to the efficiency target on day one, and search the curve before you draw the board. ## Try it in Voltecx 1. Open the template buck with the `circuit.template` command: `{"topology":"buck","vin":48,"vout":12,"iout":5,"fsw":100e3}` (from the CLI, Python or the assistant). 2. Run **Design → Automate → Pareto Front** (`analysis.pareto`) with your spec. Start with the objectives loss and volume, then add `cost` with your own `prices` for the candidate switches, diodes and cores. 3. Re-run with `switches` restricted to two or three candidates and compare their losses at your operating point. 4. Run the simulation, then **Design → Thermal** (`design.thermal`) for the junction temperatures and the heatsink each device needs. 5. Export the BOM (**Design → Manufacturing → Export BOM**, `bom.export`) with your prices and `prefer: "cost"`, then check the margins with `design.reliability` and the capacitor choices with `design.tradeoff`. Every number and figure in this article comes from those commands, and a regression test re-runs them and checks each value against the text. --- # How to design TL431 and optocoupler feedback for a flyback URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/tl431-optocoupler-feedback-design/ Design TL431 and optocoupler feedback in four steps. Set the divider so that $V_{out} = 2.495\ \text{V}\,(1 + R_{up}/R_{low})$. Put a bias resistor across the LED so the TL431 always carries at least 1 mA. Keep the LED resistor $R_{LED}$ small enough that, at the lowest CTR, the LED can still pull the controller's feedback pin all the way down. Then design the Type II network knowing that the LED path adds a gain $G = \text{CTR}\cdot R_{pullup}/R_{LED}$ that the network cannot go below. Take a 12 V output with a 3.3 kΩ pull-up to 5 V and a CTR between 0.3 and 1.0. The divider is 9.53 kΩ over 2.49 kΩ, the bias resistor 1 kΩ, and $R_{LED}$ at most 1.70 kΩ (1.5 kΩ fitted). $G$ is then 0.66 to 2.2, and the crossover moves between 1.5 and 4.6 kHz with that CTR spread. ## The idea in one picture An off-line flyback measures its output on the secondary, but the PWM controller sits on the primary, behind the isolation barrier. The TL431 is the error amplifier: it compares a fraction of the output with its internal 2.495 V reference and sinks more current when the output is high. That current flows through the optocoupler's LED. Light crosses the barrier, and the phototransistor pulls the controller's feedback pin down against a pull-up resistor. A high output means more LED current, a lower feedback voltage and a smaller duty cycle. The catch is that the LED's anode does not hang from a clean supply: it hangs from the output itself, through $R_{LED}$. So the LED current has two paths to follow the output. The slow lane goes through the TL431 and its compensation network. The fast lane goes straight through $R_{LED}$: if the output rises by 10 mV, the LED current rises by $10\ \text{mV}/R_{LED}$, whatever the TL431 does. Most of the surprises in this circuit come from that second path. ## How do I set the output voltage with the TL431 divider? The TL431 regulates when its REF pin sits at $V_{ref}$ above its anode: 2.495 V typical for the TL431C (Texas Instruments, *TL431, TL432 Adjustable Precision Shunt Regulator*, SLVS543, Electrical Characteristics). With $R_{up}$ from the output to REF and $R_{low}$ from REF to the secondary ground, $$V_{out} = V_{ref}\left(1 + \frac{R_{up}}{R_{low}}\right) + I_{ref}\,R_{up}$$ The REF input current $I_{ref}$ is 2 µA typical in the same table, so the second term is about 20 mV with a 10 kΩ upper resistor. Pick $R_{low}$ so the divider carries about 1 mA (here 2.49 kΩ). Much larger values make $I_{ref}$ and its spread matter; much smaller ones waste power at no load. Then solve for $R_{up}$ and round to an E96 value. ## How much bias current does the TL431 need? The TL431 regulates only while its cathode current is above its minimum. The data sheet's Recommended Operating Conditions give a cathode current of at least 1 mA. At light load, or whenever the loop asks for little LED current, the LED alone may carry less than that. So a resistor $R_{bias}$ across the LED supplies the difference: $$R_{bias} \le \frac{V_f}{1\ \text{mA}}$$ With an LED forward drop near 1 V, that is 1 kΩ. The bias current flows through $R_{LED}$ too, which matters for the next step. The TL431 also needs some voltage across it. The same Recommended Operating Conditions ask for a cathode voltage of at least $V_{ref}$, so plan for $V_{KA,min} \approx 2.5$ V. ## What is the largest LED resistor I can use? The worst case is the lowest CTR (an old part, hot) at the point where the controller wants the smallest duty cycle. There the phototransistor must sink the most current, $I_{C,max} = (V_{dd} - V_{FB,min})/R_{pullup}$, which takes an LED current of $I_{C,max}/\text{CTR}_{min}$. The LED path has $V_{out} - V_f - V_{KA,min}$ of headroom, and $R_{LED}$ carries both the LED and the bias current: $$R_{LED} \le \frac{V_{out} - V_f - V_{KA,min}}{\dfrac{V_{dd} - V_{FB,min}}{\text{CTR}_{min}\,R_{pullup}} + \dfrac{V_f}{R_{bias}}}$$ This follows C. Basso's treatment of the TL431 in *Designing Control Loops for Linear and Switching Power Supplies*. A larger $R_{LED}$ than this and the loop runs out of authority at light load: the output rises because the opto cannot pull the feedback pin low enough. ## What is the small-signal gain of the TL431 and optocoupler loop? Write the TL431 with $R_z$ and $C_z$ in series from its cathode to REF: the Type II network. Its cathode then moves against the output as $-(1 + sR_zC_z)/(sR_{up}C_z)$. The LED current is the difference between the output and the cathode, divided by $R_{LED}$. Add the collector side, where $R_{pullup}$ and the capacitance on the feedback pin make a pole. The transfer function from the output to the feedback pin is $$\frac{V_{FB}}{V_{out}} = -\frac{\text{CTR}\cdot R_{pullup}}{R_{LED}}\cdot\frac{1 + s\,(R_{up} + R_z)\,C_z}{s\,R_{up}\,C_z}\cdot\frac{1}{1 + s\,R_{pullup}\,C_{pole}}$$ Three things to read from it: - **The gain $G = \text{CTR}\cdot R_{pullup}/R_{LED}$** multiplies everything. The CTR here is the small-signal one, the slope of the collector current against the LED current at the operating point. - **The zero is at $1/(2\pi\,(R_{up} + R_z)\,C_z)$**, not at $1/(2\pi R_z C_z)$ as in an op-amp Type II. The fast lane adds the "1" that moves it. - **Above the zero the gain flattens at $G\,(R_{up} + R_z)/R_{up}$**, which can never be less than $G$. Even with $R_z = 0$, the fast lane alone sets a floor on the mid-band gain. ## Where do the zero and the pole of the Type II go? - **The pole at the origin** is the TL431's integrator ($R_{up}C_z$). It gives the loop its high DC gain, so the output holds its set point. - **The zero** goes a few times below the crossover; a factor of three to five is common. It returns the phase the integrator took. - **The high-frequency pole** is the optocoupler pole, $1/(2\pi R_{pullup}(C_{pole} + C_{opto}))$. Here $C_{opto}$ is the phototransistor's own capacitance, and a larger pull-up lowers its pole further. Put it above the crossover, usually near the ESR zero of the output capacitor or a decade below the switching frequency. A capacitor across the TL431, which would make the pole in an op-amp Type II, does nothing at high frequency here: the fast lane goes around it. Place the capacitor on the feedback pin instead. ## Worked example: 12 V flyback, 3.3 kΩ pull-up, CTR 0.3 to 1.0 The power stage is the one in the `flybackTl431` example (see below), so the numbers can be checked against the circuit. Assumptions: | Input | Value | Where it comes from | |---|---|---| | Output | 12 V | spec | | $V_{ref}$, $I_{ref}$ | 2.495 V, 2 µA | TL431C typical, TI SLVS543 | | Lowest cathode current | 1 mA | TI SLVS543, Recommended Operating Conditions | | $V_{KA,min}$ | 2.5 V | TI SLVS543: cathode voltage at least $V_{ref}$ | | LED $V_f$ | 1.0 V | Vishay TCET1100 data sheet (document 83503), Fig. 7: 1.005 V at 1 mA | | CTR, small-signal | 0.3 to 1.0 | assumption: TCET1100 Fig. 13 (typical) gives 0.46 at 1 mA, and Fig. 8 lowers the CTR to 76 % at 75 °C; we allow for ageing and take 0.3. The upper end is near the curve's peak; a part from a higher CTR grade needs a higher one | | Pull-up | 3.3 kΩ to 5 V, 4.7 nF on the feedback pin | design choice | | Feedback pin | zero duty at 1 V, duty $= (V_{FB} - 1\ \text{V})/2\ \text{V}$ | the example's primary-side modulator | | Plant, duty to output | 29.4 V per unit of duty, one pole at 133 Hz (full load, 24 Ω, 100 µF) | the example's discontinuous-mode flyback: $1/(\pi R C)$ | | Target | crossover 1.5 kHz at the lowest CTR, zero at a fifth of it | design choice | The CTR is used both for the DC bound and for the small-signal gain. That is a simplification: the slope of the CTR curve is not the same as $I_C/I_F$. **Divider.** $R_{low} = 2.49$ kΩ carries 1.00 mA. $R_{up} = 2.49\ \text{k}\Omega \times (12/2.495 - 1) = 9.49$ kΩ; take 9.53 kΩ. Then $V_{out} = 2.495 \times (1 + 9.53/2.49) + 2\ \mu\text{A} \times 9.53\ \text{k}\Omega = 12.06$ V. **Bias.** $R_{bias} \le 1.0\ \text{V}/1\ \text{mA} = 1.0$ kΩ. **LED resistor.** The collector must sink up to $(5 - 1)/3.3\ \text{k}\Omega = 1.21$ mA. At CTR 0.3 that takes 4.04 mA in the LED, plus 1.0 mA in $R_{bias}$. The headroom is $12.06 - 1.0 - 2.5 = 8.56$ V, so $R_{LED} \le 8.56/5.04\ \text{mA} = 1.70$ kΩ. Take 1.5 kΩ. **Fast-lane gain.** $G = 0.3 \times 3.3/1.5 = 0.66$ (−3.6 dB) at the lowest CTR and $1.0 \times 3.3/1.5 = 2.2$ (+6.8 dB) at the highest. **Compensation.** From the feedback pin, the plant gain is $29.4 \times 0.5 = 14.7$. At 1.5 kHz that is 1.29 (+2.2 dB) at −85°, so the network must give 0.77 there. The opto pole is $1/(2\pi \times 3.3\ \text{k}\Omega \times 4.7\ \text{nF}) = 10.3$ kHz. With the zero at 300 Hz, $(R_{up} + R_z)/R_{up} = 1.16$, so $R_z = 1.53$ kΩ (1.54 kΩ) and $C_z = 48$ nF (47 nF, a zero at 306 Hz). | Result | Lowest CTR (0.3) | Highest CTR (1.0) | |---|---|---| | $G$ | 0.66 | 2.2 | | Mid-band gain $G\,(R_{up}+R_z)/R_{up}$ | 0.77 (−2.3 dB) | 2.56 (+8.1 dB) | | Crossover | 1.50 kHz | 4.56 kHz | | Phase margin | 75° | 64° | | Opto pole lag at crossover | 8° | 24° | The 3.3:1 spread of the CTR becomes a 3:1 spread of the crossover. Even with $R_z = 0$ (and the zero still at a fifth of the crossover), the fast lane alone would cross at 1.3 kHz at the lowest CTR, so no choice of the Type II network can bring the crossover lower without changing $R_{LED}$. These margins use the simple model above. They leave out the TL431's own response, the opto's internal pole and the half-load plant, whose lower gain moves the crossover down. ## What goes wrong in practice? - **The fast lane fixes a gain floor.** You cannot make the mid-band gain smaller than $\text{CTR}\cdot R_{pullup}/R_{LED}$. If the loop needs less gain than that at the crossover, at the highest CTR, the fast lane must go: feed the LED from a small Zener-regulated or RC-filtered supply instead of the output. Then $R_z/R_{up}$ alone sets the gain. - **The CTR spreads and ages.** Data sheets give the CTR at one LED current, often over a wide range for the unbinned part, and the CTR falls with temperature and operating hours. Size $R_{LED}$ at the end-of-life minimum, and check the margins at the highest CTR, cold. The TCET1100 data sheet gives no ageing curve, so the end-of-life factor is a design assumption. - **The opto pole moves with the pull-up.** The phototransistor's pole falls as $R_{pullup}$ grows, and data sheets give it at one load resistance only. A pole you placed at 10 kHz may sit lower; measure it, or keep the crossover well under it. - **The TL431 starves.** Without $R_{bias}$, a light load can leave the TL431 below 1 mA, where it stops regulating and the loop gain collapses. - **The cathode bottoms out.** At high LED current the cathode can fall to $V_{ref}$. During a load step there is then no room left, and the loop saturates. Check $V_{KA}$ at the highest LED current. ## Try it in Voltecx Open **File › Open Example › Isolated › Flyback with TL431 and optocoupler** (`file.openExample` with `flybackTl431`). It is a 12 V, 0.5 A flyback from 12 V: a 1:1 coupled inductor of 20 µH at 100 kHz, 100 µF on the output and a 24 Ω load, which halves (48 Ω) at 4 ms. Its secondary has its own ground `sgnd`, tied to the primary by 10 MΩ and a 2.2 nF Y capacitor. The loop closes through a TL431-class `shuntRegulator` (TL431C data-sheet values) and a TCET1100-class `optocoupler`, both placed as IC modules. Its feedback is the network of this article, sized differently: - divider $R_{up}$ 9.53 kΩ over $R_{low}$ 2.49 kΩ, for 12.06 V; - $R_{LED}$ 3 kΩ, with $R_{bias}$ 1.5 kΩ across the LED (0.67 mA at 1 V; the LED current brings the TL431 above 1 mA); - $R_z$ 2.7 kΩ and $C_z$ 27 nF, a zero at 480 Hz; - $R_{pullup}$ 3.3 kΩ to 5 V with $C_{pole}$ 4.7 nF, the opto pole at 10.3 kHz. It is sized for the typical CTR curve, not the 0.3 minimum. Its design notes give a crossover near 2.5 kHz with about 65° of phase margin at full load, and near 1.7 kHz at half load. By the bound above, its 3 kΩ $R_{LED}$ needs a CTR of at least 0.55 to pull the feedback pin to 1 V. 1. Run the simulation (`simulation.run`). The output holds 12.06 V at full and half load, in both solvers. Watch `v(out)` and `v(fb)` across the load step: when the load drops, the LED current increases and the feedback pin falls, so the duty cycle falls. 2. Run `circuit.problems` with `"run": true`. It reports `shunt.lowCurrent` when a shunt regulator carries less than 1 mA for more than a fifth of the second half of the run. Delete `Rbias` and run it again to see the warning. 3. Read the model's parameters and their data-sheet sources with `ic.describe` (`{"name":"optocoupler"}`). The optocoupler's `ctrScale` scales its whole CTR curve, for another bin or for the lower CTR at end of life. Place one with a lower CTR with `ic.place` and `"params": {"ctrScale": 0.5}`. 4. To measure a loop gain in a switching circuit, use **Analysis › Loop Gain** (`analysis.loopGain`): it breaks the loop at a control signal you name and reports the crossover and the margins. See [loop gain and phase margin in simulation](https://voltecx-web.nguyenvanqui291.workers.dev/blog/loop-gain-phase-margin-simulation). From a script: ```sh powercraft-cli run \ --cmd file.openExample --params '{"name":"flybackTl431"}' \ --cmd simulation.run --params '{}' \ --cmd scope.measure --params '{"signals":["v(out)","v(sgnd)","i(Rled)"],"t0":"3.5m","t1":"4m"}' ``` For an isolated flyback designed from a spec, [automatic design](https://voltecx-web.nguyenvanqui291.workers.dev/features/auto-design) sizes the same TL431 and optocoupler network. It tries each CTR bin of the TCET1100 family and checks the margins at the bin's highest CTR, its lowest and its lowest after ageing (by default, half the CTR is left at end of life). ## Frequently asked questions ### Why does my TL431 loop have more gain than I designed? Almost always it is the fast lane. The LED is fed from the output through $R_{LED}$, so the gain never drops below $\text{CTR}\cdot R_{pullup}/R_{LED}$, whatever $R_z$ you choose. At the highest CTR this floor can put the crossover several times higher than planned. ### What value should the resistor across the optocoupler LED have? About $V_f/1\ \text{mA}$, near 1 kΩ for an LED drop of 1 V. It keeps the TL431 at or above the 1 mA its data sheet recommends when the LED itself needs little current. ### Can I put the compensation pole capacitor across the TL431? It will not make the high-frequency pole you expect. The fast lane carries the output ripple to the LED around the TL431, so the pole must come after the opto: a capacitor from the feedback pin to ground, with the pull-up resistor and the phototransistor's own capacitance. ### Which CTR should I design with? Size $R_{LED}$ at the lowest CTR at end of life and at the highest temperature. Check the phase margin at the highest CTR, cold. Use the small-signal CTR (the slope of the curve at the operating LED current) for the loop gain, not the ratio printed in the data sheet's table. ## Sources - Texas Instruments, *TL431, TL432 Adjustable Precision Shunt Regulator*, data sheet SLVS543 (Voltecx's model uses revision S, May 2024): Recommended Operating Conditions and Electrical Characteristics, TL431C. - C. Basso, *Designing Control Loops for Linear and Switching Power Supplies: A Tutorial Guide*, Artech House, 2012. - C. Basso, "The TL431 in the Control of Switching Power Supplies", ON Semiconductor seminar, 2009. - Vishay Semiconductors, *TCET1100, TCET1100G Optocoupler, Phototransistor Output, High Temperature*, document 83503: Fig. 7, Fig. 8 and Fig. 13. --- # How to size a bootstrap capacitor for a high-side gate driver URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/bootstrap-capacitor-calculation/ Size a bootstrap capacitor from the charge the high side draws during its longest on-time and the droop the driver's under-voltage lockout allows: $C_{boot} \ge Q_{total} / \Delta V_{boot}$, with $Q_{total} = Q_g + I_{HBS}\,t_{on,max} + I_{HB}/f_{sw} + Q_{ls}$ and $\Delta V_{boot}$ no larger than $V_{DD} - V_F - V_{UVLO}$. Check that it is also at least ten times the gate's equivalent capacitance, then choose a diode, a series resistor that recharges it within the shortest off-time, and the duty limit that follows. For a MOSFET with 50 nC of gate charge at 100 kHz, a 12 V supply and a 1 V droop, the budget is 56.6 nC, the capacitor 68 nF, the diode carries 5.7 mA on average, and a 4.7 Ω series resistor allows a duty cycle of up to 0.904. ## The idea in one picture A high-side MOSFET's source sits on the switch node, which swings from ground to the bus voltage. Its gate driver needs a supply that rides along with that node. The bootstrap is a bucket: while the low-side switch is on, the switch node is at ground and the bucket (the capacitor between the driver's HB and HS pins) fills from $V_{DD}$ through a diode. When the high side turns on, the switch node climbs to the bus, the diode blocks, and the bucket alone drives the gate and keeps the high-side half of the driver alive until the next refill. So sizing the bootstrap is two questions: is the bucket big enough to last through the longest on-time without falling below the driver's lockout, and does it have time to refill during the shortest off-time? ## What draws charge from a bootstrap capacitor? Everything on the floating side, over one cycle (International Rectifier AN-978, *HV Floating MOS-Gate Driver ICs*; Texas Instruments SLUA887, *Bootstrap Circuitry Selection for Half-Bridge Configurations*): - **The gate charge $Q_g$**, once per turn-on, at the voltage the gate is really driven to: $V_{DD}$ less the diode drop. A data sheet gives $Q_g$ at one test voltage; read the gate-charge curve at your drive voltage. - **The high-side quiescent current $I_{HB}$** of the driver, which flows all the time. Taken over a whole period, $I_{HB}/f_{sw}$, it is a safe upper bound. - **Leakage $I_{HBS}$** from the floating supply to ground, plus the reverse leakage of the bootstrap diode and the capacitor's own leakage, over the on-time. - **The level-shift charge $Q_{ls}$** that a high-voltage level shifter draws from the floating supply each cycle, which AN-978 counts separately for high-voltage driver ICs. Use the figure your driver's data sheet or application note gives. $$Q_{total} = Q_g + I_{HBS}\,t_{on,max} + \frac{I_{HB}}{f_{sw}} + Q_{ls}, \qquad t_{on,max} = \frac{D_{max}}{f_{sw}}$$ Use maximum values from the data sheets, not typical ones, and the hottest temperature: leakage grows with it. ## How much droop can the bootstrap allow? The capacitor charges to $V_{DD} - V_F$ (the diode's forward drop at the charging current). During the on-time it falls by $Q_{total}/C_{boot}$. The high side must stay above the falling threshold of its own under-voltage lockout, $V_{UVLO}$; below it, the driver turns the high-side gate off. The largest droop is therefore $$\Delta V_{max} = V_{DD} - V_F - V_{UVLO}$$ and the capacitor is $$C_{boot} \ge \frac{Q_{total}}{\Delta V_{boot}}, \qquad \Delta V_{boot} \le \Delta V_{max}$$ (SLUA887). Do not design right at $\Delta V_{max}$: the gate then reaches the plateau and turns on with a low drive voltage, its on-resistance rises near the end of the on-time, and every tolerance (the supply, the diode, the threshold) eats into a margin of zero. Pick a droop well inside it, often a volt or less, and leave the rest as margin. ## Why at least ten times the gate capacitance? When the high side turns on, the bootstrap capacitor shares its charge with the gate. With the gate's equivalent capacitance $C_g = Q_g/(V_{DD} - V_F)$, the voltage left after the transfer is $C_{boot}/(C_{boot} + C_g)$ of the starting voltage. SLUA887 asks for $$C_{boot} \ge 10\,\frac{Q_g}{V_{DD} - V_F}$$ so that the transfer alone costs at most $1 - 10/11 \approx 9.1$ % of the gate voltage. Take the larger of the two values (the charge budget and the 10× rule), then round up to a standard value. Ceramic capacitors lose capacitance under DC bias, so the value that counts is the one at $V_{DD} - V_F$, read from the capacitor's bias curve. SLUA887 also asks for a local $V_{DD}$ bypass of at least ten times the bootstrap capacitor, because every refill is drawn from it. ## How do I choose the bootstrap diode? - **Voltage rating** above the bus voltage, with your derating margin: while the high side is on, the diode blocks the full bus plus the ringing of the switch node. - **Recovery**: ultrafast or Schottky. The diode is forward biased while the low side is on and is reverse biased every time the switch node rises, so its recovery charge flows back out of the bootstrap capacitor into $V_{DD}$ at every cycle and adds to the switch-node noise (AN-978). - **Current**: the average current is small, $I_{F,avg} = Q_{total}\,f_{sw}$, but the peak current at start-up is large, because the capacitor starts empty. - **Forward drop**: it lowers both the gate drive and the droop margin; use its value at the charging current. Many half-bridge driver ICs build the diode in. Its data sheet then gives the forward voltage and a dynamic resistance, which are the $V_F$ and the series resistance of the charging path. ## Series resistor, peak current and refresh time A resistor $R_{boot}$ in series with the diode limits the charging current. At start-up, with the capacitor empty and the switch node at ground, the peak is $$I_{pk,start} = \frac{V_{DD} - V_F}{R_{boot}}$$ In steady state the capacitor only has to make up the droop, so the peak is about $\Delta V_{boot}/R_{boot}$. The price of the resistor is time: the capacitor recharges with $\tau = R_{boot} C_{boot}$, and SLUA887 takes about $3\tau$ (95 % of the deficit) as the recharge time. That time must fit in the shortest interval in which the switch node sits at ground: the low side's minimum on-time, $(1 - D_{max})/f_{sw}$ in a synchronous stage. ## What is the maximum duty cycle with a bootstrap? From the refresh condition $3 R_{boot} C_{boot} \le (1 - D_{max})/f_{sw}$: $$D_{max} \le 1 - 3\,R_{boot}\,C_{boot}\,f_{sw}$$ A plain bootstrap cannot hold 100 % duty either. With the high side on and no switching, only the leakage and the quiescent current drain the capacitor, and the on-time is limited to about $C_{boot}\,(V_{DD} - V_F - Q_g/C_{boot} - V_{UVLO}) / (I_{HB} + I_{HBS})$. Beyond that, you need a charge pump, an isolated supply, or a forced refresh pulse. ## Worked example: a 100 kHz half-bridge with a 12 V driver supply All of these inputs are **assumed example values**, not the data of a particular part. Replace each with the maximum from your own data sheets. | Input | Value | |---|---| | Driver supply $V_{DD}$ | 12 V | | Bootstrap diode drop $V_F$ (at the charging current) | 0.9 V | | High-side UVLO, falling, maximum $V_{UVLO}$ | 8.0 V | | Gate charge $Q_g$ at about 11 V | 50 nC | | High-side quiescent current $I_{HB}$ (max) | 0.15 mA | | Leakage $I_{HBS}$ (driver, diode and capacitor) | 10 µA | | Level-shift charge $Q_{ls}$ | 5 nC | | Switching frequency $f_{sw}$ | 100 kHz | | Longest high-side duty $D_{max}$ | 0.9 | **Charge budget.** $t_{on,max} = 0.9/100\ \text{kHz} = 9$ µs. The leakage contributes $10\ \mu\text{A} \times 9\ \mu\text{s} = 0.09$ nC, the quiescent current $0.15\ \text{mA}/100\ \text{kHz} = 1.5$ nC: $$Q_{total} = 50 + 0.09 + 1.5 + 5 = 56.6\ \text{nC}$$ **Droop.** $\Delta V_{max} = 12 - 0.9 - 8.0 = 3.1$ V. Design for 1 V and keep 2.1 V of margin. **Capacitor.** The charge budget needs $56.6\ \text{nC}/1\ \text{V} = 56.6$ nF; the 10× rule needs $10 \times 50\ \text{nC}/11.1\ \text{V} = 45.0$ nF. The budget is larger; the next E6 value is **68 nF** (effective, at 11.1 V of bias). The droop is then $56.6/68 = 0.83$ V and the bootstrap ends the longest on-time at 10.27 V, 2.27 V above the lockout. The $V_{DD}$ bypass is at least $10 \times 68\ \text{nF} = 0.68$ µF. **Resistor and duty limit.** The low side is on for at least $(1 - 0.9)/100\ \text{kHz} = 1$ µs. | | $R_{boot}$ = 10 Ω | $R_{boot}$ = 4.7 Ω | |---|---|---| | $\tau = R_{boot} C_{boot}$ | 680 ns | 320 ns | | Recharge $3\tau$ | 2.04 µs | 0.96 µs | | Fits in the 1 µs off-time | no | yes | | Duty limit $1 - 3 R C f_{sw}$ | 0.796 | 0.904 | | Start-up peak $(V_{DD} - V_F)/R$ | 1.11 A | 2.36 A | | Steady-state peak $\approx 0.83\ \text{V}/R$ | 0.083 A | 0.18 A | 10 Ω would cap the duty at 0.80, below the 0.9 we need, so the resistor drops to 4.7 Ω, and the diode (or the driver's built-in one) must take a 2.36 A start-up pulse. If that is too much, soft-start the converter so the first low-side pulses are short, or accept a lower duty limit. **Diode.** Average current $56.6\ \text{nC} \times 100\ \text{kHz} = 5.66$ mA; reverse rating above the bus with margin; ultrafast recovery. **Static hold.** With the high side held on, the gate charge transfer leaves $11.1 - 50/68 = 10.36$ V, 2.36 V above the lockout, and $0.16$ mA of drain empties that in about $68\ \text{nF} \times 2.36\ \text{V}/0.16\ \text{mA} = 1.0$ ms. Longer on-times need another supply. ## Common mistakes - **Using $Q_g$ at the data sheet's test voltage.** If the gate-charge curve is given at 10 V and you drive at 11 V, the gate takes more charge than the table shows. - **Designing at the full UVLO margin.** It leaves nothing for the tolerance of the supply, the diode drop and the capacitor's DC-bias loss. - **Reading the capacitor's nominal value.** A small ceramic capacitor at 11 V of bias can have a fraction of its rated capacitance. Use the bias curve. - **Forgetting the start-up peak.** The first refill charges an empty capacitor through only $R_{boot}$ and the diode. - **Assuming 100 % duty works.** Without refresh pulses, the bootstrap runs down in milliseconds. ## Try it in Voltecx 1. Open **File › Open Example › buckSync**: a synchronous buck, 48 V to 12 V at 100 kHz, with Q1 on the high side (its source on the switch node `sw`) and Q2 below it, each gate fed by a `deadtime` block with 200 ns. The example drives both gates directly from the control signals: there is no driver IC and no bootstrap capacitor in the circuit, so the floating supply is ideal. 2. Run **Design › Design Steps › Gate Drive** (`design.gateDrive`). It recognises Q1 as high side, pairs it with Q2, picks a half-bridge driver with a bootstrap from its catalogue (TI and Infineon parts, every number from the cited data sheet), and sizes the bootstrap with the SLUA887 equations above: the reply gives `Q1.qBoot` (the charge budget), `Q1.bootDroopMax` ($V_{DD} - V_F - V_{UVLO}$ of that driver), `Q1.cBootCharge`, `Q1.cBootRule`, `Q1.cBoot`, `Q1.cVdd`, `Q1.tOnMax` and `Q1.bootDiodeCurrent`. Its checks compare the bootstrap voltage after the longest on-time with the high-side UVLO and, for a driver with a built-in diode, the $3\tau$ recharge with the shortest off-time. 3. The switches need a library device with gate charges. Name one with `switchDevice`, set the supply with `vdd`, a design droop with `droop` (by default it uses the whole margin) and `bootDiodeVf` for a driver without its own diode. The charge it adds up is $Q_g + I_{HBS}\,D_{max}/f_{sw} + I_{HB}/f_{sw}$; add a level-shift charge yourself when your driver's data sheet gives one. The command changes nothing in the circuit. ```sh powercraft-cli run --cmd file.openExample --params '{"name":"buckSync"}' \ --cmd design.gateDrive --params '{"switchDevice":"infineon/bsc070n10ns5","vdd":10,"droop":1}' ``` `design.auto` runs the same step for a whole design. See [design tools](https://voltecx-web.nguyenvanqui291.workers.dev/features/design-tools), [models and parts](https://voltecx-web.nguyenvanqui291.workers.dev/features/models-and-parts) and the [automatic design chapter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/16-automatic-design/) of the manual. ## Frequently asked questions ### What value of bootstrap capacitor should I use? The larger of $Q_{total}/\Delta V_{boot}$ and $10\,Q_g/(V_{DD} - V_F)$, rounded up, and read at its DC bias. ### Can the bootstrap capacitor be too large? Yes. A large capacitor takes longer to recharge through the same resistor, which lowers the duty limit, and draws a larger start-up current from $V_{DD}$ and through the diode. Size it, then check the refresh time. ### Why does the high side shut off at high duty cycle? Either the capacitor does not refill in the short low-side on-time ($3 R_{boot} C_{boot}$ is longer than $(1-D)/f_{sw}$), or it droops below the high-side UVLO during the long on-time. Both show up as a high-side gate that drops out after a few cycles. ### Does the bootstrap diode need to be fast? Yes. It is reverse biased by the full bus every time the switch node rises, and its recovery charge is pulled from the bootstrap capacitor and injected into the switch-node edge. Use an ultrafast or Schottky diode rated above the bus. ## Sources - International Rectifier, AN-978, *HV Floating MOS-Gate Driver ICs* (charge components of the bootstrap supply, level-shift charge, diode recovery). - Texas Instruments, SLUA887, *Bootstrap Circuitry Selection for Half-Bridge Configurations* (the charge budget, $\Delta V$ from the UVLO, the 10× rule, the $V_{DD}$ bypass and the $3\tau$ recharge). - L. Balogh, *Design and Application Guide for High Speed MOSFET Gate Drive Circuits*, Texas Instruments SLUP169 (gate charge and drive power). --- # How to size the DC-link capacitor of a three-phase inverter URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/dc-link-capacitor-sizing-inverter/ The DC-link capacitor of a three-phase PWM inverter is sized first by its RMS ripple current, $I_{C,rms} = I_N\sqrt{2M\left[\frac{\sqrt{3}}{4\pi} + \cos^2\varphi\left(\frac{\sqrt{3}}{\pi} - \frac{9M}{16}\right)\right]}$, where $I_N$ is the RMS phase current and $M$ the modulation index (Kolar and Round, 2006). Then check the switching voltage ripple and any hold-up time. The current never goes above about $0.65\,I_N$. For a 700 V bus, 50 A RMS per phase, $M = 0.9$ and $\cos\varphi = 0.85$, the capacitor carries 27.7 A RMS. Two 60 µF film capacitors cover that with margin and hold the ripple to about 11 V peak to peak. A 1 ms hold-up from 700 V down to 600 V needs 437 µF. ## Why does the DC link need a capacitor at all? Each leg of the inverter connects its phase to the positive rail or to the negative rail. The current drawn from the bus, $i_{dc}$, is therefore a chopped sum of the phase currents. During a zero vector (all upper or all lower switches on) it is zero. During an active vector it equals one phase current, or the negative of one. The supply cable has inductance and cannot follow steps at the switching frequency, so the capacitor supplies these pulses and the cable carries only their average. Averaged over one carrier period, the bus current of a balanced inverter with sinusoidal currents is constant: $$I_{dc} = \frac{3}{4}\, M\, \hat{I}\cos\varphi = \frac{P}{V_{dc}}$$ So the capacitor current is $i_{dc} - I_{dc}$: pulses at the switching frequency with no mean. Its RMS value heats the capacitor, and this sets the size of the part in most designs. ## How much RMS current does the DC-link capacitor carry? J. W. Kolar and S. D. Round derived the RMS current for sine-triangle PWM with sinusoidal phase currents and a carrier much faster than the output frequency: $$I_{C,rms} = I_N\sqrt{2M\left[\frac{\sqrt{3}}{4\pi} + \cos^2\varphi\left(\frac{\sqrt{3}}{\pi} - \frac{9M}{16}\right)\right]}$$ - $I_N$ is the **RMS** phase current, so the peak is $\hat{I} = \sqrt{2}\,I_N$. - $M = \hat{V}_{ph}/(V_{dc}/2)$ is the peak phase voltage (line to the star point of the load) over half the bus voltage. $M = 1$ is the limit of sine-triangle PWM. - $\varphi$ is the angle between the fundamental phase voltage and current. We checked the formula against a direct calculation. We built the switched bus current from ideal switching functions at a carrier 2000 times the output frequency and took the RMS of its AC part. The two agree to within 0.01 % at every $M$ and $\cos\varphi$ we tried. That check also shows which definition is used: $I_N$ is the RMS phase current, and $M$ is referred to $V_{dc}/2$. The ratio $I_{C,rms}/I_N$ from the formula: | $\cos\varphi$ | $M = 0.3$ | $M = 0.5$ | $M = 0.7$ | $M = 0.9$ | $M = 1.0$ | |---|---|---|---|---|---| | 1 | 0.559 | 0.639 | 0.643 | 0.574 | 0.503 | | 0.85 | 0.499 | 0.577 | 0.594 | 0.554 | 0.509 | | 0.5 | 0.374 | 0.453 | 0.498 | 0.518 | 0.520 | | 0 | 0.288 | 0.371 | 0.439 | 0.498 | 0.525 | The worst case is $\cos\varphi = 1$ at $M \approx 0.61$, where $I_{C,rms} = 0.650\,I_N$. When the operating point is unknown, as in a motor drive that runs at every speed, size for $0.65\,I_N$. ## Is there a ripple at six times the output frequency? Not from the inverter itself. With balanced sinusoidal currents the carrier-averaged bus current is constant, so the capacitor current contains only switching-frequency components. In our calculation for $M = 0.9$ and $\cos\varphi = 0.85$, the largest of them sit at twice the switching frequency and at the switching frequency plus or minus three times the output frequency. Below half the switching frequency there is practically nothing. A ripple at six times the **line** frequency, 300 Hz on a 50 Hz grid, comes from the supply side: a six-pulse diode rectifier feeding the DC link. Unbalanced or distorted phase currents add components at low multiples of the output frequency. If your link has either, add those currents to the capacitor's RMS budget. They are also where electrolytic capacitors carry their ripple most cheaply. ## How much capacitance for the voltage ripple? The switching ripple of the bus voltage is the integral of these current pulses over a carrier period. A simple bound is $$\Delta V_{pp} \le \frac{\hat{I}}{4\, C\, f_{sw}}$$ We scanned ideal sine-triangle PWM over $0.1 \le M \le 1$ and $0 \le \cos\varphi \le 1$, integrating the capacitor current. The peak-to-peak ripple stayed below 87 % of this bound; the highest value came at $M = 1$, $\cos\varphi = 0$. With film capacitors sized for the ripple current, the voltage ripple is usually small. Check it anyway, because the modulator and the current sensing see it. ## How much capacitance for hold-up? If the link must keep the inverter running for a time $t_{hold}$ while the supply is gone, the stored energy must cover it as the bus falls from $V_1$ to the lowest voltage the inverter still works at, $V_2$: $$C \ge \frac{2\, P\, t_{hold}}{V_1^2 - V_2^2}$$ Hold-up quickly needs much more capacitance than the ripple current does. When it applies, it often decides the technology. ## Film or electrolytic? The two technologies differ by two orders of magnitude in ripple current per microfarad. Two parts from the Voltecx parts catalogue show it: | Part | Capacitance, voltage | Rated ripple current | Per µF | |---|---|---|---| | TDK B32778G0606K000, film | 60 µF, 1100 V DC | 30.5 A at 10 kHz, 70 °C | 0.51 A/µF | | TDK B43544E5827M060, aluminium electrolytic | 820 µF, 450 V DC | 3.8 A at 100 Hz, 105 °C | 0.0046 A/µF | The rated conditions differ, so read the ratio, about 110, as an order of magnitude. Electrolytic data sheets also list frequency factors that raise the rating above 100 Hz; apply them before you compare at 10 kHz. - **Film** (metallized polypropylene): high ripple current per µF, high voltage in one part, and self-healing. Its rated voltage falls with temperature. The TDK B3277* data sheet gives 1100 V at 70 °C, 920 V at 85 °C, and a further 1.33 %/°C up to 105 °C for the 1100 V parts. Size by current; the capacitance usually comes out small. - **Aluminium electrolytic**: high capacitance per volume and per cost, but little ripple current per µF. A 700 V bus needs two in series (the B43544 series stops at 550 V), with balancing resistors. Their life is set by the core temperature. Panasonic's aluminium electrolytic data sheets (for example the FR-A series, 01-Sep-25) give $L_2 = L_1 \cdot 2^{(T_1 - T_2)/10}$: life doubles for every 10 K cooler. A part rated 3000 h at 105 °C (the useful life of the B43544 series) would reach $3000 \times 2^4 = 48\,000$ h with its core at 65 °C by that rule. The ripple current heats the core, so check against the manufacturer's own life curve. ## Worked example: 700 V bus, 50 A RMS per phase Inputs: $V_{dc} = 700$ V, $I_N = 50$ A RMS, $M = 0.9$, $\cos\varphi = 0.85$, $f_{sw} = 10$ kHz, sine-triangle PWM. Hold-up requirement: 1 ms from 700 V to 600 V. Current derating: 70 % of the rated ripple current, the default of `analysis.stress`. | Quantity | Formula | Value | |---|---|---| | Peak phase voltage | $M\, V_{dc}/2$ | 315 V (386 V line to line, RMS) | | Output power | $3\,(\hat{V}_{ph}/\sqrt{2})\, I_N \cos\varphi$ | 28.4 kW | | Mean bus current | $\tfrac{3}{4} M \hat{I}\cos\varphi = P/V_{dc}$ | 40.6 A | | Capacitor RMS current | Kolar–Round | 27.7 A ($0.554\,I_N$) | | Rating needed at 70 % | $27.7 / 0.7$ | 39.6 A | | Film parts for the current | 2 × B32778G0606K000 | 120 µF, 61 A rated | | Ripple bound with 120 µF | $\hat{I}/(4 C f_{sw})$ | 14.7 V | | Ripple, integrated | numerical, this $M$ and $\varphi$ | 10.6 V peak to peak | | Capacitance for hold-up | $2 P t_{hold}/(V_1^2 - V_2^2)$ | 437 µF | Without the hold-up requirement, two film capacitors do the job. With it, you need eight of them (480 µF), which also brings the ripple down to about 2.6 V. The other route is electrolytics. With 2 × 820 µF, 450 V in series per string and 3.8 A per string at 100 Hz, the 27.7 A needs at least 8 strings (16 cans, 3280 µF). That meets hold-up many times over, but the parts must keep their core temperature down at 10 kHz. That bank is far larger than the voltage ripple needs, which is why film is the usual choice when there is no hold-up requirement. ## Try it in Voltecx 1. Open **File › Open Example › inverter3**. It is a two-level inverter with sine-triangle PWM ($M = 0.8$, 10 kHz, 1 µs dead time). It feeds a star-connected 10 Ω + 10 mH load at 50 Hz ($\cos\varphi = 0.954$) from an ideal 600 V source. `inverter3Bus` is the same circuit wired with buses, and it simulates the same. 2. The example has no DC-link capacitor: the ideal source supplies the pulses. So the AC part of the source current, `i(Vdc)`, is what a stiff link capacitor would carry. Run it, then open **Scope › Measurements** (`scope.measure`) from 20 ms. In our run, `acRms` of `i(Vdc)` was 9.6 A, with 15.7 A RMS in each phase. The formula gives 9.5 A for $M = 0.8$; the dead time lowers the effective $M$ a little. 3. To see a real capacitor, feed the bus through a source impedance and add the capacitor. `analysis.stress` then lists it with its measured `rippleRmsA` and the current rating it needs at your derating. ```sh powercraft-cli run --cmd file.openExample --params '{"name":"inverter3"}' \ --cmd circuit.connect --params '{"component":"Vdc","port":"p","net":"src"}' \ --cmd circuit.addComponent --params '{"name":"Rs","kind":"resistor","params":{"r":1}}' \ --cmd circuit.connect --params '{"component":"Rs","port":"p","net":"src"}' \ --cmd circuit.connect --params '{"component":"Rs","port":"n","net":"mid"}' \ --cmd circuit.addComponent --params '{"name":"Ls","kind":"inductor","params":{"l":"1m"}}' \ --cmd circuit.connect --params '{"component":"Ls","port":"p","net":"mid"}' \ --cmd circuit.connect --params '{"component":"Ls","port":"n","net":"dcp"}' \ --cmd circuit.addComponent --params '{"name":"Cdc","kind":"capacitor","params":{"c":"200u","v0":600}}' \ --cmd circuit.connect --params '{"component":"Cdc","port":"p","net":"dcp"}' \ --cmd circuit.connect --params '{"component":"Cdc","port":"n","net":"dcn"}' \ --cmd simulation.run \ --cmd scope.measure --params '{"signals":["i(Cdc)","i(Ls)","v(dcp)"],"t0":"20m"}' \ --cmd analysis.stress --params '{"t0":"20m"}' ``` In our run the capacitor carried 9.4 A RMS and the source branch 12.1 A with only 0.08 A of ripple. The bus rippled by 2.1 V peak to peak, under the 2.75 V that the bound gives for 200 µF. `analysis.stress` asked for a 13.5 A rating. The [analyses overview](https://voltecx-web.nguyenvanqui291.workers.dev/features/analyses) lists the other post-run checks, and the [motor drive](https://voltecx-web.nguyenvanqui291.workers.dev/use-cases/motor-drive) page shows where the inverter sits in a drive. ## Frequently asked questions ### Is $I_N$ in the Kolar–Round formula the peak or the RMS phase current? The RMS phase current. With $M$ defined as the peak phase voltage over $V_{dc}/2$, the formula matches a direct calculation of the switched bus current. The maximum, $0.65\,I_N$, occurs at $\cos\varphi = 1$ and $M \approx 0.61$. ### Does space vector PWM change the capacitor current? In our numerical check, adding the min-max zero-sequence signal (equivalent to SVPWM) left the RMS current unchanged. The formula still matched at $M = 1.1$, inside the extended linear range. The zero sequence moves the zero vectors within the period but does not change how long each active vector lasts. Discontinuous PWM schemes are a different case, which we did not check here. See [space vector PWM explained](https://voltecx-web.nguyenvanqui291.workers.dev/blog/space-vector-pwm-explained). ### Why not simply use a big electrolytic bank? You can, but it is sized by ripple current, not by capacitance. At 0.0046 A/µF the bank ends up with many times the capacitance the ripple voltage needs, and its life depends on keeping the core cool. Electrolytics make sense when hold-up or a rectifier's 300 Hz ripple needs the capacitance anyway. ### Does the switching frequency change the RMS current? Not in the formula. The RMS current depends only on $M$, $\cos\varphi$ and $I_N$, as long as the carrier is much faster than the output. A higher switching frequency lowers the voltage ripple, $\propto 1/f_{sw}$, and moves the current to frequencies where the capacitor's ESR and the wiring inductance matter more. ## Sources - J. W. Kolar and S. D. Round, "Analytical calculation of the RMS current stress on the DC-link capacitor of voltage-PWM converter systems", *IEE Proceedings – Electric Power Applications*, 2006. - TDK Electronics, *Film Capacitors, Capacitors for DC Link, Series/Type B3277\*D/E/G/J/T*, June 2026: ordering table (B32778G, p13) and technical data (p14). - TDK Electronics, *Aluminum electrolytic capacitors, Snap-in capacitors, Series/Type B43544*, December 2019: technical data and ordering codes (pp12–15) and useful life (p3). - Panasonic, FR-A series aluminium electrolytic capacitor data sheet, 01-Sep-25: the life formula under "Matters to Be Observed When Using This Product". --- # Interleaved boost PFC: ripple cancellation, inductors and current sharing URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/interleaved-boost-pfc-ripple-cancellation/ An interleaved boost PFC runs two (or more) boost legs in parallel with their carriers shifted by half a switching period. Their ripple currents have opposite slopes, so in the line current they cancel by the factor $(1-2D)/(1-D)$ below $D = 0.5$ and $(2D-1)/D$ above it, completely at $D = 0.5$, and what is left moves from $f_{sw}$ to $2f_{sw}$. In the 2 kW, 230 V to 400 V example of this article, with 2 mH per leg at 20 kHz, the worst input ripple falls from 5 A to 1.25 A peak to peak, the switching ripple in the line current from 1.12 A to 0.28 A rms, and the switching part of the bulk capacitor's current from 3.56 A to 1.73 A rms. The catch is current sharing: one current loop for the total current leaves the split to the parts, and a duty mismatch of 1 % puts 81 % of the current in one leg. ## Why interleave a PFC? A single boost PFC above a kilowatt or so meets three problems at once: the inductor gets large, the input ripple at the switching frequency is large and has to be filtered, and the bulk capacitor carries the full pulsed diode current. Splitting the converter into two legs of half the power each, and switching them half a period apart, attacks all three: - **Each leg carries half the current**, so each inductor, switch and diode handles half the power, and the heat spreads over twice as many parts. - **The ripples cancel in the sum.** The line and the EMI filter see the sum of the two leg currents, whose ripple is smaller than either. - **The ripple frequency doubles.** What remains of the input ripple, and of the diode current into the bulk capacitor, repeats at $2f_{sw}$. The idea is old and well documented: B. A. Miwa, D. M. Otten and M. F. Schlecht, "High efficiency power factor correction using interleaving techniques", IEEE APEC 1992, and L. Balogh and R. Redl, "Power-factor correction with interleaved boost converters in continuous-inductor-current mode", IEEE APEC 1993. ## The example circuit The `interleavedPfc` example in Voltecx is a two-phase interleaved boost PFC: 230 V rms, 50 Hz in, 400 V DC out, 2 kW into 80 Ω. The bridge feeds two legs, each a 2 mH inductor, a MOSFET (20 mΩ) and a boost diode (0.8 V, 10 mΩ), into a 1 mF bulk capacitor. The two PWM carriers run at 20 kHz, the second shifted by half a period (`phase` 0.5). The control is average current mode on the total current `il`: an outer voltage PI sets the amplitude of a current reference shaped like the rectified line, and an inner current PI with a duty feedforward $1 - |v_{ac}|/V_{ref}$ makes one duty for both legs. All parameters are illustrative. ![The interleavedPfc example in Voltecx: the bridge, the two boost legs L1/S1/Db1 and L2/S2/Db2 sharing one bulk capacitor, and the controller as one subsystem (CTRL) that reads the total current il, the line voltage vac and the output vdc, and drives the gates g1 and g2 through net labels.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/interleaved-boost-pfc-ripple-cancellation/interleaved-pfc.svg) All the numbers below are from the example's own run, 0.25 s with a 1 µs step on the fast solver, measured over the last two line cycles (0.2 s to 0.24 s). The output sits at 398.5 V with 16.8 V of ripple at 100 Hz (the formula $P/(2\pi f_{line} C V_{dc})$ gives 15.9 V), the line current is 8.80 A rms, and the two legs carry 3.955 A and 3.954 A on average, 4.43 A rms each. ## How the ripples cancel In continuous conduction each leg is a boost with $V_{in}$ on the inductor while its switch is on, and $V_{in} - V_{out}$ while it is off. Its peak-to-peak ripple is (R. W. Erickson and D. Maksimović, *Fundamentals of Power Electronics*, 3rd ed., chapter 2): $$\Delta I_L = \frac{V_{in} D}{L f_{sw}} = \frac{V_{out}\, D (1-D)}{L f_{sw}}$$ Over a line half cycle, $V_{in}$ moves slowly compared with the switching period, so each period sees a near-constant duty $D = 1 - |v_{in}|/V_{out}$. Now shift leg 2 by half a period. For $D < 0.5$, the on-times never overlap: in each half period, one leg is rising at $V_{in}/L$ for a time $DT$ while the other falls at $(V_{in}-V_{out})/L$, and for the rest of the half period both fall. Adding the slopes over the interval when one rises and the other falls gives the ripple of the sum, and dividing by one leg's ripple gives the ripple-cancellation factor: $$K(D) = \frac{\Delta I_{in}}{\Delta I_L} = \begin{cases} \dfrac{1-2D}{1-D} & D \le 0.5 \\[2ex] \dfrac{2D-1}{D} & D \ge 0.5 \end{cases}$$ At $D = 0.5$ the rising slope of one leg exactly cancels the falling slope of the other, and the sum is flat. Close to $D = 0$ or $D = 1$ there is little to cancel. For a PFC the duty sweeps a wide range every half cycle: from near 1 at the zero crossing down to $1 - 325/400 = 0.19$ at the crest of 230 V. So the cancellation is perfect twice per half cycle, where the rectified line is at 200 V, and partial elsewhere. ![The ripple-cancellation factor against the duty: the formula, and Voltecx's ratio of the input ripple to one leg's ripple, period by period over one half line cycle of the interleavedPfc example.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/interleaved-boost-pfc-ripple-cancellation/ripple-factor.svg) To compare with the simulation, each 50 µs switching period of one half line cycle was measured on its own: the peak-to-peak ripple of the total current `il` and of the leg current `i(L1)` (each with the line's slope over the period removed), and the duty the voltages ask for, $1 - |v_{ac}|/v_{dc}$. In the 186 periods where both legs conduct throughout, the ratio follows the formula within 0.07, and within 0.016 on average. It is never quite zero at $D = 0.5$: the one duty command carries a little of the current ripple through the current loop's proportional gain, and the two carriers sample it at different instants, so the legs do not get exactly the same duty in every period. ![The leg currents i(L1) and i(L2) and their sum il over three switching periods: where the duty passes 0.5 (top), the ripples cancel and the sum is nearly flat; at the crest of the line, D = 0.19 (bottom), they cancel only in part.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/interleaved-boost-pfc-ripple-cancellation/leg-currents.svg) ## Sizing the inductor of each leg A leg's ripple is largest at $D = 0.5$, where $D(1-D) = 1/4$, so for a target worst-case leg ripple $\Delta I_{L,max}$: $$L = \frac{V_{out}}{4\, f_{sw}\, \Delta I_{L,max}}$$ In the example, $L = 400 / (4 \times 20\,\text{k} \times 2.5) = 2$ mH per leg for 2.5 A peak to peak; the simulation's largest leg ripple is 2.53 A. Each leg carries half of the input current, 6.2 A at the crest (half of the line current's 12.41 A fundamental peak), so 2.5 A is a ripple ratio of about 40 % there, a common choice for a continuous-conduction PFC leg. The input ripple is a different curve. Multiplying the leg ripple by $K(D)$: $$\Delta I_{in} = \frac{V_{out}\, D (1-2D)}{L f_{sw}} \;\; (D \le 0.5), \qquad \Delta I_{in,max} = \frac{V_{out}}{8\, L f_{sw}} \;\text{ at } D = 0.25 \text{ and } 0.75$$ That is $400/(8 \times 2\,\text{m} \times 20\,\text{k}) = 1.25$ A in the example (1.29 A simulated). Compare the single-phase converter with the same total inductance, one 1 mH inductor (the two 2 mH in parallel) with both legs switching together: its input ripple is the full leg ripple, $V_{out}/(4 \cdot 1\,\text{mH} \cdot f_{sw}) = 5$ A at $D = 0.5$ (5.08 A simulated with the second carrier's `phase` set to 0). Interleaving cuts the worst input ripple by four with the same inductors, and the same inductor current in each leg (4.43 A rms either way). So there are two ways to spend the cancellation: keep the inductors and enjoy a quarter of the input ripple, or make each leg's ripple larger (smaller, cheaper inductors, possibly in boundary or discontinuous conduction) and let the cancellation clean up the line current. ## The spectrum: from fsw to 2·fsw In the frequency domain, leg 2 is leg 1 delayed by half a period, so its $n$-th harmonic of the switching frequency is shifted by $n\pi$. In the sum, the odd harmonics ($f_{sw}$, $3f_{sw}$, …) cancel and the even ones ($2f_{sw}$, $4f_{sw}$, …) add, exactly as they would with the legs in phase: $$I_{in}(n f_{sw}) = I_L(n f_{sw}) \big(1 + e^{-jn\pi}\big) = \begin{cases} 0 & n \text{ odd} \\ 2\, I_L(n f_{sw}) & n \text{ even} \end{cases}$$ The FFT of the line current over two line cycles shows it. The switching ripple sits in sidebands around 20 kHz and 40 kHz (the line frequency modulates it). ![The spectrum of the line current iac from 10 kHz to 45 kHz, Voltecx FFT over two line cycles: with the two legs in phase (top) and interleaved (bottom). Note the different scales.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/interleaved-boost-pfc-ripple-cancellation/input-spectrum.svg) | Line current iac, rms of the lines in the band | In phase | Interleaved | |---|---|---| | 15–25 kHz (around $f_{sw}$) | 1.08 A | 0.0004 A | | largest line near $f_{sw}$ | 0.98 A at 20.05 kHz | 0.0001 A | | 35–45 kHz (around $2f_{sw}$) | 0.28 A | 0.28 A | | all switching ripple, 5–45 kHz | 1.12 A | 0.28 A | The 20 kHz group almost disappears, and the 40 kHz group stays about the same. The 50 Hz fundamental is 12.41 A peak in both cases: interleaving changes only the ripple. ![The line current over 1 ms around the point where D = 0.5, with the legs in phase and interleaved.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/interleaved-boost-pfc-ripple-cancellation/input-current.svg) ## What it does for the EMI filter The differential-mode filter must attenuate the ripple of the line current. Interleaved, the largest switching line is 0.178 A at 39.85 kHz; in phase, it is 0.98 A at 20.05 kHz. A two-pole LC filter attenuates by about $(f/f_c)^2$ above its corner, so for a filter that brings the largest line down to the same level, the corner can be higher by $$\frac{f_{c,interleaved}}{f_{c,in\ phase}} = \frac{39.85}{20.05}\sqrt{\frac{0.98}{0.178}} = 4.7$$ and the LC product smaller by $4.7^2 = 22$. That is the "smaller filter" of interleaving, and it applies to the ripple lines the filter sees directly. Two cautions keep it honest: - **The conducted-emission band starts at 150 kHz** (CISPR 32, as for most limits on mains-powered equipment). What counts there is the first harmonic at or above 150 kHz. With $f_{sw}$ = 20 kHz that is the 8th, an even harmonic, which interleaving does not remove; the benefit in the band comes from the lines it does cancel and from what the duty does to each harmonic. Choose $f_{sw}$ with the band edge in mind, and check the result with a conducted-emission estimate. - **Common-mode noise is a separate matter.** It comes from each switch node's voltage steps driving current through the parasitic capacitance to earth (the heatsink, the chassis), and it needs its own common-mode filter; this simulation does not model it. ## The bulk capacitor The capacitor takes the diode currents minus the load current. Its RMS current has two parts: the 100 Hz part, set by the power and the line frequency, which interleaving cannot touch, and the switching part, which it reduces. | Bulk capacitor current, rms | In phase | Interleaved | |---|---|---| | total | 5.32 A | 4.08 A | | below 5 kHz (100 Hz and its harmonics) | 3.53 A | 3.53 A | | 5–45 kHz (switching) | 3.56 A | 1.73 A | The switching part halves, and the total drops by about a quarter. For electrolytic capacitors, whose life follows their ripple heating, that matters; check the capacitor's ripple-current rating at both frequencies with the frequency multipliers of its data sheet. ## Current sharing: the legs do not share by themselves The example controls only the total current, with one duty for both legs. That works here because the two legs are identical in the simulation. In hardware they are not: the gate drivers' delays, the switches' on-resistances and the inductors' winding resistances all differ a little. In steady state the average voltage across each inductor must be zero, so a small difference in duty becomes a large difference in current, limited only by the small resistances of each leg. To see it, the second leg's duty was raised by a fixed offset, with everything else unchanged: | Duty offset of leg 2 | Leg 1, average | Leg 2, average | Leg 2 peak | Output | |---|---|---|---|---| | 0 | 3.95 A | 3.95 A | 7.06 A | 398.5 V | | 0.5 % | 2.38 A | 5.51 A | 9.13 A | 398.5 V | | 1 % | 1.52 A | 6.36 A | 11.63 A | 398.5 V | The outer loops do not notice: the total current and the output voltage are as before. But a 1 % mismatch, about 0.5 µs of gate delay at 20 kHz, puts 81 % of the current in one leg, whose peak current rises by 65 %. The example's inductors have no winding resistance, so this is the worst case; real resistance helps a little, not enough. The fix is a current loop per leg. Measure each leg's current (a shunt or a current transformer per leg), and either run a current loop per leg with the reference split in two, or keep the total-current loop and add a slow sharing loop that trims each leg's duty by the difference between its current and half the total. Controller ICs for interleaved PFC do one or the other; a digital controller does it in a few lines. ## Common mistakes - **Expecting cancellation at every duty.** It is complete only at $D = 0.5$ (for two phases); at the crest of a low line, the duty is near 0.2 and the cancellation is weak. - **Sizing the EMI filter from the ripple reduction alone.** The even harmonics are untouched, and the CISPR band starts at 150 kHz. - **One current loop and no sharing.** Identical legs share only in simulation; plan a per-leg current measurement. - **Forgetting the capacitor's low-frequency current.** Interleaving does nothing for the 100 Hz ripple, which in this example is still the larger part of the capacitor's current. ## How to do it in Voltecx 1. Open **File › Open Example › Power quality › interleavedPfc** and run it (**Simulation › Run Simulation**, F5). The example simulates 0.25 s; measure after 0.2 s, when the output has settled. 2. Put `i(L1)`, `i(L2)` and `il` on the scope to see the cancellation, and `iac` for the line current. **Scope › Measurements** (`scope.measure`) gives the RMS, the mean and the peak to peak over a window such as 0.2 s to 0.24 s. 3. **Analysis › FFT** (`analysis.fft`) on `iac` with a 50 Hz fundamental gives the switching sidebands; on `i(C1)` it splits the capacitor current into its 100 Hz and switching parts. 4. Select `PWM2` and set its `phase` to 0 in **Circuit › Parameters** (`circuit.setParam`) to run the same converter with the legs in phase, the single-phase equivalent. 5. To try a duty mismatch, add a `constant` and a `sum` block in front of `PWM2` (**Circuit › Add Component**) and run again. 6. **Circuit › Subsystem › Create Subsystem** (`circuit.createSubsystem`) wraps the control blocks into one block with named pins, as in the drawing above; the netlist does not change. The [boost PFC basics](https://voltecx-web.nguyenvanqui291.workers.dev/blog/boost-pfc-basics) article covers the single-phase PFC, its inductor and its bulk capacitor, and [input filter design](https://voltecx-web.nguyenvanqui291.workers.dev/blog/input-filter-middlebrook-stability) the filter in front of it. ## Frequently asked questions ### When is an interleaved PFC worth it? Often above about a kilowatt, where one inductor gets large and the input filter is a significant part of the size and cost. Below that, the extra switch, diode, driver and current sensing cost more than they save. ### What is the ripple-cancellation factor? The ratio of the input ripple to one leg's ripple. For two legs half a period apart it is $(1-2D)/(1-D)$ for $D \le 0.5$ and $(2D-1)/D$ above, zero at $D = 0.5$. For $N$ legs the zeros fall at $D = k/N$. ### Does interleaving reduce conducted EMI? It removes the odd harmonics of the switching frequency from the differential-mode input ripple and reduces the total ripple, which makes the filter smaller. It leaves the even harmonics and the common-mode noise, so the filter is still needed, and the result in the 150 kHz to 30 MHz band depends on the choice of switching frequency. ### Do the two legs need separate current sensing? In practice, yes. With one loop on the total current, small differences in duty, delay or resistance decide how the legs share; in the simulation a 1 % duty difference moved 81 % of the current into one leg. --- # Peak current mode control and slope compensation, with simulated subharmonic oscillation URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/peak-current-mode-slope-compensation/ Peak current mode control is unstable above a duty cycle of 0.5 unless a compensating ramp is added: a disturbance of the inductor current is multiplied by $-(m_2 - m_a)/(m_1 + m_a)$ every switching period, where $m_1$ and $m_2$ are the inductor current's up and down slopes and $m_a$ is the ramp's slope. With no ramp that factor is $-m_2/m_1 = -D/(1-D)$, larger than 1 in size above $D = 0.5$, so the current breaks into subharmonic oscillation. A ramp of $m_a \ge m_2/2$ keeps every duty cycle stable, and $m_a = m_2$ cancels a disturbance in one period. In a 12 V to 8 V buck at 200 kHz with 10 µH ($D = 2/3$), Voltecx shows a 0.2 A disturbance doubling every period with no ramp, halving with $m_a = 0.4$ A/µs, and gone after one period with $m_a = 0.8$ A/µs. ## What peak current mode control does In voltage mode control, the error amplifier sets a duty cycle and a PWM comparator turns it into a gate signal. In peak current mode control, the error amplifier sets a *current* instead, and each switching period goes like this: 1. A clock pulse sets a latch, and the switch turns on. 2. The inductor current rises at $m_1$. A comparator watches it (through a current-sense resistor or transformer). 3. When the sensed current reaches the command $i_c$, the comparator resets the latch, and the switch turns off. 4. The current falls at $m_2$ until the next clock pulse. For a buck the slopes are $m_1 = (V_{in} - V_o)/L$ and $m_2 = V_o/L$. The duty cycle is no longer commanded directly: it is whatever on-time makes the current reach $i_c$. The attractions are well known. The inductor nearly disappears from the voltage loop, which then sees a single pole instead of the LC double pole, so a simple Type II compensator does the job. The switch current is limited cycle by cycle just by clamping $i_c$. Parallel phases share current naturally, and input voltage changes are corrected within a period, because a higher input steepens $m_1$ and shortens the on-time at once. This is why so many controller ICs, from the UC384x family on, use it. The catch is that the loop is a sampled system: the current is only "looked at" once per period, at the instant it crosses $i_c$. A sampled loop can oscillate at half its sampling rate, and this one does. ## The circuit in Voltecx The test circuit is the textbook buck example, `buckIdeal`, with its open-loop PWM replaced by a peak current modulator built from five control blocks: - `Clk`, a PWM block at a fixed duty of 0.02 on a 200 kHz sawtooth, gives a 100 ns clock pulse at the start of every period (net `clk`); - `Latch`, an SR flip-flop, is set by `clk` and drives the switch gate `g`; - `Cmp`, a comparator, resets the latch when its input `isum` passes the 5 A command `Ic`; - `Saw` and `Se`, a ramp block in saw mode restarted by `clk` and a gain, make the compensating ramp, $m_a$ in A/µs (its height at the end of a period is $m_a T$); - `Sum` adds the ramp to the inductor current `iL`, measured by the ammeter `AmL`. To look at the current loop alone, the output is held at 8 V by a voltage source, as a battery or a large output capacitor would hold it over a few periods. The switch and diode are ideal (100 µΩ on). With $V_{in} = 12$ V and $L = 10$ µH, $D = 2/3$, $m_1 = 0.4$ A/µs and $m_2 = 0.8$ A/µs. ![The peak current mode buck: the power stage below, the modulator above (clock, compensating ramp, sum, comparator and SR latch), joined by the labels g and iL.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/peak-current-mode-slope-compensation/schematic.svg) ## Why it oscillates: the perturbation gain Take the converter in steady state and add a small error $\Delta i_0$ to the inductor current at the start of a period. The current now rises from a higher valley, so it reaches $i_c$ earlier: the on-time shrinks by $\Delta t = \Delta i_0 / m_1$. The off-time grows by the same $\Delta t$, during which the current falls at $m_2$ instead of rising at $m_1$. At the next clock edge the error is $$\Delta i_1 = -\Delta i_0 \, \frac{m_2}{m_1}$$ and after $n$ periods $\Delta i_n = \Delta i_0 \,(-m_2/m_1)^n$. In steady state the volt-seconds balance, $m_1 D = m_2 (1-D)$, so $$\frac{m_2}{m_1} = \frac{D}{1-D}$$ Below $D = 0.5$ the error shrinks and changes sign every period; above it, the error grows. At $D = 2/3$ the factor is $-2$. The simulation shows exactly that. Starting the buck 0.2 A above its 3.67 A steady-state valley, the valley error goes $+0.2$, $-0.4$, $+0.8$ A in the first three periods, each ratio within 5 % of $-2$. Then the on-time runs into the next clock edge, the linear picture ends, and the current settles into no steady state at all: each valley is followed by one on the other side, wandering below 2 A and above 4.5 A while the peaks stay pinned at the 5 A command. That is subharmonic oscillation: a large ripple at half the switching frequency (and its sub-multiples), audible in magnetics, and a current loop that no longer controls the average current. ![Without a ramp at D = 2/3: the inductor current peaks at the 5 A command (horizontal line) every period, but the valleys and on-times alternate irregularly.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/peak-current-mode-slope-compensation/subharmonic.svg) Notice that the peak current is perfectly controlled. It is the *average* current that wanders, because a peak with a short on-time and a peak with a long on-time give different averages. ## The cure: a compensating ramp Add a ramp of slope $m_a$ to the sensed current (or, equivalently, subtract it from the command). The comparator now trips when $i_L + m_a t = i_c$. Repeating the argument, the on-time shrinks by $\Delta i_0/(m_1 + m_a)$ and the error at the next edge is $$\frac{\Delta i_1}{\Delta i_0} = -\frac{m_2 - m_a}{m_1 + m_a}$$ This is the perturbation gain, derived in Erickson and Maksimović, *Fundamentals of Power Electronics*, 2nd ed. (Kluwer, 2001), Chapter 12 "Current Programmed Control". Three values of $m_a$ are worth remembering: - **The stability edge** is where the gain reaches $-1$: $m_a = (m_2 - m_1)/2$. In the example, 0.2 A/µs, a quarter of $m_2$. - **$m_a = m_2/2$** makes the gain smaller than 1 in size for every duty cycle up to 1, because $m_1 \ge 0$. It is the usual rule. In the example the gain is $-(0.8-0.4)/(0.4+0.4) = -0.5$. - **$m_a = m_2$** makes the gain zero: a disturbance is gone after one period (deadbeat). The ramp then makes the comparator see a falling-slope mirror of the inductor current, so the trip point no longer depends on where the current started. With $m_a = 0.4$ A/µs the same 0.2 A start becomes $-0.1$ A, then $+0.05$ A, and the valley settles at 2.33 A within a few periods. ![With a ramp of m2/2 = 0.4 A/µs: the sum of the inductor current and the ramp (iL + ramp) reaches the 5 A command each period; the inductor current settles within a few periods.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/peak-current-mode-slope-compensation/ramp-stable.svg) The ramp costs something: the peak inductor current is no longer $i_c$ but $i_c - m_a D T$. Here the ramp takes $0.4 \times 3.33 = 1.33$ A off the peak, so the steady-state valley drops from 3.67 A to 2.33 A for the same 5 A command. The outer voltage loop simply asks for more current, but the current limit (a clamp on $i_c$) becomes duty-dependent: at high duty the converter can deliver less current before it limits. Too much ramp also turns the converter back towards voltage mode, which is the subject of the next section. The figure below puts the four cases side by side: the valley error after each period, divided by the first error. At $D = 0.4$ (20 V in) the gain with no ramp is $-m_2/m_1 = -0.8/1.2 = -2/3$, so the error rings down. At $D = 2/3$ it grows by $-2$ with no ramp, decays by $-0.5$ with $m_2/2$, and vanishes in one step with $m_2$. Every simulated point is within 0.05 of the formula, or 5 % where the formula's value is larger than 1. ![Valley-current error after each period, as a share of the first, for the 12 V buck with no ramp, m2/2 and m2, and the 20 V buck (D = 0.4) with no ramp.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/peak-current-mode-slope-compensation/perturbation.svg) ## Ridley's model: the double pole at half the switching frequency The sampled-data picture explains stability, but loop design needs a transfer function. R. B. Ridley, "A new, continuous-time model for current-mode control", *IEEE Transactions on Power Electronics*, vol. 6, no. 2, April 1991, folds the sampling into a pair of complex poles at half the switching frequency, in the current loop: $$H_e(s) \approx 1 + \frac{s}{\omega_n Q_p} + \frac{s^2}{\omega_n^2}, \qquad \omega_n = \pi f_s$$ with the quality factor $$Q_p = \frac{1}{\pi\,(m_c D' - 0.5)}, \qquad m_c = 1 + \frac{m_a}{m_1}, \quad D' = 1 - D$$ The two pictures agree. $Q_p$ goes to infinity, an undamped oscillation at $f_s/2$, exactly when $m_c D' = 0.5$, which works out to $m_a = (m_2 - m_1)/2$, the edge where the perturbation gain reaches $-1$. Below that $Q_p$ is negative: right-half-plane poles, the subharmonic oscillation of the previous section. For the example at $D = 2/3$ ($D' = 1/3$): | Ramp $m_a$ | $m_c$ | Gain $-(m_2-m_a)/(m_1+m_a)$ | $Q_p$ | |---|---|---|---| | 0 | 1 | −2 | negative (unstable) | | 0.2 A/µs ($m_2/4$) | 1.5 | −1 | infinite | | 0.4 A/µs ($m_2/2$) | 2 | −0.5 | 1.91 | | 0.58 A/µs ($0.73\,m_2$) | 2.46 | −0.22 | 1 | | 0.8 A/µs ($m_2$) | 3 | 0 | 0.64 | A $Q_p$ of 1.91 is stable but peaky: the current loop's response has a resonance at 100 kHz that eats phase margin from the voltage loop near crossover, and it rises further at low input voltage where $D$ grows. Ridley recommends a ramp that gives $Q_p$ about 1; here that is $m_a = 0.58$ A/µs. With $m_a = m_2$, $Q_p = 2/\pi = 0.64$, well damped, at the cost of more peak-current error. The next figure sweeps the ramp from 0 to $1.25\,m_2$. Each point is one Voltecx run of the 12 V buck, measuring the ratio of the second valley error to the first; all eleven lie within 0.04 of the formula. The lower panel is Ridley's $Q_p$ from the formula, crossing 1 at $m_a/m_2 = 0.73$. ![Top: perturbation gain against the ramp, as a share of m2, from the formula and from Voltecx runs. Bottom: Ridley's Qp from the formula; the vertical lines mark the stability edge (m2/4 here) and m2/2.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/peak-current-mode-slope-compensation/gain-vs-ramp.svg) ## Sizing the ramp in practice 1. **Find the worst case.** $m_2$ depends only on the output: $V_o/L$ for a buck, $(V_o - V_{in})/L$ for a boost, the reflected output for a flyback. The required ramp is set at the highest duty cycle, which for a buck is the lowest input voltage. 2. **Refer everything to the comparator.** The controller compares a voltage. With a sense resistor $R_s$ (or a current transformer with its burden), the inductor slope becomes $m_2 R_s$ in V/s, and the ramp you add must be specified in the same units. Controller data sheets give the internal ramp in mV per period or mV/µs. 3. **Choose between $m_2/2$ and $m_2$.** $m_2/2$ is the minimum for any duty; aim for $Q_p$ near 1 at the lowest input voltage, which usually lands between the two. 4. **Remember the inductance tolerance.** $m_2 = V_o/L$ grows when $L$ drops with temperature or with DC bias in a powder core. Size the ramp with the lowest $L$ you expect. 5. **Check the current limit.** The peak current at the limit is $i_{c,max} - m_a D T$; at the highest duty it is lowest. Make sure that is still above the full-load peak current. Below $D = 0.5$ a small ramp is still worth adding: the perturbation gain at $D = 0.4$ is $-0.67$, which rings for several periods and makes the loop sensitive to noise on the sense signal. ## Common mistakes - **Testing only at nominal input.** A buck from 12 V to 5 V is at $D = 0.42$ and looks fine; the same board at 9 V in runs at $D = 0.56$ and oscillates. - **Adding the ramp in the wrong place.** The ramp has to be synchronised to the clock and restarted every period. A free-running ramp or one taken from a different oscillator does nothing useful. - **Leading-edge spikes.** The current-sense signal carries the diode's reverse recovery and the switch-node charge at turn-on. Without leading-edge blanking or a small RC filter, the comparator trips on the spike, at minimum on-time, every period. - **Too much filtering on the sense signal.** A large RC delays the sensed current and flattens its slope, which changes $m_1$ and $m_2$ as the comparator sees them. - **Reading the waveform at too coarse a time step.** In simulation, a comparator crossing is only as accurate as the step around it. The runs here use steps of at most 2 ns, 0.04 % of the period. With 50 ns steps the trip can come up to 50 ns late, 40 mA at 0.8 A/µs, a fifth of the 0.2 A disturbance studied here. ## How to do it in Voltecx 1. **File › Open Example › buck**, then remove `Duty` and `PWM` and add the modulator blocks with **Circuit › Add Component** (`circuit.addComponent`): a `pwm` at duty 0.02 as the clock, a `ramp` in saw mode clocked by it, a `gain` for the ramp height $m_a T$, a `sum`, a `comparator` against a `constant` current command, and an `srff` latch driving the switch gate. Put an ammeter in series with the inductor for `iL`. 2. **Simulation › Settings** (`simulation.settings`): a maximum step of a few ns (here 2 ns at 200 kHz), and an initial inductor current a little off steady state (`L1.i0`) to see the disturbance grow or decay. 3. **Simulation › Run Simulation** (`simulation.run`, F5), then look at `iL`, `isum` and `g` on the scope; **Scope › Measurements** (`scope.measure`) gives the valley and peak of each. 4. **Analysis › Parameter Sweep** (`analysis.paramSweep`) over the gain of `Se` sweeps the ramp; measure `iL` with `min` over a late window to see where the valley settles. 5. **Circuit › Subsystem › Create Subsystem** (`circuit.createSubsystem`) wraps the modulator blocks into one subsystem, with pins for the sensed current, the command and the gate, once it works. For a complete loop rather than the current loop alone, `design.compare` (**Design › Automate › Compare Topologies and Control**) designs peak current mode with a Type II compensator on Ridley's model, and the behavioural `pwmController` IC (UC384x type) is a ready peak-current-mode controller to place with `ic.place`. ## Frequently asked questions ### Why does peak current mode control need slope compensation above 50 % duty? Because the current loop is sampled once per period and a disturbance in the inductor current is multiplied by $-m_2/m_1 = -D/(1-D)$ each period. Above $D = 0.5$ that is larger than 1 in size, so the disturbance grows into subharmonic oscillation. ### How much slope compensation is enough? At least $m_a = (m_2 - m_1)/2$ at the highest duty cycle to be stable; $m_a = m_2/2$ is stable at every duty cycle. For a well-damped current loop, choose $m_a$ so that Ridley's $Q_p = 1/(\pi(m_c D' - 0.5))$ is about 1, which lies between $m_2/2$ and $m_2$. ### What does $m_a = m_2$ give? A perturbation gain of zero: any disturbance of the inductor current is corrected in one switching period (deadbeat control), and $Q_p = 2/\pi \approx 0.64$. The price is the largest difference between the commanded and the actual peak current. ### Does slope compensation matter below 50 % duty? The loop is stable without it, but the disturbance rings for several periods (gain $-0.67$ at $D = 0.4$) and the current loop is sensitive to noise. A small ramp also damps the $f_s/2$ poles that otherwise peak near the voltage loop's crossover at high duty. ### Does the same apply to a boost or a flyback? Yes. Only the slopes change: for a boost $m_1 = V_{in}/L$ and $m_2 = (V_o - V_{in})/L$; for a flyback in continuous conduction, $m_2$ is the reflected output voltage over the magnetising inductance. The formulas for the perturbation gain and $Q_p$ are the same. --- # Phase-shifted full bridge: where zero-voltage switching holds and where it is lost URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/psfb-zvs-range/ A phase-shifted full bridge (PSFB) switches at zero voltage only while the series inductance holds enough energy to swing the lagging leg: $\tfrac12 L_r I_p^2 \ge \tfrac12 (2C_{oss} + C_{tr}) V_{in}^2$. The leading leg is driven by the full reflected load current and keeps zero-voltage switching (ZVS) almost to no load; the lagging leg has only the energy of $L_r$ and loses ZVS below a minimum load. In a 400 V to 48 V, 1 kW, 100 kHz example with 30 µH of series inductance and 200 pF per switch, the bound is $I_p \ge 1.46$ A, about 32 % of full load; Voltecx counts ZVS down to 25 %, where the swing already stalls 18 V short, and a hard turn-on at 20 %. A larger inductor lowers that limit (15 % of load at 60 µH) but doubles the duty-cycle loss, and the dead time must sit inside a window that the inductor also sets. ## How the phase-shifted full bridge works A full bridge has two legs, each a pair of switches with a midpoint. In a PSFB both legs run a fixed 50 % square wave (less a small dead time), and the output is controlled by the *phase* between them instead of by the pulse width: - When the diagonal switches $Q_{ah}$ and $Q_{bl}$ are both on, the transformer primary sees $+V_{in}$; when $Q_{bh}$ and $Q_{al}$ are on, $-V_{in}$. This is the power-transfer interval. - When both upper or both lower switches are on, the primary is shorted and the current freewheels through the bridge. The leg that changes first, ending a power-transfer interval, is the **leading leg** (leg `a` here). The leg that changes next, starting the following power-transfer interval, is the **lagging leg** (leg `b`). The duty cycle $D$ is the share of time spent transferring power, and the secondary is a buck stage at twice the switching frequency: $$V_o = \frac{D_{eff} V_{in}}{n}$$ with $n$ the turns ratio and $D_{eff}$ the effective duty, a little smaller than $D$ for reasons we come to later. The appeal of the topology is that every switch can turn on at zero voltage without any resonant tank: the inductance in series with the transformer (its leakage plus, usually, an added inductor) and the output inductor do the work during the dead time. This is the analysis of J. A. Sabaté, V. Vlatković, R. B. Ridley, F. C. Lee and B. H. Cho, "Design considerations for high-voltage high-power full-bridge zero-voltage-switched PWM converter", IEEE APEC 1990, and of B. Andreycak, "Phase Shifted, Zero Voltage Transition Design Considerations and the UC3875 PWM Controller", Unitrode application note U-136A (Texas Instruments SLUA107). Mohan, Undeland and Robbins, *Power Electronics*, 3rd ed. (Wiley, 2003), Chapter 9, covers the same ZVS mechanism in its resonant-converter treatment. ## The example The `psfb` example in Voltecx: $V_{in} = 400$ V, $n = 6$, $f_s = 100$ kHz, magnetising inductance 1 mH, series inductance $L_r = 30$ µH (variable `Lres`), $C_{oss} = 200$ pF per switch (`Coss`), dead time $t_d = 200$ ns (`td`), a diode bridge, $L_o = 15$ µH, $C_o = 47$ µF and a 2.304 Ω load: 48 V, 20.8 A, 1 kW. A PI loop moves the phase to hold 48 V. All values are illustrative, not from a data sheet; the switch capacitance is linear and the transformer has no winding capacitance. ![The phase-shifted full bridge: the two legs, the current meter AmP, the series inductor Lr and the transformer in one row, the diode bridge and output filter to the right, and the phase-shift controller as the subsystem U1 above, joined by gate labels.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/psfb-zvs-range/schematic.svg) Every run below uses the fast solver with steps of at most 20 ns for 4 ms, and measures from 3.5 ms to 4 ms. The example's default step is 50 ns; at 20 ns the DC part of the magnetising current left from the start has decayed below 0.03 A by 3.5 ms, so both halves of the period are symmetric. At full load the output sits at 48.0 V, the duty is 0.846 and the primary current peaks at 4.53 A. `analysis.softSwitching` finds every one of the four switches turning on at zero voltage. ![One switching period at full load: the leg voltages v(a) and v(b), the primary current ip and the secondary voltage v(s1,s2). Leg a moves first and ends the power transfer; leg b starts the next one.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/psfb-zvs-range/waveforms.svg) Read the period from the left: $v(a)$ rises while $v(b)$ is high, so the primary is shorted and the current freewheels, decaying only slowly. When $v(b)$ falls, $+400$ V appears across $L_r$ and the primary current swings from negative to positive in about half a microsecond; only when it has caught up with the reflected output current does the secondary voltage jump to $+V_{in}/n = 66.7$ V. That gap is the duty-cycle loss. ## The leading leg: easy ZVS When the leading leg's switch turns off, the primary current is near its peak: the output-inductor current at its top, referred through the transformer, plus the magnetising current, $$I_{lead} = \frac{I_o + \Delta I_o/2}{n} + I_m$$ The output inductor is in series with the primary during this transition (the secondary is still conducting), so its large energy acts like a current source. The two output capacitances of the leg are charged and discharged linearly, in $$t_{lead} = \frac{2 C_{oss} V_{in}}{I_{lead}}$$ With the ripple $\Delta I_o = V_o (1 - D_{eff}) / (2 f_s L_o) = 4.48$ A peak to peak (at $D_{eff} = n V_o / V_{in} = 0.72$) and $I_m = V_{in} D_{eff} / (4 L_m f_s) = 0.72$ A, $I_{lead} = 4.57$ A and $t_{lead} = 35$ ns. Voltecx measures 34 ns for both switches of leg `a`, well inside the 200 ns dead time. ## The lagging leg: the energy condition The lagging leg switches at the end of the freewheeling interval. The secondary is then shorted by the rectifier (all four diodes conduct), so the output inductor is decoupled and only the series inductance $L_r$ drives the swing. Its energy must charge one output capacitance to $V_{in}$ and discharge the other: $$\tfrac12 L_r I_{lag}^2 \;\ge\; \tfrac12 \left(2 C_{oss} + C_{tr}\right) V_{in}^2$$ where $C_{tr}$ is the transformer's winding capacitance, which this example leaves out. In other words, $I_{lag} \ge V_{in}/Z$ with $Z = \sqrt{L_r / 2C_{oss}}$. For the example $\tfrac12 \cdot 2 C_{oss} V_{in}^2 = 32$ µJ, $Z = 274$ Ω and $$I_{lag} \ge \frac{400}{274} = 1.46\ \text{A}$$ The current at the lagging edge is lower than at the leading edge, because during freewheeling the output-inductor current has fallen to its valley: $$I_{lag} = \frac{I_o - \Delta I_o/2}{n} + I_m$$ Setting the two equal gives the smallest load current with ZVS: $$I_{o,min} = n\left(\frac{V_{in}}{Z} - I_m\right) + \frac{\Delta I_o}{2} = 6\,(1.46 - 0.72) + 2.24 = 6.68\ \text{A}$$ or 32 % of the 20.8 A full load. At that limit the swing is a quarter of the $L_r$–$2C_{oss}$ resonance, $\tfrac{\pi}{2}\sqrt{L_r \cdot 2 C_{oss}} = 172$ ns, so it only just fits in the 200 ns dead time. The simulation agrees. At full load the lagging leg swings in 38.5 ns. At 40 % load the swing is slower but completes, and 2.9 V are left when the incoming switch turns on, counted as ZVS (below 5 % of 400 V). At 25 % load the swing stalls: $\tfrac12 L_r I_{lag}^2$ is 27 µJ of the 32 µJ it needs, and the switch turns on at 18 V. That is just inside the 5 % that `analysis.softSwitching` counts as ZVS, so a sweep of the load puts the counted boundary between 20 % and 25 %, below the 32 % bound: the bound is a safe design value. Read the voltage left at turn-on as well as the verdict: 18 V on a 400 V bus is a small hard turn-on all the same. ![The lagging leg's node voltage v(b) after Qbh turns off, at full, 40 % and 25 % load, in ns from the gate edge. Qbl turns on at 200 ns (vertical line).](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/psfb-zvs-range/lagging-edge.svg) At 40 % the node reaches zero well before 200 ns and then creeps back up a little. That is the second ZVS condition at work. ## The dead-time window Once the lagging node has swung, the current flows through the body diode of the incoming switch while $V_{in}$ sits across $L_r$, so it falls at $V_{in}/L_r$ (13.3 A/µs at 30 µH). The switch must turn on before that current reaches zero, or the node swings back and the turn-on is hard again. The dead time therefore has to sit in a window: $$t_{swing} \;<\; t_d \;<\; t_{swing} + \frac{L_r}{V_{in}}\sqrt{I_{lag}^2 - (V_{in}/Z)^2}$$ The lower limit grows at light load (up to the quarter period, 172 ns here); the upper limit shrinks at light load and with a smaller $L_r$. Two runs show both edges: - With $L_r = 15$ µH and the same 200 ns dead time, the current falls twice as fast and reverses inside the dead time at *every* load: the lagging leg never turns on at zero voltage. With 100 ns it keeps ZVS down to 50 % of load, right at the energy bound of 49.5 %. - With $L_r = 30$ µH and only 100 ns, the swing near the boundary no longer fits: ZVS ends at 40 % of load instead of 25 %. An adaptive dead time, longer at light load, widens the usable range; many PSFB controllers provide one for that reason. ## Choosing the series inductance A larger $L_r$ stores more energy and pushes the ZVS limit down. The figure below shows the energy bound against $L_r$ and the lowest load with ZVS found by `analysis.softSwitching` sweeps of the load at four inductances: | $L_r$ | Dead time | Energy bound | Voltecx: lowest load with ZVS | |---|---|---|---| | 15 µH | 200 ns | 49.5 % | none | | 15 µH | 100 ns | 49.5 % | 50 % | | 30 µH | 200 ns | 32 % | 25 % | | 30 µH | 100 ns | 32 % | 40 % | | 45 µH | 200 ns | 24 % | 20 % | | 60 µH | 200 ns | 20 % | 15 % | ![The lowest load with ZVS on the lagging leg against the series inductance: the energy bound and Voltecx sweeps with 200 ns and 100 ns of dead time.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/psfb-zvs-range/zvs-boundary.svg) The price is the duty-cycle loss. ## The duty-cycle loss When the lagging leg starts a power-transfer interval, the primary current has to reverse through $L_r$ before the secondary gets any voltage. The load part of the current changes by $2 I_o / n$ at a rate of $V_{in}/L_r$, which takes $2 L_r I_o / (n V_{in})$ every half period. As a share of the period, the textbook result is $$\Delta D = \frac{4 L_r f_s I_o}{n V_{in}}$$ which at full load is $4 \times 30\,\mu \times 100\,\text{k} \times 20.8 / (6 \times 400) = 0.104$. The current that has to reverse is really the output-inductor current at the end of freewheeling, its valley $I_o - \Delta I_o/2$, which gives 0.093. Measured from the waveforms (the share of time with $|v_{ab}| > 200$ V less the share with $|v_{s1,s2}| > 33$ V), the loss is 0.1007 at full load, and it lies between the two forms of the formula at every load from 20 % to 100 %; the swing time of the lagging leg accounts for the rest. ![Duty-cycle loss against load: the formula with the load current (textbook) and with the valley current, and Voltecx measurements.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/psfb-zvs-range/duty-loss.svg) The loss matters because the bridge has to make up for it. The output needs $D_{eff} = n V_o / V_{in} = 0.72$, so at full load the bridge runs at about $0.72 + 0.10$; the example's feed-forward is 0.82 and the PI trims it to the measured 0.846. Double $L_r$ to 60 µH and the textbook loss doubles to 0.208: the bridge would need 0.93 of the PI's 0.95 limit at nominal input, and at the lowest input it would run out of duty. The usual way out is a lower turns ratio, which raises the primary current and the rectifier's voltage stress. A large $L_r$ also rings with the rectifier's capacitance, which a real design clamps or snubs (the diodes here are ideal, so this run does not show it). The trade-off, in short: - **Small $L_r$**: little duty loss, a high turns ratio, low primary current, but ZVS only near full load and a narrow dead-time window. - **Large $L_r$**: ZVS to light load, but more duty loss, a lower turns ratio, more circulating current and more secondary ringing. A common compromise is to size $L_r$ for ZVS down to 20 % to 50 % of load, where switching loss starts to matter less than conduction loss anyway, and to accept hard switching below. ## Common mistakes - **Designing ZVS for the leading leg.** It is the lagging leg that runs out of energy. Check it at the lightest load where you want ZVS. - **Forgetting the output-inductor ripple.** The lagging leg sees the valley of the output current, not its average. With a small output inductor this moves the limit a long way. - **Forgetting the transformer and board capacitance.** They add to $2C_{oss}$ in the energy condition. Use the energy-equivalent $C_{o(er)}$ of the switches from their data sheet, not the small-signal $C_{oss}$ at high voltage. - **One dead time for both legs and all loads.** The leading leg needs far less than the lagging leg, and the lagging leg's window moves with the load. - **Ignoring the duty-cycle loss when choosing the turns ratio.** Size $n$ for the lowest input voltage with $D_{eff} + \Delta D$ below the controller's maximum duty. ## How to do it in Voltecx 1. **File › Open Example › psfb**. The variables `Lres`, `Coss`, `td`, `Rload`, `Lmag` and `Dff` hold the numbers above; change them in **Circuit › Variables** (`circuit.variables`). 2. **Simulation › Settings** (`simulation.settings`): 4 ms and a maximum step of 20 ns, then **Simulation › Run Simulation** (`simulation.run`). Plot `v(a)`, `v(b)`, `ip` and `v(out)`. 3. **Analysis › Soft Switching** (`analysis.softSwitching`) classifies every turn-on as ZVS, partial or hard, gives the voltage at each turn-on, and for each leg compares the measured swing with the dead time and suggests a value. 4. Its `sweep` option over `Rload` (or `Lres`, `td`, `Vin`) runs the circuit once per value and reports between which values each switch loses ZVS: the boundary of this article in one command. 5. **Analysis › Parameter Sweep** (`analysis.paramSweep`) over `Lres` with `duty` as the measure shows how much duty the loop needs as the inductance grows. ## Frequently asked questions ### Why does the lagging leg lose ZVS first? At the lagging edge the secondary is shorted by the rectifier, so only the energy stored in the series inductance can swing the node. The leading leg is driven by the reflected output-inductor current, which behaves like a current source and swings the node at almost any load. ### What is the ZVS condition of a phase-shifted full bridge? For the lagging leg, $\tfrac12 (L_{lk} + L_r) I^2 \ge \tfrac12 (2 C_{oss} + C_{tr}) V_{in}^2$, with $I$ the primary current at the lagging edge: the output-inductor valley current over $n$ plus the magnetising current. The dead time must also be longer than the swing and shorter than the time the current takes to reverse after it. ### How do I extend the ZVS range to light load? Increase the series inductance (at the cost of duty-cycle loss), increase the magnetising current with a smaller magnetising inductance (at the cost of conduction loss), add an auxiliary circuit that supplies current only at light load, or use an adaptive dead time. Each moves the limit in the energy condition above. ### What is the duty-cycle loss and how big is it? The share of each half period in which the primary current reverses through the series inductance and the secondary sees no voltage: $\Delta D = 4 L_r f_s I_o / (n V_{in})$, 0.104 at full load in the example. It forces a lower turns ratio than the ideal one. ### Does the PSFB need a DC-blocking capacitor? Not in principle, because both halves of the period apply equal volt-seconds; in practice, small timing differences between the legs can build a DC component in the magnetising current, and many designs add a blocking capacitor or use peak current mode control to prevent it. In this example the DC part from the start-up decays below 0.03 A within 3.5 ms. --- # PWM explained simply: carrier, duty cycle, and what the filter sees URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/pwm-explained/ Almost every power converter does the same trick: it cannot make an in-between voltage directly, so it switches between two voltages it does have, very fast, and lets a filter average the result. The pattern of on and off times is pulse-width modulation, PWM. This article builds PWM up from a light switch to the sine PWM of an inverter, with every waveform taken from a Voltecx simulation and every number checked against the formula. ## The idea: a light switch flicked very fast Imagine a lamp on a switch. Flick it on for one second and off for three, again and again. Your eye sees a lamp that blinks. Now do the same a hundred thousand times a second: on for 2.5 µs, off for 7.5 µs. Your eye can no longer follow, and the lamp looks steady at a quarter of its full brightness. That is all PWM is: - A **switch** that is either fully on or fully off. A transistor that is fully on or fully off wastes very little power, which is why converters work this way and not like a variable resistor. - A **period** $T_s$ that repeats at the **switching frequency** $f_{sw} = 1/T_s$. - A **duty cycle** $D$: the fraction of each period the switch is on. - A **filter** (the inductor and capacitor in a converter, the eye in the lamp) that is too slow to follow each pulse and so passes on only the average. ## Carrier and reference: how the pulses are made How does a controller decide when to turn the switch off? The classic method compares two signals: - the **carrier**, a fast repeating ramp that runs from 0 to 1 once per period; - the **reference** (or modulating signal), here simply the duty cycle we want, a number between 0 and 1. The gate is on while the reference is above the carrier and off while it is below. With a sawtooth carrier, the ramp starts at 0 at the beginning of each period, so the switch turns on at the start and turns off when the ramp crosses the reference, after $D \cdot T_s$. The textbook buck example in Voltecx, `buckIdeal`, does exactly this: a constant `D = 0.25` feeds a PWM block at 100 kHz, which drives the switch of a buck converter from 48 V into a 2.4 Ω load. ![The buck example in Voltecx: a constant duty D feeds the PWM block, whose gate signal drives the switch S1; the diode D1, L1 (100 µH) and C1 (100 µF) filter the switch node into R1 (2.4 Ω).](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/pwm-explained/buck.svg) ![Three switching periods of the buck in Voltecx: the sawtooth carrier and the duty of 0.25 (top), the gate g (middle), and the switch-node voltage v(sw) with the output voltage v(out) (bottom).](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/pwm-explained/buck-pwm.svg) Read the figure from top to bottom. Where the red duty line is above the blue ramp, the gate is 1. The switch node $v_{sw}$ copies the gate: 48 V while the switch is on, about 0 V while the diode carries the current. The output is flat at 12 V. ## Duty cycle and the average voltage The switch node is a rectangular wave between 0 and $V_{in}$. Its average over one period is the height times the fraction of time it is high: $$\overline{v_{sw}} = \frac{1}{T_s}\int_0^{T_s} v_{sw}\,dt = \frac{V_{in} \cdot D\,T_s}{T_s} = D\,V_{in}$$ An ideal inductor cannot hold a DC voltage across it in steady state (its average voltage must be zero, or its current would grow without limit), so the average of the switch node appears at the output: $$V_{out} = D\,V_{in} = 0.25 \times 48\ \text{V} = 12\ \text{V}$$ This is the buck converter's conversion ratio, derived this way in R. W. Erickson and D. Maksimović, *Fundamentals of Power Electronics*, 3rd ed., chapter 2 (the volt-second balance). **In the simulation:** over the last ten periods of a 4 ms run, the switch node averages 12.0 V and the output 12.0 V (11.99 V, the switch and diode each have 1 mΩ). The important intuition: **the duty cycle is a knob on the average voltage.** A controller that wants more output raises $D$; one that wants less lowers it. Everything else in this article is about the price of making that average out of pulses. ## The price of pulses: ripple The filter does not average perfectly. While the switch is on, the inductor sees $V_{in} - V_{out}$ and its current ramps up; while it is off, it sees $-V_{out}$ and ramps down. The peak-to-peak current ripple is $$\Delta i_L = \frac{(V_{in} - V_{out})\,D}{L\,f_{sw}}$$ and that triangular current, flowing into the output capacitor, leaves a small voltage ripple of $$\Delta v_{out} \approx \frac{\Delta i_L}{8\,C\,f_{sw}}$$ (both from Erickson and Maksimović, chapter 2, for a capacitor without ESR). ### Worked example For the buck example at 100 kHz: $$\Delta i_L = \frac{(48 - 12) \times 0.25}{100\ \mu\text{H} \times 100\ \text{kHz}} = 0.90\ \text{A}$$ $$\Delta v_{out} = \frac{0.90}{8 \times 100\ \mu\text{F} \times 100\ \text{kHz}} = 11.3\ \text{mV}$$ The simulation gives 0.90 A and 11.3 mV. ### Ripple against switching frequency Both formulas have $f_{sw}$ in the denominator, and the voltage ripple has it twice. Double the frequency and the current ripple halves while the voltage ripple falls to a quarter. That is why converters keep moving to higher frequencies: the same ripple needs a smaller inductor and capacitor. ![Inductor current ripple and output voltage ripple of the buck example against the switching frequency, from 25 kHz to 400 kHz: the formulas and nine Voltecx runs.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/pwm-explained/ripple-vs-fsw.svg) In nine runs from 25 kHz to 400 kHz, the simulated ripple stays within 2 % of both formulas: from 3.6 A and 180 mV at 25 kHz down to 0.22 A and 0.70 mV at 400 kHz. The catch, covered in [Choosing a switching frequency](https://voltecx-web.nguyenvanqui291.workers.dev/blog/choosing-switching-frequency), is that every switching edge costs energy, so switching losses grow in proportion to $f_{sw}$. PWM frequency is always a trade between filter size and switching loss. ## Sawtooth or triangle: where in the period the pulse sits The carrier does not have to be a sawtooth. A **triangle** carrier ramps up for half the period and down for the other half. Compared with the same reference, it gives the same duty cycle, but the pulse sits in the middle of the period instead of at its start. This is called **centre-aligned** (or up-down) PWM; the sawtooth version is **edge-aligned**. ![The same duty of 0.25 compared with a sawtooth carrier (top two panels) and a triangle carrier (bottom two): the gate is on for the same 2.5 µs per period, at the start of the period or centred on the carrier's valley.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/pwm-explained/sawtooth-vs-triangle.svg) Why would anyone care where the pulse sits? - **Current sampling.** With a triangle carrier, the middle of the on-time and the middle of the off-time fall on the carrier's valley and peak. At those two instants the inductor current is exactly at its average value, because the ripple is a symmetric triangle around it. A controller that samples its ADC at the carrier's valley reads the average current with no filter and no delay. In the simulation, the inductor current at each valley and peak equals its mean (5.00 A) to within 0.02 %. - **Multiple legs.** In a full bridge or a three-phase inverter, centre-aligned PWM keeps the pulses of different legs symmetric, which reduces the ripple and the harmonics. - **Edges spread out.** With edge-aligned PWM all legs turn on at the same instant, at the start of each period; centre-aligned PWM moves the turn-on edges apart. Most motor-drive and inverter microcontrollers offer an "up-down" counter mode for exactly this reason. ## Digital PWM: a counter, not a ramp In a microcontroller the carrier is not a smooth ramp but a **timer counter**. It counts clock ticks from 0 to a period value $N$ and starts again; the compare register holds the duty in counts. The duty can therefore only take the values $0, 1/N, 2/N, \dots, 1$: $$N = \frac{f_{clk}}{f_{sw}} \quad\text{(edge-aligned)}, \qquad N = \frac{f_{clk}}{2 f_{sw}} \quad\text{(centre-aligned, up-down)}$$ The resolution in bits is $\log_2 N$, and the smallest step of the buck's average output is $V_{in}/N$. | Timer clock | $f_{sw}$ | Counts $N$ (edge-aligned) | Resolution | Output step of the 48 V buck | |---|---|---|---|---| | 100 MHz | 20 kHz | 5000 | 12.3 bits | 9.6 mV | | 100 MHz | 100 kHz | 1000 | 10.0 bits | 48 mV | | 100 MHz | 1 MHz | 100 | 6.6 bits | 0.48 V | The higher the switching frequency, the coarser the duty. To make the steps visible, the next figure feeds the buck a duty command that falls smoothly from 0.30 to 0.20 over 1 ms and limits the PWM to 20 and to 100 counts per period. ![Mean switch-node voltage of each 10 µs period while the duty command falls from 0.30 to 0.20: the command times 48 V, and the PWM rounding the duty to 20 counts (2.4 V steps) and to 100 counts (0.48 V steps).](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/pwm-explained/pwm-resolution.svg) With 20 counts the average can only move in steps of 48 V / 20 = 2.4 V. Between 430 µs and 440 µs the command is 0.26: 20 counts round it to 0.25 (12.0 V), 100 counts keep 0.26 (12.48 V). Why this matters in practice: - **Limit cycles.** If the duty step is coarser than what the ADC can measure, a closed loop can never land exactly on its set point. It hunts between two duty values forever, a low-frequency oscillation called a limit cycle. The usual rule is that the PWM resolution must be finer than the ADC's resolution at the output (A. V. Peterchev and S. R. Sanders, "Quantization resolution and limit cycling in digitally controlled PWM converters", *IEEE Transactions on Power Electronics*, vol. 18, no. 1, 2003). - **High-resolution PWM.** Many controllers add a fine delay line to the timer. TI specifies a typical 150 ps step for the F2837xD (data sheet SPRS880P, section 6.11.4.1.2) and ST 184 ps for the STM32G474's HRTIM (DS12288 Rev 4, section 3.24.1). At 1 MHz, 184 ps is a duty step of 0.000184, about 12.4 bits instead of 6.6. ## From DC to AC: sine PWM in a full bridge So far the reference was constant, so the output was DC. Now let the reference move **slowly** compared with the carrier. Each period still produces a pulse whose width follows the reference at that moment, so the average voltage follows the reference. Make the reference a 50 Hz sine and the averaged output is a 50 Hz sine. This is **sine PWM** (sine-triangle PWM), the basis of most inverters. The `fullBridgeSpwm` example is a single-phase inverter: two legs (a and b) across a 400 V link, a triangle carrier at 10 kHz, and an LC filter (1 mH in each leg, 10 µF) into a 50 Ω load. Leg a's duty is $0.5 + 0.4\sin(\omega t)$ and leg b's is its mirror image, $0.5 - 0.4\sin(\omega t)$. ### The modulation index The ratio of the reference's amplitude to the carrier's half range is the **modulation index** $m$. Here the reference swings ±0.4 around 0.5 on a carrier that spans 1, so $m = 0.4 / 0.5 = 0.8$. Each leg then averages $V_{dc}/2 + m\,(V_{dc}/2)\sin\omega t$, and the voltage between the legs has a fundamental of $$\hat V_{ab,1} = m\,V_{dc} = 0.8 \times 400\ \text{V} = 320\ \text{V peak} \quad (226\ \text{V rms})$$ as in N. Mohan, T. M. Undeland and W. P. Robbins, *Power Electronics: Converters, Applications and Design*, 3rd ed., chapter 8. As long as $m \le 1$ the relation is linear; above 1 the reference leaves the carrier's range, some periods have no pulse at all, and the output grows more slowly than $m$ (overmodulation). To see the comparison, the next figure slows the carrier down to 1 kHz, so that each triangle is visible. ![Sine PWM of the full bridge with the carrier slowed to 1 kHz: the triangle carrier and the two leg references da and db (top), and the bridge voltage vab (bottom), whose pulses widen and narrow with the sine.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/pwm-explained/sine-pwm-slow-carrier.svg) At the real 10 kHz the pulses are too dense to see one by one, but the filter output is a clean sine: ![One 50 Hz cycle of the full bridge at 10 kHz: the bridge voltage vab (a dense band of pulses) and the filtered output vo, and the inductor current i(L1) with its switching ripple.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/pwm-explained/bridge-and-output.svg) The simulated fundamental of $v_{ab}$ is 314.2 V. The 6 V missing from 320 V go to the 500 ns dead time (each leg loses $V_{dc}\,t_d\,f_{sw} = 2$ V, see [Dead-time effects](https://voltecx-web.nguyenvanqui291.workers.dev/blog/dead-time-effects)), the 50 mΩ switches and the simulation's 500 ns time step. ### Unipolar and bipolar PWM A full bridge can be modulated in two ways: - **Bipolar:** the two legs switch as one. The diagonal switches turn on together, so the bridge puts out only $+V_{dc}$ or $-V_{dc}$. - **Unipolar:** each leg compares its own reference (the sine and its mirror image) with the carrier. The bridge also uses the state where both legs are at the same rail, so its output steps between $+V_{dc}$, 0 and $-V_{dc}$, and in each half-cycle it only switches between one rail and zero. Both give the same fundamental (the bipolar run gives 315.1 V). The difference is in the pulses. ![0.6 ms around the positive peak of the output: the bridge voltage and the inductor current with unipolar PWM (the example as it is) and with bipolar PWM (each switch of leg b gated with the diagonal switch of leg a).](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/pwm-explained/unipolar-vs-bipolar.svg) With unipolar PWM the bridge pulses at **twice** the carrier frequency and swings by only $V_{dc}$ instead of $2V_{dc}$. The inductor current ripple near the peak is 1.81 A peak to peak, against 3.91 A with bipolar PWM, with the same filter and the same switching frequency. ## What the filter sees: the spectrum The clearest way to see what PWM does is its spectrum. A Fourier analysis of $v_{ab}$ over one 50 Hz cycle (`analysis.fft` in Voltecx) shows three things: 1. a large line at 50 Hz, the fundamental we wanted; 2. almost nothing at low frequencies: below 2 kHz no line reaches 2 % of the fundamental; 3. groups of lines around multiples of the carrier, at $k\,f_{sw} \pm n\,f_1$. ![Spectrum of the bridge voltage vab over one 50 Hz cycle, up to 45 kHz: unipolar PWM (top) has no group at 10 kHz and its first group at 20 kHz; bipolar PWM (bottom) has a 331 V line at the 10 kHz carrier.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/pwm-explained/bridge-spectrum.svg) - **Bipolar:** the largest unwanted line is the carrier itself, 331 V at 10 kHz. The analytic result for naturally sampled sine PWM, $(4V_{dc}/\pi)\,J_0(m\pi/2)$, gives 327 V, within 1.5 % (D. G. Holmes and T. A. Lipo, *Pulse Width Modulation for Power Converters*, Wiley-IEEE Press, 2003, chapter 3). - **Unipolar:** the carrier group at 10 kHz cancels between the two legs (under 3 V is left), and the first group sits at 20 kHz, with sidebands of 128 V at both 20.05 kHz and 19.95 kHz. This is why the spectrum matters more than the waveform: the **filter only has to remove what is far above the fundamental.** The LC filter here resonates at 1.1 kHz, and above that it attenuates by about 40 dB per decade. With bipolar PWM it leaves 4.2 V at 10 kHz on the output; with unipolar PWM only 0.41 V at 20 kHz, ten times less, from the same filter and the same switching losses. The rule of thumb that follows: put the switching frequency (or, with unipolar PWM, twice it) a decade or more above the filter's resonance, and the resonance a decade or more above the fundamental. ## Practical pitfalls - **The filter averages, the switches do not.** The switch, the diode and the inductor carry the full pulse current, with peaks of $I_{out} + \Delta i_L/2$. Size them for the peak, not the average. - **Duty limits.** A real gate driver needs a minimum on-time and off-time, and a bootstrap supply needs the low switch to turn on every period. Near $D = 0$ and $D = 1$ the PWM cannot do what the formula says. - **Dead time.** A half bridge needs a short gap between turning one switch off and the other on. That gap shifts the average voltage by $V_{dc}\,t_d\,f_{sw}$ per leg, as in the full bridge above. - **Carrier and reference must not be related by accident.** If the reference contains a component near the carrier frequency, the comparison aliases it down to low frequency. Filter or sample the reference properly. - **Simulate the edges where they are.** A fixed-step simulation puts each switching edge on its time grid, which adds a timing error of up to one step per edge. Use a step well below the smallest pulse width, or a solver that lands its steps on the PWM edges (the fast solver in Voltecx does). ## Try it in Voltecx - Open the `buckIdeal` example (`File › Open Example`, DC-DC). Change the variable `D` in `Circuit › Variables` and run again: the output follows $D \cdot 48$ V. Change `fsw` to see the ripple change as in the figure above. - On the PWM block, `shape` switches between a `sawtooth` and a `triangle` carrier, `counts` rounds the duty to a timer's counts per period, and `hrpwm` rounds it to a high-resolution step (`f28379d` or `stm32g474`). - A `carrier` block with the same frequency and shape records the carrier itself, so you can plot it against the reference as in the figures. - Open `fullBridgeSpwm` (Inverters) and run `analysis.fft` on the bridge voltage or on `vo` to see the carrier groups and how much of them the filter leaves. `analysis.paramSweep` over `fsw` or `Mi` gives the ripple or the fundamental against either. Every figure in this article comes from a Voltecx test that runs these examples with the numbers above, and the test fails if a simulated number quoted here no longer matches the run. --- # RC snubber design: measure the ring, then size R and C URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/rc-snubber-design/ To design an RC snubber, measure the ring frequency $f_0$, add a known capacitor $C_{add}$ and measure the new frequency $f_1$; then the parasitic capacitance is $C_p = C_{add}/((f_0/f_1)^2 - 1)$, the inductance is $L_p = 1/((2\pi f_0)^2 C_p)$, the resistor is $R = \sqrt{L_p/C_p}$ and the capacitor is about $4\,C_p$, which costs $C V^2 f_{sw}$ in the resistor. In a 48 V buck that rings at 22.5 MHz this recovers $C_p$ = 1.0 nF and $L_p$ = 50 nH, gives 6.8 Ω and 3.9 nF, and cuts the switch-node peak from 93.9 V to 64.5 V for 0.91 W. This article explains where the ring comes from, why the method works, how to pick R and C, what the snubber costs, and what the sweeps of R and C show. All numbers come from Voltecx runs, and a test in the Voltecx source checks them. ## Where the ring comes from Every hard-switched converter has a commutation loop: the input capacitor, the switch and the diode (or the other switch). Its wiring has inductance, a few nanohenries per centimetre, and the devices have capacitance. When the switch turns on, the current in the loop rises until the diode no longer carries any; the diode then turns off and its capacitance is charged through the loop inductance. That is a series LC circuit excited by a step, and it rings at $$f_0 = \frac{1}{2\pi\sqrt{L_p C_p}}$$ with a characteristic impedance $$Z_0 = \sqrt{\frac{L_p}{C_p}}$$ With almost no resistance in the loop, the voltage swings to nearly twice the bus voltage and decays slowly. The ring stresses the diode and the switch (the peak must stay inside their voltage rating), and its tens of megahertz are right in the band of conducted and radiated emission limits. Mohan, Undeland and Robbins (*Power Electronics: Converters, Applications, and Design*, 3rd ed., chapter 27, "Snubber Circuits") treat the snubber as the damping of this circuit; P. C. Todd's Unitrode seminar paper *Snubber Circuits: Theory, Design and Application* (SEM-900, 1993) gives the design of the RC snubber used here, and ROHM's application note *Snubber Circuit for Buck Converter IC* (Rev. 001) walks through the measurement method step by step. ## The circuit The example is Voltecx's textbook buck example, `buckIdeal`, (48 V to 12 V, 100 kHz, D = 0.25, 100 µH, 100 µF, 2.4 Ω, so 5 A and 60 W) with the parasitics a real board has: - **Lp** = 50 nH with 0.1 Ω in series, the commutation loop between the source and the switch; - **1 nF across the diode** (its junction capacitance, the `cj` parameter of D1); - **0.5 nF across the switch** (`coss` of S1), so that the loop current has somewhere to go when the switch opens. These values are illustrative, not from a data sheet: the point of the method is that you do not know them. They are in the right range for a large Schottky diode at low voltage and a few centimetres of loop. ![The buck with its commutation-loop inductance Lp (50 nH) and the RC snubber Rs and Cs across the diode. The diode's 1 nF and the switch's 0.5 nF are parameters of D1 and S1. The PWM output reaches the switch by the label g.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/rc-snubber-design/buck-snubber.svg) The run starts at the operating point (5 A in the inductor, 12 V on the output) and lasts 20 µs on a fixed 0.25 ns step, so the 44 ns ring period has about 180 points. The switch turns on at 0, 10 and 20 µs; every measurement here uses the turn-on at 10 µs. ## Step 1: measure the ring Without a snubber the switch node jumps from 0 to the bus and rings: the first peak is **93.9 V** on a 48 V bus, and the ring decays slowly because the only damping is the loop's 0.1 Ω. The period, measured between upward crossings of 48 V over four cycles, is **44.4 ns**, so $$f_0 = \frac{1}{44.4\ \text{ns}} = 22.5\ \text{MHz}$$ On the bench this is a scope measurement at the switch node with a short ground spring; a long ground lead adds its own ring (see [bench testing tips](https://voltecx-web.nguyenvanqui291.workers.dev/blog/bench-testing-power-converter-tips)). One frequency is not enough: the same 22.5 MHz could be 50 nH with 1 nF or 10 nH with 5 nF, and the right resistor differs by a factor of five between the two. ## Step 2: add a known capacitor Put a capacitor $C_{add}$ of known value across the diode, the same place as the snubber will go, and measure again. The capacitances add: $$\frac{f_0}{f_1} = \sqrt{\frac{C_p + C_{add}}{C_p}} \quad\Rightarrow\quad C_p = \frac{C_{add}}{(f_0/f_1)^2 - 1}$$ The ROHM note adds capacitance until the frequency halves, which means $C_{add} = 3\,C_p$; any known value works with the formula above, as long as it moves the frequency clearly. With 2.2 nF added, the period becomes **79.4 ns** (12.6 MHz): $$C_p = \frac{2.2\ \text{nF}}{(79.4/44.4)^2 - 1} = 1.0\ \text{nF}, \qquad L_p = \frac{1}{(2\pi f_0)^2 C_p} = 50\ \text{nH}$$ Both are within 0.2 % of what the circuit contains. On a real board the result is the effective capacitance at the switch node, whatever it is made of: the diode, the switch's output capacitance through the input capacitor, the inductor's winding capacitance and the board. ![The ring as built (44.4 ns period) and with 2.2 nF added across the diode (79.4 ns). The frequency ratio gives the parasitic capacitance, and then the loop inductance.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/rc-snubber-design/ring-added-capacitor.svg) ## Step 3: size R and C **The resistor.** A series RLC circuit is critically damped (fastest settling without overshoot of the ring) when $R = 2 Z_0$ and well damped from about $R = Z_0$, which is the usual choice because the snubber capacitor also matters: $$R = \sqrt{\frac{L_p}{C_p}} = \sqrt{\frac{50\ \text{nH}}{1.0\ \text{nF}}} = 7.07\ \Omega \;\rightarrow\; 6.8\ \Omega$$ **The capacitor.** The resistor alone across the diode would draw current from the bus all the time, so it goes in series with a capacitor that is large compared with $C_p$ (so that at the ring frequency the resistor is what the ring sees) but small enough to keep the loss low. Three to four times $C_p$ is the usual compromise: $$C_s = 4\,C_p = 4.0\ \text{nF} \;\rightarrow\; 3.9\ \text{nF}$$ **The loss.** Every period the snubber capacitor is charged to the bus voltage and discharged again. Charging a capacitor through a resistor from a step loses $\frac{1}{2} C V^2$ in the resistor, whatever the resistance, and discharging it loses the rest: $$P = C_s V^2 f_{sw} = 3.9\ \text{nF} \times (48\ \text{V})^2 \times 100\ \text{kHz} = 0.90\ \text{W}$$ The simulation measures **0.91 W** in the resistor, 1 % more: the ring's own energy is added to it. That is 1.5 % of the converter's 60 W, a real cost for a 48 V, 5 A converter, and the reason not to use more capacitance than the ring needs. The resistor needs a pulse-rated part rated for this power with margin. ## The result With 6.8 Ω and 3.9 nF across the diode, the switch node rises to **64.5 V** and settles within about one cycle. The overshoot above the bus falls from 45.9 V to 16.5 V. ![The switch node at the turn-on, without a snubber (it rings at 22.5 MHz up to 93.9 V) and with 6.8 Ω and 3.9 nF (64.5 V, settled within a cycle).](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/rc-snubber-design/ring-vs-snubber.svg) The snubber does not remove the first peak entirely: the capacitor needs current to charge, and the first rise is shaped by the loop inductance against $C_p + C_s$ through $R$. To lower the first peak further, reduce the loop inductance (layout) or slow the switch; the snubber's job is to stop the ringing. ## Sweeping R: damping against loss Holding $C_s$ at 3.9 nF and sweeping $R$: | R | Peak v(sw) | Loss in R | |---|---|---| | 1 Ω | 81.5 V | 0.57 W | | 2.2 Ω | 73.2 V | 0.70 W | | 4.7 Ω | 65.3 V | 0.85 W | | 6.8 Ω | 64.5 V | 0.91 W | | 10 Ω | 67.2 V | 0.94 W | | 22 Ω | 76.7 V | 0.97 W | | 47 Ω | 84.4 V | 0.97 W | ![The peak of the switch node and the loss in the snubber resistor against R, with Cs = 3.9 nF. The peak is lowest near √(Lp/Cp) = 7.07 Ω (the marker at 6.8 Ω); the loss hardly moves above a few ohms.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/rc-snubber-design/sweep-r.svg) The peak has a clear minimum near $Z_0$: a small resistor puts $C_s$ almost directly in parallel with $C_p$ and the circuit just rings slower, and a large resistor disconnects $C_s$ and the circuit rings as before. The loss barely depends on $R$ above a few ohms, because it is set by $C_s V^2 f_{sw}$. Below that, part of the same energy is dissipated in the loop resistance instead of the snubber resistor, so the resistor's share falls, but the converter loses it all the same. ## Sweeping C: more damping, more loss Holding $R$ at 6.8 Ω and sweeping $C_s$: | Cs | Peak v(sw) | Loss in R | $C_s V^2 f_{sw}$ | |---|---|---|---| | 1 nF | 79.9 V | 0.28 W | 0.23 W | | 2.2 nF | 70.5 V | 0.54 W | 0.51 W | | 3.9 nF | 64.5 V | 0.91 W | 0.90 W | | 6.8 nF | 60.3 V | 1.53 W | 1.57 W | | 10 nF | 58.3 V | 2.23 W | 2.30 W | ![The peak of the switch node and the loss in the snubber resistor against Cs, with R = 6.8 Ω. More capacitance lowers the peak a little more and costs in proportion.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/rc-snubber-design/sweep-c.svg) From 2.2 nF up the loss stays within 7 % of $C_s V^2 f_{sw}$. Beyond about $4\,C_p$ the peak improves slowly while the loss keeps rising linearly: going from 3.9 nF to 10 nF cuts the peak by 6.2 V and costs 1.3 W more. At 1 nF ($C_s = C_p$) the ring is not well damped. ## When an RC snubber is the wrong tool - **When the loss is too high.** At high voltage or high frequency, $C V^2 f$ grows quickly. Reduce the loop inductance first: a tighter layout raises $f_0$ and lowers the energy in the ring. - **When the ring is the diode's reverse recovery.** A slower or softer diode, or a Schottky or SiC diode, can remove the cause. - **When the switch can be slowed.** A larger gate resistor at turn-on lowers the di/dt that excites the ring, at the cost of switching loss (see the [double-pulse test](https://voltecx-web.nguyenvanqui291.workers.dev/blog/double-pulse-test-switching-energy)). - **Flyback leakage spikes.** The energy there is in the leakage inductance and too large for an RC; use an [RCD clamp](https://voltecx-web.nguyenvanqui291.workers.dev/blog/flyback-rcd-clamp-design). ## How to do it in Voltecx 1. Open **File › Open Example › buck** (DC-DC) (`file.openExample`, `{"name":"buck"}`). Add an inductor for the loop with **Circuit › Add Component** (`circuit.addComponent`), and set `cj` on D1 and `coss` on S1 (**Circuit › Parameters**, `circuit.setParam`). 2. Set **Simulation › Settings** (`simulation.settings`) to a fixed step well below the ring period (`maxStep` 0.25 ns, `fixedStep` true), or the ring disappears; the [simulation checklist](https://voltecx-web.nguyenvanqui291.workers.dev/blog/five-things-to-check-in-power-electronics-simulation) shows what a coarse step does to it. 3. Run, and read the period with the scope cursors (**Scope › Cursors**, `scope.cursors`) or `analysis.diagnoseWaveforms`, which reports ringing with its frequency. 4. Add a known capacitor, run again, and compute $C_p$, $L_p$, $R$ and $C_s$ as above. 5. Sweep R or C with **Analysis › Parameter Sweep** (`analysis.paramSweep`), measuring the peak of `v(sw)` and the RMS of `i(Rs)`. 6. On a converter made by Voltecx's design flow, **Design › Automate › Debug Aids** (`design.debugAids`) adds a do-not-populate RC snubber footprint across the low-side device with the same rules (R = √(L/C_par), C = 4·C_par, its loss C·V²·fsw); give it `ringHz` from your bench measurement and it sizes the snubber from that ring. The numbers are checked by `the_snubber_post_ring_measurement_and_design_match_the_simulation` and `the_snubber_post_resistor_and_capacitor_sweeps_trade_damping_for_loss` in `crates/engine/src/auto/tests_blog.rs`. ## Frequently asked questions ### How do I find the parasitic inductance and capacitance of the ring? Measure the ring frequency, add a known capacitor at the same node and measure it again. Then $C_p = C_{add}/((f_0/f_1)^2 - 1)$ and $L_p = 1/((2\pi f_0)^2 C_p)$. If adding $C_{add}$ halves the frequency, $C_p = C_{add}/3$. ### What resistor value should an RC snubber have? About the characteristic impedance of the ring, $R = \sqrt{L_p/C_p}$. In the sweep above the peak is lowest between 4.7 Ω and 10 Ω for a 7.07 Ω ring; the result is not sensitive to the exact value within a factor of about 1.5. ### How big should the snubber capacitor be? Three to four times the parasitic capacitance. Smaller does not damp well; larger damps a little better but the loss $C V^2 f_{sw}$ grows in proportion. ### How much power does an RC snubber dissipate? $P = C_s V^2 f_{sw}$, independent of R. For 3.9 nF at 48 V and 100 kHz that is 0.90 W; the simulation measures 0.91 W. ### Where should the snubber go? Across the device that rings, with the shortest possible loop: usually across the diode or the low-side switch of the commutation loop. A snubber at the end of a long trace has its own inductance and damps less. --- # Sensing current and voltage: shunt, Hall sensor, divider and isolated amplifier URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/current-voltage-sensing-shunt-hall-divider/ A controller can only regulate what it measures. If the current sensor reads 3 % high, the converter delivers 3 % less current than you asked for, and no amount of loop tuning will notice. If the sensor is slow, the loop sees an old copy of the current and loses phase margin. If the sensor's output does not fit the ADC, the reading clips at the worst possible moment: during a fault. This post goes through the sensors a power converter actually uses and how to size each one: - a **resistive divider** for voltages, with its anti-alias capacitor; - a **shunt resistor** with a current-sense amplifier; - a **Hall-effect sensor**; - an **isolated amplifier** across an isolation barrier; - and the last step every one of them shares: **scaling the signal into the ADC range** with headroom. Every number comes from a Voltecx run with sensor models whose values cite their data sheets. ## The intuition: every sensor takes something A perfect sensor would read the true value instantly and change nothing in the circuit. Real sensors all pay for their reading somewhere: | Sensor | What it costs | What it gives | |---|---|---| | Divider | Current from the measured node, resistor tolerance | Cheap, simple, accurate DC | | Shunt + amplifier | Power $I^2 R$ and a voltage drop | Accurate, fast, cheap | | Hall sensor | Offset, noise, limited bandwidth | Built-in isolation, almost no loss | | Isolated amplifier | A delay of microseconds, a price | Accurate reading across a barrier | Choosing a sensor is choosing which of these costs your design can afford. Keep that table in mind; the rest of the post puts numbers on each line. ## The signal chain Whatever the sensor, the path to the controller has the same four parts: 1. **The sensor** turns the current or voltage into a small voltage. 2. **The scaling** (a gain or a divider) maps the range you care about onto the ADC's input range. 3. **The filter** removes what the ADC must not see (switching noise that would alias) at the price of some phase lag. 4. **The ADC** samples and rounds it (see the [ADC sampling post](https://voltecx-web.nguyenvanqui291.workers.dev/blog/adc-sampling-power-converters)). Each stage adds an error and a delay. The design job is to keep the sum inside the regulation band and the phase budget. ## Voltage: the divider A divider of $R_1$ (top) and $R_2$ (bottom) scales the voltage by $$k = \frac{R_2}{R_1 + R_2}$$ It looks trivial, but four numbers decide it. **1. The highest voltage it must read.** Not the nominal output: the output at the top of its tolerance, plus start-up overshoot, plus half the ripple. The ratio $k$ must keep that highest value inside the ADC's full scale, even with the resistors at the worst of their tolerance and temperature drift. **2. The source resistance the ADC accepts.** A SAR ADC charges a small sampling capacitor through whatever drives its pin, during a short sampling time. If the source resistance $R_1 \parallel R_2$ is too high, the capacitor does not finish charging and the reading is low. The microcontroller data sheet gives the limit: for the STM32G474 at 12 bits and a sampling time of 12.5 ADC clocks at 42.5 MHz (294 ns) on a slow channel, ST's DS12288 (Rev 4, Table 67) allows **470 Ω**. **3. The power the divider burns.** A low source resistance means a low $R_1$, and $R_1$ carries the whole voltage. **4. The error.** With a large attenuation, $k \approx R_2/R_1$, so the errors of both resistors add almost in full. ### Worked example: a 48 V boost output into a 3.3 V ADC Take a boost from 12 V to 48 V at 100 kHz, output tolerance ±2 %, 0.5 V of ripple. `design.senseNetwork` sizes the network into an STM32G474 input: - **Highest signal:** $48 \times 1.02 \times 1.10 + 0.25 = 54.1$ V (10 % start-up overshoot by default). - **Divider:** $R_1 = 8.06$ kΩ over $R_2 = 499$ Ω, both Vishay CRCW E96 values (±1 %, ±100 ppm/K, document 20035). $k = 0.0583$, so the ADC's full-scale code corresponds to **56.6 V**. - **Source resistance:** $8.06\text{ k} \parallel 499 = 470$ Ω, right at the limit. - **Power:** at 54.1 V, $R_1$ takes **0.32 W**, which needs a 1210 chip. That is the price of the 470 Ω limit. - **Error:** the ratio alone can be off by **3.15 %** at the worst of tolerance and drift; with the ADC's own error the worst case is **3.35 %** of full scale. Two lessons hide in those numbers. First, a 1 % resistor does not give a 1 % divider when the divider attenuates 17 times: both resistors' errors add. For a tight output tolerance use 0.1 % resistors, or calibrate. Second, the 0.32 W is not inevitable: a longer sampling time or a fast channel raises the allowed source resistance (the same table allows 1.8 kΩ at 47.5 cycles), and a buffer amplifier removes the limit altogether. ### The anti-alias capacitor A capacitor from the ADC pin to ground does two jobs. It is a charge reservoir: the sampling capacitor takes its charge from it, not through the resistors. And with $R_1 \parallel R_2$ it forms a low-pass filter with a pole at $$f_p = \frac{1}{2\pi\,(R_1 \parallel R_2)\, C}$$ Here $C = 15$ nF puts the pole at **22.6 kHz**. The loop's crossover is 10 kHz, so the filter costs $\arctan(10/22.6) = 23.9°$ of phase margin, which must be added to the loop budget. ![The boost output in Voltecx scaled by the divider ratio, v(out) × k, and the voltage at the ADC pin, v(adc), behind the 15 nF capacitor: the 29.4 mV sawtooth becomes 4.98 mV.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/current-voltage-sensing-shunt-hall-divider/divider-filter.svg) In the simulation, the 0.505 V output ripple becomes 29.4 mV after the divider and **4.98 mV** at the pin: about 6 LSB of a 12-bit, 3.3 V ADC, rounded off and delayed. The average at the pin is exactly $k$ times the output. ## Current: the shunt A shunt is a small resistor in the current path. Ohm's law does the measuring, $V = I R$, and Joule's law sends the bill, $P = I^2 R$. The choice of $R$ is a pure trade-off: - **A larger shunt** gives more signal, so offset and noise matter less and one ADC code is a smaller current. - **A smaller shunt** wastes less power and drops less voltage. The amplifier sits between the two. In the examples below it is the **INA240A2** (Texas Instruments, SBOS662C): a gain of 50 V/V, 400 kHz of bandwidth, ±5 µV typical offset, an input common-mode range of −4 V to 80 V, with its reference pins at ground for a unidirectional output. ### Worked example: the 5 A buck Put the shunt and the amplifier in series with the inductor of the 12 V to 3.3 V, 5 A, 200 kHz buck. The inductor current is 4.96 A RMS in the simulation. We want to read up to 10 A (twice the rated current, for the current limit) inside a 3.3 V ADC. ![The shunt choice against its value: the loss I²R at the simulated 4.96 A RMS, the amplifier output at 10 A with a gain of 50 (the line marks 3.3 V), and the current of one 12-bit LSB of 3.3 V. The vertical line marks 5 mΩ.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/current-voltage-sensing-shunt-hall-divider/shunt-tradeoff.svg) Read the three panels from top to bottom: - **Loss** grows linearly with $R$. - **Signal at 10 A** is $50 \times R \times 10$ A. It must stay below 3.3 V, so $R \le 6.6$ mΩ. - **Resolution**: one LSB of a 12-bit ADC over 3.3 V is 0.806 mV, so one code is $0.806\ \text{mV} / (50 R)$ of current. A **5 mΩ** shunt gives 0.25 V/A: 2.5 V at 10 A, which leaves 0.8 V of headroom; 3.22 mA per code; and **0.123 W** of loss at 4.96 A RMS (0.5 W at 10 A). That loss is about 0.75 % of the 16.5 W output: small, but not free, which is why high-current converters go down to fractions of a milliohm and higher gains. ### Kelvin connection At 5 mΩ, the copper of the board is part of the measurement. Half a milliohm of trace between the shunt and the amplifier's input pins is a **10 % error**. The fix is a **Kelvin** (four-wire) connection: the current flows through the outer pads, and two separate thin traces take the voltage from the inner points of the shunt to the amplifier, routed together as a pair, carrying no current. Many shunts have four terminals for exactly this. ### High side or low side? - **Low side** (between the load and ground): the amplifier sees almost 0 V of common mode, so any amplifier works. But the load is no longer at ground, and a short from the load to ground bypasses the shunt and is never seen. - **High side** (between the supply and the load, or in series with an inductor whose node switches): the amplifier must reject a large and possibly fast-moving common-mode voltage. That is what parts like the INA240 are made for, with its −4 V to 80 V input range and its enhanced PWM rejection. - **In the switch leg** of a bridge: the shunt sees the current only while that switch conducts, which is fine if you sample in that window. ### How fast is the shunt amplifier? The INA240A2 is a single pole at 400 kHz in Voltecx, so a 10 A step reaches half its final value after $\ln 2 / (2\pi \times 400\,\text{kHz}) = 0.28$ µs (the simulation agrees). Against the buck's 200 kHz triangle it is not perfect either: ![Three switching periods of the buck in Voltecx: the inductor current i(L1) and what the INA240A2 and the ACS712-05B report, converted back to amperes.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/current-voltage-sensing-shunt-hall-divider/sensed-ripple.svg) The true ripple is 1.46 A peak to peak; the INA240A2 reports **1.12 A** of it, slightly rounded and shifted right. Both sensors report the right average, 4.95 A. Two consequences: - For **average-current control** sampled in the middle of the on-time, the sensor's delay shifts the waveform. Move the ADC trigger later by about the sensor's delay, or the sample is no longer at the midpoint. - For **peak-current protection**, a slow sensor reads the peak low and late. Trip on a fast comparator path, or lower the threshold to allow for it. ## Current: the Hall sensor A Hall sensor measures the magnetic field of the current, so the primary conductor has no electrical connection to the output: **isolation comes free**, and the loss is only that of the conductor. The **ACS712ELC-05B** (Allegro MicroSystems, ACS712-DS Rev. 22) has a primary resistance of 1.2 mΩ, a sensitivity of 185 mV/A around a zero-current output of 2.5 V on a 5 V supply, and 80 kHz of bandwidth. The costs are in the other columns of the table: - **Bandwidth.** 80 kHz is well below the 200 kHz switching frequency. In the figure above the ACS712 reports only **0.43 A** of the 1.46 A ripple, a smooth wave delayed by about a fifth of a period. For a loop crossing at a few kHz that is fine; for cycle-by-cycle current limiting it is not. - **Offset and noise.** The zero-current level and the sensitivity are ratiometric to the supply (they follow VCC), so a noisy 5 V supply becomes a noisy reading, and the data sheet gives 21 mV peak to peak of noise (with its filter capacitor set for 2 kHz of bandwidth) at 185 mV/A: about 0.11 A. Calibrate the zero at start-up with no current flowing. - **The 5 V output.** The output is centred at 2.5 V for a bidirectional range. On a 3.3 V ADC, that is the next problem. ## Isolated amplifiers across a barrier When the shunt sits on a high-voltage node (the phase current of a 400 V inverter, a PFC's DC bus) the controller must be isolated from it. An **isolated amplifier** measures the small shunt voltage on the hot side and sends it across a reinforced barrier. The **AMC1302** (Texas Instruments, SBAS812D) takes a linear input of ±50 mV with a gain of 41, has 280 kHz of output bandwidth, and outputs a differential voltage around a 1.44 V common mode. In the bench below its shunt is 4 mΩ, so 10 A is 40 mV, inside the ±50 mV range. Its cost is **delay**: the data sheet gives a signal delay of 1.6 µs (50 % to 50 %), because the signal is modulated, sent across the barrier and demodulated. ![A 9.9 A current step down in Voltecx and what three sensors report, in amperes: the INA240A2 crosses half way after 0.28 µs, the ACS712-05B after 1.39 µs and the AMC1302 after 1.61 µs, its data-sheet delay.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/current-voltage-sensing-shunt-hall-divider/step-response.svg) The three sensors in series carry the same 9.9 A current, which drops to zero at once: | Sensor | Model in Voltecx | 50 % time | Before the step | |---|---|---|---| | INA240A2 | 400 kHz pole | 0.28 µs | 9.9 A | | ACS712-05B | 80 kHz pole | 1.39 µs | 9.9 A | | AMC1302 | 1.21 µs delay + 280 kHz pole | 1.61 µs | 9.9 A | The AMC1302 is accurate (all three read the steady current within 0.1 %) but late. For a current loop at 100 kHz sampling, 1.6 µs is 16 % of a period, so move the ADC trigger by that much; for overcurrent protection, use the hot-side comparator or a desaturation detector, which do not wait for the barrier. Read the output as the difference of its two pins. Each pin sits near 1.44 V, so a single-ended reading of one pin is off by that much. ## Scaling into the ADC range, with headroom The last step is the same for every sensor: map the range you must read onto the ADC's input range, with some room left at the top. ![The output voltage against the current in Voltecx for the INA240A2 on 5 mΩ, the ACS712-05B, and the ACS712-05B through a 10 kΩ over 20 kΩ divider. The horizontal lines mark the 0 to 3.3 V range of the ADC.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/current-voltage-sensing-shunt-hall-divider/adc-scaling.svg) The figure ramps a test current from 0 to 12 A through the sensors: - **INA240A2 on 5 mΩ:** 0 V at 0 A, 3.0 V at 12 A. The whole range fits with 0.3 V to spare. Note that with the reference pins at ground it reads only positive current; a bidirectional reading needs the reference at mid-supply and half the span each way. - **ACS712-05B straight into the ADC:** 2.5 V at 0 A, and it leaves the 3.3 V range at $(3.3 - 2.5)/0.185 = 4.32$ A. Above that the ADC clips: a current limit set at 6 A would never trip. At 12 A the sensor outputs 4.72 V, well beyond what the ADC can convert; check the microcontroller data sheet for what the pin itself may take. - **ACS712-05B through a 2/3 divider** (10 kΩ over 20 kΩ): 1.67 V at 0 A and 3.14 V at 12 A. It fits, at the cost of a third of the resolution. The headroom is not wasted range. It is what lets the controller see an overcurrent instead of a flat line, absorbs gain error and offset, and keeps the pin within its rating. A useful rule is to put the largest current you must read (the current-limit trip, not the rated current) at about 80 to 90 % of full scale. ## A checklist 1. Write down the highest signal: tolerance, overshoot, ripple, and the fault current you must still read. 2. Pick the sensor by what it costs you: loss (shunt), bandwidth and offset (Hall), delay (isolated amplifier). 3. Scale it to about 80 to 90 % of the ADC's full scale at that highest signal, at the worst of the tolerances. 4. Check the source resistance against the ADC data sheet, and the power in every resistor. 5. Place the filter pole between the crossover and half the sampling rate, and add its lag to the loop budget. 6. Route the shunt with a Kelvin connection, and move the ADC trigger by the sensor's delay. ## Try it in Voltecx - `ic.place` puts the sensor ICs in the circuit as modules with named pins: `shuntAmplifier` (INA240A1 defaults), `hallCurrentSensor` (ACS712ELC-05B), `isolatedAmplifierAmc1302` (AMC1302), `isolatedAmplifier` (AMC1301), `isolatedVoltageSensor` (AMC1311 with a divider) and `closedLoopHall` (LEM LA 55-P). Each parameter cites the data-sheet section it comes from, and `rSense` is your own shunt. - `design.senseNetwork` sizes the divider and the anti-alias capacitor in front of an STM32G474 ADC input from the spec, with the error budget, the resistor power and the phase lag at the crossover. It changes nothing in the circuit; `bom.export` can turn its parts into BOM lines. - `circuit.problems` with a run reports a sensor whose output saturated (`sensor.saturated`), the failure the scaling figure warns about. - The [ADC sampling post](https://voltecx-web.nguyenvanqui291.workers.dev/blog/adc-sampling-power-converters) continues from the ADC pin: when to sample, aliasing and the cost of delay. --- # SEPIC converter design: duty cycle, inductors and the coupling capacitor URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/sepic-converter-design/ Size a SEPIC in four steps. The duty cycle is $D = (V_{out} + V_d)/(V_{in} + V_{out} + V_d)$. Each of the two uncoupled inductors is $L = V_{in,min}\,D_{max}/(\Delta I_L\,f_{sw})$, with the ripple $\Delta I_L$ about 40 % of the input current at the lowest input voltage; a 1:1 coupled inductor needs half that per winding. The coupling capacitor sits at $V_{in}$ and carries an RMS current of $I_{out}\sqrt{(V_{out} + V_d)/V_{in,min}}$. The switch sees $V_{in} + V_{out} + V_d$ and the sum of both inductor peaks. For 9–16 V to 12 V at 1 A and 300 kHz, $D$ runs from 0.58 to 0.44 and each inductor is 31 µH (33 µH fitted), or 16 µH coupled. The coupling capacitor carries 1.18 A RMS, and the switch peaks at 2.92 A and 28.5 V. ## The idea in one picture A SEPIC is a boost with a capacitor in its path and a second inductor behind it. The input inductor $L_1$ and the switch work exactly as in a boost: while the switch is on, $L_1$ stores energy from the input. The coupling capacitor $C_s$ charges to the input voltage and blocks it from the output. The second inductor $L_2$ hangs from the capacitor to ground. When the switch turns on, it pulls the capacitor's left side to ground, and the right side swings to $-V_{in}$. So $L_2$ sees $V_{in}$ across it, the same voltage as $L_1$, and stores energy too. When the switch opens, both inductors push their current through the diode into the output. Two things follow. The output is positive and can be above or below the input, which a boost or a buck alone cannot do. And there is no DC path from input to output: with the switch off, the capacitor stops the input from reaching the load. That is why SEPICs are used for battery inputs that cross the output voltage, and for outputs that must switch fully off when the converter stops. ## What duty cycle does a SEPIC need? In continuous conduction, the volt-seconds on each inductor balance over a period. With the diode drop $V_d$ included, that gives (J. Falin, *Designing DC/DC converters based on SEPIC topology*, TI Analog Applications Journal, SLYT309, 2008) $$D = \frac{V_{out} + V_d}{V_{in} + V_{out} + V_d}, \qquad \frac{V_{out}}{V_{in}} = \frac{D}{1 - D}\ \text{(ideal diode)}$$ It is the same conversion ratio as the inverting buck-boost, without the inversion (R. W. Erickson and D. Maksimović, *Fundamentals of Power Electronics*, the chapter on converter circuits). $D = 0.5$ gives $V_{out} = V_{in}$. The largest duty cycle comes at the lowest input, and that sets the switch's on-time and the inductors' ripple at that point. ## How do I size the two inductors? Both inductors see $V_{in}$ during the on-time, so each one's ripple is $$\Delta I_L = \frac{V_{in}\,D}{L\,f_{sw}}$$ Falin's rule sets the ripple at about 40 % of the input current at the lowest input voltage, where the input current $I_{in} = I_{out}(V_{out} + V_d)/V_{in,min}$ is largest. That gives $$L_1 = L_2 = L = \frac{V_{in,min}\,D_{max}}{\Delta I_L\,f_{sw}}$$ The average currents are different: $L_1$ carries the input current and $L_2$ the output current. The peaks are $I_{L1,pk} = I_{in} + \Delta I_L/2$ and $I_{L2,pk} = I_{out} + \Delta I_L/2$. **Check the ripple at the highest input too.** $V_{in}\,D = V_{in}(V_{out} + V_d)/(V_{in} + V_{out} + V_d)$ grows with $V_{in}$. So the ripple at maximum input is larger than the one you designed for at minimum input, even though the average input current is smaller there. ## Why does a coupled inductor need only half the inductance? Wound on one core with equal turns, the two windings see the same voltage at every instant, so they can share a core. The mutual inductance then adds to each winding's own inductance. For the same ripple current, each winding needs half the value of the uncoupled case (Falin, SLYT309): $$L_{coupled} = \frac{L}{2}$$ The ripple splits between the two windings, and the part is smaller than two separate inductors of value $L$. The windings must be 1:1. A coupled inductor with poor coupling behaves more like two separate inductors, with the leakage inductance carrying a circulating ripple. ## How do I choose the coupling capacitor? The capacitor's average voltage is the input voltage, so rate it for $V_{in,max}$. With ceramics, which most designs use here, leave margin for the capacitance lost under DC bias. Its current is the output inductor's current during the on-time and the input inductor's current during the off-time. Its average is zero, so its RMS value is $$I_{Cs,rms} = \sqrt{D\,I_{out}^2 + (1 - D)\,I_{in}^2} = I_{out}\sqrt{\frac{D}{1 - D}} = I_{out}\sqrt{\frac{V_{out} + V_d}{V_{in,min}}}$$ This is the form in Falin's SLYT309; it reduces to $I_{out}\sqrt{V_{out}/V_{in,min}}$ for an ideal diode. It is largest at the lowest input. During the on-time the capacitor carries $I_{out}$, so its voltage ripple is $$\Delta V_{Cs} = \frac{I_{out}\,D_{max}}{C_s\,f_{sw}}$$ The RMS current, not the capacitance, usually decides the part: it must be a low-ESR type rated for that current at your temperature. ## What do the switch and the diode see? - **Switch voltage.** While it is off, the switch node sits at the coupling capacitor's voltage plus the output plus the diode drop: $V_{Q,max} = V_{in,max} + V_{out} + V_d$. Add margin for ringing. - **Switch current.** While it is on, the switch carries both inductor currents, which ripple in phase. So $I_{Q,pk} = I_{L1,pk} + I_{L2,pk}$, and its RMS current is $I_{Q,rms} = I_{out}\sqrt{(V_{out} + V_{in,min} + V_d)(V_{out} + V_d)}/V_{in,min}$ (SLYT309). - **Diode.** Reverse voltage $V_{in,max} + V_{out}$, average current $I_{out}$, and the same peak as the switch. ## How big must the output capacitor be? As in a boost, the output capacitor alone feeds the load while the switch is on, and takes the pulsed diode current while it is off. Its RMS current is the same expression as the coupling capacitor's: $$I_{Cout,rms} = I_{out}\sqrt{\frac{V_{out} + V_d}{V_{in,min}}}$$ The ripple has a charge part, $I_{out}D/(C_{out}f_{sw})$, and an ESR part, $\text{ESR}\cdot(I_{L1,pk} + I_{L2,pk})$, because the diode current steps between zero and the sum of both inductor currents. The input capacitor has it easy: $L_1$ keeps the input current continuous, so it carries only the ripple, $\Delta I_L/\sqrt{12}$ RMS. ## Does a SEPIC have a right-half-plane zero? Yes. As in a boost, energy reaches the output only while the switch is off. A step up in duty cycle first shortens the off-time, so the output dips before it rises: a right-half-plane zero (see [the boost RHP zero](https://voltecx-web.nguyenvanqui291.workers.dev/blog/boost-converter-design-rhp-zero)). The SEPIC adds the resonances of $C_s$ with the two inductors, which makes its control-to-output response fourth order, with sharp peaks the loop must stay clear of. Keep the crossover well below the RHP zero at the lowest input and full load. A damping network across $C_s$ (a series RC in parallel with it) tames the resonance. ## Worked example: 9–16 V to 12 V at 1 A, 300 kHz | Input | Value | |---|---| | Input voltage | 9 to 16 V (12 V nominal) | | Output | 12 V, 1 A | | Switching frequency | 300 kHz | | Diode drop $V_d$ | 0.5 V (assumption: a Schottky diode at 1 A; use your part's data sheet) | | Inductor ripple | 40 % of the input current at 9 V | **Duty cycle.** At 9 V: $D = 12.5/21.5 = 0.581$. At 12 V: 0.510. At 16 V: 0.439. **Inductance.** The input current at 9 V is $1 \times 12.5/9 = 1.39$ A, so $\Delta I_L = 0.556$ A. Then $L = 9 \times 0.581/(0.556\ \text{A} \times 300\ \text{kHz}) = 31.4$ µH. Take **33 µH** for each uncoupled inductor, or a coupled 1:1 part with at least **15.7 µH** per winding. **Coupling capacitor.** It sits at up to 16 V. Its RMS current is $1 \times \sqrt{12.5/9} = 1.18$ A at 9 V. With 10 µF, its ripple is $1 \times 0.581/(10\ \mu\text{F} \times 300\ \text{kHz}) = 0.19$ V. **Output capacitor.** 1.18 A RMS at 9 V. 22 µF gives a charge ripple of $1 \times 0.581/(22\ \mu\text{F} \times 300\ \text{kHz}) = 88$ mV, before ESR. With 33 µH uncoupled inductors: | Quantity | $V_{in}$ = 9 V | $V_{in}$ = 16 V | |---|---|---| | Duty cycle $D$ | 0.581 | 0.439 | | Input current $I_{L1}$ | 1.39 A | 0.78 A | | Inductor ripple $\Delta I_L$ | 0.53 A | 0.71 A | | $L_1$ peak | 1.65 A | 1.14 A | | $L_2$ peak | 1.26 A | 1.35 A | | Switch peak $I_{L1,pk} + I_{L2,pk}$ | 2.92 A | 2.49 A | | Switch RMS | 1.82 A | 1.18 A | | Switch voltage $V_{in} + V_{out} + V_d$ | 21.5 V | 28.5 V | | Diode reverse voltage $V_{in} + V_{out}$ | 21 V | 28 V | | Coupling capacitor RMS | 1.18 A | 0.88 A | | Coupling capacitor ripple (10 µF) | 0.19 V | 0.15 V | | Output capacitor RMS | 1.18 A | 0.88 A | | Input capacitor RMS | 0.15 A | 0.20 A | The worst case is not the same for every part. The switch, the coupling capacitor and the output capacitor are hardest at 9 V. The ripple, $L_2$'s peak and the input capacitor's current are highest at 16 V. Rate each part at its own worst corner. ## Try it in Voltecx Open **File › Open Example › DC-DC › SEPIC converter** (`file.openExample` with `sepic`). It is an open-loop SEPIC: 12 V in, 12 V out at 1 A (12 Ω), 100 kHz, $D = 0.5$, with an ideal switch and a diode of 10 mΩ. It has two separate 150 µH inductors $L_1$ and $L_2$, a 10 µF coupling capacitor `Cs` and 47 µF at the output. Every part starts at its steady-state average, so the run settles quickly. 1. Run the simulation (`simulation.run`). The scope opens on `v(out)`, `i(L1)` and `i(L2)`. The output settles near 12 V, the switch node `v(sw)` swings to about 24 V ($V_{in} + V_{out}$), and both inductor currents average 1 A. 2. Run `analysis.stress` over the second half of the run (`{"t0":"4m"}`). It lists each part's measured voltage and current. In this example it measures 1.00 A RMS in `Cs`, which is $I_{out}\sqrt{V_{out}/V_{in}}$ = 1 A at $V_{in} = V_{out}$. The switch peaks near 2.4 A: both inductor peaks added. 3. Open the Design panel and choose **Converter** (`design.converter`). It sizes both inductors, the coupling capacitor and the output capacitor from the voltages, the load and the ripple you give (Erickson and Maksimović; TI SLYT309). With `"ripplePct": 40` it returns the 150 µH the example already has. It treats the diode as ideal and sizes $L_2$ for the ripple share of the output current, so its values can differ from the equal-inductor rule above. From a script: ```sh powercraft-cli run \ --cmd file.openExample --params '{"name":"sepic"}' \ --cmd simulation.run --params '{}' \ --cmd analysis.stress --params '{"t0":"4m"}' ``` For the inverting relative of the SEPIC, open **File › Open Example › DC-DC › Ćuk converter** (`cuk`). Same 12 V, 1 A, 100 kHz and $D = 0.5$, with an output of −12 V. Its energy-transfer capacitor sits at $V_{in} - V_{out}$ = 24 V instead of $V_{in}$, and both its input and output currents are smooth. To close the loop, [automatic design](https://voltecx-web.nguyenvanqui291.workers.dev/features/auto-design) designs a SEPIC's controller on its fourth-order averaged model, with the crossover below a fifth of the right-half-plane zero, and adds a damping network across the coupling capacitor. ## Frequently asked questions ### What is the duty cycle of a SEPIC? $D = (V_{out} + V_d)/(V_{in} + V_{out} + V_d)$ in continuous conduction. With an ideal diode $V_{out}/V_{in} = D/(1-D)$, so $D = 0.5$ gives an output equal to the input. Above 0.5 the SEPIC steps up, below it steps down. ### Should I use two inductors or a coupled inductor in a SEPIC? Either works. A 1:1 coupled inductor needs half the inductance per winding for the same ripple and saves board space. Two separate inductors are easier to buy and keep the two currents independent. With either, the duty cycle and the coupling capacitor are the same. ### What voltage and current rating does the SEPIC coupling capacitor need? It sits at the input voltage, so rate it for $V_{in,max}$ with margin for the DC-bias loss of a ceramic. Its RMS current is $I_{out}\sqrt{(V_{out}+V_d)/V_{in,min}}$, largest at the lowest input, and that RMS rating usually decides the part. ### Why is the SEPIC switch rated for $V_{in} + V_{out}$? While the switch is off, its drain sits at the coupling capacitor's voltage ($V_{in}$) plus the output and the diode drop on the other side. A 16 V input and a 12 V output put 28.5 V on the switch, more than either voltage alone. ## Sources - J. Falin, "Designing DC/DC converters based on SEPIC topology", *Analog Applications Journal*, Texas Instruments, SLYT309, 2008. - R. W. Erickson and D. Maksimović, *Fundamentals of Power Electronics*, Springer: the chapter on converter circuits. --- # Sequencing several power rails: order, delays, power-good and tracking URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/power-rail-sequencing/ A modern board rarely has one supply. A microcontroller or an FPGA wants a core rail around 1 V, an I/O rail at 1.8 V or 3.3 V, maybe an auxiliary rail for PLLs and analog blocks, and the whole lot is made from one input, often 12 V. Each regulator on its own is easy. The question this article answers is the one that only appears when there are several: **in what order do they come up, and how do you make sure they do?** We start with why the order matters, go through the four common ways to sequence rails, and then build and simulate a 12 V board with 5 V, 1.2 V and 3.3 V rails in Voltecx, with and without sequencing, including the power-down. ## The intuition: a building's lights and lifts Think of turning on the power in an office building after a blackout. You switch on the main feed first, then the lighting, then the lifts and the air conditioning. If everything switches on at once, the inrush trips the main breaker. If the lifts come on before their control panels have power, they may move without knowing where they are. Rails on a board are the same: - some rails **feed** others (5 V feeds the LDOs below it), so they must come first; - some chips need their **core** powered before their **I/O**, or the I/O pins misbehave; - and switching everything on at once makes one big **inrush** instead of several small ones. ## Why the order matters ### Latch-up and back-powering Every input and output pin of a CMOS chip has protection diodes from the pin to its own supply rail. Suppose a 3.3 V I/O rail is up, and another chip on the board drives a pin high, while the chip's own rail is still at 0 V. Current flows from the pin, through the protection diode, into the unpowered rail. This is **back-powering**: the chip is partly powered through its pins, in an undefined state, and the rail that should be at 0 V floats up to a few hundred millivolts or more. Back-powering can: - confuse a regulator's start-up, because its output is already pre-biased (see the [start-up article](https://voltecx-web.nguyenvanqui291.workers.dev/blog/power-converter-startup-sequence) for what a synchronous converter does to a pre-biased output); - let large currents flow through diodes that were sized for ESD pulses, not continuous current; - trigger **latch-up**: the parasitic thyristor formed by the n- and p-wells of CMOS turns on and shorts the supply until the power is removed. ### What the data sheet asks for The order is not a matter of taste: it comes from the data sheet of the device you power. Many processors and FPGAs specify an order. For example, AMD's 7-series FPGA data sheets (such as DS181, *Artix-7 FPGAs Data Sheet: DC and AC Switching Characteristics*, section on power-on/off power supply sequencing) recommend the core supply first, then the auxiliary supplies, then the I/O banks, and the reverse to power off. Other parts allow any order, as long as the rails reach their levels within a given time of each other, or as long as no I/O rail is more than a given voltage above the core. Read the device's power sequencing section before choosing a method. A typical requirement has four parts: 1. **Order:** which rail starts first. 2. **Delay:** how long after the previous rail is valid the next may start. 3. **Ramp:** how fast each rail must rise (often a minimum and a maximum ramp time). 4. **Power-down:** the order and the time limits on the way down. ## Four ways to sequence rails ### 1. Power-good chaining Each regulator's power-good output (PG) drives the enable (EN) of the next one. The second regulator only starts when the first is in regulation. It is simple and needs no extra parts when the regulators have PG and EN pins. ### 2. RC delays A resistor and capacitor between a PG output (or the input rail) and the next EN pin delay the start. The EN pin charges as $$v_{EN}(t) = V_{PU}\left(1 - e^{-t/RC}\right)$$ and crosses its threshold $V_{EN}$ after $$t_d = RC \ln\frac{V_{PU}}{V_{PU} - V_{EN}}$$ where $V_{PU}$ is the voltage the PG pin is pulled up to. The delay depends on the threshold's tolerance and on $V_{PU}$, so it is approximate, typically ±30 %. That is fine for "a few hundred microseconds later", not for tight timing. ### 3. Supervisors and sequencer ICs A voltage supervisor compares a rail against a precise reference and releases its output only when the rail is above the threshold, often with a fixed delay. A sequencer IC does this for several rails at once, with programmable thresholds, delays and a defined power-down order. This is what you use when a regulator has no PG pin, when the thresholds must be accurate, or when the power-down order matters. ### 4. Tracking Instead of one rail after another, tracking brings rails up **together**: - **Coincident tracking:** the rails rise with the same slope, so the lower one stops at its value while the higher one keeps going. The difference between them never exceeds the final difference. - **Ratiometric tracking:** the rails rise in proportion, reaching their final values at the same moment. Controllers with a tracking input (often a combined SS/TRK pin) do this by following a shared reference ramp. It suits devices that specify a maximum voltage difference between two rails rather than an order. ## A worked example: 12 V to 5 V, 1.2 V and 3.3 V The board in the simulation: - **5 V:** a synchronous buck with an LM5145-class controller from 12 V, with a 1 ms soft start. It feeds 1 A of its own loads, and both LDOs. - **1.2 V core:** an LP5907-class LDO from 5 V, 0.2 A load. - **3.3 V I/O:** an LP5907-class LDO (the LP5907MFX-3.3) from 5 V, 0.2 A load. The LP5907 data sheet (TI SNVS798Q) gives the values the model uses: an EN threshold of 1.2 V rising ($V_{IH}$ min) and 0.4 V falling ($V_{IL}$ max), an 80 µs start-up time, a 0.5 A short-circuit current limit, 1 µF input and output capacitors, and an input range of 2.2 V to 5.5 V. The fixed 1.2 V option is the LP5907MFX-1.2. The sequence we want is **5 V, then 1.2 V core, then 3.3 V I/O**, with a delay of about half a millisecond between steps. ### The sequencing circuit 1. **5 V to 1.2 V: power-good chain with an RC delay.** The buck's PGOOD is pulled up to 5 V by 10 kΩ and drives the 1.2 V LDO's EN through 1 MΩ and 2.2 nF. With PGOOD at 4.93 V, the delay to the 1.2 V threshold is $$t_d = 2.2\ \text{ms} \times \ln\frac{4.93}{4.93 - 1.2} = 2.2\ \text{ms} \times 0.28 = 0.61\ \text{ms}$$ 2. **1.2 V to 3.3 V: a discrete supervisor.** The LDO has no PG pin, so a supervisor watches the 1.2 V rail: a REF3025 2.5 V reference (TI SBVS032K) divided by 13.7 kΩ and 10.7 kΩ gives a 1.096 V threshold (91 % of 1.2 V), and an LM393B comparator (TI SLCS005AH, open-collector output) compares the rail with it. Its output, pulled up to 5 V, drives the 3.3 V LDO's EN through the same 1 MΩ and 2.2 nF. This is deliberately built from basic parts so you can see each function. On a real board, a two-channel supervisor or a sequencer IC replaces the reference, the divider and the comparator. ### The run, sequenced ![The three rails coming up in order in Voltecx: 5 V, then the 1.2 V core, then the 3.3 V I/O rail, with the power-good and enable signals of each step and the 1.2 V enable threshold.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/power-rail-sequencing/sequenced.svg) | Event | Time | |---|---| | 5 V reaches 90 % (end of the 1 ms soft start) | 0.97 ms | | PGOOD of the 5 V buck released | 1.00 ms | | EN of the 1.2 V LDO crosses 1.2 V (0.62 ms later) | 1.62 ms | | 1.2 V rail at 90 %, supervisor output released | 1.69 ms | | EN of the 3.3 V LDO crosses 1.2 V | 2.30 ms | | 3.3 V rail at 90 % | 2.37 ms | The simulated delay between PGOOD and the 1.2 V enable is 0.617 ms, against the formula's 0.61 ms. Each LDO then takes about 80 µs to ramp up, its specified start-up time. The rails settle at 1.194 V and 3.294 V. ### The inrush of each rail Each rail start draws a current pulse from the rail above it: the load current plus the charging current of the output capacitance, $C \, dV/dt$. For the LDOs, $dV/dt$ is set by their 80 µs ramp: - 1.2 V: $0.2\ \text{A} + 1\ \mu\text{F} \times 1.2\ \text{V} / 80\ \mu\text{s} = 0.215$ A; simulated 0.213 A. - 3.3 V: $0.2\ \text{A} + 1\ \mu\text{F} \times 3.3\ \text{V} / 80\ \mu\text{s} = 0.241$ A; simulated 0.240 A. ![The currents while the rails come up in order: the 12 V input current and the 5 V inductor current, each averaged over a switching period, and the output current of each LDO. Each rail adds its own step.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/power-rail-sequencing/rail-currents.svg) With 1 µF the charging part is small. On a real board, though, the 3.3 V rail of an FPGA carries tens of microfarads of decoupling. With 47 µF, the same 80 µs ramp would need $47\ \mu\text{F} \times 3.3 / 80\ \mu\text{s} = 1.9$ A, far above the LP5907's 0.5 A current limit. The LDO would then rise in current limit instead, taking about $47\ \mu\text{F} \times 3.3\ \text{V} / (0.5 - 0.2)\ \text{A} = 0.52$ ms, longer than its specified start-up. If the device has a maximum ramp time, check it with the real decoupling, not the regulator's own capacitor. ### The same board without sequencing Now tie both LDO enables to the 5 V rail, as is often done to "keep it simple". ![The same rails without sequencing: both LDOs start as soon as the 5 V rail passes 1.2 V, and the 3.3 V rail follows the rising 5 V rail in dropout. Below, the 12 V input current averaged over each switching period.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/power-rail-sequencing/unsequenced.svg) - Both LDOs start at 0.29 ms, as soon as the rising 5 V rail passes their 1.2 V EN threshold. - The 1.2 V core is at 90 % at 0.35 ms. By then the 3.3 V I/O rail is already at 1.51 V. It reaches 3.3 V at 0.66 ms by following the rising 5 V rail up in dropout, so its ramp is set by the buck's soft start, not by the LDO. - The I/O rail is above the core during the whole start-up. For a device that asks for core first, this order is wrong. Whether it is harmful depends on the device; the point is that the order was decided by accident, by thresholds and capacitor values, not by the designer. - Every load comes on during the 5 V soft start, so the 12 V input peaks at 0.76 A, against 0.61 A when sequenced. ## Power-down: the forgotten half Sequencing on the way down is harder than on the way up, and power-good chains do not do it. In the sequenced board, at 3 ms the buck's EN is pulled low, as a power switch or a supervisor would do. ![Power-down of the sequenced board: the buck is disabled at 3 ms. The 5 V rail falls, PGOOD drops at once, but the 1.2 V enable discharges slowly through 1 MΩ and stays high. The LDOs drop out as their input collapses: 3.3 V first, then 1.2 V.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/power-rail-sequencing/power-down.svg) What the run shows: - The 5 V rail leaves its band at 3.04 ms and its PGOOD is pulled low immediately. - The 1.2 V enable does **not** follow: its capacitor discharges through the 1 MΩ delay resistor, and it is still at 1.6 V at 4.4 ms, above the LDO's threshold. The RC delay that spaced the start-up now delays the turn-off by milliseconds. - So the LDOs are never disabled. They simply fall out of regulation as their input collapses: the 3.3 V rail at 3.17 ms, when the 5 V rail has fallen to 3.05 V, and the 1.2 V core last, at 3.44 ms. In this board the I/O falls before the core, which is the order a core-first device asks for. But it happened because of dropout, not because of the design. With a different load on the 1.2 V rail, or with a 3.3 V rail fed from somewhere else, it could reverse. If the power-down order matters: - use a sequencer or supervisor with a defined power-down sequence, triggered by an **early warning** (an input-voltage monitor that sees the 12 V falling before the 5 V rail does); - discharge the enable capacitors quickly when power-good drops, for example with a diode across the delay resistor; - use regulators with **active output discharge** (the LP5907 discharges its output through 230 Ω when disabled), so a disabled rail goes to zero promptly instead of floating; - keep enough hold-up on the input rail that the sequence can finish before the energy runs out. ## Monitoring after start-up: supervisors Sequencing does not end once the rails are up. A supervisor keeps watching each rail and asserts reset if one falls out of its window, holding the processor in reset until all rails are good again (with a delay, so the processor does not restart on a brief glitch). Practical points: - Set the threshold below the regulator's worst-case low output (tolerance, load regulation, ripple and transients), but above the device's minimum supply voltage. - Use hysteresis or a filter time, as the 25 µs PGOOD filter of the LM5145 does, so a fast load step does not reset the system. - Monitor the core rail directly at the device, not at the regulator output, if the board's IR drop is significant. ## Common mistakes - **Tying every enable to the input.** The order is then whatever the thresholds and capacitors make it; the run above brings the I/O rail up before the core. - **Forgetting the power-down order.** A power-good chain sequences the start only. The RC delays that space the start-up can even delay the shutdown. - **Leaving EN floating.** Some regulators have an internal pull-down, others do not; a floating EN picks up noise and can start a rail at random. - **RC delays with tight timing requirements.** The delay depends on the EN threshold, the pull-up voltage and the capacitor tolerance; use a supervisor or sequencer if the window is narrow. - **Ignoring the decoupling capacitance in the ramp time.** The device's bypass capacitors set the inrush and can push an LDO into current limit. - **Back-powering through I/O pins.** A chip on an always-on rail driving the pins of a chip that is off; add series resistors, use bus switches, or put both on rails that come up together. - **Not checking the order at the extremes.** Cold, at low input voltage and with the largest capacitors, the delays and ramps change; the order must hold at every corner. The analysis of RC delays and supervisors follows standard circuit theory (for example P. Horowitz and W. Hill, *The Art of Electronics*, 3rd ed.). Regulator, reference and comparator values are from the TI data sheets named above: LM5145 (SNVSAI4B), LP5907 (SNVS798Q), REF30xx (SBVS032K) and LM393B (SLCS005AH). ## Try it in Voltecx - **Build the rails.** Start from the buck: `circuit.applicationCircuit` with `ic` = `syncBuckController` and `topology` = `syncBuck`; its PGOOD pin and soft-start capacitor are already wired. Add LDOs with `ic.place` (`name` = `ldo`, `preset` = `LP5907MFX-3.3`, or `params: {vOut: 1.2}` for the core), a reference with `voltageReference` and a comparator with `comparatorHyst` and `preset` = `LM393B`. Each IC model lists what it models and what it leaves out with `ic.describe`. - **Measure the sequence.** Run the circuit and read the crossing times with the cursors on the scope, or with `scope.measure` and `waveform.get` from a script, as the test behind this article does. - **Auxiliary rails in automatic design.** `design.auto` with `spec.auxRails` picks LDOs for auxiliary rails and post-regulators from a catalogue of parts with cited data sheets, and checks their dropout headroom, supply rejection and junction temperature. It does not sequence the rails; the enables and the order remain your design, as in this article. - **The converter's own start-up.** For the soft start, UVLO and power good of each regulator, see [how a power converter starts up](https://voltecx-web.nguyenvanqui291.workers.dev/blog/power-converter-startup-sequence). See also the [models and parts](https://voltecx-web.nguyenvanqui291.workers.dev/features/models-and-parts) page. --- # Space vector PWM (SVPWM) explained step by step URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/space-vector-pwm-explained/ Space vector PWM is the modulator inside nearly every three-phase motor drive and grid inverter. It has a reputation for being hard: hexagons, sectors, dwell-time formulas. The idea underneath is simple, and it ends in a surprisingly short piece of code. This article builds it step by step on the `inverter3` example in Voltecx (a 600 V, 10 kHz three-phase inverter driving a 50 Hz RL load), and checks every number against a simulation. If PWM itself is new to you, start with [PWM explained simply](https://voltecx-web.nguyenvanqui291.workers.dev/blog/pwm-explained): carrier, duty cycle and sine PWM are used here without introduction. ## Why three phases need a better modulator A three-phase inverter has three legs, a, b and c, across one DC link. The obvious way to modulate it is three copies of single-phase sine PWM: compare three sines, 120° apart, with one triangle carrier. That works, but it wastes voltage. Each leg's output (its **pole voltage**, measured from the midpoint of the link) can swing between $-V_{dc}/2$ and $+V_{dc}/2$, so with sine PWM the phase voltage can reach at most $V_{dc}/2$ peak. The load, however, is connected between the legs, and what it feels is the **line-to-line** voltage $v_a - v_b$. With phase peaks of $V_{dc}/2$, the line voltage peaks at only $$\hat v_{ab} = \sqrt{3}\cdot\frac{V_{dc}}{2} = 0.866\,V_{dc}$$ yet two legs could put the full $V_{dc}$ between them: one at the top rail, the other at the bottom. Sine PWM never uses the top 13 % of the link. Space vector PWM does. ## The eight switch states Each leg has two useful states: upper switch on (the phase sits at $+V_{dc}/2$, write 1) or lower switch on ($-V_{dc}/2$, write 0). Three legs give $2^3 = 8$ combinations, written as three bits for legs a, b and c: | State | Pole voltages $(v_a, v_b, v_c)$ | Name | |---|---|---| | 100 | $(+, -, -)$ | V1 | | 110 | $(+, +, -)$ | V2 | | 010 | $(-, +, -)$ | V3 | | 011 | $(-, +, +)$ | V4 | | 001 | $(-, -, +)$ | V5 | | 101 | $(+, -, +)$ | V6 | | 000 | all $-$ | V0 (zero) | | 111 | all $+$ | V7 (zero) | In states 000 and 111 all three phases sit at the same rail, so every line-to-line voltage is zero: these are the **zero vectors**. The other six put voltage on the load: the **active vectors**. ## A picture for three numbers: the αβ plane Three phase voltages are awkward to picture. In a balanced load, though, only two of the three numbers are independent (whatever is common to all three phases, the **zero sequence**, never drives a current through a three-wire load). The **Clarke transform** turns the three phases into two coordinates, $\alpha$ and $\beta$, and drops the common part: $$v_\alpha = \frac{2v_a - v_b - v_c}{3}, \qquad v_\beta = \frac{v_b - v_c}{\sqrt{3}}$$ This is the amplitude-invariant form that the `clarke` block in Voltecx uses: a balanced set $v_a = \hat V\cos\theta$ (and $b$, $c$ 120° behind and ahead) becomes the point $(\hat V\cos\theta, \hat V\sin\theta)$, a vector of length $\hat V$ turning at the output frequency. A sinusoidal three-phase voltage is a **point moving on a circle**. Put each switch state through the transform. For 100, with $V_{dc} = 600$ V: $$v_\alpha = \frac{2(300) - (-300) - (-300)}{3} = 400\ \text{V}, \qquad v_\beta = 0$$ All six active states land at the same distance, $2V_{dc}/3 = 400$ V, 60° apart; the two zero states land at the origin. Together they form a **hexagon**. ![The vα–vβ plane of the 600 V inverter: the six active vectors V1 to V6 on a hexagon of radius 400 V, the zero vectors at the origin, the circle of radius Vdc/√3 (346 V) inside the hexagon, the sine PWM limit Vdc/2 (300 V), and the average output vector simulated in Voltecx at m = 0.8 and m = 1.3.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/space-vector-pwm-explained/vector-plane.svg) This picture holds the whole story: - The inverter can only **sit on** one of the seven points at any instant. - Over one switching period it can **average** any point inside the hexagon, by spending the right fraction of the period on nearby vectors. PWM is averaging, here in two dimensions. - To turn a circle at constant speed, the circle must fit inside the hexagon. The largest one that fits touches the middle of each edge, at radius $\frac{2V_{dc}}{3}\cos 30° = V_{dc}/\sqrt{3} = 346$ V. - Sine PWM stops at the circle of radius $V_{dc}/2 = 300$ V. The ratio is $346/300 = 2/\sqrt{3} = 1.155$: **15.5 % more voltage** from the same DC link. In the figure, the purple circle is the simulated average output at a modulation index $m = 0.8$ (defined below): a circle of 240 V, to within 0.1 %. ## Sectors and dwell times The six active vectors split the plane into six 60° **sectors**. Suppose the reference vector $\vec v^{\,*}$ lies in sector 1, between V1 (100) and V2 (110), at an angle $\theta$ from V1. Over one switching period $T_s$ the inverter spends: - $T_1$ on V1, - $T_2$ on V2, - $T_0$ on the zero vectors, the rest of the period. The average must equal the reference: $T_1 \vec V_1 + T_2 \vec V_2 = T_s \vec v^{\,*}$. Solving this in the αβ plane gives the **dwell times** (H. W. van der Broeck, H.-C. Skudelny and G. V. Stanke, "Analysis and realization of a pulsewidth modulator based on voltage space vectors", *IEEE Transactions on Industry Applications*, vol. 24, no. 1, 1988): $$T_1 = T_s\,\frac{\sqrt{3}\,|v^*|}{V_{dc}}\,\sin(60° - \theta), \qquad T_2 = T_s\,\frac{\sqrt{3}\,|v^*|}{V_{dc}}\,\sin\theta, \qquad T_0 = T_s - T_1 - T_2$$ ### Worked example Take $m = 0.8$, so the reference has $|v^*| = 0.8 \times 300 = 240$ V, at $\theta = 30°$, the middle of sector 1: $$\frac{\sqrt{3} \times 240}{600} = 0.693, \qquad T_1 = T_2 = 0.693 \times \sin 30° \cdot T_s = 0.346\,T_s, \qquad T_0 = 0.307\,T_s$$ At 10 kHz ($T_s = 100$ µs) that is 34.6 µs on V1, 34.6 µs on V2 and 30.7 µs on the zero vectors. The same shares can be read off the simulation. In each period, the time with one upper switch on (100, 010 or 001) is the largest duty minus the middle one; the time with two upper switches on (110, 011, 101) is the middle duty minus the smallest; the rest is spent in 000 and 111. ![Dwell times against the angle of the reference, read from the duties simulated in Voltecx at m = 0.8: the share of each switching period on an active vector with one upper switch on, with two, and on the zero vectors. The vertical lines are the sector boundaries.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/space-vector-pwm-explained/dwell-times.svg) Over the whole cycle the simulated shares follow the formulas to within 0.002 of a period, and at 30° they are 0.346, 0.346 and 0.307, as computed above. Note how the zero-vector share never falls to zero at $m = 0.8$: there is margin left. It reaches zero in the corners of the sectors when the reference circle touches the hexagon. ## Zero vectors and the switching sequence The dwell times say how long, not in which order. The standard choice: - split $T_0$ equally between 000 and 111; - arrange the period symmetrically, so that going from one state to the next changes **one leg at a time**. In sector 1 the period runs 111, 110, 100, 000, 100, 110, 111 (or the same starting from 000): seven segments, each leg switching exactly twice per period. This is the **seven-segment** sequence. ![One 100 µs switching period of the simulated inverter with the reference at 30°: the triangle carrier and the three duties (top), and the gates ga, gb and gc (bottom, offset for clarity). The state steps 111, 110, 100, 000, 100, 110, 111, one leg at a time.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/space-vector-pwm-explained/switching-period.svg) Look at the top panel: this sequence is just three duties compared with **one triangle carrier**, exactly like sine PWM. Phase a has the largest duty and is on the longest, phase c the smallest. The space vector modulator is a carrier comparison in disguise; only the duties are different. ## SVPWM is sine PWM plus a zero sequence Which duties? Write the duty of each leg as $d_x = 0.5 + (v_x + v_0)/V_{dc}$, where $v_x$ is the sine reference of that phase and $v_0$ is a voltage added to **all three** phases. Since $v_0$ is common, it cancels in every line-to-line voltage and the load never sees it. It is free to choose. - $v_0 = 0$ gives sine PWM. - Centring the active vectors in the period (equal 000 and 111 times) is the same as centring the three duties between 0 and 1: $$v_0 = -\frac{\max(v_a, v_b, v_c) + \min(v_a, v_b, v_c)}{2}$$ This is the **min-max** (or centred) zero sequence. With it, carrier-based PWM and the seven-segment space vector modulator switch at exactly the same instants (K. Zhou and D. Wang, "Relationship between space-vector modulation and three-phase carrier-based PWM: a comprehensive analysis", *IEEE Transactions on Industrial Electronics*, vol. 49, no. 1, 2002). That is why a practical SVPWM fits in a few lines of firmware: no sectors, no trigonometry. ```c float v0 = -0.5f * (fmaxf(va, fmaxf(vb, vc)) + fminf(va, fminf(vb, vc))); da = 0.5f + (va + v0) / vdc; /* and the same for db, dc */ ``` The `svpwm` block in Voltecx does exactly this (and clamps each output to the PWM's range). ![The phase-a reference over one 50 Hz cycle in the simulated inverter. At m = 0.8 (top): the sine as a duty, the SVPWM duty da with its "saddle" shape, and their difference, the min-max zero sequence. At m = 1.15 (bottom): the sine would need a duty of 1.075, which no PWM can give, while the SVPWM duty stays inside 0 to 1.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/space-vector-pwm-explained/references.svg) At $m = 0.8$ the sine duty peaks at $0.5 + 0.8/2 = 0.9$, while the SVPWM duty, flattened by the zero sequence, peaks at $0.5 + (\sqrt{3}/2)(0.8/2) = 0.846$. The zero sequence itself is a triangle-like wave at three times the output frequency, peaking at $m/8 = 0.1$. At $m = 1.15$ the difference decides everything: the sine needs a duty of 1.075, which cannot be made, so sine PWM is already overmodulated. The saddle peaks at 0.998 and still fits. The older idea of adding a pure third harmonic (one sixth of the fundamental) gives the same 15.5 % (J. A. Houldsworth and D. A. Grant, "The use of harmonic distortion to increase the output voltage of a three-phase PWM inverter", *IEEE Transactions on Industry Applications*, vol. IA-20, no. 5, 1984). The min-max sequence is simply the one that reaches it with the most symmetric switching. ## The modulation index and the 15.5 % Define the modulation index as the phase reference peak over half the link, $m = \hat v_{ph}/(V_{dc}/2)$. As long as the modulator stays linear, the fundamental of the line-to-line voltage is $$\hat v_{ab,1} = \sqrt{3}\cdot m\cdot\frac{V_{dc}}{2}$$ - **Sine PWM** is linear up to $m = 1$: $\hat v_{ab,1} = 0.866 \times 600 = 519.6$ V. - **SVPWM** is linear up to $m = 2/\sqrt{3} = 1.155$: $\hat v_{ab,1} = V_{dc} = 600$ V. ![Fundamental of the line-to-line voltage against the modulation index in Voltecx runs of the inverter: sine PWM and SVPWM, with the linear law √3·m·Vdc/2. Vertical lines at m = 1 and m = 1.155; horizontal lines at 519.6 V and 600 V.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/space-vector-pwm-explained/line-voltage-vs-m.svg) The simulation confirms both limits to within 0.5 %: 519.2 V for sine PWM at $m = 1$, 599.6 V for SVPWM at $m = 1.155$. At $m = 1.155$ sine PWM, already clipping, gives only 565 V. ## Overmodulation: beyond the hexagon's circle Ask for more than $m = 1.155$ and the reference circle pokes out of the hexagon near the middle of each edge. The inverter cannot average a point outside the hexagon, so something has to give. The `svpwm` block clamps the duties to 0 and 1, which keeps the line voltage between the largest and smallest phase at the full $V_{dc}$, so the average vector **slides along the hexagon's edge** until the reference comes back inside. In the vector plane above, the orange trajectory at $m = 1.3$ follows the edges, between 346 V (the middle of an edge) and 390 V (the reference, in the corners). The price: - **Little extra voltage.** The line voltage grows only to 630 V at $m = 1.3$, and creeps towards the **six-step** limit, where each leg is a square wave: $\hat v_{ab,1} = (2\sqrt{3}/\pi)\,V_{dc} = 662$ V. Neither modulator passes it. - **Low-order harmonics.** Clipping distorts the waveform with the 5th, 7th, 11th and 13th harmonics, which drive extra current and torque ripple in a motor. Dedicated overmodulation schemes manage this transition smoothly up to six-step (J. Holtz, W. Lotzkat and A. M. Khambadkone, "On continuous control of PWM inverters in the overmodulation range including the six-step mode", *IEEE Transactions on Power Electronics*, vol. 8, no. 4, 1993). Most drives simply limit $m$ to about 1.15 and leave a small margin for the current controller. ## What the zero sequence does to the spectrum The zero sequence is invisible to the load but not to the pole voltage. A Fourier analysis of one 50 Hz cycle shows where it goes: ![Low-order harmonics of the simulated inverter at m = 0.8. Top: the pole voltage v(oa) of leg a with sine PWM and with SVPWM. Bottom: the line-to-line voltage vab with SVPWM.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/space-vector-pwm-explained/pole-spectrum.svg) - Both modulators give the same 240 V fundamental on the pole voltage at $m = 0.8$. - The SVPWM pole voltage carries a 49.6 V **third harmonic**, plus smaller lines at the 9th and 15th: the zero sequence. Its value matches the third harmonic of the min-max sequence of a 240 V sine computed directly, 49.6 V. - In the line-to-line voltage the triplen harmonics cancel: under 1 V is left at the third. The load sees the same clean fundamental, just with 15.5 % more headroom. One consequence: in a three-wire load the star point is not at the link's midpoint but follows the zero sequence. Connect the star point to the midpoint (a four-wire system) and the third harmonic drives a current in that wire. SVPWM is for three-wire loads. ## Practical pitfalls - **Scale the reference with the link.** The duties are $v/V_{dc}$, so a drive must divide by the **measured** link voltage. The `svpwm` block takes $V_{dc}$ as an input for this reason. - **Leave headroom.** Running at exactly $m = 1.155$ leaves the current controller nothing to correct with. Limit the voltage vector to a little under $V_{dc}/\sqrt{3}$. - **Dead time eats small vectors.** At low speed the zero-vector time is long and the active-vector times are short; the dead-time error of $V_{dc}\,t_d\,f_{sw}$ per leg is then a large fraction of the command (see [Dead-time effects](https://voltecx-web.nguyenvanqui291.workers.dev/blog/dead-time-effects)). - **Minimum pulses.** Near the corners of the hexagon, $T_0$ approaches zero and the 000 and 111 segments shrink below what the gate driver can produce. Clamp them or move to discontinuous PWM, which clamps one leg to a rail for 60° at a time and saves a third of the switching events. - **Simulate the edges exactly.** An edge that falls between two steps of a fixed-step run has to be recorded at the instant it happens, with the switch still in its old state. On its default fixed 1 µs step, the reference solver now does that for `inverter3`, and at $m = 0.2$ it reads a line fundamental within 0.5 % of the 103.9 V of the formula, with sine PWM and with SVPWM alike. The fast solver, which lands its steps on the PWM edges, gives 103.8 V for both. The runs in this article use the fast solver. ## Try it in Voltecx - Open `inverter3` (`File › Open Example`, Inverters): sine-triangle PWM from a `sine3` source into a `pwm3` block. - To make it SVPWM, set the `sine3` source to volts (`amp` = $m \cdot V_{dc}/2$, `offset` = 0), wire its three outputs into an `svpwm` block with `output` set to `duty` and a constant 600 V on its `vdc` input, and wire the block's `ma`, `mb`, `mc` outputs to the `pwm3` inputs. That is exactly what the test behind this article does. - A `clarke` block on the three duties gives `alpha` and `beta`; plot one against the other (an x-y plot) to see the vector turn inside the hexagon. - `analysis.fft` on `v(oa)` shows the third harmonic of the zero sequence; on a voltmeter between `oa` and `ob` it shows the clean line voltage. `analysis.paramSweep` over the source's `amp` gives the voltage-against-$m$ curve. - In `simulation.settings`, set `solver` to `fast` to put the steps on the PWM edges. - The `pmsmFoc` example (Motor drives) uses the same `svpwm` block inside a field-oriented current loop. Every figure here comes from a Voltecx test that runs the inverter with these numbers, and the test fails if a simulated number quoted in this article no longer matches the run. --- # Testing a power converter on the bench: what to watch out for URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/bench-testing-power-converter-tips/ The first power-up of a new converter is the moment the design meets reality. It is also the moment when most boards get damaged, and when most misleading measurements are taken. A wrong probe setup can show 70 V of ringing on a node that never goes above 50 V; a hasty power-up can blow a MOSFET that would have worked. This article is a practical guide for the bench: how to stay safe, in which order to bring a board up, how to probe a fast switch node, how to measure current and efficiency, and how to run a double-pulse test. Where a mistake can be shown, a Voltecx simulation shows it, with the numbers. ## 1. Safety first Power electronics benches combine high voltage, high energy and fast edges. A few habits prevent almost every accident. ### Know where the dangerous voltage is - **Mains-connected circuits.** Everything on the primary side of an offline converter is at mains potential, including the "ground" of the primary controller. Touching it, or clipping an earthed scope ground to it, is dangerous. - **Isolation transformer for the unit under test.** Feed an offline converter from an isolation transformer so that a single touch to the primary side does not complete a path to earth. It protects you, not the scope. - **Never float the oscilloscope** by removing its protective earth. The whole chassis and every BNC shell then sit at whatever voltage your ground lead touches. Use a differential probe or an isolated-input instrument instead (section 4). ### Stored energy stays after you switch off Bulk capacitors hold their charge long after the supply is off. The energy in a capacitor is $\frac{1}{2}CV^2$: a 470 µF capacitor at 400 V stores 37.6 J, enough to burn and to throw a screwdriver tip. A bleeder resistor discharges it, but slowly. With a time constant $\tau = RC$, the voltage falls as $V(t) = V_0 e^{-t/\tau}$, so the time to fall to a safe level $V_{safe}$ is $$t = RC \ln\frac{V_0}{V_{safe}}$$ With a 100 kΩ bleeder on 470 µF ($\tau = 47$ s), going from 400 V to 60 V (the DC limit of energy source class ES1 in IEC 62368-1) takes $47 \times \ln(400/60) = 89$ s. That is a minute and a half. Practical rules: - **Measure before you touch.** Use a meter across the bulk capacitor every time, even if the bleeder "should" have discharged it. - **Discharge through a resistor**, never with a screwdriver short: the spark welds tips and the current spike can damage the capacitor. - **Put a visible indicator** (a lamp or LED with a resistor) across the high-voltage bus on prototypes. ### Limit the energy that a fault can release - **Current-limited supply.** For the first power-up, set the bench supply's current limit just above the expected no-load input current. A short then trips the limit instead of burning a trace. - **Enclosure or shield.** Electrolytic capacitors and power semiconductors can explode. Run new boards behind a clear shield and wear safety glasses. - **One hand rule and no jewellery** around live high-voltage circuits. - **Probes and leads rated for the voltage.** Read the voltage rating and measurement category printed on each probe and lead. ## 2. Bring-up order: one stage at a time The worst way to bring up a converter is to connect everything and switch on full power. If anything is wrong, you learn only that something is wrong, usually with smoke. Bring it up in steps so that each step tests one thing. 1. **Visual and resistance checks, unpowered.** Look for solder bridges, wrong polarity on capacitors and diodes, rotated ICs. Measure resistance from each rail to ground: a near-zero reading is a short to find now. 2. **Auxiliary rails first.** Power only the controller, gate-driver and bias supplies from a bench supply. Check each rail's voltage and current. 3. **Gate signals without power.** With the power stage unpowered (or its input disconnected), check every gate waveform: frequency, duty cycle, dead time, amplitude, and that complementary gates never overlap. A shoot-through found here costs nothing. 4. **Low input voltage.** Apply a fraction of the rated input (for example 10 to 20 %) through a current-limited supply, at light load. Check the switch node and the output. 5. **Raise the voltage in steps**, watching input current, temperatures and the switch node at each step. 6. **Then load**, in steps, then **load steps** and line steps to test the control loop. ### Why a soft start matters When a converter starts with its full duty cycle into an empty output capacitor, the LC filter rings: the inductor current and the output voltage overshoot. A soft start ramps the duty cycle (or the reference) up slowly instead. The textbook buck example in Voltecx, `buckIdeal`, (48 V to 12 V, 5 A, 100 µH and 100 µF) shows the difference. The hard start applies its duty of 0.25 at once; the soft start ramps the duty from 0 to 0.25 over 1 ms. ![The buck's output voltage v(out) and inductor current i(L1) in Voltecx, with a hard start (full duty at once) and a 1 ms soft start, both from an empty output capacitor.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/bench-testing-power-converter-tips/soft-start.svg) | | Peak inductor current | Peak output voltage | |---|---|---| | Hard start | 13.6 A | 18.1 V | | 1 ms soft start | 6.7 A | 12.9 V | The hard start pushes 13.6 A through an inductor meant for 5 A (it may saturate) and 18.1 V onto a 12 V output (it may damage the load or trip over-voltage protection). The soft start halves the current peak and keeps the overshoot under 1 V. On the bench, check the start-up at the lowest and highest input voltage and with no load and full load: the overshoot changes with all of them. ## 3. Probing the switch node: the ground lead rings ### The intuition A passive probe is not just a wire. Its tip has input capacitance, and the ground lead (the clip on a wire) has inductance. Together they form an LC circuit, and a fast switch-node edge rings it. The ring you see on the screen is in your probe, not in your converter. The longer the ground lead, the larger its inductance. For a straight round wire of length $l$ and radius $r$ (in cm), Grover's low-frequency formula gives $$L \approx 2\,l \left[\ln\left(\frac{2l}{r}\right) - 0.75\right]\ \text{nH}$$ ### A worked example Take wire of 0.5 mm diameter ($r = 0.025$ cm) and a probe with 10 pF of input capacitance: | Ground connection | Inductance | Ring frequency $1/(2\pi\sqrt{LC})$ | |---|---|---| | 15 cm clip lead | 190 nH | 115 MHz | | 1 cm spring tip | 7.3 nH | 590 MHz | The simulation below drives that probe model with a clean 48 V edge rising in 5 ns. A 10 Ω resistor lumps the losses of the lead and tip; its exact value sets how fast the ring decays, not its frequency. ![A 48 V switch-node edge v(sw) with a 5 ns rise, and what the probe shows with a 15 cm ground lead and with a 1 cm spring, simulated in Voltecx: 190 nH or 7.3 nH, 10 Ω and 10 pF.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/bench-testing-power-converter-tips/probe-ground-lead.svg) With the long lead, the probe shows **71 V** on an edge that never exceeds 48 V, ringing near 115 MHz for tens of nanoseconds. With the spring tip the overshoot is 49.8 V, about 4 %, and its ring is above the bandwidth of many probes. Same converter, same edge: one measurement would make you add a snubber and buy a higher-voltage MOSFET for nothing. ### The fix - **Shortest possible ground.** Remove the clip lead and use the spring tip (or a probe-tip adapter soldered on the board) with its ground on a pad right next to the measured node. - **Design the test points in.** Put a ground pad beside every switch node and gate on the PCB, so the short ground is possible. `design.debugAids` in Voltecx adds test points on each switch node, each gate (with a ground pad on its source), VIN, VOUT and current shunts to the schematic. - **Check the probe with the edge it measures.** Touch the probe tip and its ground together to the ground of the switch node. You should see nothing; what you see is pick-up from the loop between the lead and the board. - **Bandwidth.** Your scope and probe need several times the bandwidth of the edge: for a rise time $t_r$, the edge's content reaches about $0.35/t_r$ (70 MHz for 5 ns). ## 4. Differential versus single-ended probes A standard passive probe measures between its tip and its ground, and its ground is the oscilloscope's earth. That is fine only when the reference point of the measurement is ground. - **High-side gate voltage** of a half bridge is referenced to the switch node, which jumps between 0 V and the bus voltage at every edge. A ground-referenced probe on it either shorts the switch node to earth through the scope or, with two probes subtracted in math, shows a large error from their mismatch. - **High-voltage differential probes** measure between two points that both move. Check their common-mode rejection at the switching frequency and its harmonics: the fast $dv/dt$ of the switch node appears as an error when rejection is poor. - **Isolated probe systems** (optically isolated front ends) give the best common-mode rejection for high-side gate measurements on GaN and SiC. - **Deskew** differential and current probes against each other before measuring power or switching energy (section 7). ## 5. Current probes and shunts Measuring current is harder than measuring voltage. Three common ways: | Method | Good for | Watch out for | |---|---|---| | Clamp-on current probe (Hall plus transformer) | Inductor and wire currents, DC to tens of MHz | Its own insertion inductance, saturation, offset drift; degauss and zero it first | | Rogowski coil | Large pulsed currents, a flexible loop around a device leg | No DC; limited low-frequency accuracy | | Coaxial or SMD shunt | Fast switch currents in the power loop | It adds resistance and inductance to the loop; the voltage across it is millivolts | Each one changes the circuit a little. A current probe needs a wire loop to clamp around, and that loop adds inductance to the power loop, which raises the ringing you are trying to measure. Design a current loop into the prototype board where you need it: `design.debugAids` adds 0 Ω links between the source and the input and between the output and the load, which you lift to power one stage alone and to clamp a probe around a short wire. ## 6. Measuring efficiency correctly Efficiency $\eta = P_{out}/P_{in}$ looks simple, but at high efficiency a small measurement error is a large error in the loss, and the loss is what you actually want to know. ### Why it is sensitive Suppose the converter is 95 % efficient and each power reading has a 0.5 % error. In the worst case the two errors push in opposite directions: $$\eta_{min} = 0.95 \times \frac{0.995}{1.005} = 94.05\ \%, \qquad \eta_{max} = 0.95 \times \frac{1.005}{0.995} = 95.95\ \%$$ The loss is 5 % of the input power, but the measurement says anything from 4.05 % to 5.95 %: a **19 % error in the loss** from 0.5 % meters. ### How to do it right - **Four-wire (Kelvin) voltage sensing.** Measure the input and output voltages at the converter's terminals, not at the supply or the load, so the drop in the cables is not counted as converter loss. - **DC meters on DC quantities.** The input current of a buck is pulsed; measure it after the input capacitor, or with a power analyser that integrates over whole periods. An oscilloscope with a current probe has percent-level DC accuracy at best. - **Wait for thermal steady state.** A MOSFET's on-resistance rises with temperature, so the efficiency drops as the board warms up. Read it after the temperatures stop changing, which can take many minutes on a heatsink. - **Record the conditions**: input voltage, output current, ambient temperature, airflow, the time since power-up. - **Cross-check with temperature.** If you know the thermal resistance, a device's temperature rise gives an independent estimate of its loss. The same rule as in simulation applies to any average or RMS value: use whole switching periods (or whole line cycles for an AC input). The [simulation checklist](https://voltecx-web.nguyenvanqui291.workers.dev/blog/five-things-to-check-in-power-electronics-simulation) shows an 18 % RMS error from a window of 1.5 periods. ## 7. Thermal checks - **Thermocouples** glued to the device case or tab with thermal adhesive, the wire leads run away from the switch node (they pick up noise and can be at switch-node potential). - **Thermal cameras** are fast and show hot spots you did not expect, but they read emissivity: shiny metal and glossy packages read cold. Put a piece of matt tape or a dot of matt paint on the spot you measure. - **Worst case.** Test at the lowest input voltage (highest current) and the highest ambient temperature you specify, at full load, in the final enclosure or airflow. - **Leave margin.** Compare the estimated junction temperature, case temperature plus loss times junction-to-case thermal resistance, with the device's maximum from its data sheet. ## 8. The double-pulse test To know a transistor's switching losses in your circuit (your gate driver, your layout), measure them with a double-pulse test. It is the clamped inductive switching test that data sheets use. ### How it works A half bridge with an inductor across the upper device. The upper switch is held off; its diode (or body diode) freewheels the inductor current. 1. **First pulse:** the lower device (the device under test) turns on and the inductor current ramps up: $I = V\,t_1/L$. 2. **Turn-off:** at the test current the device turns off. You measure $E_{off}$ here. 3. **Short gap:** the current freewheels in the upper diode, almost constant. 4. **Second pulse:** the device turns on again at the same current. You measure $E_{on}$, including the reverse recovery of the upper diode. Because the test lasts microseconds, the device stays cold and you can test at full current and voltage without a heatsink. The `doublePulse` example in Voltecx is this bench with a SiC MOSFET from the device library at 400 V. The first pulse is 4.95 µs long with a 99 µH inductor: $$I = \frac{V\, t_1}{L} = \frac{400\ \text{V} \times 4.95\ \mu\text{s}}{99\ \mu\text{H}} = 20\ \text{A}$$ The simulated current at turn-off is 20.2 A. ![The double-pulse test in Voltecx: the gate command gl, the drain voltage v(dd) and the drain current i(Id) of the device under test over both pulses.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/bench-testing-power-converter-tips/double-pulse.svg) ![The turn-off edge of the double-pulse test at 20 A and 400 V in Voltecx: the drain voltage v(dd) and current i(Id).](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/bench-testing-power-converter-tips/double-pulse-turn-off.svg) In the run, the drain voltage overshoots to 412 V at turn-off, and at turn-on the current peaks at 36.7 A as the upper body diode recovers. The switching energies are 38 µJ at turn-off and 289 µJ at turn-on. ### What to watch out for - **Probe deskew.** Switching energy is the integral of $v \cdot i$ over the edge. A time offset between the voltage and current probes shifts that product. At 400 V and 20 A, a 1 ns skew moves the energy by up to $400 \times 20 \times 1\ \text{ns} = 8\ \mu\text{J}$, which is **21 % of the 38 µJ turn-off energy**. Deskew with a fixture before you measure. - **Current sensing in the loop.** A coaxial shunt or a Rogowski coil on the device leg; whatever you insert adds loop inductance and changes the overshoot. - **The inductor.** It must not saturate at the test current, and its winding capacitance should be small, or it adds a current spike at every edge. - **Overshoot margin.** The turn-off overshoot (412 V on a 400 V bus here, more on a real layout) must stay well inside the device's rating. - **Gate-voltage measurement.** Measure the gate between gate and source at the package (Kelvin source if there is one), with a short ground. ## 9. Load steps show the loop's real margins A load step is the quickest test of the control loop on the bench: switch an electronic load between two currents and watch the output voltage. It shows what the Bode plot predicts, and sometimes what it hides. The `buckClosedLoop` example in Voltecx, with two compensators from `design.voltageLoop`, steps from 5 A to 7.5 A at 1 A/µs and back 4 ms later: | Compensator | Crossover | Phase margin | Gain margin | Lowest output | Back within ±2 % | |---|---|---|---|---|---| | PI | 685 Hz | 86° | 2.6 dB | 9.86 V | not within 4 ms | | Type III | 5.78 kHz | 60° | 13.8 dB | 11.46 V | 0.12 ms | ![The output voltage v(out) of buckClosedLoop in Voltecx with a PI and with a Type III compensator, as an electronic load i(Iload) adds 2.5 A at 4 ms and removes it at 8 ms.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/bench-testing-power-converter-tips/load-step.svg) The PI has a large phase margin, 86°, but only 2.6 dB of gain margin: at the LC filter's resonance the loop gain comes close to 1 again. The load step rings at that resonance, swinging from 9.86 V to 14.07 V, and is still outside ±2 % when the load is released. The Type III compensator crosses higher with more gain margin: the output dips to 11.46 V and recovers in 0.12 ms. On the bench: - **Use a load with a controlled slew rate** and note it: a faster step gives a deeper dip. - **Trigger on the load current** and measure the output at the converter's terminals with a short ground. - **Step at the corners**: lowest and highest input, light and full load. Margins change with all of them. - **A ringing step means a small margin somewhere**, even if one margin looks large. Measure the loop gain if you can (an injection resistor in the feedback path, which `design.debugAids` adds with a test point on each side). ## 10. What to log A measurement you cannot reproduce is not worth much. For every capture, record: - **Conditions:** input voltage, load current, ambient temperature, airflow, time since power-up, board serial and revision, any rework. - **Setup:** probe type and attenuation, ground connection (spring or lead), bandwidth limit, deskew values, current probe range. - **Data, not screenshots only:** save the scope capture as a CSV file as well as the picture. With the CSV you can compare the bench with the simulation. In Voltecx, `file.importMeasurement` reads a scope export and overlays it on the simulated signals, `waveform.compare` gives the RMS error and the difference in rise and settling times, and `analysis.diagnoseWaveforms` runs its fault checks (ringing, inrush, sub-harmonic oscillation, overlapping gates) on the measurement. If the ringing on the bench is at a different frequency from the simulation, `design.debugAids` takes the measured ring frequency (`ringHz`) to work out the real loop inductance, and `debug.fitToMeasurement` adjusts chosen parameters until the simulation matches the capture. ## A bench checklist - Isolation transformer for offline units; never float the scope. - Measure the bulk capacitor voltage before touching anything. - Current-limited supply for the first power-up; shield and glasses. - Bring up auxiliary rails, then gates without power, then low voltage, then load. - Spring ground on the switch node; differential or isolated probe for high-side signals. - Deskew probes before measuring power or switching energy. - Kelvin voltage sensing and thermal steady state for efficiency. - Save CSVs with the conditions. The formulas come from standard texts: F. W. Grover, *Inductance Calculations*, for the wire inductance; R. W. Erickson and D. Maksimović, *Fundamentals of Power Electronics*, 3rd ed., for the buck and its control loop. The ES1 limit is from IEC 62368-1. The double-pulse example's device data cite the Wolfspeed C3M0065090D data sheet. ## Try it in Voltecx - `design.testPlan` writes the production test procedure of a design: each step with its condition and its limit, the source of each limit, and the equipment with the range each instrument must reach (the DC source's voltage and current, the electronic load's current). It exports the steps as CSV. - `design.debugAids` adds test points, 0 Ω links, a loop-injection resistor, DNP snubber and bulk-capacitor footprints to the schematic as a proposal you accept, and returns bring-up steps. - `testbench.list` and `testbench.run` simulate the start-up, load steps, hold-up and inrush cases of a specification before you build anything. - Open the `doublePulse` example to see the test above; `analysis.losses` gives the switching energy of each device. More on the [debugging and scope](https://voltecx-web.nguyenvanqui291.workers.dev/features/debugging-and-scope) and [design tools](https://voltecx-web.nguyenvanqui291.workers.dev/features/design-tools) pages. --- # Timing inside a digitally controlled converter: from PWM counter to duty update URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/digital-control-loop-timing/ An analog controller reacts the instant the output moves. A digital one cannot. It has to wait for the next sample, convert it, run the interrupt, compute a new duty cycle, and then wait again until the PWM timer is willing to use that duty. Every step takes time, and the steps happen in a fixed order inside each switching period. This post follows that order step by step on a real example: a 48 V to 12 V buck at 100 kHz with a Type III voltage loop, run in Voltecx with the timing of a microcontroller. You will see where the delay comes from, why it is usually one to one and a half switching periods, how much phase margin it eats, and what goes wrong when the interrupt runs late or the PWM is too coarse. It is about **timing**: what happens when, and in what order. For how a PWM signal is made, see [PWM explained](https://voltecx-web.nguyenvanqui291.workers.dev/blog/pwm-explained); for how and where to sample, see [ADC sampling in power converters](https://voltecx-web.nguyenvanqui291.workers.dev/blog/adc-sampling-power-converters). ## The picture: a photo, a calculation and a mailbox Think of the controller as three people in a relay. 1. **The photographer** (the ADC) takes a snapshot of the output voltage at a fixed moment in each period. Whatever happens between snapshots, the controller does not see. 2. **The calculator** (the interrupt service routine, ISR) takes the photo, works out the new duty cycle and writes it down. This takes a few microseconds. 3. **The mailbox** (the PWM's shadow register) accepts the note at any time, but the postman (the PWM timer) only empties it once per period, at the start of the next one. The output voltage only changes when the new duty reaches the switch. So the information in the photo arrives at the power stage after the photo, the calculation *and* the wait at the mailbox. That chain is the loop delay. ## The chain inside one switching period Here is the order of events in a typical microcontroller (the same structure appears on most microcontrollers made for power conversion): 1. **The PWM counter counts.** In up/down (center-aligned) mode it counts from 0 to its period value and back. Plotted, it is a triangle: the *carrier*. The gate is on while the duty value is above the counter. 2. **The ADC is triggered at a fixed point of the counter**, usually the valley (counter = 0) or the peak. With a triangle carrier those are the middle of the on-time and the middle of the off-time, where the inductor current crosses its average and the switching noise is furthest away. 3. **The conversion runs.** The ADC needs a conversion time (see its data sheet) before the result is ready. 4. **The end of conversion raises an interrupt.** After the interrupt latency, the ISR starts. 5. **The ISR computes the new duty.** It reads the result, runs the compensator (a difference equation), limits the output and converts it to timer counts. 6. **The ISR writes the compare register.** With preload (shadow register) on, the value waits in a buffer. 7. **The timer copies the buffer into the active register at its update event**, usually the next counter valley. Only now does the gate edge move. If you remember one thing: **the sample is taken at the start of period k, and the duty computed from it acts in period k + 1.** ## The timing diagram from a run The figure below is not drawn by hand. It is two switching periods from a Voltecx run of the buck, zoomed on the moment a reference step arrives (the reference jumps from 12 V to 12.5 V at 3.003 ms, just after a sample). Time is in µs from the carrier peak at 3.005 ms; the vertical lines mark the sample at 5 µs, the end of the ISR at 7.94 µs and the next counter valley at 15 µs. ![Two switching periods of the digitally controlled buck in Voltecx: the triangle carrier with the duty in the shadow register and in a register written at the end of the ISR, the error and its sampled value, and the gate signal for each register.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/digital-control-loop-timing/timing-diagram.svg) How to read it, from top to bottom: - **Panel 1, carrier and duty.** The triangle is the counter. The red line is the duty in the shadow register: it only changes at the valley at 15 µs. The green line is the same duty written into the register at the end of a 2.94 µs ISR: it changes at 7.94 µs. - **Panel 2, error.** The error (blue) has been 0.5 V since the step at −2 µs, but the controller's sampled error (red) only jumps at the sample at 5 µs. The step was invisible for 7 µs. - **Panels 3 and 4, gates.** With the shadow register, the first pulse after the sample is still the old, narrow one; the wider pulse starts at 13.75 µs. With the update at the end of the ISR, the wider pulse starts 1.35 µs earlier, at 12.4 µs. Notice the gate edges: with a triangle carrier, the gate turns on where the falling carrier crosses the duty and turns off where the rising carrier crosses it. A duty written in the middle of a period changes only the edges that are still to come. ## Immediate update or shadow register? Most PWM timers let you choose when a new compare value takes effect. | | Shadow register (update at period start) | Immediate update (at the end of the ISR) | |---|---|---| | When the duty acts | Next counter valley | As soon as it is written | | Delay from sample | One full period | ISR time only | | Pulse shape | Always symmetric | Can be asymmetric for one period | | Risk | None from the update itself | A value written just after the counter passed it can skip or add an edge | | Typical use | The default; safest | Fast loops, when the ISR is short and its timing is known | The immediate update is faster, but it is a race: if the ISR writes a new value just after the counter has passed it, that period loses its edge (a missed pulse) or gets one too many. That is why the shadow register is the default and why firmware that uses immediate update usually limits how far the duty can move in one step. ## Adding up the delay The delay the loop sees has two parts. - **The computation delay** $t_c$: from the sample to the moment the new duty is in the active register. With a shadow register that is one sample period $T_s$; with an immediate update it is the ISR time. - **The modulator delay**: the duty acts over the whole period, not at one instant. Averaged, a duty that is held for a period acts about half a period late. This is the same half sample that a zero-order hold costs (Franklin, Powell and Workman, *Digital Control of Dynamic Systems*, §6.3). So the total loop delay is $$T_d = t_c + \frac{T_s}{2}$$ | Timing scheme | $t_c$ | $T_d$ | |---|---|---| | Ideal, no computation | 0 | 0.5 $T_s$ | | ISR of 2.94 µs, update at its end ($T_s$ = 10 µs) | 0.294 $T_s$ | 0.79 $T_s$ | | Shadow register, update at the next period (the usual case) | 1 $T_s$ | 1.5 $T_s$ | | Calculation that needs two periods | 2 $T_s$ | 2.5 $T_s$ | That is where the rule of thumb "a digital loop has one to one and a half periods of delay" comes from (D. G. Holmes and T. A. Lipo, *Pulse Width Modulation for Power Converters*, ch. 4, on regular-sampled PWM; S. Buso and P. Mattavelli, *Digital Control in Power Electronics*). ## Why the delay matters: phase lag A pure delay does not change the gain of the loop at all. It only shifts the phase, and the shift grows with frequency: $$\varphi_{delay} = 360° \cdot f \cdot T_d$$ At the crossover frequency $f_c$, every degree of that lag comes straight out of the phase margin. A delay is like talking to someone on a satellite phone: each of you waits for the other, and if you both react too quickly you keep talking over each other. The faster you want the conversation (the higher $f_c$), the more the delay hurts. ### Worked example The buck is the `buckClosedLoop` example: 48 V in, 12 V out, 5 A, 100 kHz, 100 µH and 100 µF. `design.voltageLoop` gives it a Type III compensator that crosses at $f_c$ = 5.78 kHz with 60° of phase margin, already counting the half period of the modulator. The sample period is $T_s$ = 10 µs. Each extra sample of computation costs $$360° \times 5.78\ \text{kHz} \times 10\ \mu\text{s} = 20.8°$$ | Computation delay | Total $T_d$ | Phase margin | Gain margin | |---|---|---|---| | 0 | 0.5 $T_s$ | 60° | 12.2 dB | | 0.5 $T_s$ | 1 $T_s$ | 49.6° | 8.9 dB | | 1 $T_s$ (shadow register) | 1.5 $T_s$ | 39.2° | 6.4 dB | | 2 $T_s$ | 2.5 $T_s$ | 18.4° | 2.6 dB | `design.digitalize` reads the loop gain of the discretized compensator with each delay; its phase margin lies exactly on the straight line $60° - 20.8°$ per sample. The gain margin falls too, because the extra phase lag moves the −180° crossing down to where the loop gain is higher. ![Phase margin (from design.digitalize and from 60° − 20.8° per sample) and gain margin of the buck's Type III loop against the computation delay in samples.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/digital-control-loop-timing/phase-margin-vs-delay.svg) A loop designed in the s-domain for 60° and then put into firmware with the usual shadow register ends up with 39°. If you designed for 45° (a common target), you would be at about 24°. ## What the delay looks like in the time domain Phase margin is abstract; overshoot is not. The figure below is the same 0.5 V reference step simulated four times, with 0, 0.5, 1 and 2 samples of computation (the duty loaded as soon as it is ready). ![Output voltage of the buck in Voltecx for a 12 V to 12.5 V reference step with a total loop delay of 0.5, 1, 1.5 and 2.5 switching periods.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/digital-control-loop-timing/step-response-delay.svg) | Total delay $T_d$ | Phase margin | Simulated overshoot | |---|---|---| | 0.5 $T_s$ | 60° | 4.5 % | | 1 $T_s$ | 49.6° | 15.7 % | | 1.5 $T_s$ | 39.2° | 30 % | | 2.5 $T_s$ | 18.4° | 66 % | The shadow register (one sample, loaded at the valley) gives the same 30 % as the 1.5 $T_s$ case, as it should. At 2.5 $T_s$ the output rings for several cycles: the loop is close to oscillating. The slow approach to 12.5 V after the first peak, in all four curves, is not caused by the delay. It comes from the two compensator zeros at 676 Hz, far below the crossover, which the integrator needs some time to settle against. ## Single update or double update? With a triangle carrier you can sample and update twice per period: at the valley and at the peak. The ISR then runs at 200 kHz, and with one sample of computation the delay halves: $$T_d = 1.5 \times 5\ \mu\text{s} = 7.5\ \mu\text{s} \quad\text{instead of}\quad 1.5 \times 10\ \mu\text{s} = 15\ \mu\text{s}$$ For the buck, `design.digitalize` at a 200 kHz sample rate gives 54.8° instead of 39.2°, and the simulated overshoot drops from 30 % to 8.1 %. The price: - **Twice the CPU load.** The ISR must fit into half the time. - **Both sample points must be clean.** The peak is the middle of the off-time, which is fine for a buck's inductor current but may be close to another converter's switching edge in an interleaved design. - **Asymmetric pulses.** The on-time is now built from two halves computed at different times, which is fine for control but makes the pulse no longer centered. ## When the calculation is late The ISR has a time budget: it must finish within one sample period, with margin for other interrupts. The *CPU load* of the control ISR is $t_{ISR}/T_s$. In Voltecx the `mcu` block models the ISR time. Each ISR starts at its sample instant, or when the previous one returns if that is later. If an ISR cannot even start before the next instant, its sample is lost, as an interrupt controller keeps only one interrupt pending. The figure compares an ISR of 2.94 µs (29 % load) with one of 10.6 µs (106 % load), both writing the duty at their end. ![The duty register and the output voltage of the buck in Voltecx for an ISR taking 29 % and 106 % of the 10 µs period; the vertical lines are the sample instants.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/digital-control-loop-timing/late-isr.svg) What happens with the late ISR: - Each ISR starts 0.6 µs later than the one before, so the duty updates every 10.6 µs instead of every 10 µs. They drift against the sample instants (the vertical lines). - Once the lag reaches a whole period, one sample is dropped and the drift starts over: about one sample in $10/0.6 \approx 17$ is lost. - The delay grows from period to period, so the loop sees a delay that changes over time (jitter), and on average a much longer one. The overshoot rises from 15.6 % to 72.5 %. - The `overrun` output of the block goes to 1 and its `load` output reads 1.06. On real hardware the symptoms are the same: an output that rings more than the design says, an audible or visible subharmonic, and a converter that gets worse when you add a feature to the ISR. ## Limit cycles from PWM resolution The last timing effect is about *steps* rather than delays. A PWM timer can only set the duty in whole counts. At 100 kHz with a 100 MHz timer clock there are 1000 counts per period, so the duty moves in steps of 0.1 %. In the buck, one step moves the output by $$\Delta V_{DPWM} = V_{in} \cdot \frac{1}{1000} = 48\ \text{mV}$$ A 12-bit ADC over 0 to 16 V resolves $16/4096 = 3.9$ mV. The controller can see a 3.9 mV error but can only correct in 48 mV steps. It can never land exactly on the set point, so it hunts between duty levels forever: a **limit cycle**. The condition to avoid it (A. V. Peterchev and S. R. Sanders, "Quantization resolution and limit cycling in digitally controlled PWM converters", IEEE Trans. Power Electron. 18(1), 2003) is that one DPWM step must move the output less than one ADC step, and that the loop has integral action. With the 184 ps high-resolution step of the STM32G474 timer (ST RM0440), one step moves the output 0.88 mV, a quarter of an ADC step. ![The sampled error and the duty register of the buck in Voltecx in steady state, with a 1000-count PWM timer and with a 184 ps high-resolution PWM step.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/digital-control-loop-timing/limit-cycle.svg) With 1000 counts the duty never rests: it hops over five counts (0.258 to 0.263) and the sampled error jumps by ±1 ADC step. With the 184 ps step, the loop settles on one ADC code and both lines stay flat. [Tutorial 7](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/07-digital-control) walks through the same check in `design.digitalize`, with the fix. ## Common mistakes - **Designing the analog loop with no delay and adding firmware later.** Plan for $T_d$ = 1.5 $T_s$ from the start, or design directly with the delay in the loop. - **Pushing the crossover too close to the switching frequency.** With $T_d$ = 1.5 $T_s$, a crossover at $f_s/10$ already costs 54° of phase, more than most loops can spare. Keep the crossover well below that, or shorten the delay. - **Triggering the ADC after the ISR instant and still counting a full sample of delay.** If the sample is taken *after* the interrupt starts (an ADC trigger offset), the controller reads the previous sample, and the latency is already one period. Counting another sample on top makes it two. - **Forgetting the ISR's worst case.** Measure the longest path, with every branch and other interrupts that can preempt the ISR. The average does not matter; the worst case does. - **Using immediate update without thinking about edges.** A compare value written just after the counter passed it skips an edge for that period. - **A PWM coarser than the ADC.** If $V_{in}/N_{counts}$ is larger than one ADC step, expect a limit cycle. Use high-resolution PWM, dithering or a coarser ADC reading in the integrator. - **Measuring the delay in the wrong units.** The delay that matters is in seconds against the crossover frequency, not in "cycles". One period at 20 kHz is five times worse than one period at 100 kHz for the same crossover. ## A timing budget, step by step 1. Pick the switching frequency and the sample rate (single or double update). 2. Pick where the ADC samples (valley, peak) and check that it is away from switching edges. 3. Measure or estimate the worst-case ISR time, including the conversion time and interrupt latency. 4. Decide on shadow register or immediate update, and compute $T_d = t_c + T_s/2$. 5. Compute the phase lag at your crossover, $360° \cdot f_c \cdot T_d$, and design the compensator with it. 6. Check the CPU load, $t_{ISR}/T_s$, with margin for everything else the processor does. 7. Check the PWM resolution against the ADC resolution. 8. Simulate the loop with the real timing and look at the step response. ## Try it in Voltecx - The **`mcu` block** models the timing of the microcontroller between the controller and the PWM: `fs` (ISR rate), `fpwm`, `align` (`start` for an ISR at the carrier valley, or `peak`), `delay` (computation delay in samples) or `tIsr` / `cycles` and `fclk` (the ISR time), `update` (`period` for the shadow register, `immediate` or `end`), and `counts` or `bits` for the duty resolution. Its `load` and `overrun` outputs show the CPU load. - The **`zoh`** block samples a signal, and **`ztf`**, **`dpi`** and **`dpid`** run discrete controllers at the same instants. The `pwm` block's `counts` and `hrpwm` round the duty like a real timer. - **`design.digitalize`** turns a `design.voltageLoop` compensator into a difference equation and reads the loop again with the computation delay, the ISR time and the update mode, the coefficient rounding and the limit-cycle check. It reports the phase margin lost. - [Tutorial 7](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/07-digital-control) goes through the whole flow, and **Tools › Code Generation** writes the C of the control blocks; see [code generation](https://voltecx-web.nguyenvanqui291.workers.dev/features/code-generation). - To see your own timing diagram, record the carrier, the `mcu` block's duty output and the gate, and zoom on two periods after a step. --- # What is CMTI, and how much does an isolated gate driver need? URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/cmti-isolated-gate-driver/ Common-mode transient immunity (CMTI) is the fastest slope of the voltage between an isolator's two grounds, $dV_{CM}/dt$, that it withstands without an error at its output, stated in kV/µs or V/ns (the same number). For an isolated gate driver that voltage is the switch node, so estimate its slope as $dv/dt \approx 0.8\,\Delta V / t_{10\text{–}90}$, multiply by your margin, and choose a part whose **minimum** CMTI is above the result. An 800 V SiC edge with an 8 ns rise from 10 to 90 % moves at 80 V/ns; with a margin factor of 2 it needs at least 160 V/ns, and each picofarad of capacitance across the barrier carries 80 mA during that edge. ## The idea in one picture An isolated gate driver has two halves: the controller side, referenced to the controller's ground, and the output side, referenced to the source (or emitter) of the switch it drives. For a high-side switch that reference is the switch node. Every time the switch node jumps by hundreds of volts in a few nanoseconds, the whole output side is lifted with it, while the controller side stays put. The barrier between them is not perfect: there is always some capacitance across it. Push a fast voltage step across a capacitor and a current flows, $i = C\,dv/dt$. That current lands in the isolator's receiver, its supply pins and the board around it. If it is large enough, the receiver reads it as data, and the output flips: a gate turns on that should be off, a fault flag fires for no reason, or a PWM pulse disappears. CMTI is the slope at which that stops being true. ## What exactly does CMTI measure? The isolator's output is held at a known state (high or low), a common-mode voltage step of known height and slope is applied between the two grounds, and the slope is raised until the output leaves its valid level. The test is defined for magnetic and capacitive isolators in IEC 60747-17, *Semiconductor devices – Part 17: Magnetic and capacitive coupler for basic and reinforced insulation*. Read the data sheet's test conditions: the common-mode voltage used, whether the output was held high and low, and what counts as a failure. Two details matter when you compare parts: - **Minimum versus typical.** A typical CMTI says what most parts do; the minimum is what every part is guaranteed to do. Design to the minimum. - **Units.** 1 kV/µs = 1 V/ns. A part rated "100 kV/µs" withstands 100 V/ns. ## How fast is my switch node? Measure or estimate the switching edge and divide the swing by its time. Data sheets and scopes usually give the 10 to 90 % rise time, which spans 80 % of the swing: $$\frac{dv}{dt} \approx \frac{0.8\,\Delta V}{t_{10\text{–}90}}$$ This is the average slope over the edge. The edge is not a straight line: the slope in the middle is steeper than the average, and ringing after the edge adds its own slopes. That is one reason to keep a margin. The edge rate depends on the device and on how hard you drive it. SiC MOSFETs and GaN transistors switch much faster than silicon IGBTs, so the same bus voltage gives a much steeper slope. Take the rise and fall times from the device's data sheet at a gate resistance near yours, or better, from a double-pulse measurement or simulation of your own stage. A larger gate resistor slows the edge, at the cost of switching loss. ## How much margin should I keep? No standard sets one; it is a design choice. The estimate above is an average, the real peak is higher, the edge gets faster as the device heats up or the load changes, and the CMTI test of a data sheet uses its own waveform, not yours. This post uses a factor of 2 on the estimated slope as its own working margin. Whatever factor you pick, write it down with the estimate, so the next reviewer can see it. ## How does the barrier capacitance inject current? The current through any capacitance across the barrier is $$i = C_{io}\,\frac{dv}{dt}$$ $C_{io}$ is the isolator's input-to-output capacitance, which its data sheet gives. But the isolator is often not the largest capacitance across the barrier: the isolated DC-DC converter that supplies the output side has its own transformer interwinding capacitance, and the board adds capacitance wherever copper from one side runs near copper from the other. All of these currents return through the controller's ground, where they can disturb other circuits even if the isolator itself survives. ## Optocoupler, capacitive or magnetic isolator? - **Optocouplers** carry the signal as light from an LED to a photodetector. The common-mode current couples through the capacitance between the LED side and the detector; high-CMTI parts shield the detector. They are simple and well understood, but slower, and the LED's output falls with age and temperature. - **Capacitive isolators** carry the signal through small capacitors in the package, usually as a modulated, differential signal so that a common-mode step appears equally on both lines and is rejected. - **Magnetic isolators** use small on-chip transformers to carry pulses or a modulated carrier, also differentially. The technology does not decide the CMTI on its own: the receiver's design and the symmetry of the differential path do. Compare the minimum CMTI in the data sheets. ## Worked example: Si, SiC and GaN edges All edge times and capacitances below are **assumed example values** for illustration, not data of particular parts. | Case | $\Delta V$ | $t_{10\text{–}90}$ | $dv/dt$ | With a factor of 2 | $i$ through 1 pF | $i$ through 10 pF | |---|---|---|---|---|---|---| | Si IGBT | 800 V | 100 ns | 6.4 V/ns | 12.8 V/ns | 6.4 mA | 64 mA | | SiC MOSFET | 800 V | 8 ns | 80 V/ns | 160 V/ns | 80 mA | 0.80 A | | GaN transistor | 400 V | 3 ns | 107 V/ns | 213 V/ns | 107 mA | 1.07 A | For the SiC case, $0.8 \times 800\ \text{V}/8\ \text{ns} = 80$ V/ns. Compare with two values from data sheets that Voltecx's models carry: the Texas Instruments UCC21750 isolated gate driver gives a CMTI of 150 V/ns minimum (data sheet SLUSD78C, Table 6.8), and the Texas Instruments ISO7710 digital isolator 100 kV/µs, which is 100 V/ns, typical (data sheet SLLSER9E, Section 5.9). Both are above the 80 V/ns estimate. Neither reaches 160 V/ns: with the UCC21750 the margin is $150/80 = 1.9$, and with the ISO7710 $100/80 = 1.25$, on a typical value. Either accept the smaller margin knowingly, slow the edge with a larger gate resistor, or choose a part with a higher minimum. The last two columns show why the isolated supply matters: an assumed 10 pF of interwinding capacitance carries 0.8 A during the SiC edge, a current that has to return somewhere. ## Layout that helps - **Keep the barrier clear.** No copper of either side under the isolator or the isolated supply's transformer, beyond what the creepage and clearance rules already forbid. Every square millimetre of overlap adds capacitance. - **Reference the output side to the switch's own source.** Use a Kelvin source connection where the package has one, so the output side moves with the source and not with the power loop's inductive drop. - **Choose a low-capacitance isolated supply.** Its interwinding capacitance is often the largest path across the barrier. - **Decouple both sides at the pins.** The displacement current has to find a short way back to its own side's ground instead of through the receiver. - **Slow the edge only as far as you need.** A gate resistor that lowers dv/dt below the isolator's rating with margin is cheaper than a redesign, but it costs switching loss. ## Common mistakes - **Comparing with the typical CMTI.** Use the minimum. - **Dividing the full swing by the 10 to 90 % time.** That overstates the average slope by 25 %; it is harmless as a margin but should be written down as one. - **Checking only the gate driver.** Every part that crosses the same barrier sees the same slope: digital isolators for PWM, isolated amplifiers for current sensing, the optocoupler of a fault line. - **Ignoring the isolated supply.** Its capacitance can carry more current than the isolator's. ## Try it in Voltecx 1. Open **File › Open Example › doublePulse**: two Wolfspeed C3M0065090D SiC MOSFETs with gate and capacitance data from the device library, at the data sheet's test point of 400 V and 20 A, VGS −4 V / 15 V and 2.5 Ω of gate resistance. Run it and plot `v(dd)`, the drain-source voltage of the device under test. Zoom in on the turn-off at the end of the first pulse (5.25 µs) and put the two **Cursors** at 20 % (80 V) and 80 % (320 V) of the edge: the readout gives $\Delta t$, the expanded `v(dd)` row in the **Measurements** table gives $\Delta v$, and $\Delta v/\Delta t$ is the slope. `scope.measure` with `step`, over a window around the edge, reports a 10 to 90 % `riseTime` as a number. Raise the gate resistor (`rgon` of Q2) and the edge slows down. 2. Four isolating IC models in Voltecx carry a CMTI check: `optocoupler`, `highSpeedOpto` (the high-speed logic-output optocoupler), `digitalIsolator` and `gateDriverIso`. During the run each one measures the slope of the voltage across its barrier over a 1 ns window, short enough to catch the steepest part of a nanosecond edge. When the slope passes its `cmti` rating, the output glitches for `tGlitch` (an inverted output, or a phototransistor turned on), and **View › Problems** (`circuit.problems`) lists a warning such as `CMTI exceeded: 120 V/ns > 100 V/ns rating on U1`, with the part named. 3. The ratings come from data sheets where Voltecx has them: the `digitalIsolator` default is the ISO7710's 100 V/ns (typical) and the `UCC21750` preset of `gateDriverIso` sets 150 V/ns (minimum). Where a part's CMTI is not in Voltecx yet (the default `optocoupler` and `gateDriverIso` parts), `cmti` is 0: the slope is still measured, but nothing glitches or is reported until you enter your part's value. The `highSpeedOpto` defaults are a generic 10 MBd set marked "typical, user must set", 10 V/ns among them. The 20 ns glitch width is an assumption, since data sheets give CMTI as a pass or fail limit. The models check the slope; they do not model the barrier capacitance or the current it carries. To check an isolator against the double-pulse edge, put a digital isolator's output side on the switch node `mid` (the source of the upper switch) and run: ```sh powercraft-cli run --cmd file.openExample --params '{"name":"doublePulse"}' \ --cmd ic.place --params '{"name":"digitalIsolator","instance":"U1"}' \ --cmd circuit.connect --params '{"component":"U1","port":"IN","net":"vcc1"}' \ --cmd circuit.connect --params '{"component":"U1","port":"VCC1","net":"vcc1"}' \ --cmd circuit.connect --params '{"component":"U1","port":"GND1","net":"0"}' \ --cmd circuit.connect --params '{"component":"U1","port":"OUT","net":"out"}' \ --cmd circuit.connect --params '{"component":"U1","port":"VCC2","net":"vcc2"}' \ --cmd circuit.connect --params '{"component":"U1","port":"GND2","net":"mid"}' \ --cmd circuit.addComponent --params '{"name":"Vcc1","kind":"dcVoltageSource","params":{"v":5}}' \ --cmd circuit.connect --params '{"component":"Vcc1","port":"p","net":"vcc1"}' \ --cmd circuit.connect --params '{"component":"Vcc1","port":"n","net":"0"}' \ --cmd circuit.addComponent --params '{"name":"Vcc2","kind":"dcVoltageSource","params":{"v":5}}' \ --cmd circuit.connect --params '{"component":"Vcc2","port":"p","net":"vcc2"}' \ --cmd circuit.connect --params '{"component":"Vcc2","port":"n","net":"mid"}' \ --cmd simulation.run --params '{}' \ --cmd circuit.problems --params '{}' ``` If the edge is steeper than the isolator's 100 V/ns, `circuit.problems` names U1 and the slope it saw; place it with another rating (`"params":{"cmti":150e9}` in `ic.place`, in V/s), or slow the edge, and run again. See [models and parts](https://voltecx-web.nguyenvanqui291.workers.dev/features/models-and-parts), [isolation and gate drive](https://voltecx-web.nguyenvanqui291.workers.dev/features/isolation-and-gate-drive) and the [models chapter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/10-models/) of the manual. ## Frequently asked questions ### What is a good CMTI for a SiC gate driver? There is no single number: it follows from your edge. Estimate $0.8\,\Delta V/t_{10\text{–}90}$ at your fastest operating point, multiply by your margin, and compare with the data sheet's minimum CMTI. ### Is kV/µs the same as V/ns? Yes. 1 kV/µs = $10^3\ \text{V}/10^3\ \text{ns}$ = 1 V/ns. ### What happens when CMTI is exceeded? The output leaves its valid state for a short time: a gate driver can turn its switch on or off spuriously, a digital isolator can drop or add a pulse, a fault output can trip. In a half-bridge a spurious turn-on means shoot-through. ### Does a higher CMTI rating mean I can ignore layout? No. The rating covers the isolator itself. The current that the barrier capacitance, the isolated supply and the board carry still flows, and it can disturb other parts of the circuit. ## Sources - IEC 60747-17, *Semiconductor devices – Part 17: Magnetic and capacitive coupler for basic and reinforced insulation* (CMTI test of magnetic and capacitive isolators). - Texas Instruments, UCC21750 data sheet, SLUSD78C, Table 6.8 (CMTI, minimum). - Texas Instruments, *ISO7710 High-Speed, Robust EMC Reinforced and Basic Single-Channel Digital Isolators*, data sheet SLLSER9E, Section 5.9 (CMTI, typical). - Wolfspeed, C3M0065090D data sheet, Rev. 08 (the device of the `doublePulse` example). --- # Which converter topology for my spec? Buck, boost, flyback, forward, LLC, PSFB, DAB and more URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/which-converter-topology-for-my-spec/ You have a spec: an input voltage range, an output voltage, a load current, maybe "isolated" and a target efficiency. Before you can size an inductor or close a loop, you have to pick a power stage. There are dozens of named topologies, but for most DC-DC specs the choice comes down to a handful of questions asked in the right order. This article walks through those questions, from intuition to numbers. Then it runs three real specs through Voltecx and compares the candidates by efficiency, device stress and part count: - 12 V to 3.3 V at 5 A (a point-of-load rail); - 400 V to 12 V at 100 W, isolated (an auxiliary supply off a DC bus); - 400 V to 48 V at 1 kW, isolated (a bus converter). ## The intuition: a gearbox for voltage A switching converter is a gearbox. A car gearbox trades speed for torque; a converter trades voltage for current. Power in is power out, less the losses, so stepping 12 V down to 3.3 V at 5 A draws only about 1.4 A from the input. Like a gearbox, each topology has a natural range of ratios: - A **buck** is a reduction gear. It can only step down. - A **boost** is an overdrive gear. It can only step up. - A **buck-boost** or **SEPIC** can do both, at a price: every part works harder. - A **transformer** is a second gear stage. It gives a big fixed ratio, and, because primary and secondary are only coupled magnetically, it gives isolation. The rest of the decision is about how hard each part works for a given ratio and power, and how many parts you need. ## Question 1: do you need isolation? Isolation means no DC path between input and output. You need it when: - **Safety requires it.** Anything powered from the mains, or anything a person can touch that is fed from a high-voltage bus, needs reinforced or basic insulation per the product safety standard (IEC 62368-1 for IT and audio-video equipment). - **Grounds must stay apart.** Measurement systems, communication ports and stacked battery cells often need their own ground. - **The ratio is very large.** Going from 400 V to 12 V with a buck needs a duty cycle of 3 %, a few hundred nanoseconds of on-time at 100 kHz. A transformer with a 17:1 turns ratio lets the switches run at a comfortable duty cycle instead. If none of these apply, stay non-isolated. A transformer adds size, cost, leakage inductance and a feedback path that must cross the barrier. ## Question 2: step down, step up or both? The ideal conversion ratio $M = V_{out}/V_{in}$ of each basic topology is a function of the duty cycle $D$ (Erickson and Maksimović, *Fundamentals of Power Electronics*, ch. 2 and 6): $$M_{buck} = D, \qquad M_{boost} = \frac{1}{1-D}, \qquad M_{buck\text{-}boost} = \frac{D}{1-D}, \qquad M_{flyback} = \frac{N_s}{N_p}\cdot\frac{D}{1-D}$$ ![Ideal conversion ratio against duty cycle for the buck, boost, buck-boost (and SEPIC) and a flyback with Ns/Np = 0.5.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/which-converter-topology-for-my-spec/conversion-ratio.svg) Read the plot from the ratio you need: - Below 1 the buck is the obvious choice: $M = D$, so 12 V to 3.3 V runs at $D = 0.275$. - Above 1 the boost is the obvious choice. - If the input range straddles the output (a 9 to 16 V battery to 12 V), you need a buck-boost, SEPIC or four-switch buck-boost. - Stay away from the edges. Very small or very large duty cycles mean very short pulses, high peak currents and poor control. A practical window is roughly $0.1 < D < 0.85$; outside it, add a transformer. ## Question 3: how hard does each part work? Two converters with the same input and output can stress their parts very differently. For the ideal non-isolated stages, with $M = V_{out}/V_{in}$: | Topology | Switch voltage | Switch current while on | |---|---|---| | Buck | $V_{in}$ | $I_{out}$ | | Boost | $V_{out} = M\,V_{in}$ | $I_{in} = M\,I_{out}$ | | Buck-boost, SEPIC | $V_{in} + V_{out}$ | $I_{in} + I_{out}$ | ![Switch voltage over Vin and switch current over Iout against the conversion ratio M, ripple left out.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/which-converter-topology-for-my-spec/switch-stress.svg) The buck-boost family always pays the sum of both sides. That is the price of flexibility: at 12 V to 3.3 V, a SEPIC's switch blocks 15.3 V and carries 6.4 A, where a buck's blocks 12 V and carries 5 A. Higher voltage means a part with more on-resistance per square millimetre, higher current means more conduction loss, and both mean more switching loss. Isolated topologies have their own stresses: - A **flyback** switch sees $V_{in}$ plus the reflected output, plus a leakage-inductance spike. - A **forward** converter with a 1:1 reset winding sees $2V_{in}$. - **Half bridges, full bridges and the LLC** clamp each switch to the input bus, $V_{in}$, which is why they dominate at high input voltage. ## Question 4: how much power? Power decides where each topology is comfortable. These are the usual ranges Voltecx's ranking uses (rules of thumb, after Erickson and Maksimović and Mohan, Undeland and Robbins, *Power Electronics*, ch. 7 and 10), not hard limits: | Topology | Isolated | Usual power | Switches + rectifiers | Magnetic parts | Notes | |---|---|---|---|---|---| | Buck (diode) | no | up to 100 W | 2 | 1 | simplest; diode drop hurts at low output voltage | | Synchronous buck | no | 1 W to 1 kW | 2 | 1 | the default for step-down | | Multiphase buck | no | 10 W to 10 kW | 4+ | 2+ | for tens of amperes | | Boost | no | up to 100 W (sync to 1 kW) | 2 | 1 | right-half-plane zero in its loop | | SEPIC | no | up to 50 W | 2 | 2 | up or down, positive output | | Four-switch buck-boost | no | 20 W to 1 kW | 4 | 1 | up or down, efficient | | Flyback | yes | up to 100 W | 2 | 1 | fewest parts; transformer stores all the energy | | Forward | yes | 50 to 300 W | 3 | 2 | needs core reset | | Push-pull | yes | 150 W to 1 kW | 4 | 2 | low-voltage input | | Half bridge | yes | 200 W to 1 kW | 4 | 2 | switches see Vin only | | Phase-shifted full bridge (PSFB) | yes | 500 W to 10 kW | 6 | 2 | ZVS at fixed frequency, wide input | | LLC | yes | 100 W to 5 kW | 4 | 2 | soft switching, narrow input range | | Dual active bridge (DAB) | yes | 1 kW and up | 8 | 2 | bidirectional | `topology.suggest` turns these rules into a score: it drops what cannot work (ratio out of the duty range, no isolation when isolation is asked), then subtracts points for being outside the usual power and current range, for duty-cycle extremes, for an unneeded transformer or second bridge, for a wide input range on an LLC and for size, and adds points for estimated efficiency. The weights are Voltecx's own choices, and the reply lists the reason behind each one. Plotting that score against power for 400 V to 48 V shows the classic picture. ![The topology.suggest score (higher is better) of six isolated topologies for 400 V to 48 V, against output power.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/which-converter-topology-for-my-spec/score-vs-power.svg) The flyback leads at 20 to 40 W, the LLC leads from about 100 W, and by 1 kW the full bridge has passed both the forward and the flyback. The DAB climbs only near its kilowatt range, and even there it loses points because this spec does not need power to flow back. ## Question 5: one direction or two? If energy must flow both ways (a battery charger that also discharges, a motor drive that regenerates), the rectifier diodes must become switches: - non-isolated: a synchronous buck or boost run in reverse, or a four-switch buck-boost; - isolated: a dual active bridge, or a bidirectional CLLC. If power only flows one way, the second active bridge is cost without benefit. ## The decision flow Put together, the order is: 1. **Isolation?** If yes, go to step 4. 2. **Ratio:** below 1 with margin, a buck; above 1, a boost; straddling 1, a SEPIC or four-switch buck-boost. 3. **Current:** above about 30 A, interleave (multiphase). Above a few amperes at low output voltage, use synchronous rectification. Done. 4. **Power:** below about 100 W, a flyback; 50 to 300 W, a forward (or flyback with care); above about 100 W, an LLC if the input range is narrow (a highest-to-lowest ratio up to about 1.2, roughly ±9 %), or a PSFB for a wide input range at high power. 5. **Direction:** bidirectional at high power, a DAB. 6. **Check the candidates** against your spec numbers: efficiency, stress, part count, control difficulty and cost. The rules get you to two or three candidates; the numbers pick one. Step 6 is where a simulator earns its keep. Here are the three specs. ## Worked example 1: 12 V to 3.3 V at 5 A `design.compare` ranks the candidates with `topology.suggest`, sizes each one's inductors with `magnetics.design` (core and copper loss, smallest catalogue core first) and tabulates the result. It drops the boost (it only steps up) and the linear regulator, which would turn $(12 - 3.3) \times 5 = 43.5$ W into heat. | Candidate | Efficiency (semiconductors + inductors) | Switch voltage | Power-stage parts | Inductor volume | |---|---|---|---|---| | Synchronous buck | 98.5 % | 12 V | 3 | 5.6 cm³ | | 2-phase buck | 98.5 % | 12 V | 6 | 10.7 cm³ | | Buck (diode) | 94.7 % | 12 V | 3 | 5.6 cm³ | | SEPIC | 91.4 % | 15.3 V | 4 | 15.1 cm³ | The synchronous buck wins: the same efficiency as two phases with half the parts. Replacing the low-side MOSFET by a diode raises the semiconductor loss from 0.095 W to 0.77 W. The SEPIC is worst on every column: higher stress (its switch carries 6.4 A), two inductors and more loss. These are first-order estimates; gate drive, the controller and the board copper are not in them. How do they scale with current? Running the same comparison at each rated current from 1 to 5 A: ![Estimated efficiency of each candidate designed for 1 to 5 A, at 12 V to 3.3 V: the synchronous and 2-phase buck stay near 98.5 %, the diode buck and the SEPIC fall as the current rises.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/which-converter-topology-for-my-spec/efficiency-vs-load.svg) At 1 A the diode buck is still at 97.5 % and the SEPIC at 96.3 %; at 5 A they are down to 94.7 % and 91.4 %. The diode's loss grows with the current while a MOSFET's conduction loss falls with a lower-resistance part, which is why synchronous rectification takes over above a few amperes. The waveforms show where the SEPIC's extra loss comes from. Both converters were drawn with `circuit.template` at 100 kHz and run into steady state: ![One buck and one SEPIC at 12 V to 3.3 V, 5 A, 100 kHz: switch-node voltage (top) and switch current (bottom). The SEPIC's switch blocks 15.4 V and carries up to 6.9 A; the buck's 11.9 V and 5.4 A.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/which-converter-topology-for-my-spec/buck-vs-sepic.svg) The SEPIC switch sees $V_{in} + V_{out}$ plus the diode drop, less the 1 % its supply sags at full load, 15.4 V, and the sum of both inductor currents, up to 6.9 A. The buck switch sees 11.9 V and 5.4 A. The SEPIC runs at a shorter duty cycle, $D = 0.216$ against $0.275$ for the buck, but every microsecond it is on costs more. ## Worked example 2: 400 V to 12 V at 100 W, isolated The input is 370 to 410 V. The non-isolated stages are dropped because the spec asks for isolation. For isolated candidates `design.compare` does not size the transformer yet, so the efficiency column counts the semiconductors only. | Candidate | Semiconductor efficiency | Highest switch voltage | Power-stage parts | |---|---|---|---| | LLC half bridge | 99.92 % | 410 V | 6 | | Full bridge (PSFB) | 99.79 % | 410 V | 8 | | Flyback | 98.58 % | 683 V | 3 | | Forward | 98.42 % | 820 V | 5 | The LLC is chosen: its switches see only the input bus and, near resonance, switch softly. The flyback has half the parts, but its switch must block 683 V at 410 V in (the input plus 273 V of reflected output, before any leakage spike), and its rectifier carries 13.9 A peaks. The forward's switch sees twice the input, 820 V, which pushes it to a 1200 V device. Be careful with the LLC's number: the ranking counts no switching loss for it, because it assumes zero-voltage switching. That holds near resonance and at moderate load, not always at light load. The flyback's 98.58 % already includes its hard switching. The waveforms make the difference visible: ![A flyback and an LLC half bridge at 400 V to 12 V, 100 W: the flyback's drain rings up to 896 V with a 6.2 A turn-on spike; the LLC's switch node stays between 0 and 400 V with a 0.9 A sinusoidal tank current.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/which-converter-topology-for-my-spec/flyback-vs-llc.svg) - The flyback's drain jumps to the clamp at 896 V when the switch turns off, then rings around the reflected level of $400 + 12/0.045 \approx 667$ V. At turn-on, a 6.2 A spike discharges the switch's own capacitance: that is hard-switching loss you can see. - The LLC's switch node is a clean square wave between 0 and the 400 V bus, and its tank current is a 0.9 A sine. The upper switch carries −0.48 A at the start of its on-time: the current flows through its body diode first, so the switch turns on at zero voltage. ## Worked example 3: 400 V to 48 V at 1 kW, isolated At 1 kW the ranking changes: | Rank | Candidate | Semiconductor loss | Power-stage parts | |---|---|---|---| | 1 | LLC half bridge | 5.05 W | 6 | | 2 | Full bridge (PSFB) | 4.87 W | 8 | | 3 | Half bridge (hard switched) | 9.87 W | 6 | | 5 | Dual active bridge | 3.25 W | 10 | | 6 | Forward | 19.4 W | 5 | The forward's loss is almost four times the LLC's, and the flyback is far outside its usual range. The DAB has the lowest semiconductor loss of all, yet it ranks fifth: it has ten power devices and nothing in this spec needs power to flow back. The LLC and the PSFB are within 1 W of each other. Between those two, the deciding question is the input range: the LLC is best when the input stays within about ±9 %, the PSFB holds ZVS at a fixed frequency over a wider range. ## Pitfalls - **First-order numbers are for ranking, not for the datasheet.** The ranking's loss model takes the session's device library and simple waveforms. Use it to choose two or three candidates, then design and simulate those. - **Light load and soft switching.** An LLC or PSFB loses ZVS at light load. If your product spends most of its life at 10 % load, check efficiency there, not only at full load. - **Wide input range.** An LLC needs its gain range to cover the input range. For a 2:1 input it gets big and inefficient; that is where a PSFB or a two-stage design fits better. - **Minimum on-time.** A 48 V to 1 V buck at 500 kHz needs 42 ns pulses. Check your controller's minimum on-time before you rule out a transformer or an intermediate bus. - **Control difficulty.** The boost, buck-boost and flyback have a right-half-plane zero in continuous conduction, which limits the loop bandwidth. `design.compare` rates each candidate's control difficulty from 1 to 3 and gives the reason. - **The flyback's leakage spike.** The real drain voltage is the clamp voltage, not $V_{in} + V_{out}/n$. Leave margin for it when you choose the switch. - **Cost and availability.** Two inductors cost more board area than one; a 1200 V switch costs more than a 650 V one. `design.compare` adds the catalogue cost of the devices that have a cited price and lists the ones that have none; it never fills in a missing price. ## Try it in Voltecx - `topology.suggest` ranks every topology in its rule table for your spec and says why each one was dropped or ranked. - `design.compare` (**Design › Automate › Compare Topologies and Control**) tabulates the top candidates with efficiency, stress, part count, magnetics volume, cost and control difficulty, and explains the choice. For a buck, boost or buck-boost it also compares voltage mode, peak current mode, average current mode and digital control on a load step; see [Digital, analog or controller IC](https://voltecx-web.nguyenvanqui291.workers.dev/blog/digital-vs-analog-vs-controller-ic-control). - `circuit.template` draws any candidate sized from your numbers, so you can simulate it straight away, as for the waveforms above. - `design.auto` (**Design › Auto Design**) designs the best-ranked candidate end to end, or the one you name with `topology`. See [Automatic design](https://voltecx-web.nguyenvanqui291.workers.dev/features/auto-design) and, for what happens after the topology, [How a power supply gets designed](https://voltecx-web.nguyenvanqui291.workers.dev/blog/power-supply-product-design-flow). The rules follow R. W. Erickson and D. Maksimović, *Fundamentals of Power Electronics*, 3rd ed., ch. 2, 3 and 6, and N. Mohan, T. M. Undeland and W. P. Robbins, *Power Electronics*, 3rd ed., ch. 7, 8 and 10. --- # Worked example: choosing the switching frequency with a sweep URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/switching-frequency-sweep-worked-example/ This worked example picks the switching frequency of a 48 V to 12 V, 10 A synchronous buck by running it at ten frequencies from 100 kHz to 1 MHz. At each frequency the inductor and output capacitor are sized again, both switches are a real MOSFET with its data-sheet loss model, and the efficiency, ripple and inductor size come from the run. The answer is the knee of the curve of loss against inductor size: below it, a higher frequency buys a much smaller inductor for little loss; above it, it buys little for much loss. [Choosing the switching frequency](https://voltecx-web.nguyenvanqui291.workers.dev/blog/choosing-switching-frequency) explains the trade-off; this article puts numbers on it. Every number below is pasted by the script that runs the sweep, and a test fails when the article and the script's output differ. ## The design - **Spec.** 48 V in, 12 V out, 10 A. `circuit.template` (topology `syncBuck`) sizes the inductor for a 30 % ripple (3 A peak to peak) and the output capacitor for a 1 % ripple at each frequency: $L = (V_{in} - V_{out}) D / (f_{sw} \Delta I)$ and $C = \Delta I / (8 f_{sw} \Delta V)$. Its ceramic output and input capacitors carry an ESR that grows as their capacitance falls. - **Switches.** Q1 and Q2 are both an Infineon BSC070N10NS5 (100 V, 6.0 mΩ typical at $V_{GS}$ = 10 V; [data sheet](https://www.infineon.com/assets/row/public/documents/24/49/infineon-bsc070n10ns5-datasheet-en.pdf), Rev. 2.3, 2019-11-13), from the built-in library. - **Dead time.** 30 ns at every frequency: the part's turn-off delay plus fall time, $t_{d(off)} + t_f$ = 24 ns + 6 ns (Table 5). The duty is raised by $t_d f_{sw}$ for the on-time the dead time takes. - **Losses counted.** For each switch, conduction from the data sheet's $R_{DS(on)}$ table, and switching from the gate-charge method with the output charge $Q_{oss}$ (Graovac, Pürschel and Kiep, Infineon application note, 2006), the data sheet giving no switching energies. Also the gate drive of both switches, $2 Q_g V_{GS} f_{sw}$ with $Q_g$ = 30 nC at 10 V (Table 6), and the ESR loss of the capacitors. - **Not counted.** The inductor is ideal: no part is chosen yet, so its copper and core loss are left out (see below). The junction is at 25 °C. ## Run the sweep One point of the sweep is a chain of commands in the command line. This is the one at the knee found below: [//]: # "sweep:command" ```sh powercraft-cli run \ --cmd circuit.template --params '{"topology":"syncBuck","vin":48,"vout":12,"iout":10,"ripplePct":30,"vripplePct":1,"fsw":300000}' \ --cmd circuit.setParam --params '{"component":"Vin","key":"rs","value":0}' \ --cmd circuit.variables --params '{"set":{"td":3e-08,"D":0.259}}' \ --cmd device.fromPartNumber --params '{"mpn":"BSC070N10NS5","component":"Q1","apply":true}' \ --cmd device.fromPartNumber --params '{"mpn":"BSC070N10NS5","component":"Q2","apply":true}' \ --cmd simulation.settings --params '{"tEnd":0.000666667,"maxStep":2.5e-09}' \ --cmd simulation.run --params '{}' \ --cmd scope.measure --params '{"signals":["i(L1)","v(out)","i(R1)","i(C1.esr)","i(Cin.esr)"],"t0":0.0005}' \ --cmd analysis.losses --params '{"t0":0.0005}' \ --cmd device.get --params '{"id":"infineon/bsc070n10ns5"}' ``` [//]: # "/sweep:command" Each run lasts 200 switching periods and is measured over the last 50. The script `docs/tutorials/python/fsw_sweep.py` runs this chain at every frequency, writes the table to `sweep.csv`, draws the figures and pastes the numbers into this article: ```sh python3 docs/tutorials/python/fsw_sweep.py all # data, figures, article python3 docs/tutorials/python/fsw_sweep.py check # fails when the article differs from sweep.csv ``` ## Results [//]: # "sweep:table" | $f_{sw}$ (kHz) | L (µH) | C (µF) | ½LI²pk (µJ) | Efficiency | Loss (W) | Q1 switching (W) | ΔiL (A) | ΔVout (mV) | |---|---|---|---|---|---|---|---|---| | 100 | 30.00 | 31.25 | 1981.8 | 98.64 % | 1.65 | 0.52 | 3.00 | 120.2 | | 200 | 15.00 | 15.62 | 990.9 | 97.79 % | 2.70 | 1.03 | 3.00 | 120.8 | | 300 | 10.00 | 10.42 | 660.6 | 96.96 % | 3.75 | 1.55 | 3.00 | 122.1 | | 400 | 7.50 | 7.81 | 495.5 | 96.15 % | 4.80 | 2.06 | 3.00 | 124.0 | | 500 | 6.00 | 6.25 | 396.4 | 95.34 % | 5.85 | 2.58 | 3.00 | 126.6 | | 600 | 5.00 | 5.21 | 330.3 | 94.55 % | 6.90 | 3.10 | 3.00 | 129.8 | | 700 | 4.29 | 4.46 | 283.2 | 93.78 % | 7.95 | 3.61 | 3.00 | 133.6 | | 800 | 3.75 | 3.91 | 247.8 | 93.01 % | 9.00 | 4.13 | 3.00 | 138.1 | | 900 | 3.33 | 3.47 | 220.2 | 92.26 % | 10.05 | 4.64 | 3.00 | 143.3 | | 1000 | 3.00 | 3.12 | 198.2 | 91.52 % | 11.10 | 5.16 | 3.00 | 149.0 | [//]: # "/sweep:table" ½LI²pk is the energy the inductor stores at its peak current. The size of its core grows with it, so it is the inductor size in this comparison. ![Efficiency against switching frequency from the sweep, one point per run, with the knee circled.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/switching-frequency-sweep-worked-example/efficiency-vs-fsw.svg) ![The loss against switching frequency: Q1's switching loss, the conduction loss of both switches and the total loss.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/switching-frequency-sweep-worked-example/losses-vs-fsw.svg) ![The inductance sized for a 30 % ripple at each frequency, falling as one over the switching frequency.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/switching-frequency-sweep-worked-example/inductor-vs-fsw.svg) ![The simulated output ripple at each frequency. It grows because the smaller output capacitor has a larger ESR. The inductor ripple, in the table, stays the same because the inductor is resized.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/switching-frequency-sweep-worked-example/ripple-vs-fsw.svg) [//]: # "sweep:summary" From 100 kHz to 1000 kHz the inductor falls from 30.00 µH to 3.00 µH, and the energy it stores at its peak current from 1981.8 µJ to 198.2 µJ. The efficiency falls from 98.64 % to 91.52 %, because the loss grows from 1.65 W to 11.10 W. Of that 9.45 W, 4.64 W is Q1's switching loss and 3.84 W is the reverse recovery of Q2's body diode. The conduction loss of both switches only rises from 0.65 W to 1.05 W: the fixed 30 ns dead times, in which Q2's body diode carries the current, take a larger share of a shorter period. The gate drive reaches 0.60 W at 1000 kHz. The inductor ripple stays at 3.00 A at every point, because L is resized each time. The knee of the trade-off is at **300 kHz**: 10.00 µH, 660.6 µJ, 96.96 % efficiency and 3.75 W of loss. Up to the knee, each watt of extra loss removes 629 µJ of inductor energy. Above it, each watt removes only 63 µJ. [//]: # "/sweep:summary" ## Where the knee is ![The total loss against the inductor's stored energy, one point per switching frequency, with the knee circled.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/switching-frequency-sweep-worked-example/loss-vs-inductor-energy.svg) The knee is the point of the loss-against-size curve farthest from the straight line between its two ends, with both axes scaled to their range (the "Kneedle" rule of Satopää, Albrecht, Irwin and Raghavan, ICDCS Workshops 2011). It is a reproducible way to name the point after which each step costs more than it gives; it is not an optimum. If the heatsink or the efficiency target is fixed, read the table instead: the highest frequency whose loss you can still remove is the answer. ## What the sweep leaves out - **Inductor loss.** A real inductor adds copper loss, which falls with frequency (fewer turns), and core loss, which rises with it. Both push the knee lower than the switches alone do. Repeat the sweep once a part is chosen: `device.fromPartNumber` fills L with the part's inductance, DCR and saturation current. - **Reverse recovery.** The library has no $E_{rr}$ table for this part, so the body diode's recovery when Q1 turns on is not counted. The data sheet gives $Q_{rr}$ = 89 nC at 40 A and 100 A/µs (Table 7), a test point well above this converter's. - **Temperature.** The junction is at 25 °C. Hot, $R_{DS(on)}$ is higher (1.65 times at 125 °C in the data sheet's Diagram 9), which raises the conduction loss at every frequency but barely moves the knee. - **Gate driver.** The switching estimate assumes a 10 V driver with 2 Ω of external gate resistance. A stronger driver lowers the switching loss line and moves the knee up. ## Do it yourself - **One point in the app.** Press Ctrl+K (Cmd+K on a Mac), choose **Circuit From Template** and give topology `syncBuck` with the spec above. Type `BSC070N10NS5` in the part-number field of Q1 and of Q2, run, and read **Analysis › Losses**. - **The sweep.** **Analysis › Parameter Sweep** (`analysis.paramSweep`) steps the `fsw` variable of an open circuit; note that it keeps L and C fixed, so for a sweep that resizes them use the template at each frequency, as the script does. - **Read on.** [MOSFET loss and junction temperature](https://voltecx-web.nguyenvanqui291.workers.dev/blog/mosfet-loss-and-thermal-estimation) explains the loss equations; [How to choose an inductor](https://voltecx-web.nguyenvanqui291.workers.dev/blog/how-to-choose-an-inductor) the part that comes after this choice. --- # Averaged model or switching model: which simulation to run when URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/averaged-vs-switching-model/ Use an averaged model for anything slower than the switching period: start-up, load and line steps, loop gain and long mission profiles. Use the switching model for anything inside a period: ripple, peak and RMS currents, switching and conduction losses, dead time, junction temperature at full load and EMI. An averaged model replaces the switch and diode by their averages over one period, so it needs no time steps inside each period; a 20 ms load-step study at 100 kHz takes about 400,000 steps in the switching circuit at 200 steps per period, and 10,000 in the averaged one. ## The idea: watch the tide, not the waves A switching converter's waveforms look like waves on top of a tide. The waves are the ripple: the inductor current ramps up and down every period, the switch node jumps between the rails. The tide is the slow part underneath: the output rising at start-up, sagging on a load step and recovering as the loop reacts. An averaged model draws only the tide. It replaces the switch by what it does on average over one period, so there is nothing left that changes faster than the period, and the simulator can take long steps. That makes it fast, and it makes it blind to everything inside a period. ![The buckClosedLoop example (48 V to 12 V, 5 A, 100 kHz, PI control) starting up in Voltecx, on the switching circuit and on its averaged model. The output voltages lie on top of each other; the averaged inductor current runs through the middle of the switching one's ripple band.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/averaged-vs-switching-model/start-up.svg) ## What is an averaged model? Averaging over one switching period removes the ripple and keeps the low-frequency behaviour. For a buck in continuous conduction (Erickson and Maksimović, *Fundamentals of Power Electronics*, AC equivalent circuit modelling): $$L\frac{d\langle i_L\rangle}{dt} = d\,\langle v_{in}\rangle - \langle v_{out}\rangle, \qquad C\frac{d\langle v_{out}\rangle}{dt} = \langle i_L\rangle - \frac{\langle v_{out}\rangle}{R}$$ Linearising those about an operating point gives the small-signal transfer functions used for loop design. The *circuit-averaged* form keeps the circuit and replaces the switch network by controlled sources, so the same schematic runs in both modes. Discontinuous conduction needs its own averaged switch, because the diode's conduction time then depends on the current. ## What does each model get right? | Question | Averaged | Switching | |---|---|---| | Output voltage after a load step | yes | yes | | Loop gain, phase margin | yes, below about $f_{sw}/2$ | yes, with periodic small-signal analysis | | Start-up and soft start | yes | yes, slow | | Inductor ripple, output ripple | no | yes | | Peak and RMS currents in each part | no (only averages) | yes | | Switching and conduction loss, efficiency | no | yes | | Dead time, body-diode conduction | no | yes | | EMI spectrum | no | yes | | Hours of a drive cycle or mission profile | yes | rarely practical | ![A 2.5 A load step at 12 ms on the same buck, both models in Voltecx. Both outputs dip to 10.41 V and ring back the same way; the switching current peaks higher by half its ripple.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/averaged-vs-switching-model/load-step.svg) ![Three switching periods at steady state. The switching model shows the inductor current's 0.9 A triangle; the averaged model shows only the 5 A it averages to. Peak current, RMS current and ripple are invisible to it.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/averaged-vs-switching-model/ripple-zoom.svg) ## How much faster is averaging? A switching simulation needs steps fine enough to resolve each period: with 100 steps per period at 100 kHz, 20 ms of simulated time is $100 \times 20\,\text{ms} \times 100\,\text{kHz} = 200{,}000$ steps, plus extra steps at each switching event. An averaged model steps at the speed of the slowest dynamics. In Voltecx, the 20 ms load-step run above took **402,154 steps** on the switching circuit (the example uses 50 ns steps, 200 per period) and **10,000 steps** on the averaged model, which steps at a fifth of a switching period: 40 times fewer, for the same output waveform. For loop gain the difference is larger. On the `buckClosedLoop` example, `analysis.loopGain` with the periodic method needs 16,659 solver steps for 12 frequencies, where injecting a sine and waiting for it to settle at each frequency (the perturbation method) needs more than 20 million ([Analyses in the manual](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/06-analyses/)). ## Where do the two models disagree? - **Near half the switching frequency**, where averaging misses the sampling effect. Current-mode control's subharmonic instability is the classic example: the averaged model does not show it. - **At light load**, when the converter enters discontinuous conduction and a continuous-mode averaged model is wrong. - **With large ripple**, where the average of a nonlinear device (a saturating inductor, a diode near its knee) is not the device at the average. A practical check: run the full-load corner on both and compare the output mean. ## Common mistakes - **Reading ripple or peak current off an averaged run.** It has none by construction. Size parts from the switching run. - **Trusting the averaged loop gain near $f_{sw}/2$.** Sampling effects, such as current-mode subharmonic oscillation, are not in it. - **Using a continuous-conduction model at light load.** The gain and dynamics change in discontinuous conduction; the model must cover it. - **Running hours of switching simulation to see a slow effect.** A thermal or battery profile over minutes belongs on the averaged model, with a switching check at the corners. - **Never comparing the two.** One full-load run on both models takes seconds and tells you whether the averaged one can be trusted for the rest. ## How to do it in Voltecx - **Automatic design uses both.** With `auto.model` set to `averaged` (the default), `design.auto` runs the light-load corners, the load and line steps and the loop gain on the circuit-averaged model of a buck, boost, buck-boost, SEPIC or flyback, in continuous and discontinuous conduction. The full-load corners (worst ripple and stress), the efficiency and the junction temperatures stay on the switching circuit, and each full-load corner runs on both models so the report shows how well they agree (within 1 % of the output). - **Loop gain on the switching circuit.** `analysis.loopGain` picks the `periodic` method on a circuit that switches: it finds the periodic steady state, linearises one switching period about it and reads the response from that model. That is the sampled-data approach of Verghese, Elbuluk and Kassakian (IEEE Trans. Power Electron., 1986). - **Steady state without the start-up.** `simulation.steadyState` (**Simulation › Steady-State Analysis**) finds the periodic steady state and shows its last period. - **Speed of the switching solver.** On the rectifier and buck cases of a published benchmark, Voltecx's fast solver ran 7 to 10 times faster than ngspice on the same netlists, with waveforms within 0.04–0.13 % of ngspice's, 1.2 % on one exported buck (Voltecx benchmark against ngspice-47 on an Apple M1 Pro, measured 2026-10-18). That is a measurement on one machine and a few circuits, not a guarantee for every circuit. See [simulation](https://voltecx-web.nguyenvanqui291.workers.dev/features/simulation) and [analyses](https://voltecx-web.nguyenvanqui291.workers.dev/features/analyses). ## Frequently asked questions ### Can I design a control loop with an averaged model? Yes, below roughly half the switching frequency. Check the result on the switching circuit, especially for current-mode control, where sampling effects near $f_{sw}/2$ matter. ### Why does my averaged model not show ripple? Because averaging over one switching period removes it by construction. Use the switching model for ripple, peak currents and losses. ### Does an averaged model work in discontinuous conduction? Only if it models DCM. A continuous-conduction averaged model gives the wrong gain and dynamics at light load. ### How do I know the averaged model is accurate enough? Run the same operating point on both models and compare the mean output and the loop gain below $f_{sw}/10$. They should agree within a percent or so. --- # Boost converter design: duty cycle, inductor and the right-half-plane zero URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/boost-converter-design-rhp-zero/ Design a boost from its lowest input voltage: there the duty cycle $D = 1 - V_{in}/V_{out}$ is largest, the input current $I_o/(1-D)$ is highest and the right-half-plane (RHP) zero $f_{RHP} = R(1-D)^2/(2\pi L)$ is lowest. The RHP zero limits a voltage-mode loop's crossover to roughly a fifth of $f_{RHP}$ or less. For 10–14 V to 24 V at 2 A and 200 kHz, a 25 µH inductor gives a 5.4 A peak current at 10 V and puts the RHP zero at 13 kHz, so the loop must cross below about 2.6 kHz. ## What are the steady-state equations of a boost? In continuous conduction (Erickson and Maksimović, *Fundamentals of Power Electronics*, steady-state analysis): $$\frac{V_{out}}{V_{in}} = \frac{1}{1 - D}, \qquad I_{in} = I_L = \frac{I_o}{1 - D}$$ $$\Delta I_L = \frac{V_{in}\, D}{f_{sw}\, L}, \qquad \Delta V_{out} = \frac{I_o\, D}{f_{sw}\, C}$$ The switch and the diode each carry the full inductor current, the switch during $D$ and the diode during $(1-D)$. The output capacitor supplies the whole load current while the switch is on, so its ripple current is large, unlike a buck's. In plain words, a boost works in two beats. While the switch is on, the inductor is shorted across the input and charges up; the output gets nothing and lives on its capacitor. While the switch is off, the inductor's current is pushed through the diode on top of the input voltage, which is how the output ends up higher than the input. The longer the charging beat ($D$), the higher the output, and the more current the input must supply for the same output power. ![The boost of this article in Voltecx: inductor L1 = 25 µH from the input to the switch node, switch S1 to ground, diode D1 to the output, C1 = 47 µF and a 12 Ω load (24 V at 2 A), driven open loop at the duty D.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/boost-converter-design-rhp-zero/boost.svg) ## Worked example: 10–14 V to 24 V, 2 A, 200 kHz ### Duty cycle and inductor current | $V_{in}$ | $D$ | $I_{in}$ | $\Delta I_L$ (25 µH) | $I_{pk}$ | |---|---|---|---|---| | 10 V | 0.583 | 4.80 A | 1.17 A | 5.38 A | | 12 V | 0.500 | 4.00 A | 1.20 A | 4.60 A | | 14 V | 0.417 | 3.43 A | 1.17 A | 4.01 A | ![The inductor current simulated in Voltecx at 10, 12 and 14 V input. The ripple stays near 1.2 A at every input, but the whole triangle moves up as the input falls: the peak is 5.38 A at 10 V against 4.01 A at 14 V.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/boost-converter-design-rhp-zero/inductor-current-vs-vin.svg) The inductor was sized for a 30 % ripple at the nominal 12 V: $L = 12 \times 0.5 / (200\,\text{kHz} \times 1.2\,\text{A}) = 25$ µH. The ripple $V_{out}D(1-D)/(f_{sw}L)$ is largest at $D = 0.5$, so it barely changes over this range, while the peak current is set by low line. Choose the inductor's saturation current and the switch's current limit from the 5.38 A at 10 V plus margin. ### Output capacitor For 120 mV of ripple (0.5 %) at $D = 0.5$: $$C \ge \frac{2 \times 0.5}{200\,\text{kHz} \times 0.12\,\text{V}} = 41.7\ \mu\text{F}$$ so 47 µF effective (106 mV ripple). At $D = 0.583$ the ripple grows to about 124 mV; recompute at your worst duty. ## What is the right-half-plane zero? Imagine you want more output voltage, so you raise the duty cycle. The switch now stays on longer, and the inductor charges for longer. But the diode, the only path to the output, now conducts for a shorter part of each period. For the first few periods the inductor current has not yet grown, so the output gets *less* current than before, and the output voltage dips. Only once the inductor current has built up does the output start to rise. The converter first moves the wrong way. ![A duty step from 0.5 to 0.6 at 12 V input, simulated in Voltecx and averaged over each 5 µs switching period. The diode current drops at once from 2.0 A to 1.76 A and the output dips 37 mV over the next three periods, while the inductor current climbs. Only about 20 µs after the step is the output back above its old level.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/boost-converter-design-rhp-zero/duty-step-rhp-zero.svg) A control loop that reacts quickly to that dip makes things worse: it sees the output fall, raises the duty cycle further, and the output falls more. That is why the loop has to be slow compared with this effect. In the frequency domain, the effect shows up as a zero in the right half plane. The control-to-output transfer function has a zero in the right half plane (Erickson and Maksimović, converter transfer functions): $$f_{RHP} = \frac{R\,(1 - D)^2}{2\pi L}$$ It adds gain like a zero but phase lag like a pole, and no compensator can cancel it. The loop must cross over well below it. ![The control-to-output transfer function Gvd of the boost at 10 V and 14 V input, from the plant model in Voltecx's design.voltageLoop. The LC resonance peaks near 2 kHz; above it, the right-half-plane zeros (vertical lines at 13.3 and 26 kHz) flatten the gain while the phase keeps falling, past −180° and on toward −360°.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/boost-converter-design-rhp-zero/plant-bode.svg) With $R = 24/2 = 12$ Ω and 25 µH: | $V_{in}$ | $f_{RHP}$ | LC resonance $f_0 = \frac{1-D}{2\pi\sqrt{LC}}$ (47 µF) | |---|---|---| | 10 V | 13.3 kHz | 1.9 kHz | | 12 V | 19.1 kHz | 2.3 kHz | | 14 V | 26.0 kHz | 2.7 kHz | The worst case is low line at full load: $f_{RHP} = 13.3$ kHz. A crossover at a fifth of it, 2.6 kHz, sits right on the LC double pole, which makes a voltage-mode design hard. How hard? Asked for a Type III crossing at 2.6 kHz at 10 V, Voltecx's `design.voltageLoop` refuses even with only 30° of phase margin: with this lightly damped LC filter, the highest crossover it can place is about 265 Hz, below the resonance. So in practice, voltage mode leaves this boost with a loop of a few hundred hertz, and the output capacitor has to carry every load step on its own for that long. ## How do you get around it? - **Peak current mode.** The inner current loop removes the LC double pole from the outer loop, which leaves a single pole and the RHP zero. The crossover can then go to about $f_{RHP}/5$ with a simple Type II compensator. - **A smaller inductor.** $f_{RHP} \propto 1/L$; halving $L$ doubles $f_{RHP}$ but doubles the ripple. - **Lower bandwidth.** If the load is slow, accept a crossover of a few hundred hertz and size the output capacitor for the load step. ## What limits the boost ratio? The ideal gain $1/(1-D)$ goes to infinity as $D \to 1$, but the inductor's resistance, the switch and diode drops limit the real gain. Erickson and Maksimović show the output peaking and then falling at high duty when losses are included. Beyond a step-up of about 4 to 5, a coupled-inductor, tapped or isolated topology is often a better choice. ## Common mistakes - **Designing at nominal input.** The peak current, the input current and the lowest RHP zero all come at the lowest input voltage. Check that corner first. - **Using the buck's capacitor rule.** In a boost the output capacitor carries the full load current every time the switch is on. Its ripple current, and the ripple voltage, are far larger than in a buck of the same power. - **Pushing the crossover up with more phase boost.** No compensator cancels a right-half-plane zero. Phase you add is taken back by the zero's lag. - **Forgetting light load and high line.** The RHP zero moves with load and input. A loop tuned at one corner can be unstable at another; check them all. - **Expecting high boost ratios.** Above a step-up of about 4 to 5, losses eat the gain and the RHP zero moves very low. Look at other topologies. ## How to do it in Voltecx 1. Open **File › Open Example › boostClosedLoop** (24 V from 12 V with a slow PI) or draw a boost with `circuit.template`. 2. The Design panel's **Converter** task (`design.converter`) sizes L and C for the boost. The **Voltage loop** task (`design.voltageLoop`) picks a PI, Type II or Type III for your crossover and phase margin and checks it three ways: on the model, by measuring the loop gain on the circuit, and with a 50 % load step. 3. In automatic design, a converter with an RHP zero gets its loop from `design.robustLoop`, which designs over every corner of the input and load range, including light-load discontinuous conduction. 4. `design.compare` (**Design › Automate › Compare Topologies and Control**) designs voltage mode, peak current mode, average current mode and a digital PI for the same phase margin on a boost and simulates each through a load step. 5. `analysis.loopGain` measures the loop gain on the switching circuit, so you can see the RHP zero's phase lag at low line. See the [loop gain article](https://voltecx-web.nguyenvanqui291.workers.dev/blog/loop-gain-phase-margin-simulation) for reading margins, and the [design tools overview](https://voltecx-web.nguyenvanqui291.workers.dev/features/design-tools). ## Frequently asked questions ### Why is the boost RHP zero worst at low input voltage? $f_{RHP} = R(1-D)^2/(2\pi L)$ falls as $D$ rises, and $D$ is largest at the lowest input voltage. Full load (smallest $R$) lowers it further. ### Can a compensator cancel the right-half-plane zero? No. A compensator zero cannot cancel a right-half-plane zero without creating an unstable pole. Keep the crossover well below it, typically under a fifth of its lowest value. ### Does current-mode control remove the RHP zero? No. It removes the LC double pole from the voltage loop, which makes compensation easier, but the RHP zero stays in the control-to-output transfer function. ### Where is the boost's inductor ripple largest? At $D = 0.5$, that is when the input is half the output: $\Delta I = V_{out}D(1-D)/(f_{sw}L)$ peaks there. --- # Boost PFC basics: power factor, inductor sizing and bulk capacitor URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/boost-pfc-basics/ A boost power-factor corrector (PFC) shapes the line current into a sine in phase with the line voltage, so power factor approaches 1 and low-order harmonics drop, while it charges a bulk capacitor to a DC voltage above the line peak, typically 380–400 V. Size its inductor for the ripple at the crest of the lowest line voltage, its bulk capacitor for hold-up time, and keep the voltage loop well below twice the line frequency. For 1 kW from 207–253 V at 50 Hz to 400 V at 100 kHz, that gives about 570 µH, 330 µF and a voltage-loop crossover of 10–20 Hz. ## What is power factor, and why correct it? Power factor is real power divided by apparent power. For a sinusoidal voltage and a distorted current: $$PF = \frac{P}{V_{rms} I_{rms}} = \cos\varphi \cdot \frac{1}{\sqrt{1 + THD_i^2}}$$ A diode bridge with a capacitor draws current only near the voltage peaks; with a current THD of 100 % the distortion factor alone limits PF to $1/\sqrt{2} = 0.71$. A PFC with 10 % THD and $\cos\varphi = 0.99$ reaches 0.985. Picture it this way: the mains is a pump that pushes hardest at the top of each half cycle. A plain bridge and capacitor draw nothing for most of the cycle and then gulp a big pulse right at the peak, when the capacitor voltage falls below the line. The wiring has to carry that pulse, and its harmonics travel back into the grid. A PFC sips evenly instead, a little at low voltage and more at high voltage, in proportion to the push. ![The line current of a plain bridge rectifier with 330 µF and a 90 Ω load, against the boost PFC of this article at 1 kW, both from 230 V, 50 Hz, simulated in Voltecx. The rectifier draws 20 A pulses near the peaks (power factor 0.59, current THD 119 %); the PFC draws a sine with a little switching ripple on it (power factor 0.986, THD 5 %).](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/boost-pfc-basics/rectifier-vs-pfc-current.svg) Harmonic current limits for equipment up to 16 A per phase are set by IEC 61000-3-2, which is why most supplies above a few tens of watts need a PFC stage. ## How does a boost PFC work? The bridge rectifies the line; a boost converter follows. Two loops control it: - **An inner current loop** makes the inductor current follow a reference shaped like the rectified line voltage. - **An outer voltage loop** sets the amplitude of that reference to hold the bulk voltage. The duty cycle varies over each half cycle: $d(t) = 1 - |v_{in}(t)|/V_{out}$. ![The pfcBoost template in Voltecx at the numbers of this article (574 µH, 330 µF, 1 kW at 230 V, 100 kHz) after it has settled: the line voltage and the line current, which follows it as a sine, 4.40 A rms. The current peaks a little before the voltage, which is why the power factor is 0.986 and not 0.999.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/boost-pfc-basics/line-voltage-and-current.svg) ## Worked example: 1 kW, 230 V ±10 %, 50 Hz, 400 V out, 100 kHz ### Input current Assuming unity power factor and 100 % efficiency (a lower bound on the current; divide by your efficiency): | $V_{rms}$ | $I_{rms}$ | $I_{pk}$ | $V_{pk}$ | $d$ at the crest | |---|---|---|---|---| | 230 V | 4.35 A | 6.15 A | 325 V | 0.187 | | 207 V | 4.83 A | 6.83 A | 293 V | 0.268 | ### Inductor At the crest, the ripple is $\Delta I = V_{pk}\, d / (f_{sw} L)$. For a ripple of 20 % of the peak current at low line ($\Delta I = 1.37$ A): $$L = \frac{292.7 \times 0.268}{100\,\text{kHz} \times 1.37\,\text{A}} = 574\ \mu\text{H}$$ The ripple is not largest at the crest, though. $\Delta I = v_{in}(1 - v_{in}/V_{out})/(f_{sw}L)$ peaks where $v_{in} = V_{out}/2 = 200$ V, which the low-line sine passes through, at $\Delta I_{max} = V_{out}/(4 f_{sw} L) = 400/(4 \times 100\,\text{k} \times 574\,\mu) = 1.74$ A. Use that for core loss, and the crest current plus half the ripple ($6.83 + 0.68 = 7.5$ A) for saturation. ![The inductor current over one half cycle at 230 V, simulated in Voltecx. The band is the switching ripple: about 1.1 A wide at the crest, but up to 1.8 A where the line passes about 200 V, on both sides of the crest, and narrow near the zero crossings. That is a little over the formula's 1.74 A because the bulk voltage there sits near 410 V on its 100 Hz ripple, not at 400 V.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/boost-pfc-basics/inductor-current-half-cycle.svg) ### Bulk capacitor Hold-up: keep the converter running for $t_{hold} = 10$ ms (half a 50 Hz cycle) while the bulk voltage falls from 400 V to the 300 V the downstream stage still accepts: $$C \ge \frac{2 P\, t_{hold}}{V_{out}^2 - V_{min}^2} = \frac{2 \times 1000 \times 0.01}{400^2 - 300^2} = 286\ \mu\text{F} \rightarrow 330\ \mu\text{F}$$ The input power pulses at twice the line frequency, so the bulk voltage ripples: $$\Delta V_{pp} = \frac{P}{2\pi f_{line}\, C\, V_{out}} = \frac{1000}{2\pi \times 50 \times 330\,\mu\text{F} \times 400} = 24\ \text{V}$$ ![The bulk voltage in the same simulation: a 100 Hz ripple of 24.7 V peak-to-peak around 399 V. The capacitor stores energy when the line is near its peak and gives it back near the zero crossings, when the line delivers almost nothing.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/boost-pfc-basics/bulk-voltage.svg) ### Why must the voltage loop be slow? That 100 Hz ripple is not an error to correct. If the voltage loop follows it, the current reference is distorted and THD rises. Keep the voltage-loop crossover around 10–20 Hz, well below 100 Hz, or filter the 100 Hz out of the feedback. The price is a slow response to load steps, which the bulk capacitor absorbs. ## Common mistakes - **Sizing the inductor ripple at the crest only.** The ripple is largest where the line is at half the output voltage, here about 1.8 A against 1.1 A at the crest. Core loss follows the largest ripple. - **Making the voltage loop fast.** It then follows the 100 Hz bulk ripple and distorts the line current. Keep it near 10–20 Hz. - **Forgetting the efficiency in the input current.** The table assumes 100 %; the real current is higher by $1/\eta$, and at low line the losses rise. - **Choosing the bulk capacitor for ripple alone.** Hold-up time usually sets it; then check the ripple current rating at 100 Hz plus the switching ripple. - **Testing at one line voltage.** Run 207 V and 253 V too: the peak current and the conduction loss are highest at low line, the inrush and the line peak at high line. ## What about interleaved and bridgeless PFC? - **Interleaved boost**: two legs half a period apart. Their ripple currents cancel in the sum, completely where the duty is 0.5, so the input filter and each inductor get smaller. - **Bridgeless and totem-pole PFC**: remove the bridge diode drops, which matters at high power and high efficiency targets, at the cost of more complex control and sensing. ## How to do it in Voltecx 1. Open **File › Open Example › pfcBoost**: a boost PFC that draws a sine current from 230 V, 50 Hz and holds 400 V DC for a 1 kW load, with an outer voltage loop and an inner current loop that follows the rectified voltage. 2. Run it, then `analysis.fft` on the line current gives each harmonic, the fundamental and the THD. Compare the harmonics with the class limits of IEC 61000-3-2 in your copy of the standard. 3. `interleavedPfc` is the two-phase interleaved version at 2 kW; put the inductor currents and their sum on the scope to see the ripple cancellation. 4. `design.inputProtection` (**Design › Design Steps › Input Protection**) sizes the fuse, the hold-up capacitance, the inrush limiter and an optional surge TVS for a mains input from cited data sheets. See [inrush current limiting](https://voltecx-web.nguyenvanqui291.workers.dev/blog/inrush-current-ntc-sizing). 5. `emi.conducted` estimates the conducted emission against CISPR 32 class A or B; it is a pre-compliance estimate, not a measurement. The [EV charger](https://voltecx-web.nguyenvanqui291.workers.dev/use-cases/ev-charger) and [server power](https://voltecx-web.nguyenvanqui291.workers.dev/use-cases/server-power) pages show where PFC sits in larger systems. ## Frequently asked questions ### What output voltage should a boost PFC have? Above the highest line peak, with margin: 264 V rms peaks at 373 V, which is why 380–400 V is common for universal or 230 V input. ### Why is the PFC voltage loop so slow? The bulk voltage ripples at twice the line frequency by design. A fast voltage loop would follow that ripple and distort the input current, so its crossover is kept around 10–20 Hz. ### How do I size the PFC bulk capacitor? Usually by hold-up time: $C \ge 2 P t_{hold} / (V_{out}^2 - V_{min}^2)$. Then check the twice-line ripple voltage and the capacitor's ripple-current rating. ### Does a PFC need an input EMI filter? Yes. The PFC shapes the low-frequency current, but its switching ripple still needs a differential-mode and common-mode filter to meet conducted-emission limits. --- # Digital, analog or controller IC: choosing how to control a converter URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/digital-vs-analog-vs-controller-ic-control/ Use a controller IC when a standard topology and control method fit, because it brings tested protection, soft start and gate drive in one part; use an analog op-amp compensator when you need a custom loop with no sampling delay; use digital control on a microcontroller when you need flexibility, communication, adaptive behaviour or many converters on one chip. The deciding numbers for digital control are its delay and its PWM resolution. A sampled loop with 1.5 sampling periods of delay loses 54° of phase at a 10 kHz crossover with 100 kHz sampling, and a 170 MHz timer at 200 kHz gives only 850 duty steps. ## The idea: three ways to drive the same car Think of the control loop as the driver of a car. A controller IC is a car with cruise control built in: you set the speed with a few resistors and capacitors, and it handles the common cases very well, with the safety features already fitted. An analog compensator is a driver you train yourself: an op-amp and a handful of parts, reacting continuously and instantly, but you add the safety features. Digital control is a driver who looks at the road through a camera that updates every few microseconds: very clever, able to learn and to talk to other systems, but always reacting to a picture that is slightly old. That last point is the whole trade-off of digital control. The delay and the coarseness of its actions (the PWM resolution) are what this article puts numbers on. ## What are the three options? | | Controller IC | Analog compensator | Digital (MCU, DSP) | |---|---|---|---| | Loop | Fixed method (voltage or peak current mode), external R and C set the compensator | Type II or III network around an op-amp or the controller's error amplifier | Difference equation in firmware | | Protection, soft start | Built in | You add it | You write it | | Delay | None to speak of | None to speak of | Sampling and computation, about 1–1.5 periods | | Flexibility | Low | Medium | High: adaptive gains, mode changes, telemetry | | Parts | One IC, few passives | Op-amp, reference, network | MCU, ADC front ends, gate drivers | | Best for | Standard DC-DC and flyback | Custom analog loops, legacy designs | Inverters, PFC, motor drives, multi-converter systems | ## Why does digital control lose phase margin? A digital loop samples the error, computes, then updates the PWM. A common total delay is 1.5 sampling periods: one for computation and half for the PWM's zero-order hold. A pure delay $T_d$ adds a phase lag of $$\varphi_d = 360^\circ \cdot f_c \cdot T_d$$ With $f_s = 100$ kHz ($T_s = 10$ µs) and $T_d = 1.5\,T_s$: | Crossover $f_c$ | Phase lag | |---|---| | 5 kHz | 27° | | 10 kHz | 54° | At $f_c = f_s/10$, the delay alone eats most of a 60° phase margin target, so digital loops usually cross lower, or sample twice per period, or use a predictive update. ![The phase of a buck's control-to-output transfer function at 100 kHz sampling, from the plant model of Voltecx's design.voltageLoop, with no delay and with 1.5 sampling periods of delay. The two curves part as the frequency rises: 27° apart at 5 kHz and 54° at 10 kHz (vertical lines), which is phase the compensator can no longer use.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/digital-vs-analog-vs-controller-ic-control/delay-phase.svg) On a whole converter the effect is easy to see. `design.compare` designs every method for the same 60° of phase margin on a 48 V to 12 V, 10 A buck at 200 kHz, and keeps a PI's gain margin at 6 dB or more. The analog Type III crosses at 20 kHz; the digital PI, with its 1.5 periods of delay, can only cross at 4.1 kHz. ![The output of the 48 V to 12 V, 10 A buck for a load step from 5 A to 10 A, for the four control methods design.compare designs for 60° of phase margin, on the averaged model in Voltecx. Voltage mode with a Type III network dips 1.74 V and recovers in about 60 µs; the digital PI, crossing at only 4.1 kHz, dips 2.88 V and rings for longer.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/digital-vs-analog-vs-controller-ic-control/compare-load-step.svg) ## What does PWM resolution do? A digital PWM puts each edge on a timer count, so the duty can only take $N = f_{clk}/f_{sw}$ values. With a 170 MHz timer clock at 200 kHz, $N = 850$. In a buck from 48 V, one count moves the output by $$\Delta V_{out} = \frac{V_{in}}{N} = \frac{48}{850} = 56\ \text{mV}$$ which is 0.47 % of a 12 V output. If the ADC resolves the output more finely than one PWM step, the loop hunts between two duty values: a limit cycle. Two cures: a high-resolution PWM, whose sub-count edge step can be 150 ps on some MCUs (TI's F28379D data sheet gives this typical MEP step), giving $150\,\text{ps} \times 200\,\text{kHz} \times 48\ \text{V} = 1.4$ mV per step; or enough integral gain and dither so that the average duty is right. ![The output of the 48 V buck at 200 kHz, open loop, as the commanded duty cycle rises by three timer counts in fifths of a count, simulated in Voltecx with the pwm block's timer resolution. With 850 counts the output moves in 56 mV steps and ignores everything in between; with the 150 ps high-resolution step it follows the command smoothly, 11 mV per fifth of a count.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/digital-vs-analog-vs-controller-ic-control/pwm-resolution.svg) ## How do you choose? - **Standard buck, boost or flyback, under a few hundred watts, no communication**: a controller IC. Check that its control method suits your topology, for example peak current mode for a boost with an RHP zero. - **A loop the ICs don't offer, but no need for software**: an analog compensator, often around the error amplifier of a simple PWM controller. - **Inverters, PFC, motor drives, grid-tied systems, or anything with a state machine, telemetry or adaptive control**: digital. Budget the delay and PWM resolution first. ## Common mistakes - **Designing a digital loop as if it were analog.** Add the 1–1.5 periods of delay to the model before you pick the crossover; otherwise the margin you designed for is not the margin you get. - **Ignoring PWM resolution.** If one timer count moves the output more than the ADC can see, the loop hunts. Compute $V_{in}/N$ and compare it with an ADC count at the output. - **Choosing an IC whose control method does not fit.** A voltage-mode controller on a boost with a low RHP zero leaves very little bandwidth; peak current mode suits it better. - **Forgetting what the IC gives for free.** Soft start, cycle-by-cycle current limit, UVLO and gate drive all have to be designed and tested again in an analog or digital solution. - **Assuming digital is cheaper because it has fewer parts.** The MCU, its ADC front ends and the firmware effort often cost more than a controller IC for a single converter. ## How to do it in Voltecx - **Compare control methods on your converter.** `design.compare` (**Design › Automate › Compare Topologies and Control**) designs voltage mode with a Type III network, peak current mode with a Type II network (Ridley's model), average current mode with two PIs and a digital PI, all for the same phase margin, and simulates each through a load step on a buck, boost or buck-boost. - **Controller ICs.** The behavioural IC library includes a `pwmController` (peak-current-mode, UC384x type), a `syncBuckController` (voltage mode, LM5145 type) and a `syncBoostController` (peak current mode, LM5122 type). Place them with `ic.place`; each is a subsystem with named pins. - **Analog compensators.** The **Voltage loop** task (`design.voltageLoop`) gives a PI or a Type II or III transfer function; the `opAmp` IC model (with `TL072`, `OPA2171` and `TLV9062` presets) builds the network around a real op-amp's gain-bandwidth. - **Digital.** `design.digitalize` turns a loop design into a difference equation in your number format (Tustin, prewarped at the crossover, or matched poles and zeros). The `pwm` block takes the timer `counts` and an `hrpwm` step, and an ISR execution time, so the simulation shows the real delay and resolution. [Code generation](https://voltecx-web.nguyenvanqui291.workers.dev/features/code-generation) writes the C for the MCU. - *In development*: a choice of control implementation inside automatic design (digital firmware, an analog op-amp compensator or a controller IC). See the [design tools overview](https://voltecx-web.nguyenvanqui291.workers.dev/features/design-tools). ## Frequently asked questions ### Is digital control better than analog control for power supplies? Not by itself. Digital control adds flexibility, communication and adaptive behaviour, but also delay and quantisation. For a standard DC-DC converter a controller IC is often simpler, cheaper and faster. ### How much phase does a digital control delay cost? $360° \cdot f_c \cdot T_d$. With 1.5 sampling periods of delay and crossover at a tenth of the sampling frequency, that is 54°. ### What is a limit cycle in digital power control? A steady oscillation between duty values that happens when the ADC resolves the output more finely than the PWM can adjust it. Higher PWM resolution, or integral gain with dither, removes it. ### Can I simulate a controller IC's loop before I build it? Yes, with a behavioural model of the IC that includes its error amplifier, ramp and current-sense path. It is not the vendor's transistor-level model, so check the data sheet's application circuit against it. --- # How to choose the output capacitor of a buck converter URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/buck-output-capacitor-selection/ Size a buck's output capacitor for three things and keep the largest result: the steady-state ripple ($C \ge \Delta I / (8 f_{sw} \Delta V)$ for ceramics, $ESR \le \Delta V / \Delta I$ for electrolytics), the undershoot on a load step ($C \ge \Delta I_{step} / (2\pi f_c \Delta V)$), and the overshoot when the load is released. In most designs the load step, not the ripple, decides. For 5 V at 3 A, 400 kHz with 12 µH, ripple needs only 11 µF, but a 1.5 A step held to 150 mV with a 40 kHz loop needs about 40 µF of effective capacitance. ## The idea: a tank between two pipes Picture the output capacitor as a water tank. The inductor fills it with a current that rises and falls in a triangle; the load drains it at a steady rate. When the inductor delivers more than the load takes, the level (the output voltage) rises a little; when it delivers less, the level falls. That small rise and fall is the output ripple. A load step is a sudden bigger drain. The inductor current cannot jump, so for a few microseconds the tank alone supplies the difference, and the level drops until the control loop opens the tap wider. A bigger tank drops less; a faster loop shortens the time the tank is on its own. ![The buck of this article in Voltecx, with the 12 µH inductor and the output capacitor C1 (40 µF here) feeding a 1.67 Ω load: 5 V at 3 A.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/buck-output-capacitor-selection/buck.svg) So the capacitor has two jobs, and they need different things: small ripple needs enough capacitance (and low ESR) at the switching frequency, while a load step needs enough stored charge for the time the loop takes to react. ## How much capacitance does the ripple need? The inductor's triangular ripple current $\Delta I$ flows into the capacitor. With a ceramic capacitor, whose ESR is small, the ripple voltage comes from the charge: $$\Delta V_C = \frac{\Delta I}{8\, f_{sw}\, C}$$ With an electrolytic or polymer capacitor, the ESR term usually dominates: $$\Delta V_{ESR} = \Delta I \cdot ESR$$ and at high frequency the ESL adds a step at each switching edge. The two terms are roughly in quadrature for a triangle current, so a quick check is to keep each below the target. ![The output ripple of the 36 V, 5 V, 3 A buck simulated in Voltecx, mean removed. 11.2 µF of ceramic (no ESR) gives the 25 mV target with a smooth, rounded wave; 40 µF gives 7 mV. 220 µF with 28 mΩ of ESR gives about 25 mV again, but now it is a sawtooth that follows the inductor current through the ESR.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/buck-output-capacitor-selection/ripple-ceramic-vs-esr.svg) The shape tells you which term dominates: a rounded wave comes from the capacitance, a sharp sawtooth in step with the inductor current comes from the ESR. ## How much capacitance does a load step need? When the load jumps by $\Delta I_{step}$, the capacitor supplies the difference until the loop and the inductor catch up. With a loop crossover at $f_c$, a widely used estimate of the undershoot is $$\Delta V \approx \frac{\Delta I_{step}}{2\pi f_c\, C}$$ so a faster loop needs less capacitance. When the load is released, the inductor's stored energy dumps into the capacitor, and the inductor current can only fall at $V_{out}/L$: $$\Delta V_{release} \approx \frac{L\, \Delta I_{step}^2}{2\, C\, V_{out}}$$ This is the best case: it assumes the loop cuts the duty cycle to zero the moment the load goes away. A loop that reacts more gently overshoots more, so treat it as a floor, not an estimate. Even the floor can set the capacitance by itself with a large inductor at a low output voltage. ## Worked example: 5 V, 3 A, 400 kHz The power stage is the one of [how to size a buck inductor](https://voltecx-web.nguyenvanqui291.workers.dev/blog/buck-inductor-sizing): 12 µH, ripple 0.897 A at the 36 V maximum input. **Ripple**, target 25 mV peak-to-peak (0.5 %): $$C \ge \frac{0.897}{8 \times 400\,\text{kHz} \times 25\,\text{mV}} = 11.2\ \mu\text{F}, \qquad ESR \le \frac{25\,\text{mV}}{0.897\,\text{A}} = 28\ \text{m}\Omega$$ **Load step**, 1.5 A (half load), 150 mV allowed (3 %), loop crossover 40 kHz (one tenth of the switching frequency): $$C \ge \frac{1.5}{2\pi \times 40\,\text{kHz} \times 0.15} = 39.8\ \mu\text{F}$$ **Load release** with 40 µF: $$\Delta V \approx \frac{12\,\mu\text{H} \times 1.5^2}{2 \times 40\,\mu\text{F} \times 5} = 68\ \text{mV}$$ within the 150 mV allowance. The load step sets the value: about **40 µF effective**. The ripple with 40 µF is then $0.897 / (8 \times 400\,\text{k} \times 40\,\mu) = 7$ mV. ### Checking it in simulation The estimates are quick, but a simulation shows whether they hold. Here the buck runs closed loop at 24 V with 40 µF and a Type III compensator that `design.voltageLoop` designed for a 40 kHz crossover. (It reports that with this LC filter it can keep 60° of phase margin only up to about 30 kHz, so this design has 45°.) A 1.5 A load is switched on at 20 µs and off again 100 µs later. ![The load step in Voltecx: the output v(out) and the inductor current i(L1) when 1.5 A of load is added and, 100 µs later, removed. The output dips 134 mV and, on release, rises 127 mV; the inductor current climbs from 3 A to 4.5 A within a few switching periods.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/buck-output-capacitor-selection/load-step.svg) - **Undershoot: 134 mV**, below the 150 mV the estimate gives. The estimate is on the safe side. - **Release overshoot: 127 mV**, almost twice the 68 mV of the energy formula. The linear loop lowers the duty cycle gradually, so the inductor keeps pushing current into the capacitor for longer than the formula assumes. It still fits the 150 mV allowance, but only just. - **Recovery** takes a few tens of microseconds, with a small overshoot, as you would expect from 45° of phase margin. ## Why "effective" capacitance? Class II ceramic capacitors (X5R, X7R) lose capacitance with DC bias. A small-case part at a large fraction of its rated voltage can keep half or less of its nominal value. Read the vendor's DC-bias curve at your output voltage and temperature, then count parts. In this example, if a 22 µF part keeps 11 µF at 5 V, you need four of them, not two. ## How much ripple current must the capacitor carry? The RMS of a triangle of height $\Delta I$ is $$I_{C,rms} = \frac{\Delta I}{\sqrt{12}} = \frac{0.897}{3.46} = 0.26\ \text{A}$$ shared among the parallel parts. This is easy for ceramics; for electrolytics, check the ripple-current rating at your frequency, because it also sets their temperature rise and lifetime. ## Common mistakes - **Sizing for ripple only.** The ripple asked for 11 µF here; the load step asked for 40 µF. Always do the load-step check. - **Counting nominal, not effective, capacitance.** A ceramic capacitor at a large share of its rated voltage can lose half its value. Read the DC-bias curve. - **Treating the release formula as an estimate.** It is the best case. Simulate, or leave margin: here the real overshoot was almost twice the formula. - **Assuming any crossover is reachable.** One tenth of the switching frequency is a ceiling, not a promise: the LC resonance, the ESR zero and the PWM delay decide how much phase margin you can keep there. - **Forgetting the ESL.** At hundreds of kilohertz, a few nanohenries of ESL put spikes on every switching edge. Place small ceramics close to the load. ## How to do it in Voltecx 1. The Design panel's **Converter** task (`design.converter`, `Cmd+Shift+D`) sizes the inductor and the output capacitor for your ripple targets, and after **Apply** simulates to check that the measured output ripple is within 15 % of the target. 2. The **Voltage loop** task (`design.voltageLoop`) designs the compensator for the crossover and phase margin you ask for, then checks it with a 50 % load step, which shows whether the capacitance holds the undershoot. 3. **Simulation › Test Bench** runs the load-step case of your spec with its limits drawn on the scope, so a failing case shows its waveform. 4. Each capacitor takes an ESR and an ESL (`esr`, `esl`); `analysis.impedance` on the output node shows the output impedance of the power stage and capacitor bank against frequency. In [automatic design](https://voltecx-web.nguyenvanqui291.workers.dev/features/auto-design), the robust loop stage sizes the loop over every corner of the spec, and when one part change fixes a failing load step, such as a larger output capacitor, it makes the change and designs the loop again. ## Frequently asked questions ### Which matters more for a buck output capacitor, ripple or load step? Usually the load step. The ripple requirement is often met by a few microfarads of ceramic, while holding a fast load step within a few percent needs several times more. ### How do I calculate output ripple with a ceramic capacitor? $\Delta V = \Delta I / (8 f_{sw} C)$, with $C$ the effective capacitance after DC-bias derating. ### Can I mix ceramic and electrolytic capacitors? Yes, and it is common: ceramics handle the high-frequency ripple and electrolytics or polymers add bulk capacitance and damping for load steps. Check the combined impedance for a resonance between them. ### Does a faster control loop reduce the output capacitance? For the undershoot, yes, roughly in proportion to $1/f_c$. On load release the inductor energy sets a floor that no loop can beat; a slow loop overshoots well above it, and a fast one gets closer to it. --- # How to choose the switching frequency of a DC-DC converter URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/choosing-switching-frequency/ Choose the switching frequency as the highest one at which switching loss stays an acceptable share of the total, then check two hard limits: the controller's minimum on-time at the lowest duty cycle, and where the fundamental and its harmonics land in the conducted-EMI band. Switching loss rises in proportion to frequency while the inductance you need falls in proportion to it, so the answer is a trade-off, not a formula. For a 48 V to 12 V, 10 A buck with 20 ns edges, going from 100 kHz to 400 kHz shrinks the inductor from 30 µH to 7.5 µH but raises the high-side switching loss from 0.96 W to 3.84 W. ## The idea: every switching edge costs a little energy Each time the switch turns on or off, for a few nanoseconds it carries current while voltage is still across it. That overlap burns a small, fixed amount of energy per edge, about $\tfrac{1}{2} V I t$. Switch twice as often and you pay it twice as often: switching loss is simply energy per cycle times cycles per second. What you buy with those extra cycles is a smaller inductor. The inductor only has to carry the load from one switching edge to the next; the shorter that time, the less energy it needs to store, so the inductance falls in proportion to the frequency. Choosing the frequency is deciding how much heat you will pay for how much smaller magnetics. ## What changes with switching frequency? | Rises with $f_{sw}$ | Falls with $f_{sw}$ | |---|---| | Switching loss $\propto f_{sw}$ | Inductance $\propto 1/f_{sw}$ | | Output-capacitance ($C_{oss}$) loss $\propto f_{sw}$ | Output capacitance for the same ripple $\propto 1/f_{sw}^2$ (ceramic) | | Gate-drive loss $\propto f_{sw}$ | Loop bandwidth you can reach ($f_c$ up to about $f_{sw}/10$) | | Core loss per cycle × cycles per second | Size and cost of the magnetics, to a point | | Proximity and skin effect in windings | | Conduction loss barely moves: the RMS current depends on the ripple ratio, which you keep constant by scaling $L$. ## Worked example: 48 V to 12 V, 10 A buck The operating point and device data are the ones of the article on [MOSFET loss and junction temperature](https://voltecx-web.nguyenvanqui291.workers.dev/blog/mosfet-loss-and-thermal-estimation): $D = 0.25$, rise and fall times of 20 ns, $C_{o(er)} = 500$ pF, a ripple ratio kept at 30 %. $$P_{sw} = \tfrac{1}{2} V_{in} I_o (t_r + t_f) f_{sw}, \qquad P_{oss} = \tfrac{1}{2} C_{o(er)} V_{in}^2 f_{sw}, \qquad L = \frac{V_{out}(1-D)}{r I_o f_{sw}}$$ | $f_{sw}$ | $P_{sw}$ | $P_{oss}$ | $L$ for 3 A ripple | |---|---|---|---| | 100 kHz | 0.96 W | 0.058 W | 30 µH | | 200 kHz | 1.92 W | 0.115 W | 15 µH | | 400 kHz | 3.84 W | 0.230 W | 7.5 µH | The high-side conduction loss is about 0.35 W at 80 °C at every frequency. At 100 kHz switching (with $C_{oss}$) is already 74 % of the switch's loss; at 400 kHz it is over 90 %, and the junction would run far hotter on the same heatsink. ![The buck simulated in Voltecx from 50 to 500 kHz, with the inductor rescaled at each point to keep a 30 % ripple. Top: the high-side switch's switching loss rises in a straight line, from 0.96 W at 100 kHz to 3.84 W at 400 kHz, while its conduction loss stays at 0.35 W. Bottom: the inductance needed falls as 1/fsw, from 30 µH at 100 kHz to 7.5 µH at 400 kHz.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/choosing-switching-frequency/loss-and-inductance-vs-fsw.svg) The two curves show the trade-off at a glance. Going from 100 to 200 kHz halves the inductor and costs about 1 W; going from 200 to 400 kHz saves only another 7.5 µH and costs almost 2 W more. ![The inductor current at 100 kHz with 30 µH and at 400 kHz with 7.5 µH, simulated in Voltecx. The ripple is the same 3 A in both; at 400 kHz the inductor only has to carry the current for a quarter of the time, which is why a quarter of the inductance is enough.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/choosing-switching-frequency/inductor-current-100k-vs-400k.svg) With these switching times, 100 to 200 kHz is the sensible range. A part with faster edges, or a soft-switching topology, moves it up. For a sweep from 100 kHz to 1 MHz with a real MOSFET's data-sheet loss model, the efficiency, the ripple and the knee of the trade-off, see the [worked example](https://voltecx-web.nguyenvanqui291.workers.dev/blog/switching-frequency-sweep-worked-example). ## What limits the frequency at low duty cycle? Every controller has a minimum on-time, often tens to a few hundred nanoseconds; take it from the data sheet. The on-time is $t_{on} = D / f_{sw}$, so $$f_{sw,max} = \frac{D_{min}}{t_{on,min}}$$ From 48 V to 1 V, $D = 0.0208$. With a 100 ns minimum on-time, the converter cannot regulate above $0.0208 / 100\,\text{ns} = 208$ kHz; above it, the controller skips pulses or the output rises. Two-stage conversion (48 V to 12 V, then 12 V to 1 V) is often the answer at large step-down ratios. ## How does frequency interact with EMI? Conducted-emission limits such as those of CISPR 32 start at 150 kHz. A converter switching just below 150 kHz keeps its fundamental out of the band, although its second and higher harmonics still fall inside it. Above the band start, the fundamental is the largest line in the spectrum and usually sets the size of the input filter. The filter's corner must sit about a decade below the frequency it has to attenuate by 40 dB, so a higher switching frequency allows a smaller filter for the same attenuation. Spread-spectrum modulation lowers the measured peak but not the energy. See [conducted EMI pre-compliance in simulation](https://voltecx-web.nguyenvanqui291.workers.dev/blog/conducted-emi-pre-compliance). ![The conducted spectrum Voltecx estimates for the 48 V buck (no input filter), up to 3 MHz, against the CISPR 32 class B average limit. At 140 kHz the fundamental is below the band, and the largest line is the second harmonic at 280 kHz, 42.5 dB over the limit. At 200 kHz the fundamental itself is the largest line, 48.6 dB over.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/choosing-switching-frequency/spectrum-140k-vs-200k.svg) Moving from 200 to 140 kHz lowers the attenuation the input filter must give by about 6 dB. It does not make the filter go away: every harmonic above 150 kHz still needs it. ## Common mistakes - **Choosing the frequency first and the switch later.** The answer depends on the switch's edges. With 20 ns edges 100 to 200 kHz is sensible; a part with 5 ns edges moves the whole loss line down by a factor of four. - **Forgetting $C_{oss}$ and gate-drive loss.** They are small at 100 kHz but grow with frequency like the switching loss, and $C_{oss}$ loss does not shrink with faster edges. - **Ignoring the minimum on-time.** At a large step-down ratio the controller may simply not be able to make pulses that short. Check $D_{min}/t_{on,min}$ before falling in love with a frequency. - **Landing the fundamental just above 150 kHz.** That puts the largest line of the spectrum where the limit is strict. Either stay below 150 kHz or plan the filter for the fundamental. - **Expecting a smaller inductor to mean a smaller converter.** Above some frequency, the heatsink grows faster than the magnetics shrink. ## How to do it in Voltecx - **Sweep the frequency.** `analysis.paramSweep` runs the circuit for a list of values of a parameter, such as the PWM frequency, and returns each result; pair it with `analysis.losses` to see conduction and switching loss of each switch at each point. - **Size at each point.** The Design panel's **Converter** task (`design.converter`) sizes L and C for the frequency you give it and adds a switching-frequency hint. `design.efficiency` gives the efficiency at four loads and the loss of each device, and `design.thermal` the junction temperatures and the heatsink you need. - **Let the optimiser choose.** `analysis.pareto` searches the design space and returns the efficiency-against-size front. Automatic design (`design.auto`, **Design › Auto Design**) uses 100 kHz for a DC-DC converter unless you give `fsw`; with `auto.mode` set to `pareto` it takes the switching frequency and ripple from the knee of that front. - **Check EMI.** `emi.conducted` (**Design › Automate › Conducted EMI**) estimates the spectrum at each candidate frequency against the CISPR 32 limit. It is a pre-compliance estimate, not a measurement. See the [design tools overview](https://voltecx-web.nguyenvanqui291.workers.dev/features/design-tools) for where these steps sit in the flow. ## Frequently asked questions ### Is a higher switching frequency always more efficient? No. Higher frequency usually lowers efficiency, because switching, $C_{oss}$, gate and core losses all grow with it. It buys smaller magnetics and capacitors and a faster loop. ### What frequency do most DC-DC converters use? There is no single answer. Silicon hard-switched converters of tens to hundreds of watts often run between 100 kHz and 1 MHz; GaN and soft-switching topologies run higher. Derive it from your switching times and loss budget as above. ### Why avoid switching just above 150 kHz? Because conducted-emission limits start at 150 kHz, so a fundamental just above it falls in the band at its largest amplitude. Just below 150 kHz only the harmonics are inside the band. ### How does minimum on-time limit the frequency? The on-time $D/f_{sw}$ must stay above the controller's minimum on-time. At low duty cycle that sets the highest usable frequency: $f_{sw,max} = D_{min}/t_{on,min}$. --- # How to size a buck converter inductor URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/buck-inductor-sizing/ Size a buck inductor at the highest input voltage: $L = V_{out}(1 - D) / (f_{sw}\,\Delta I)$, with the ripple $\Delta I$ set to 20 to 40 % of the full-load current. Then pick a part whose saturation current is above the peak current at your current limit and whose RMS rating covers the full-load current. For 5 V at 3 A from up to 36 V at 400 kHz, a 30 % ripple gives 12 µH, a 3.45 A peak and a 3.01 A RMS current. ## The idea in one picture Think of the inductor as a flywheel for current. While the switch is on, the input pushes it and the current speeds up; while the switch is off, the output brakes it and the current slows down. The flywheel never stops: it only wobbles around the load current. That wobble is the ripple, and the inductance is how heavy the flywheel is. A heavy flywheel (large $L$) wobbles a little; a light one wobbles a lot. ![The buck of this article in Voltecx: switch S1, freewheeling diode D1, inductor L1 = 12 µH, output capacitor C1 = 40 µF and a 1.67 Ω load (3 A at 5 V), driven open loop at D = 5 V / Vin.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/buck-inductor-sizing/buck.svg) Sizing the inductor is choosing how much wobble you accept. Everything else in this article, the peak current, the RMS current, the saturation rating, follows from that one choice. ## Why does the ripple ratio decide the inductance? The inductor current in a buck is a triangle on top of the load current. Its peak-to-peak height is $$\Delta I = \frac{(V_{in} - V_{out})\,D}{f_{sw}\,L} = \frac{V_{out}(1 - D)}{f_{sw}\,L}, \qquad D = \frac{V_{out}}{V_{in}}$$ (R. W. Erickson and D. Maksimović, *Fundamentals of Power Electronics*, the chapter on steady-state converter analysis). Write the ripple as a fraction of the load current, $r = \Delta I / I_o$, and solve for $L$: $$L = \frac{V_{out}(1 - D)}{r\, I_o\, f_{sw}}$$ The ratio $r$ is a trade-off: - **Small $r$ (10–20 %)**: low output ripple and low core loss, but a large, slow inductor. The current can change only at $(V_{in} - V_{out})/L$, so the loop answers a load step more slowly. - **Large $r$ (40–60 %)**: a small inductor and a fast response, but more RMS current in the output capacitor, a higher peak current in the switch and more core loss. - **Around 30 %** is the usual starting point, and a common choice in controller data-sheet design examples. ![The inductor current i(L1) simulated in Voltecx at 36 V input and 3 A load with three inductors: 36 µH gives a ripple ratio of 0.1, 12 µH gives 0.3 and 6 µH gives 0.6. The average stays at 3 A; only the triangle changes.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/buck-inductor-sizing/ripple-ratio.svg) All three triangles average to the same 3 A. A smaller inductor does not change what the load gets; it changes how hard the current swings around it, and with it the peak the switch and the inductor must survive. ## Which input voltage should I design at? At the highest one. $1 - D = 1 - V_{out}/V_{in}$ grows as $V_{in}$ rises, so the ripple is largest at maximum input. An inductor sized at nominal input has more ripple than you planned at high line. Intuitively: at high input the switch is on for a shorter time, but the off-time, when the output voltage brakes the current, gets longer. The current falls for longer, so the triangle gets taller. ![The inductor current with 12 µH at 36 V and at 18 V input, simulated in Voltecx. At 36 V the on-time is shorter and the ramp steeper, and the triangle is taller: 0.897 A against 0.752 A.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/buck-inductor-sizing/ripple-18-vs-36v.svg) ![The simulated ripple over the 18 to 36 V input range. 12 µH stays at or under the 0.9 A target everywhere; 10 µH, which is enough at 18 V, reaches 1.08 A at 36 V.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/buck-inductor-sizing/ripple-vs-vin.svg) ## Worked example: 18–36 V to 5 V at 3 A, 400 kHz **Required inductance at each input** for $r = 0.3$ ($\Delta I = 0.9$ A): | $V_{in}$ | $D$ | $L$ for 0.9 A ripple | |---|---|---| | 18 V | 0.278 | 10.0 µH | | 24 V | 0.208 | 11.0 µH | | 36 V | 0.139 | 11.96 µH | Take the worst case, 11.96 µH, and round to the standard value **12 µH**. **Ripple and peak current with 12 µH.** At 36 V: $\Delta I = 5 \times 0.861 / (400\,\text{kHz} \times 12\,\mu\text{H}) = 0.897$ A, so the peak is $3 + 0.897/2 = 3.45$ A. At 18 V the ripple falls to 0.752 A. **RMS current**, which sets the winding loss: $$I_{L,rms} = I_o\sqrt{1 + \frac{r^2}{12}} = 3\sqrt{1 + \frac{0.299^2}{12}} = 3.01\ \text{A}$$ The ripple adds almost nothing to the RMS current at this ratio, which is why the inductor's RMS (heating) rating can be read at the DC load current. **Light load.** The converter leaves continuous conduction when the load drops below half the ripple, $I_{crit} = \Delta I / 2 = 0.45$ A at 36 V. Below that, a diode buck goes into discontinuous conduction and its gain changes; a synchronous buck in forced PWM keeps conducting with a negative current dip instead. ![The same buck at a 0.3 A load, below the 0.45 A critical current, simulated in Voltecx. The inductor current reaches zero and rests there each period, and the switch node v(sw) steps up to the output voltage while no current flows. With the duty cycle unchanged, the open-loop output rises from 5 V to 6.0 V.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/buck-inductor-sizing/light-load-dcm.svg) **Stored energy**, a first measure of core size: $\tfrac{1}{2} L I_{pk}^2 = \tfrac{1}{2} \times 12\,\mu\text{H} \times 3.45^2 = 71\ \mu\text{J}$. ## How much saturation current does the inductor need? The peak current at full load is not enough. During start-up, a load step or a short, the current rises to the controller's current limit before the loop reacts. Choose $I_{sat}$ above that limit, read at your hottest operating temperature: ferrite saturation flux falls as the core heats. Two ratings appear on inductor data sheets: - **$I_{sat}$**: the current at which the inductance drops by a stated amount (often 20 or 30 %). Read the footnote; vendors define it differently. - **$I_{rms}$** (or $I_{temp}$): the DC current that raises the part's temperature by a stated amount, often 40 K. It covers winding loss but not always core loss at your frequency and ripple. For the example, with a current limit set 30 % above the 3.45 A peak (4.5 A), look for a 12 µH part rated at least 4.5 A saturation at temperature and at least 3 A RMS. ## What about core loss? Core loss grows with the flux swing, which is proportional to the ripple, and with frequency. Halving $r$ by doubling $L$ lowers core loss but raises winding resistance for the same core. Use the vendor's loss calculator or the Steinmetz parameters of the core material for the final check, at the ripple and frequency of the highest input voltage. ## Common mistakes - **Sizing at nominal input.** The ripple is largest at the highest input voltage. An inductor sized at 24 V (11 µH) has 0.978 A of ripple at 36 V, about 9 % over its target. - **Choosing $I_{sat}$ from the full-load peak.** At start-up or in a short, the current climbs to the current limit. Use the limit, at the hottest temperature. - **Reading $I_{sat}$ and $I_{rms}$ as the same thing.** One is about the core (inductance collapses), the other about heat (the winding warms up). Check both. - **Forgetting light load.** Below $\Delta I / 2$ a diode buck goes discontinuous and its gain changes, which the loop then has to cope with. If that matters, use a synchronous buck in forced PWM or a larger $L$. - **Trusting the nominal inductance near $I_{sat}$.** At its rated saturation current an inductor has, by definition, already lost the stated 20 or 30 % of its inductance, and powder cores lose it gradually from much lower currents. Near the peak the ripple is then larger than you computed. ## How to do it in Voltecx 1. Open the `buck` example (**File › Open Example › buck**) or draw a buck with `circuit.template`. 2. Open the Design panel (**Design**, or `Cmd+Shift+D`) and choose **Converter** (`design.converter`). The fields start with the voltages, load and frequency already in the circuit; set the inductor ripple to 30 %. 3. Press **Run** to see the inductance and capacitance, the formula used and a plot, then **Apply** to write L1 and C1 as one undo step. The panel then simulates and checks that the measured inductor ripple and output ripple are within 15 % of the target and the mean output within 5 % of the set point. 4. Run `analysis.stress` after a simulation to read the inductor's peak and RMS current, or put the worst input in **Simulation › Test Bench** to check every corner of the spec. The same command runs from a script: ```sh powercraft-cli run --in buck.pcraft \ --cmd design.converter --params '{"vout": 5, "iout": 3, "ripplePct": 30}' ``` For a whole design, from the spec to a part number, see [automatic design](https://voltecx-web.nguyenvanqui291.workers.dev/features/auto-design) and the [design tools overview](https://voltecx-web.nguyenvanqui291.workers.dev/features/design-tools). ## Frequently asked questions ### What ripple percentage should a buck inductor have? 20 to 40 % of the full-load current is the common range, with 30 % as the usual starting point. Go lower when output ripple or core loss matters most, higher when you need a small part or a fast load response. ### Why size the inductor at maximum input voltage? The ripple $\Delta I = V_{out}(1-D)/(f_{sw}L)$ grows as $D$ falls, and $D$ is smallest at the highest input voltage. Sizing there keeps the ripple within your target over the whole range. ### Is the inductor's saturation current the same as its RMS rating? No. Saturation current is where the inductance drops; RMS current is where the part gets too hot. You need both: saturation above the peak at your current limit, RMS above the full-load current. ### Does a higher switching frequency always mean a smaller inductor? The inductance falls in proportion to $1/f_{sw}$, but switching and core losses rise, so the gain stops somewhere. See [how to choose a switching frequency](https://voltecx-web.nguyenvanqui291.workers.dev/blog/choosing-switching-frequency). --- # Input filter design and Middlebrook's stability criterion URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/input-filter-middlebrook-stability/ A regulated converter draws constant power, so its input looks like a negative resistance $-V_{in}^2/P$, and an undamped LC input filter in front of it can oscillate. Middlebrook's criterion keeps the system stable: the filter's peak output impedance must stay well below the magnitude of the converter's input impedance at every frequency. In practice you add a damping branch; for a 10 µH, 10 µF filter in front of a 120 W converter at 36 V, a 0.61 Ω resistor in series with 40 µF lowers the peak from about 67 Ω to 0.84 Ω, against a converter input impedance of 10.8 Ω. ## The idea: a swing and someone who pushes at the wrong time An LC filter is like a swing: give it a push and it rocks back and forth at its own frequency, $f_0$, a little less each time because of friction (the filter's small resistances). An ordinary resistive load adds more friction. A regulated converter does the opposite. When the bus voltage rises, it draws *less* current; when the voltage falls, it draws *more*. Every time, it pushes the swing in the direction it is already going. If that push is stronger than the friction, the swing goes higher each cycle: the filter oscillates, by itself, with nothing wrong in either the filter or the converter alone. Damping is adding enough friction at $f_0$ that the converter's push can never win. ## Why does a converter's input look like a negative resistance? A closed-loop converter holds its output power $P$ constant. If the input voltage rises, the input current falls: $I_{in} = P / V_{in}$. The small-signal slope is $$Z_{in} = \frac{dV_{in}}{dI_{in}} = -\frac{V_{in}^2}{P}$$ within the loop bandwidth. A negative resistance across the filter capacitor cancels the filter's own losses, and if its magnitude is smaller than the filter's resonant impedance, the LC rings up instead of decaying. ## What is Middlebrook's criterion? R. D. Middlebrook (1976) showed that adding an input filter changes the converter's control-to-output transfer function by a correction factor that depends on the ratio $Z_o / Z_N$ and $Z_o / Z_D$, where $Z_o$ is the filter's output impedance and $Z_N$, $Z_D$ are the converter's input impedances with the output nulled and with the duty cycle held. The design rule that follows (Erickson and Maksimović, *Fundamentals of Power Electronics*, the chapter on input filter design) is: $$\|Z_o\| \ll \|Z_N\| \quad \text{and} \quad \|Z_o\| \ll \|Z_D\|$$ at all frequencies. For a buck in its loop bandwidth, $\|Z_N\| \approx V_{in}^2/P$. A margin of 3 times (about 10 dB) is a common target, and the one Voltecx's automatic design uses. ## Worked example: a 120 W buck at 36 V minimum input Use the lowest input voltage at full load, where $V_{in}^2/P$ is smallest: $$\|Z_N\| \approx \frac{36^2}{120} = 10.8\ \Omega$$ The filter is $L_f = 10$ µH and $C_f = 10$ µF: $$f_0 = \frac{1}{2\pi\sqrt{L_f C_f}} = 15.9\ \text{kHz}, \qquad R_0 = \sqrt{\frac{L_f}{C_f}} = 1.0\ \Omega$$ ### How big is the peak without damping? With only parasitic losses, 10 mΩ of inductor resistance and 5 mΩ of capacitor ESR, the quality factor is about $R_0 / 0.015 = 67$ and the output impedance peaks near **67 Ω** at 15.9 kHz. That is six times the 10.8 Ω the converter presents, so the criterion fails badly: the system will ring or oscillate at about 16 kHz. ![The input filter of this article in Voltecx with its damping branch: Lf = 10 µH and Cf = 10 µF from the 36 V source, and Rd = 0.61 Ω in series with Cd = 40 µF across Cf. The converter connects across Cf.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/input-filter-middlebrook-stability/damped-filter.svg) ### How do you damp it? A resistor $R_d$ in series with a blocking capacitor $C_d = n C_f$, across $C_f$, damps the resonance without dissipating at DC. For a given $n$ the optimum resistance and the resulting peak are (Erickson and Maksimović, input filter design): $$R_{d,opt} = R_0\sqrt{\frac{(2+n)(4+3n)}{2n^2(4+n)}}, \qquad \|Z_o\|_{peak} = R_0\,\frac{\sqrt{2(2+n)}}{n}$$ With $n = 4$ ($C_d = 40$ µF): $$R_{d,opt} = 1.0\sqrt{\frac{6 \times 16}{2 \times 16 \times 8}} = 0.61\ \Omega, \qquad \|Z_o\|_{peak} = \frac{\sqrt{12}}{4} = 0.87\ \Omega$$ Measured with Voltecx's `analysis.impedance` on the same network, with the 10 mΩ and 5 mΩ parasitics included, the peak is 0.84 Ω, a little lower than the lossless formula. Against 10.8 Ω the margin is about 22 dB, well above 10 dB. ![The filter's output impedance seen from the converter, measured with analysis.impedance in Voltecx. Undamped, it peaks at 67 Ω (36.5 dBΩ) at 15.9 kHz, far above the converter's 10.8 Ω (upper line) and the 3.6 Ω target that keeps a 3× margin (lower line). Damped, the peak drops to 0.84 Ω and moves down to about 9 kHz.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/input-filter-middlebrook-stability/output-impedance.svg) ### What happens in the time domain? Replace the converter by what it looks like from the bus, a constant-power load of 120 W (Voltecx's `powerLoad`), and step it from 100 W to 120 W. ![The bus voltage with the converter as a 120 W constant-power load, simulated in Voltecx; the load steps up at the vertical line. Undamped, the bus oscillates at about 16 kHz and the oscillation grows every cycle until the bus swings over 100 V. Damped, it dips 0.27 V on the step and settles in about 200 µs.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/input-filter-middlebrook-stability/bus-voltage.svg) Neither the filter nor the load is faulty on its own. The oscillation comes from the combination, which is why it is so often found only when the two boards are first connected. ### Does the damping cost attenuation? Little. At a 200 kHz switching frequency the damped filter attenuates by 44 dB, the same as the undamped LC's $(f_0/f)^2$. The blocking capacitor is larger than $C_f$, but it carries only a small ripple current and can be an electrolytic whose ESR is part of $R_d$. ### Other damping choices - **$R_d$ in parallel with $L_f$**, with a series inductor to block DC current: smaller parts, but the resistor carries ripple. - **Electrolytic ESR as the damper**: an electrolytic bulk capacitor across the input with the right ESR does the same job at no extra parts, if its ESR stays in range over temperature and life. ## Common mistakes - **Checking at nominal input.** $V_{in}^2/P$ is smallest at the lowest input and full load; that is where the margin is thinnest. - **Relying on parasitic damping.** 10 mΩ of DCR and 5 mΩ of ESR left a 67 Ω peak here. Real damping needs a resistor sized for it. - **Putting a plain resistor across $C_f$.** It damps, but it burns $V_{in}^2/R$ all the time. A blocking capacitor in series keeps it out of the DC path. - **Using an ideal ceramic for bulk.** A low-ESR ceramic in place of an electrolytic can remove damping that the design silently relied on. - **Testing with a resistive load.** A resistor has positive resistance and makes the filter look stable. Test with the converter, or with a constant-power load. ## How to do it in Voltecx 1. Draw the filter in front of your converter, or let `emi.conducted` size one (**Design › Automate › Conducted EMI**). It sizes a damped LC filter when the emission margin is short, and holds the filter's peak output impedance 3 times below $V_{in,min}^2/P$, the condition above. 2. Measure the filter's output impedance with `analysis.impedance`, which injects a current into a node and returns $Z = v/I$ against frequency: `{"node": "vbus"}` on the node between filter and converter. Compare its peak with $V_{in,min}^2/P$. 3. Check the loop with the filter in place: `analysis.loopGain` on the switching circuit finds the periodic steady state first and reads the loop gain from it, so the filter's effect on the phase margin shows directly. 4. Run a load step at the lowest input in **Simulation › Test Bench** and watch the bus voltage for ringing at $f_0$. [Analyses in Voltecx](https://voltecx-web.nguyenvanqui291.workers.dev/features/analyses) lists the frequency-domain tools; the [design tools overview](https://voltecx-web.nguyenvanqui291.workers.dev/features/design-tools) shows where the EMI and filter step sits. ## Frequently asked questions ### Why does adding an input filter make my converter oscillate? The regulated converter's input behaves as a negative resistance $-V^2/P$. When the filter's resonant impedance is larger than that, the negative resistance cancels the filter's damping and the LC oscillates. ### What is a safe margin for Middlebrook's criterion? Keep the filter's peak output impedance at least about 3 times (10 dB) below the converter's input impedance magnitude at the lowest input voltage and full load. More margin means less change in the loop gain. ### Can I just use a bigger filter capacitor? A bigger $C_f$ lowers $R_0 = \sqrt{L_f/C_f}$, which helps, but an undamped LC still has a high Q peak. You need real damping: a resistor branch or a lossy capacitor. ### Which operating point is the worst case? The lowest input voltage at the highest load power, where $V_{in}^2/P$ is smallest. --- # Inrush current: how to estimate it and size an NTC limiter URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/inrush-current-ntc-sizing/ At switch-on, an empty bulk capacitor behind a rectifier looks like a short, so the inrush peak is the line peak divided by the total series resistance: often hundreds of amperes. An NTC thermistor in series limits it to $V_{pk}/(R_{NTC,cold} + R_{series})$, but it must also absorb an energy about equal to the energy stored in the capacitor, $\tfrac{1}{2}CV_{pk}^2$, on every start. For 330 µF at 264 V rms, the peak falls from about 750 A to 36 A with a 10 Ω NTC, which must then handle about 23 J per start. ## The idea: filling an empty tank from a fire hose An empty bulk capacitor is like an empty tank, and the mains at its peak is a fire hose at full pressure. Open the valve and the only thing that limits the flow is the hose itself: a few tenths of an ohm of wiring, rectifier and capacitor ESR. The water rushes in all at once. An NTC thermistor is a narrow section of pipe at the start, which slows the first rush. Once the tank is full and water flows only as fast as it is used, the narrow section warms up and widens (its resistance falls), so it costs little in normal running. Two catches: the narrow section has to survive the heat of every fill, and if you refill while it is still warm, it is already wide and limits nothing. ## Why is inrush current a problem? - It can blow the input fuse or trip a breaker at switch-on. - It stresses the bridge rectifier's surge rating ($I_{FSM}$) and the input relay or switch contacts. - Many installations and standards limit the inrush current a product may draw. The worst case is switching on at the peak of the highest line voltage with a fully discharged capacitor. ## Worked example: 330 µF bulk, 264 V rms maximum line **Line peak:** $V_{pk} = 264\sqrt{2} = 373$ V. **Without a limiter**, with 0.5 Ω total of line, wiring, rectifier and capacitor ESR (take your own value; the source impedance of the mains varies a lot): $$I_{pk} = \frac{373}{0.5} = 747\ \text{A}$$ **With a 10 Ω (at 25 °C) NTC:** $$I_{pk} = \frac{373}{10 + 0.5} = 35.6\ \text{A}$$ This assumes the NTC is cold. Its resistance falls as it heats, but most of the charge has gone by then, so the cold value sets the peak. ![The inrush current simulated in Voltecx when 264 V rms is switched on at its peak into an empty 330 µF capacitor through a diode bridge. Top: with only 0.5 Ω in the path, the current starts at 744 A and the charge is over in under a millisecond. Bottom: with the 10 Ω cold NTC added, it starts at 35.6 A, and the capacitor keeps charging over the following line peaks.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/inrush-current-ntc-sizing/inrush-current.svg) ![The bus voltage for the same two cases. Through 0.5 Ω the capacitor reaches the line peak within the first half cycle; through 10.5 Ω it takes several half cycles, a step at each line peak.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/inrush-current-ntc-sizing/bus-voltage.svg) **Energy.** Charging a capacitor through a resistor dissipates as much energy in the resistor as ends up in the capacitor, whatever the resistance: $$E = \tfrac{1}{2} C V_{pk}^2 = \tfrac{1}{2} \times 330\,\mu\text{F} \times 373^2 = 23\ \text{J}$$ That holds exactly for a DC source. From the mains it is the worst case: the line voltage is already falling while the capacitor charges, and the later peaks top it up gently. Simulated in Voltecx at switch-on at the peak, the series resistance takes 22.8 J with 0.5 Ω, where the charge is over almost at once, but 19.3 J with the 10 Ω NTC in place. ![The energy taken by the series resistance since switch-on, simulated in Voltecx. With 0.5 Ω it jumps to 22.8 J in the first millisecond, close to the 23 J stored in the capacitor (horizontal line). With 10.5 Ω it climbs in steps, one per line peak, to 19.3 J.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/inrush-current-ntc-sizing/energy.svg) Inrush NTC data sheets rate this as a maximum energy or a maximum capacitance at a given voltage. Size for the worst case: choose a part whose rating covers 23 J (or 330 µF at 264 V) with margin. **Steady state.** Once warm, the NTC's resistance drops to a fraction of an ohm, but it still dissipates $I_{rms}^2 R_{hot}$. With 2 A rms input and 0.4 Ω hot (read the data sheet's resistance at your current), that is 1.6 W, enough to matter for efficiency and for the part's temperature. ## What are the limits of an NTC? - **Hot restart.** After a short power interruption, the NTC is still hot and its resistance low, so it barely limits the next inrush. A relay or triac that bypasses the NTC after start-up, with the NTC left to cool, fixes both this and the steady-state loss. - **Cold start.** At low ambient temperature the NTC's resistance is higher, which slows start-up and may trip an undervoltage lockout. - **Efficiency.** At high power the steady-state loss of an NTC alone is often unacceptable, which is why larger supplies use an active limiter or a bypass. ## What are the alternatives? - **Resistor plus bypass relay**: a fixed resistor limits the inrush, a relay shorts it once the bus has charged. - **Active limit**: a MOSFET in the return path, ramped on slowly, so the charge current is set by the gate ramp. Common on DC inputs and in hot-swap circuits. - **Soft-start through the PFC stage**: some bridgeless designs control the bus charge with their own switches. ## Common mistakes - **Sizing at nominal line.** The peak current and the energy both grow with the line voltage; use the highest line, switched on at its peak. - **Checking only the peak current.** An NTC that limits the current but cannot absorb the energy cracks after a few starts. Check the energy (or capacitance) rating too. - **Forgetting the hot restart.** A brief dropout leaves the NTC hot and nearly transparent. If the product can be switched off and on quickly, add a bypass or an active limiter. - **Ignoring the steady-state loss.** 0.4 Ω at 2 A is 1.6 W, which can be a large share of a small supply's loss. - **Counting on the mains impedance.** It varies a lot between installations. Do not rely on it to limit the peak. ## How to do it in Voltecx - **Size it from the spec.** `design.inputProtection` (**Design › Design Steps › Input Protection**) sizes the input protection from the spec and the circuit, each part from a cited data sheet. For an AC input (give `vinAc` and `fline`) the default inrush limiter is an NTC (TDK S237 and S364 series), with the peak current, I²t and energy held to `inrushMax`; `inrush` can also be an active limit or none. It also picks the fuse (Littelfuse 215 time-lag and 451 fast-acting) for its pulse withstand over 100,000 switch-ons by default, the hold-up capacitance, a surge TVS when you give an IEC 61000-4-5 level, and reverse-polarity protection for DC inputs. - **See it on the scope.** The `inputProtection` example shows the parts in a circuit; run it and look at the input current at switch-on. - **Check it on the Test Bench.** **Simulation › Test Bench** runs an inrush case from your spec with the limit drawn on the scope. `design.inputProtection` changes nothing in the circuit by itself; it reports the parts and their checks. The AC input current it uses is the unity-power-factor current, a lower bound. ## Frequently asked questions ### How do I calculate inrush current? For a capacitor-input rectifier switched on at the line peak: $I_{pk} = V_{pk} / R_{total}$, where $R_{total}$ is the sum of the limiter, wiring, rectifier and capacitor ESR and the source resistance. ### How much energy does an inrush NTC absorb? At most about the energy stored in the capacitor at the line peak, $\tfrac{1}{2} C V_{pk}^2$, on each start; switched on at the peak through a small resistance it comes close to that. Check it against the NTC's energy or capacitance rating. ### Why doesn't the NTC protect after a quick power cycle? Because it is still hot and its resistance is low. Use a bypass relay and let the NTC cool, or an active limiter. ### Is an NTC needed on a DC input? Often an active limit (a MOSFET with a controlled turn-on) is used instead, because an NTC's steady-state loss and hot-restart behaviour are worse for battery and bus inputs. --- # LDO post-regulator for an auxiliary 3.3 V rail: dropout, PSRR and heat URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/ldo-post-regulator-aux-rail/ An LDO after a switching converter makes a quiet auxiliary rail, such as 3.3 V for a microcontroller, when three checks pass: the input stays above $V_{out}$ plus the worst-case dropout, the LDO's ripple rejection (PSRR) at the switching frequency brings the converter's ripple down far enough, and the dissipation $(V_{in} - V_{out}) I_{out}$ keeps the junction below its limit. For 5 V to 3.3 V at 150 mA with a TI LP5907 in SOT-23-5, the headroom is 1.7 V against a 250 mV maximum dropout, the LDO dissipates 0.26 W and the junction reaches about 99 °C at 50 °C ambient. ## The idea: a valve that burns the difference An LDO is a valve between the input and the output that opens and closes, very fast, to keep the output at 3.3 V. Whatever voltage is left over, $V_{in} - V_{out}$, drops across the valve, and the valve turns it into heat: every milliampere the load takes passes through it. That picture gives all three checks at once: - The valve can only drop voltage, never add it, and even fully open it drops a little: the **dropout**. Below $V_{out}$ plus dropout, the output follows the input down. - The valve moves to cancel changes in the input, so it also cancels ripple, well at low frequency and less well at hundreds of kilohertz, where it cannot move fast enough: the **PSRR**. - The heat is the leftover voltage times the current: the **dissipation**. ## When is an LDO the right choice for an auxiliary rail? - **Low current and a small step.** Efficiency is about $V_{out}/V_{in}$: 66 % from 5 V to 3.3 V, 28 % from 12 V. At tens or a few hundred milliamps the lost power is small. - **Noise-sensitive loads**: ADC references, clocks, RF and sensor supplies, where switching ripple matters. - **Simplicity**: no inductor, no switching noise of its own, a few capacitors. When the step is large or the current is high, a small buck, or a buck followed by an LDO, is better. ## Check 1: is there enough headroom? The LDO stops regulating when $V_{in} - V_{out}$ falls below its dropout voltage. Use the maximum dropout at your current and hottest junction, and the lowest input including ripple: $$V_{in,min} - \frac{\Delta V_{in}}{2} \ge V_{out} + V_{DO,max}$$ The LP5907 data sheet (TI SNVS798Q, Electrical Characteristics) gives a dropout of 50 mV typical at 100 mA, and 120 mV typical, 250 mV maximum at 250 mA for the SOT-23 and X2SON packages. From a 5 V rail, 3.3 V has 1.7 V of headroom, so dropout is not a concern. From a 3.6 V rail it would be, once tolerance and ripple are subtracted. ![The `ldo` model in Voltecx (LP5907 3.3 V) at 150 mA while its input ramps from 3.0 to 4.0 V. In dropout the output follows the input 72 mV below it, the typical dropout at this current; it regulates once the input passes about 3.37 V. The vertical line is 3.55 V, the 3.3 V output plus the data sheet's 250 mV maximum dropout.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/ldo-post-regulator-aux-rail/dropout.svg) The model uses the typical dropout. Design with the maximum: the gap between 3.37 V and 3.55 V is what tolerance and temperature can take away. The same data sheet limits the input to 5.5 V (Recommended Operating Conditions), so this LDO cannot run from a 12 V rail at all. Check the input range before anything else. ## Check 2: how much ripple gets through? An LDO's PSRR falls with frequency, and switching converters ripple at hundreds of kilohertz, where the PSRR is lowest. The LP5907 table gives 60 dB at 100 kHz (at 20 mA, $V_{in} = V_{out} + 1$ V, 1 µF in and out); its PSRR plot (Figure 5-20, measured at $V_{in} = 3.7$ V, $V_{out} = 2.8$ V) shows about 45 dB at 1 MHz. For a buck output with 20 mV peak-to-peak ripple at 400 kHz, a conservative estimate uses the lower, 1 MHz value: $$\Delta V_{out} = 20\,\text{mV} \times 10^{-45/20} = 0.11\ \text{mV}$$ Two cautions: PSRR shrinks as the headroom approaches dropout, and it depends on the output capacitor and load current. Read the curve at conditions near yours, and don't interpolate between conditions the data sheet doesn't give. ### What a model can and cannot tell you ![The rejection of Voltecx's ldo model, measured with a sine on the input at each frequency, against the LP5907 data sheet. Up to 100 kHz the model follows the data sheet's table (82 dB at 1 kHz, 65 dB at 10 kHz, 60 dB at 100 kHz). Above that the table stops; the model rises to 64 dB at 400 kHz and 71 dB at 1 MHz, while the data sheet's measured curve (Figure 5-20, other conditions) shows about 45 dB at 1 MHz.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/ldo-post-regulator-aux-rail/psrr.svg) The model is fitted to the data sheet's table, which ends at 100 kHz. Above it, its output capacitor filters the ripple and it looks better and better, while the real part gets worse. With the buck's 20 mV at 400 kHz on its input, the model's output ripple is 13 µV, eight times less than the 0.11 mV estimate above. ![The simulated input ripple (20 mV peak-to-peak at 400 kHz) and the LDO model's output ripple, about 13 µV peak-to-peak. The steps in the output trace are the resolution of the recorded signal at this tiny amplitude.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/ldo-post-regulator-aux-rail/ripple-in-out.svg) So use the simulation for what the model was fitted to, and the data sheet's curve for the rest. At the switching frequency, the conservative 45 dB estimate is the one to design with. ## Check 3: how hot does it get? $$P_{LDO} = (V_{in} - V_{out})\, I_{out} + V_{in} I_Q = (5 - 3.3) \times 0.15 + 5 \times 250\,\mu\text{A} \approx 0.26\ \text{W}$$ $$T_J = T_A + P_{LDO}\, R_{\theta JA} = 50 + 0.255 \times 193.4 = 99\ ^\circ\text{C}$$ with $R_{\theta JA} = 193.4$ °C/W for the SOT-23-5 package (SNVS798Q, Thermal Information) and the 125 °C maximum recommended junction temperature. That is 26 °C of margin. $R_{\theta JA}$ is measured on a JEDEC test board; your board's copper area changes it, so treat it as an estimate. From 12 V, the same 150 mA would dissipate 1.3 W, impossible in this package even if the input range allowed it. In the simulation the output sits at 3.295 V (load regulation takes 5 mV at 150 mA), and the dissipation and junction temperature come out the same. ## Common mistakes - **Using the typical dropout.** Design with the maximum at your current and hottest junction, and subtract the input's tolerance and ripple. - **Reading PSRR at 1 kHz.** The number on the first page is often at low frequency. Your ripple is at the switching frequency, where the rejection may be 30 to 40 dB lower. - **Trusting a model outside its data.** A behavioural model fitted to a table is only as good as the table's range. Above it, check the data sheet's curves. - **Forgetting the input range.** Many low-noise LDOs are limited to 5.5 V or 6 V input. A 12 V rail needs a different part, or a buck first. - **Ignoring heat at small currents.** 150 mA across 1.7 V is a quarter of a watt, which takes a SOT-23 to about 99 °C at 50 °C ambient. ## How to do it in Voltecx - **Place the LDO.** The behavioural IC library has an `ldo` model of the LP5907 3.3 V type, with dropout, supply rejection (a zero and a pole), current limit, enable and a start-up ramp, and pins `IN OUT GND EN`. Place it with `ic.place` and wire it to the converter's output; `circuit.enterSubsystem` shows the inside. - **Check ripple and dropout.** Run the circuit, then use `analysis.fft` on the LDO output for the ripple at the switching frequency, or `analysis.acSweep` with `"method": "perturbation"` from the converter output to the LDO output for the PSRR curve of the model (the linear method refuses this IC: its enable comparator has no transfer function). The PSRR figure above was measured the same way, one sine at a time. - **Automatic auxiliary rails** (*in the next release*). Automatic design adds auxiliary rails from the spec, such as an LDO for the MCU's 3.3 V, a gate-drive bias or a post-regulator. Each is checked for dropout, for ripple through its PSRR and for junction temperature, and drawn on the schematic as one subsystem. See the [design tools overview](https://voltecx-web.nguyenvanqui291.workers.dev/features/design-tools). The [models and parts](https://voltecx-web.nguyenvanqui291.workers.dev/features/models-and-parts) page lists the behavioural ICs and the vendor parts with their data-sheet sources. ## Frequently asked questions ### What is a good PSRR for an LDO after a buck? It depends on the ripple you start with and what the load tolerates. Look at the PSRR at your switching frequency, not at 1 kHz: many LDOs have 60–80 dB at low frequency and much less at hundreds of kilohertz. ### How do I calculate LDO power dissipation? $P = (V_{in} - V_{out}) I_{out} + V_{in} I_Q$. The second term is usually negligible. Multiply by $R_{\theta JA}$ and add the ambient for the junction temperature. ### Why does PSRR get worse near dropout? As the headroom shrinks, the pass transistor leaves its saturation region and the regulation loop loses gain, so less of the input ripple is rejected. Data sheets often show PSRR curves for several headroom values. ### Should I use an LDO or a second buck for the 3.3 V rail? An LDO for low current, a small voltage step and noise-sensitive loads; a buck when the loss $(V_{in}-V_{out})I_{out}$ would exceed what the package can dissipate. --- # Synchronous or diode buck: where the loss goes URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/synchronous-vs-diode-buck/ A synchronous buck replaces the freewheeling diode with a MOSFET, which swaps a loss of $V_F I_o (1-D)$ for $I_{rms}^2 R_{DS(on)}$ plus small dead-time, reverse-recovery and gate-drive terms. It wins whenever the output voltage is low and the duty cycle is small, because the diode then conducts for most of the period. In a 24 V to 5 V, 5 A, 300 kHz buck, a 0.5 V Schottky dissipates about 2.0 W where an 8 mΩ synchronous MOSFET loses about 0.37 W in all, which raises efficiency from about 89 % to 95 % in the example below. ## The idea: a toll gate on the return path When the high-side switch turns off, the inductor current does not stop; it needs a way back. In a diode buck that way is through a diode, which is like a toll gate that charges a fixed price per ampere: about half a volt, whatever the current. In a synchronous buck the way back is a MOSFET channel, which is more like a road with a small slope: the price grows with the current but starts at zero. At 5 V out, the return path carries the current for almost 80 % of the time. A fixed 0.5 V toll on a 5 V output is 10 % of the output voltage, paid for most of the period. That is the whole case for synchronous rectification. ![The synchronous buck of this article in Voltecx: Q1 the high-side MOSFET, Q2 the low-side MOSFET (8 mΩ) in place of the diode, L1 and C1 sized for 30 % ripple at 5 A, and the PWM split into two gates g1 and g2 with 20 ns of dead time.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/synchronous-vs-diode-buck/sync-buck.svg) ## Where does the freewheeling loss come from? When the high-side switch turns off, the inductor current keeps flowing through the low side for $(1-D)$ of the period. **Diode (non-synchronous) buck.** The loss is the forward drop times the current: $$P_{D} = V_F\, I_o\,(1 - D)$$ plus the energy to charge the diode's junction capacitance each cycle, small for a Schottky. **Synchronous buck.** The MOSFET conducts in its channel, so the loss is resistive, with three additions: $$P_{cond} = I_{rms,LS}^2\, R_{DS(on)}, \qquad I_{rms,LS} = I_o\sqrt{(1-D)\left(1 + \frac{r^2}{12}\right)}$$ $$P_{dt} = 2\, t_{dt}\, f_{sw}\, V_{SD}\, I_o, \qquad P_{rr} = Q_{rr}\, V_{in}\, f_{sw}, \qquad P_g = Q_g V_{GS} f_{sw}$$ - $P_{dt}$: during each of the two dead times the body diode carries the current at $V_{SD}$. - $P_{rr}$: when the high side turns on, it removes the body diode's reverse-recovery charge, and that loss lands mostly in the high-side switch. - $P_g$: the gate drive, mostly dissipated in the driver. (The equations follow standard treatments such as Erickson and Maksimović, *Fundamentals of Power Electronics*, and MOSFET manufacturers' application notes on synchronous rectification.) ## Worked example: 24 V to 5 V, 5 A, 300 kHz $D = 5/24 = 0.208$ and the ripple ratio is $r = 0.3$. The device values are an example; take yours from the data sheet at your operating conditions. **Schottky diode** with $V_F = 0.5$ V at 5 A: $$P_D = 0.5 \times 5 \times 0.792 = 1.98\ \text{W}$$ **Synchronous MOSFET** with $R_{DS(on)} = 8$ mΩ (hot), $V_{SD} = 0.8$ V, $Q_{rr} = 20$ nC, $Q_g = 15$ nC at 5 V and a dead time of 20 ns per edge: | Term | Formula | Value | |---|---|---| | Conduction | $4.47^2 \times 0.008$ | 0.160 W | | Dead time | $2 \times 20\,\text{ns} \times 300\,\text{kHz} \times 0.8 \times 5$ | 0.048 W | | Reverse recovery | $20\,\text{nC} \times 24 \times 300\,\text{kHz}$ | 0.144 W | | Gate drive | $15\,\text{nC} \times 5 \times 300\,\text{kHz}$ | 0.023 W | | **Total** | | **0.37 W** | ### What the simulation says Run in Voltecx with the same parts, the Schottky dissipates **1.94 W**: its 0.5 V drop makes the converter need a slightly longer duty cycle (0.224 instead of 0.208) to hold 5 V, so the diode conducts a little less than the formula assumes. The MOSFET loses **0.21 W** in conduction and dead time, the first two rows of the table. (Reverse recovery and gate drive are left to the formulas here; the simulated switches do not include them.) ![The switch node in the first 150 ns after the high-side switch turns off, simulated in Voltecx. With the Schottky it sits at −0.5 V for the whole off-time. With the synchronous MOSFET it sits at −0.8 V on the body diode for the 20 ns dead time, then at only −45 mV once the channel turns on.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/synchronous-vs-diode-buck/switch-node-off-time.svg) The picture shows where the saving comes from: the area between the two lines, times the current, for most of every period. ![The low-side loss simulated in Voltecx against load current at 5 V out. The Schottky's loss grows in a straight line with the current; the MOSFET's is a small, gently curving parabola, 0.21 W at 5 A.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/synchronous-vs-diode-buck/low-side-loss-vs-load.svg) The synchronous switch saves about 1.6 W. If the rest of the converter (high-side switch, inductor, capacitors) loses 1 W in both versions, the efficiency at 25 W output goes from $25/27.98 = 89.4\,\%$ to $25/26.37 = 94.8\,\%$. Notice that reverse recovery and dead time are almost half of the synchronous loss. A shorter dead time, a MOSFET with low $Q_{rr}$, or a Schottky diode in parallel with the low-side switch shrinks them. ## When is a diode buck still the better choice? - **High duty cycle.** From 12 V to 10 V, $D = 0.83$, the diode conducts for only 17 % of the period and loses $0.5 \times 5 \times 0.167 = 0.42$ W. The synchronous switch saves less than its driver and control cost. ![The low-side loss at 5 A against the duty cycle (24 V input, output from 2 to 20 V), simulated in Voltecx. The Schottky's loss falls from over 2 W at low duty to 0.41 W at D = 0.83, where the gap to the MOSFET is only about 0.3 W.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/synchronous-vs-diode-buck/low-side-loss-vs-duty.svg) - **Light load efficiency.** A diode buck enters discontinuous conduction by itself and stops switching losses from growing. A synchronous buck in forced PWM lets the inductor current go negative and circulates energy; it needs a diode-emulation or skip mode at light load. ![Both bucks at a 0.5 A load, simulated in Voltecx. The diode blocks reverse current, so the Schottky buck's inductor current stops at zero and waits. The synchronous buck's MOSFET conducts both ways, so its current dips below zero every period: energy goes back and forth for nothing.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/synchronous-vs-diode-buck/light-load.svg) - **Simplicity and robustness.** No dead-time tuning, no shoot-through risk, no bootstrap refresh issue at 100 % duty. - **High output voltage.** At a high output voltage the diode drop is a small fraction of the output, and fast high-voltage diodes or SiC Schottkys have no reverse recovery to speak of. ## Common mistakes - **Counting only $I^2 R$.** At hundreds of kilohertz, dead time and reverse recovery can be as large as the conduction loss. Here they are about half of the synchronous total. - **Taking $R_{DS(on)}$ at 25 °C.** The on-resistance rises with temperature, often by about half between 25 °C and 100 °C (the [MOSFET loss article](https://voltecx-web.nguyenvanqui291.workers.dev/blog/mosfet-loss-and-thermal-estimation) uses +0.7 %/K); use the hot value from the data sheet. - **Setting a long, "safe" dead time.** Every extra nanosecond is body-diode conduction at 0.8 V. Use the shortest dead time that never lets both switches conduct. - **Forgetting light load.** A forced-PWM synchronous buck circulates current at no load. If light-load efficiency matters, use a controller with diode emulation or pulse skipping. - **Comparing at the wrong duty cycle.** The saving shrinks as $D$ grows. At a 12 V to 10 V conversion, the diode costs only 0.42 W. ## How to do it in Voltecx 1. Open **File › Open Example › buckSync**: a synchronous buck that holds 12 V from 48 V with a PI controller and dead time. The `buck` example is the diode version. 2. Run it, then call `analysis.losses` for the conduction and switching loss of each switch and diode over a window, or `design.efficiency` for the efficiency at four loads and the loss split at full load. 3. Change the dead time and run again to see the body-diode conduction on the switch node, as in the article on [dead-time effects](https://voltecx-web.nguyenvanqui291.workers.dev/blog/dead-time-effects). 4. With `design.auto`, set `topology` to `buck` or `syncBuck` to draw either one, or let the ranking choose; `design.compare` (**Design › Automate › Compare Topologies and Control**) puts both in one table with efficiency, stresses and part count. The `buckGan` example shows the GaN case: with no body diode, a GaN transistor conducts in reverse at about 3.1 V in the dead time, so dead-time loss matters even more. ## Frequently asked questions ### Is a synchronous buck always more efficient? At medium and heavy load with a low output voltage, almost always. At very light load, or with a duty cycle close to 1, the difference is small, and a synchronous buck in forced PWM can be worse at light load unless it has a diode-emulation mode. ### Why is the dead time so important in a synchronous buck? During the dead time the body diode conducts at around 0.7–1 V, and when the high side turns on it must recover that diode's charge. Both losses grow with frequency and current. ### Should I add a Schottky across the low-side MOSFET? It takes the dead-time current from the body diode and has no reverse-recovery charge, so it can cut both terms. Its own capacitance and the loop inductance of the added path decide whether it helps at your frequency. --- # Monte Carlo tolerance analysis for power supplies: worst case, RSS and yield URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/monte-carlo-tolerance-analysis-power-supply/ Every part on a power-supply board comes with a tolerance, and a design that only works with nominal values will fail on some fraction of the boards you build. Tolerance analysis tells you how large that fraction is. There are three common methods: extreme-value worst case, root-sum-square (RSS), and Monte Carlo. They answer slightly different questions. This article applies all three to the same output-voltage problem, then shows how many Monte Carlo runs you need before a yield number means something. ## The example: output voltage set by a divider A regulator holds its feedback pin at a reference $V_{ref}$, and a divider sets the output: $$V_{out} = V_{ref}\left(1 + \frac{R_1}{R_2}\right)$$ Take $V_{ref} = 0.8$ V ± 1 %, $R_2 = 10$ kΩ ± 1 % and $R_1 = 31.6$ kΩ ± 1 % (the nearest E96 value for 3.3 V). The nominal output is $$V_{out} = 0.8 \times (1 + 3.16) = 3.328\ \text{V}$$ The specification is $3.3$ V ± 3 %, that is, 3.201 V to 3.399 V. The nominal is already 0.85 % above the centre, which is common when you round to standard resistor values. ## Method 1: extreme-value worst case Push every part to the end of its tolerance in the direction that moves the output most: $$V_{out,max} = 0.808 \times \left(1 + \frac{31.916}{9.9}\right) = 3.413\ \text{V}$$ $$V_{out,min} = 0.792 \times \left(1 + \frac{31.284}{10.1}\right) = 3.245\ \text{V}$$ The upper extreme exceeds 3.399 V, so by this method the design fails. The method is simple and guaranteed: no combination of in-tolerance parts can do worse. But it assumes every part sits at its limit at once, in the worst direction, which is rare. With more than a few parameters, trying every combination of extremes ($2^k$ corners for $k$ parameters) becomes expensive, and for non-monotonic responses the worst point may not be a corner at all. ## Method 2: sensitivities and RSS Linearise the output around nominal. The relative sensitivity is $$\frac{\Delta V_{out}}{V_{out}} = \frac{\Delta V_{ref}}{V_{ref}} + \frac{R_1}{R_1 + R_2}\left(\frac{\Delta R_1}{R_1} - \frac{\Delta R_2}{R_2}\right)$$ Here $R_1/(R_1+R_2) = 31.6/41.6 = 0.760$. Adding the magnitudes reproduces the worst case: $1 + 0.760 \times (1 + 1) = 2.52$ %. RSS treats the parameters as independent random variables and adds their variances: $$\sigma_{V} = \sqrt{\sum_i \left(S_i\, \sigma_i\right)^2}$$ The answer depends on what a tolerance means statistically. - **Uniform within the tolerance** $t$: $\sigma = t/\sqrt{3}$. Then $\sigma_V = (1/\sqrt{3})\sqrt{1^2 + 2 \times 0.760^2} = 0.577 \times 1.468 = 0.847$ %. - **Gaussian with the tolerance as $3\sigma$**: $\sigma = t/3$. Then $\sigma_V = 1.468/3 = 0.489$ %, and the $\pm 3\sigma$ band is ±1.47 %, much tighter than the worst case's ±2.52 %. Uniform is the cautious choice when you do not know the distribution, for example for parts that may have been sorted, where the best units were sold under a tighter tolerance. Gaussian fits processes that are centred and well controlled. ### Estimating the yield The upper limit is $3.399 - 3.328 = 0.071$ V away, which is 2.13 % of nominal. With the uniform model, that is $2.13/0.847 = 2.5\,\sigma$. The sum of three uniform variables is already close to Gaussian, so the probability of exceeding it is about 0.6 %. The lower limit is 3.8 % away, beyond $4\sigma$, which is negligible. The expected yield is therefore about 99.4 %. So the worst case says "fails" and the statistics say "about 6 boards in 1,000 fail". Both are correct. Which one you act on depends on the cost of a failure. ## Method 3: Monte Carlo Monte Carlo draws every parameter from its distribution, simulates, measures, and repeats. It needs no linearisation, so it handles non-linear behaviour, discontinuous conduction, saturation and limit cycling as long as the simulation captures them. It also measures things that have no closed form, such as the output ripple, the overshoot after a load step, or the loop's phase margin. Three choices matter. **Distributions.** Use what you know about each part. Electrolytic capacitors often have −20 % / +20 % or asymmetric tolerances and drift with age and temperature; ceramic capacitors lose capacitance with DC bias; inductors have ±20 % or ±30 %. Do not forget correlation: parts from the same reel tend to move together, which can make ratios such as $R_1/R_2$ tighter than independent draws suggest. **Seeds.** Seed the random generator and record the seed. The same seed gives the same draws, so a failing run can be reproduced, inspected and fixed, and two versions of a design can be compared on the same set of boards. **Number of runs.** A yield measured from $N$ runs is itself uncertain. If $k$ of $N$ runs pass, the Wilson score interval gives a confidence interval that behaves well near 100 %: $$\frac{\hat p + \frac{z^2}{2N} \pm z\sqrt{\frac{\hat p(1-\hat p)}{N} + \frac{z^2}{4N^2}}}{1 + \frac{z^2}{N}}, \qquad \hat p = \frac{k}{N}$$ With 199 passes out of 200 and $z = 1.96$ (95 % confidence), $\hat p = 99.5$ % but the interval is 97.2 % to 99.9 %. To claim a failure rate below 1 % with 95 % confidence when no run fails, the "rule of three" says you need about $N = 3/0.01 = 300$ runs. Rare failures need either many runs or a different tool, such as worst-case corners targeted at the parameters that matter. ![Histogram of the output voltage over 200 Monte Carlo runs in Voltecx (Vref, R1 and R2 uniform within ±1 %, seed 1), with the nominal 3.328 V and the upper limit 3.399 V marked.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/monte-carlo-tolerance-analysis-power-supply/histogram.svg) As a check, the regulator was simulated in Voltecx as an op amp that holds the feedback node at $V_{ref}$, with $V_{ref}$, $R_1$ and $R_2$ drawn uniformly within ±1 % in 200 seeded runs. The mean is 3.330 V and the standard deviation 0.886 % (the uniform RSS estimate above is 0.847 %). Every run stays inside the worst-case band, and 198 of 200 pass: a yield of 99.0 %, with a 95 % Wilson interval of 96.4 % to 99.7 %, consistent with the estimated 99.4 %. ## A practical order of work 1. **Sensitivity first.** Change each parameter a little and rank the effect on each output. Most outputs depend strongly on two or three parameters. 2. **Worst case on those few.** It is cheap with few parameters and tells you whether a guaranteed design is possible. 3. **Monte Carlo for the yield.** Use realistic distributions on all parameters, with enough runs for the confidence you need, and keep the seed. 4. **Fix the design, not the statistics.** If the yield is too low, re-centre the nominal (here, a different resistor pair) or tighten the part that dominates the sensitivity. The statistical background follows R. Spence and R. S. Soin, *Tolerance Design of Electronic Circuits* (1988), and E. B. Wilson's 1927 score interval. ## Try it in Voltecx - `analysis.monteCarlo` draws random values within part tolerances, `uniform` by default or `gauss` with the tolerance as $3\sigma$, with a `seed` that makes the run repeatable. It reports the mean, standard deviation, minimum and maximum of the measurement, a histogram, percentiles and the worst run. With `limitMin` or `limitMax` it reports the yield with a Wilson score interval (95 % confidence by default), and a run that fails to simulate counts against the yield. - `analysis.sensitivity` ranks how much each variable moves each metric. `analysis.worstCase` tries every combination of extremes with `"method": "corners"` (up to 8 variables), or uses a linear estimate plus RSS with `"method": "sensitivity"`. - In a spec, the `monteCarlo` object runs a yield test inside `spec.verify` and `design.auto`, with `minYieldPct` as the pass condition (at most 200 runs). A simulated yield is only as good as the tolerances you give it. The worst-case stage of `design.auto` assumes a 20 % part tolerance, so for a yield you can defend, give `analysis.monteCarlo` or the spec's `monteCarlo` object the tolerances from your parts' data sheets. --- # LLC resonant tank design with first-harmonic approximation: a worked example URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/llc-resonant-tank-design/ The LLC converter regulates by moving its switching frequency along a resonant gain curve. Its appeal is soft switching: the primary switches turn on at zero voltage and the output rectifiers turn off at low current. The price is a design with more coupled choices than a PWM converter. This article designs the tank of a 400 V to 48 V, 480 W half-bridge LLC with the first-harmonic approximation (FHA), and checks the result for gain range and zero-voltage switching. ## The specification - Input: $V_{in} = 380$ to $420$ V, nominal 400 V (the output of a PFC stage). - Output: $V_{out} = 48$ V at $I_{out} = 10$ A, so $P_{out} = 480$ W and $R_L = 4.8\ \Omega$. - Half bridge, centre-tapped secondary with synchronous rectifiers, so the rectifier drop is neglected. - Resonant frequency $f_r = 100$ kHz. ## First-harmonic approximation FHA replaces the square-wave voltage at the bridge and the rectified load with their fundamental components. The rectifier and load become an AC resistance seen at the primary: $$R_{ac} = \frac{8 n^2}{\pi^2} R_L$$ The tank has a series inductance $L_r$, a series capacitance $C_r$ and a magnetising inductance $L_m$. Three normalised quantities describe it: $$f_r = \frac{1}{2\pi\sqrt{L_r C_r}}, \qquad Q = \frac{\sqrt{L_r/C_r}}{R_{ac}}, \qquad L_n = \frac{L_m}{L_r}, \qquad f_n = \frac{f_{sw}}{f_r}$$ The voltage gain from the fundamental at the bridge to the fundamental at the reflected output is $$M(f_n) = \frac{L_n f_n^2}{\sqrt{\left[(L_n + 1) f_n^2 - 1\right]^2 + \left[(f_n^2 - 1)\, f_n\, Q\, L_n\right]^2}}$$ At $f_n = 1$, $M = 1$ for every load. That is the point where the series tank's impedance is zero. ## Step 1: turns ratio and gain range For a half bridge, the converter gain is $M = 2 n V_{out} / V_{in}$. Choose $n$ so that the nominal input sits near resonance. $400 / (2 \times 48) = 4.17$; take $n = 4.2$: | Input | Required gain $M$ | |---|---| | 420 V (maximum) | $2 \times 4.2 \times 48 / 420 = 0.96$ | | 400 V (nominal) | 1.008 | | 380 V (minimum) | 1.061 | A real design adds margin for component tolerance and often a hold-up requirement, which can push the minimum input much lower. Here, aim for a peak gain of at least $1.061 \times 1.1 = 1.17$. ## Step 2: AC resistance $$R_{ac} = \frac{8 \times 4.2^2}{\pi^2} \times 4.8 = \frac{8 \times 17.64 \times 4.8}{9.87} = 68.6\ \Omega$$ ## Step 3: choose Q and Ln These two set the shape of the gain curve. - A **smaller $L_n$** gives more peak gain and a narrower frequency range, but a smaller $L_m$ and therefore more circulating magnetising current and conduction loss. - A **smaller $Q$** gives more peak gain, but a larger $C_r$ and smaller $L_r$, and less selectivity against the load. Take $L_n = 6$ and $Q = 0.4$ as a first try, and evaluate the gain: | $f_n$ | 0.5 | 0.6 | 0.7 | 0.8 | 0.85 | 1.0 | 1.1 | 1.2 | |---|---|---|---|---|---|---|---|---| | $M$ at full load | 1.28 | 1.22 | 1.14 | 1.08 | 1.06 | 1.00 | 0.97 | 0.94 | The peak is about 1.28 near $f_n = 0.5$, above the 1.17 target. The required 1.061 at minimum input is reached at $f_n \approx 0.85$, and the 1.17 with margin at about $f_n \approx 0.66$. Both lie to the right of the peak, in the region where the tank's input impedance is inductive, which is where zero-voltage switching of the primary is possible. Operating left of the peak loses ZVS. ![Gain against switching frequency from Voltecx's design.llc for Q = 0.4 and Ln = 6: full load, 10 % load (shown above 70 kHz), the gain needed at maximum input (Mmin) and at minimum input (Mmax), and the resonant frequency of 100 kHz marked.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/llc-resonant-tank-design/gain-curves.svg) Voltecx's `design.llc` gives the same full-load curve: a peak of 1.28 at 48 kHz. It takes $n = 400/(2 \times 48) = 4.17$ instead of the rounded 4.2, so its $L_r$, $C_r$ and $L_m$ (43.0 µH, 58.9 nF and 258 µH) differ from the values below by about 1.6 %. At maximum input, the full-load gain of 0.96 is reached near $f_n = 1.13$. At no load ($Q \to 0$) the gain falls towards $L_n/(L_n+1) = 0.857$ as frequency rises, so the converter can still regulate: solving $6 f_n^2 / (7 f_n^2 - 1) = 0.96$ gives $f_n = 1.15$. ## Step 4: tank values $$Z_r = \sqrt{L_r/C_r} = Q R_{ac} = 0.4 \times 68.6 = 27.4\ \Omega$$ $$L_r = \frac{Z_r}{2\pi f_r} = \frac{27.4}{2\pi \times 100\,\text{k}} = 43.7\ \mu\text{H}$$ $$C_r = \frac{1}{2\pi f_r Z_r} = \frac{1}{2\pi \times 100\,\text{k} \times 27.4} = 58.0\ \text{nF}$$ $$L_m = L_n L_r = 6 \times 43.7 = 262\ \mu\text{H}$$ The switching frequency range is therefore about 66 kHz (minimum input, with margin) to 115 kHz (maximum input, no load). ## Step 5: check ZVS ZVS needs the magnetising current at the switching instant to charge and discharge the output capacitances of the bridge within the dead time. At resonance, the reflected output voltage $n V_{out}$ across $L_m$ for half a period gives a peak magnetising current of $$I_{m,pk} = \frac{n V_{out}}{4 L_m f_{sw}} = \frac{4.2 \times 48}{4 \times 262\,\mu \times 100\,\text{k}} = 1.92\ \text{A}$$ With $C_{oss,tr} = 200$ pF per switch, the switch node swings the full 400 V in $$t_{swing} \approx \frac{2 C_{oss,tr} V_{in}}{I_{m,pk}} = \frac{2 \times 200\,\text{p} \times 400}{1.92} = 83\ \text{ns}$$ so a dead time of 100 to 200 ns works, as long as the transformer's winding capacitance is added to $C_{oss}$. If the swing does not fit, reduce $L_n$ (more magnetising current) or lengthen the dead time. The magnetising current is smallest at the highest switching frequency, not at resonance. At the 119 kHz that `design.llc` finds for 10 % load, it is 1.62 A, and the swing takes 104 ns: still inside a 200 ns dead time, but check the dead time at $f_{max}$ too. ## Check the result in the time domain FHA is accurate near resonance and less so far below it and at light load, where the rectifier current is no longer close to a sine. Simulate the design at the corners: minimum input at full load (the largest gain), maximum input at no load (the highest frequency), and a load step. Check the resonant capacitor's peak voltage and the peak tank current, and confirm ZVS on both switches at every corner. ![The llcHalfBridge example in Voltecx with the tank of Step 4: Q1 and Q2 with 200 ns dead time, Cr 58 nF, Lr 43.7 µH, a transformer with n = 4.2 and Lm 262 µH, a diode bridge and the 4.8 Ω load.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/llc-resonant-tank-design/half-bridge.svg) ![Two switching periods at 100 kHz simulated in Voltecx: the bridge voltage v(sw), the resonant current i(Lr) and the magnetising current i(T1.Lm).](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/llc-resonant-tank-design/tank-current.svg) Simulated in Voltecx at resonance with the tank of Step 4 (the rectifier diodes without drop, as for synchronous rectifiers), the output settles at 47.3 V against $400/(2 \times 4.2) = 47.6$ V; the switches' and diodes' on-resistance takes the rest. The magnetising current peaks at 1.90 A, close to the 1.92 A of Step 5. The FHA model and gain expression follow the standard literature on LLC converters, for example R. W. Erickson and D. Maksimović, *Fundamentals of Power Electronics*, 3rd ed., in its chapter on resonant conversion, and manufacturers' LLC application notes. ## Try it in Voltecx - The `llcHalfBridge` example is an LLC half bridge run at its 100 kHz resonant frequency, making about 48 V from 400 V through a 4:1 transformer. - `design.llc` computes the turns ratio, $L_r$, $C_r$ and $L_m$ for an input range by first-harmonic approximation, gives the gain curves at full and lightest load with $f_{min}$ and $f_{max}$, and checks that the magnetising current swings each leg within the dead time. - `analysis.softSwitching` confirms ZVS on each switch in the simulated waveforms. In `design.auto`, an LLC is drawn and its tank is sized by `design.llc` and checked by simulation at the nominal input. Its frequency loop is not closed yet: the converter runs open loop, and the report lists that as an open item. --- # Loop gain and phase margin in simulation: injection, sweep limits and reading the plot URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/loop-gain-phase-margin-simulation/ A compensator designed on paper is only as good as the plant model behind it. Measuring the loop gain, in the lab with a network analyser or in simulation with the same method, is how you find out what the loop really does. This article explains the injection method, how to apply it to a switching converter in simulation, how to choose the injection amplitude and the sweep range, and how to read the margins from the result. ## What loop gain tells you For a feedback loop with forward path $G(s)$ and feedback $H(s)$, the loop gain is $T(s) = G(s)H(s)$. The closed-loop response depends on $1 + T(s)$, so the loop is close to instability wherever $T$ approaches $-1$, that is, 0 dB at −180°. Two numbers measure the distance: - **Phase margin (PM):** $180° + \angle T(f_c)$, where $f_c$ is the crossover frequency at which $|T| = 0$ dB. - **Gain margin (GM):** $-|T(f_{180})|$ in dB, where $f_{180}$ is the frequency at which $\angle T = -180°$. For a loop that behaves like a second-order system near crossover, phase margin maps to damping and step overshoot: | Phase margin | Damping ratio ζ | Step overshoot | |---|---|---| | 45° | 0.42 | 23 % | | 60° | 0.60 | 9.5 % | The overshoot is $e^{-\pi\zeta/\sqrt{1-\zeta^2}}$. Typical design targets are a phase margin of 45° to 60° and a gain margin of at least 6 to 10 dB, held at every corner of line, load, temperature and tolerance. ## Middlebrook's injection method You cannot open the loop of a running converter without losing its operating point. R. D. Middlebrook's method (1975) keeps the loop closed. A small voltage source $v_z$ is inserted in series at a point in the loop. Call the voltage on the downstream side of the source $v_f$ (forward, going into the rest of the loop) and the voltage on the upstream side $v_r$ (returned by the loop). The measured loop gain is $$T_v = -\frac{v_r}{v_f}$$ It equals the true loop gain only when the impedance looking upstream from the injection point, $Z_s$, is much smaller than the impedance looking downstream, $Z_l$: $$T_v = T\left(1 + \frac{Z_s}{Z_l}\right) + \frac{Z_s}{Z_l}$$ So $Z_s/Z_l$ must be small compared with 1 and with $|T|$ at every frequency of interest. The classic place is between the converter output, which has an output impedance of milliohms, and the top of the feedback divider, which has kilohms. There $Z_s/Z_l$ is around $10^{-6}$, and the measurement is accurate well above crossover. On a board, the injection goes across a small resistor (10 Ω to 50 Ω) through an isolating transformer. In simulation, an ideal voltage source does the job without disturbing the DC point. Inside a control diagram, the loop can also be broken at a signal, for example the output of the error amplifier. Signals have no source or load impedance, so the injection is exact: $T = -\text{return}/\text{forward}$. ## Averaged model or switching model **Averaged model.** Replace the switches with their averaged equivalent, linearise at the operating point and run a small-signal AC analysis. It is fast and exact for the model, but it leaves out what averaging removes: the sampling effect of the modulator, the delay of a digital controller, and behaviour near half the switching frequency. **Switching model with perturbation.** Keep the switching circuit, add a small sinusoid at frequency $f$, let the circuit reach periodic steady state, then extract the fundamental of $v_f$ and $v_r$ with a discrete Fourier transform. Repeat at each frequency. This captures the real sampled behaviour, delays included, at the cost of one settled transient per frequency point. ## Choosing the injection amplitude The amplitude is a compromise. - **Too large** and the loop leaves its linear region: the duty cycle hits a limit, the current limit acts, or the converter crosses into discontinuous conduction for part of the cycle. A practical upper bound is a perturbation of a few percent of the output voltage, and no duty saturation at any point of the cycle. - **Too small** and the response is buried in switching ripple and numerical noise. Measuring over an integer number of periods of both the injection and the switching frequency keeps the switching ripple out of the injected bin. Avoid injection frequencies at or near harmonics of $f_{sw}$. ## Choosing the sweep range and the cost - **Lower limit.** About a tenth of the expected crossover. Lower frequencies add little information about stability and cost a lot: each point needs several injection periods after the circuit has settled. - **Upper limit.** Below half the switching frequency. The modulator samples the control signal once or twice per period, and above $f_{sw}/2$ the measured response aliases. - **Number of points.** A handful per decade is enough to find crossover and the phase at it. Add points around the crossover afterwards. To see why the lower limit matters, consider a point at 100 Hz on a converter switching at 200 kHz. Ten injection periods take 0.1 s, which is 20,000 switching periods. At 200 time steps per period that is 4 million steps, for one point, after the initial settling. ## Reading the result: an example Suppose a perturbation sweep from 2 kHz to 90 kHz on a 200 kHz buck gives: - $|T|$ crosses 0 dB at 18 kHz, where $\angle T = -128°$. The phase margin is $180° - 128° = 52°$. - $\angle T$ crosses −180° at 70 kHz, where $|T| = -11$ dB. The gain margin is 11 dB. Both meet a 45° and 6 dB target at this corner. Now repeat at the corners that move the plant most: minimum and maximum input voltage, light and full load, and the tolerance extremes of the inductor and the output capacitor. In voltage mode, the gain margin at light load is often the one that fails, because the LC resonance is barely damped there. A large phase margin does not guarantee a gain margin. The plot below is from Voltecx: the 12 V to 3.3 V, 200 kHz buck of the [PI compensator article](https://voltecx-web.nguyenvanqui291.workers.dev/blog/buck-converter-pi-compensator-design), closed in voltage mode with the PI that `design.voltageLoop` designs for it ($K_p = 0.0118$, $K_i = 1.06 \times 10^3\ \text{s}^{-1}$). ![The buck closed in voltage mode in Voltecx: Vin 12 V, S1, D1, L1 8.2 µH, C1 100 µF, R1 0.66 Ω, the output sensed by VM and compared with Vref, and the PI driving the 200 kHz PWM.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/loop-gain-phase-margin-simulation/closed-loop-buck.svg) ![Bode plot of the loop gain T and the plant Gvd of that buck, from design.voltageLoop, with the crossover at 2.52 kHz marked.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/loop-gain-phase-margin-simulation/loop-gain-margins.svg) The loop crosses 0 dB at 2.52 kHz with 84° of phase margin. Above crossover the LC resonance at 5.56 kHz lifts $|T|$ back to just below 0 dB, right where the phase passes −180°, so the gain margin is only 2.4 dB. Judged by its phase margin alone, this loop would look very safe. Also look for **conditional stability**: a region below crossover where the phase dips below −180° while the gain is still above 0 dB. The loop is stable, but a drop in gain, such as during start-up or a current limit, can make it oscillate. ## Comparing with the design If the measured crossover is lower than designed, the plant gain is lower than modelled: check the modulator gain, the sensor gain and the divider. If the phase margin is lower than designed, look for delay you did not model: digital sampling and computation, gate-driver propagation, or the sampling double pole of current mode at $f_{sw}/2$. The method follows R. D. Middlebrook, "Measurement of loop gain in feedback systems", *International Journal of Electronics*, 1975, and the treatment in R. W. Erickson and D. Maksimović, *Fundamentals of Power Electronics*, 3rd ed., in its chapter on controller design. ## Try it in Voltecx - `analysis.loopGain` breaks a control signal (`signal`) and reports $T = -\text{return}/\text{forward}$ as `magnitudeDb` and `phaseDeg`. With `"method": "linear"` it uses complex nodal analysis, exact for a linear or averaged circuit. With `"method": "perturbation"` it adds a small sinusoid to the running transient simulation of the switching circuit, settles each frequency and reports the periods, steps and amplitude it used. Start with few points. - In a spec, `pmMinDeg` and `gmMinDb` set the margins, and the `loop` object sets the signal, the sweep limits (by default the switching frequency divided by 500 and by 20), the number of points and the amplitude. `spec.verify` checks the margins at the input corners. - `design.robustLoop` designs the voltage loop so that it keeps its margins at every corner of input, load, inductor, capacitor, ESR and modulator delay. The perturbation method is slower because every frequency needs its own settled run. Read the `warnings` in the result before you trust a point, and compare the margins with the averaged model: a large difference usually means a delay or a sampling effect that the averaged model leaves out. --- # MOSFET loss and junction temperature estimation, step by step URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/mosfet-loss-and-thermal-estimation/ Before you choose a heatsink, you need two numbers for each switch: how much power it dissipates, and how hot its junction gets. Both come from the data sheet and a few lines of arithmetic, as long as you remember that the losses depend on the temperature you are trying to find. This article estimates the losses of the high-side MOSFET in a 48 V to 12 V buck, then solves for its junction temperature by iteration. ## The operating point - $V_{in} = 48$ V, $V_{out} = 12$ V, $I_o = 10$ A, $f_{sw} = 100$ kHz, so $D = 0.25$. - Inductor ripple ratio $r = \Delta I / I_o = 0.3$. - MOSFET data: $R_{DS(on)} = 10$ mΩ at 25 °C; rise and fall times under these conditions $t_r = t_f = 20$ ns; effective output capacitance $C_{o(er)} = 500$ pF; total gate charge $Q_g = 30$ nC at $V_{GS} = 10$ V. - Thermal path: $R_{th,jc} = 1.0$ K/W, interface $R_{th,cs} = 0.5$ K/W, heatsink $R_{th,sa} = 20$ K/W, ambient $T_a = 50$ °C. These values are an example. Take yours from the data sheet of the part you are considering, at its test conditions. ## Conduction loss The high-side switch carries the inductor current during $DT_s$. For a trapezoidal current with ripple ratio $r$: $$I_{rms} = I_o \sqrt{D\left(1 + \frac{r^2}{12}\right)} = 10\sqrt{0.25 \times 1.0075} = 5.02\ \text{A}$$ $$P_{cond} = I_{rms}^2\, R_{DS(on)}(T_j)$$ $R_{DS(on)}$ rises with temperature. Data sheets give a normalised curve; for many silicon MOSFETs it is about 1.5 to 1.8 times the 25 °C value at 125 °C. Model it here as $$R_{DS(on)}(T_j) = R_{DS(on),25}\,[1 + \alpha (T_j - 25)], \qquad \alpha = 0.007\ \text{K}^{-1}$$ which gives 1.7 times at 125 °C. Read your own curve instead when you have it. ![The 48 V to 12 V, 10 A, 100 kHz buck simulated in Voltecx, with the high-side switch S1 at its on-resistance.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/mosfet-loss-and-thermal-estimation/buck.svg) ![Two switching periods in steady state from Voltecx: the switch current i(S1), the inductor current i(L1) with 3 A of ripple, and the switch node v(sw).](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/mosfet-loss-and-thermal-estimation/switch-current.svg) The simulation of this buck gives a switch RMS current of 5.00 A. It is slightly below 5.02 A because the output settles at 11.96 V, not 12 V, so the load draws a little less than 10 A. ## Switching loss During each transition, voltage and current overlap. With a linear approximation of a hard-switched transition: $$P_{sw} = \frac{1}{2} V_{in} I_o (t_r + t_f) f_{sw} = \frac{1}{2} \times 48 \times 10 \times 40\,\text{ns} \times 100\,\text{kHz} = 0.96\ \text{W}$$ When the data sheet gives switching energies $E_{on}$ and $E_{off}$ at a test voltage $V_{test}$ and current $I_{test}$, a first scaling is $$P_{sw} \approx (E_{on} + E_{off}) \frac{V_{in}}{V_{test}} \frac{I_o}{I_{test}} f_{sw}$$ Both forms are estimates. Switching energy depends on gate resistance, the driver, the diode's reverse recovery and the loop inductance of your layout. If the gate resistance differs from the test condition, use the data sheet's energy-versus-$R_G$ curve. ## Output capacitance and gate losses At hard turn-on, the energy stored in the switch's output capacitance is dissipated in its channel: $$P_{oss} = \frac{1}{2} C_{o(er)} V_{in}^2 f_{sw} = \frac{1}{2} \times 500\,\text{pF} \times 48^2 \times 100\,\text{kHz} = 0.058\ \text{W}$$ Use $C_{o(er)}$, the energy-related value, not the small-signal $C_{oss}$ at one voltage. Some data sheets give $E_{oss}$ directly. The gate drive takes $$P_g = Q_g V_{GS} f_{sw} = 30\,\text{nC} \times 10\ \text{V} \times 100\,\text{kHz} = 0.03\ \text{W}$$ Most of it is dissipated in the driver and the gate resistors, not in the MOSFET, so leave it out of the junction's budget but include it in the efficiency. ## The thermal path At steady state the junction sits above ambient by the dissipated power times the thermal resistances in series: $$T_j = T_a + P_{tot}\,(R_{th,jc} + R_{th,cs} + R_{th,sa}) = 50 + 21.5\,P_{tot}$$ The catch is that $P_{tot}$ depends on $T_j$ through $R_{DS(on)}$. Solve it by iteration. ## Iterating to the junction temperature **Start with a guess of 100 °C.** $R_{DS(on)} = 10 \times [1 + 0.007 \times 75] = 15.3$ mΩ, so $P_{cond} = 25.2 \times 0.0153 = 0.384$ W. $P_{tot} = 0.384 + 0.96 + 0.058 = 1.40$ W, so $T_j = 50 + 21.5 \times 1.40 = 80.1$ °C. **Second pass at 80.1 °C.** $R_{DS(on)} = 10 \times [1 + 0.007 \times 55.1] = 13.9$ mΩ, so $P_{cond} = 0.349$ W. $P_{tot} = 1.37$ W, so $T_j = 79.4$ °C. **Third pass at 79.4 °C.** $P_{cond} = 0.348$ W and $T_j = 79.4$ °C. The iteration has converged. ![Heat made in the switch (the conduction loss simulated in Voltecx at each junction temperature, plus the 0.96 W switching and 0.058 W Coss losses) and heat the thermal path removes, against junction temperature. They cross at 79.4 °C.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/mosfet-loss-and-thermal-estimation/junction-temperature.svg) The plot shows the same fixed point found graphically. The conduction losses come from simulations of the buck with $R_{DS(on)}(T_j)$ at 25 °C to 150 °C. The line of heat removed is much steeper than the curve of heat made, which is why the iteration converges in three passes. The junction runs at about 79 °C at 50 °C ambient, and switching loss is 70 % of the total. That points to the levers worth pulling: a faster gate drive, a lower switching frequency, or a part with lower switching energy. A lower $R_{DS(on)}$ alone would change little. The fixed-point iteration converges when the temperature coefficient is small compared with the thermal gain. If each pass gives a higher temperature than the last without settling, the device is in thermal runaway at that operating point, and you need a larger heatsink or a different part. ## Beyond steady state - **Transient loads.** For pulses shorter than the heatsink's time constant, use the transient thermal impedance $Z_{th,jc}(t)$ from the data sheet instead of $R_{th,jc}$. It is often given as a Foster RC network that you can simulate directly. - **Temperature dependence of switching loss.** Switching energies also change with temperature, usually by less than $R_{DS(on)}$. Data sheets that give $E_{on}$ and $E_{off}$ at two temperatures let you interpolate. - **The low-side switch.** In a synchronous buck it conducts for $(1-D)$ of the period and switches at nearly zero voltage, so its loss is mostly conduction, body-diode conduction during the dead time and reverse recovery. See [dead-time effects](https://voltecx-web.nguyenvanqui291.workers.dev/blog/dead-time-effects). The loss equations follow standard treatments such as R. W. Erickson and D. Maksimović, *Fundamentals of Power Electronics*, 3rd ed., and manufacturers' application notes on MOSFET power loss. Device values come from the data sheet of the part. ## Try it in Voltecx - The `buckThermal` example adds a thermal model that heats the MOSFET junction during the run, and `inverter3Thermal` does the same for every device of a three-phase inverter. - `analysis.losses` returns the average conduction and switching loss of each switch and diode over a time window, and `analysis.thermal` the temperatures of a circuit with a thermal network. - `design.efficiency` gives the efficiency at four loads and the loss of each device at full load. `design.thermal` gives each junction temperature and the heatsink thermal resistance you need. - In `design.auto`, the operatingTemperature stage reads the conduction model again at the junction temperature it found, then runs efficiency and thermal again: the same iteration as above. The built-in vendor library has 22 parts digitised from manufacturers' data sheets, each with its source. The data sheets of the low-voltage MOSFETs in it give gate charge and switching times but no switching energy, so those parts add no switching loss in the simulation. Their notes list the charges and times for a hand estimate like the one in this article. --- # Dead-time effects in inverters and synchronous converters, with numbers URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/dead-time-effects/ Every half bridge needs dead time: a short interval when both switches are off, so that one switch never turns on before the other has turned off. Dead time prevents shoot-through, but it is not free. During it the load current flows through a diode, and the bridge stops following its command. This article quantifies three consequences: the voltage error and distortion in an inverter, the extra loss in a synchronous buck, and the dead time that soft switching needs. ## What happens during dead time Consider one inverter leg with a DC link $V_{dc}$, an upper switch, a lower switch and their antiparallel diodes. The output current $i$ is positive when it flows out of the leg into the load. - **Upper switch turning on, $i > 0$.** The lower switch turns off first. During the dead time $t_d$, the current keeps flowing out through the lower diode, so the output stays at 0 V. The upper switch then turns on and the output rises. The leg loses $t_d V_{dc}$ of volt-seconds compared with the command. - **Upper switch turning off, $i > 0$.** The current moves to the lower diode at once, which is what the command wanted. No error. For negative current the roles swap: the upper diode holds the output at $V_{dc}$ during the dead time after the upper switch turns off, and the leg gains volt-seconds. ## The average voltage error Over one switching period $T_s = 1/f_{sw}$, the average leg voltage is off by $$\Delta V = -\,\mathrm{sign}(i)\; t_d\, f_{sw}\, V_{dc}$$ It does not depend on the duty cycle or on the size of the current, only on its sign. Switching delays add to it: a fuller expression is $\Delta V \approx -\mathrm{sign}(i)\,(t_d + t_{on} - t_{off})\,f_{sw} V_{dc}$, plus the conduction drops of the switch and diode. In a full bridge with bipolar PWM, the errors of both legs add, so the output error is $2 t_d f_{sw} V_{dc}$. ### A worked example A three-phase inverter has $V_{dc} = 400$ V, $f_{sw} = 20$ kHz and $t_d = 1$ µs: $$|\Delta V| = 1\,\mu\text{s} \times 20\,\text{kHz} \times 400\ \text{V} = 8\ \text{V}$$ ![The buckSync example in Voltecx used as one leg: Q1 and Q2 at 400 V, 20 kHz with 1 µs dead time, the PI held at a duty of 0.5, L1 10 mH and a 19.2 Ω load.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/dead-time-effects/leg.svg) ![One rising edge of the leg simulated in Voltecx: the switch node v(sw) and the gate signals g1 (upper) and g2 (lower). For 1 µs after g2 falls both switches are off and the node stays at 0 V.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/dead-time-effects/leg-dead-time.svg) Simulated in Voltecx, a leg at 400 V, 20 kHz and 1 µs of dead time, commanded to a duty of 0.5 while it carries a steady positive 10 A, averages 191.9 V instead of 200 V: the 8 V of the formula plus 0.1 V of switch drops. With sine-triangle PWM at a modulation index of 0.9, the phase fundamental is $0.9 \times 200 = 180$ V peak. The error is a square wave of ±8 V in phase with the current. Its Fourier series is $$\Delta v(t) = \frac{4 \times 8}{\pi} \left(\sin\theta + \frac{1}{3}\sin 3\theta + \frac{1}{5}\sin 5\theta + \frac{1}{7}\sin 7\theta + \dots\right)$$ - The fundamental is $32/\pi = 10.2$ V, about 5.7 % of the output, lost at unity power factor. - The third harmonic cancels between phases in a three-wire system. - The fifth and seventh, 2.0 V and 1.5 V, remain in the line-to-line voltage and drive harmonic currents in a low-impedance load such as a motor. At low speed in a motor drive, where the commanded voltage is small, the same 8 V becomes a large fraction of the output. It shows up as current distortion near each zero crossing and as torque ripple at six times the electrical frequency. ### Compensation The usual fix is to add $\mathrm{sign}(i)\, t_d f_{sw} V_{dc}$ to each phase reference. The difficulty is the sign near the zero crossing, where the measured current is noisy and the switch-node capacitance makes the error smaller than the formula says. Practical schemes use the sign of the current reference, a ramp instead of a step around zero, or a measured-voltage feedback. ## Dead time in a synchronous buck In a synchronous buck the inductor current is normally positive at both edges, so the body diode of the low-side MOSFET conducts in both dead-time intervals. That adds two losses. **Body-diode conduction.** With output current $I_o$ and diode drop $V_f$: $$P_{bd} = V_f\, I_o \cdot 2 t_d\, f_{sw}$$ For $I_o = 20$ A, $V_f = 0.8$ V, $t_d = 30$ ns and $f_{sw} = 500$ kHz: $$P_{bd} = 0.8 \times 20 \times 2 \times 30\,\text{n} \times 500\,\text{k} = 0.48\ \text{W}$$ ![The synchronous buck around one switching edge in Voltecx: the node v(sw) sits at −0.8 V while the body diode of Q2 carries the current i(Q2) during each 30 ns dead time.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/dead-time-effects/sync-buck-body-diode.svg) In a Voltecx simulation of this buck (12 V in, 30 ns of dead time, a 0.8 V body diode, 19.4 A of load current), the body diode conducts for 2.9 % of each period and loses 0.46 W, within 3 % of the formula at the simulated current; at 20 A the formula gives the 0.48 W above. **Reverse recovery.** When the high side turns on, it must sweep out the body diode's stored charge $Q_{rr}$: $$P_{rr} \approx Q_{rr}\, V_{in}\, f_{sw} = 50\,\text{nC} \times 12\ \text{V} \times 500\,\text{kHz} = 0.30\ \text{W}$$ At a high switching frequency these two can be a large share of the total loss, which is why adaptive dead-time drivers and MOSFETs with a Schottky in parallel exist. ## The dead time that soft switching needs Dead time can also do useful work. If the current at the end of a switch's on-time flows in the right direction, it charges the output capacitance of the switch that turned off and discharges the one about to turn on. When the switch-node voltage reaches the opposite rail before the dead time ends, the next switch turns on at zero voltage (ZVS). Treating the two output capacitances as a linear $C_{oss,tr}$ each, charged by a constant current $I$, the swing takes $$t_{swing} \approx \frac{2\, C_{oss,tr}\, V_{dc}}{I}$$ For $V_{dc} = 400$ V, $C_{oss,tr} = 100$ pF and $I = 5$ A, the swing takes 16 ns. Choosing the dead time is then a balance: - **Too short** (below $t_{swing}$): the switch turns on while voltage remains across it, and the remaining charge is dissipated in it. At 0.5 A of light-load current, the same swing would take 160 ns. - **Too long** (well above $t_{swing}$): the node reaches the rail and the body diode conducts for the rest of the dead time, adding diode loss and, in some topologies, reverse recovery. Since $t_{swing}$ scales with $1/I$, a fixed dead time is usually right at one load only. Converters such as the phase-shifted full bridge and the LLC are designed around this effect. The analysis follows the half-bridge treatment found in standard texts such as Mohan, Undeland and Robbins, *Power Electronics*, and R. W. Erickson and D. Maksimović, *Fundamentals of Power Electronics*, 3rd ed. Capacitance values come from the MOSFET data sheet ($C_{o(tr)}$ and $C_{o(er)}$). ## Try it in Voltecx - The `buckSync` example is a synchronous buck with a MOSFET and dead time in place of the diode. The `inverter3` example is a three-phase inverter with sine-triangle PWM. - `analysis.softSwitching` reads every gate edge of every switch and classifies each turn-on as ZVS, partial or hard. For each leg it measures how long the switch node took to swing, compares that with the dead time, and says whether the dead time is too short or too long, with a value to use. Its `sweep` option finds where ZVS is lost over load. - `analysis.losses` returns the conduction and switching loss of each switch and diode, and `analysis.fft` gives the harmonics and THD of the output current. Set `coss` on the switches and use the variable-step solver to see the transitions. With no capacitance, the switch node swings within one step. --- # Conducted EMI pre-compliance for switching converters: estimate before the lab URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/conducted-emi-pre-compliance/ A failed conducted-emission scan late in a project usually means a new filter, a new board spin and a missed date. Most of that can be predicted on paper. This article shows how to estimate the conducted emission of a DC-DC converter by hand, how to size an input filter for it, and how to keep that filter from destabilising the converter. The numbers are a pre-compliance estimate. Only a measurement in an accredited set-up is a compliance result. ## What is measured Conducted emission is the noise voltage the equipment puts on its power port between 150 kHz and 30 MHz. A **line impedance stabilisation network (LISN)** sits between the supply and the equipment under test. It gives the noise a defined impedance, nominally 50 Ω in parallel with 50 µH per line (the V-network of CISPR 16-1-2), and it routes the noise to the receiver's 50 Ω input. The receiver measures in a 9 kHz bandwidth with a quasi-peak and an average detector. For CISPR 32 class B (residential equipment), the mains-port limits are: | Frequency | Quasi-peak | Average | |---|---|---| | 0.15–0.5 MHz | 66 → 56 dBµV, falling linearly with log f | 56 → 46 dBµV | | 0.5–5 MHz | 56 dBµV | 46 dBµV | | 5–30 MHz | 60 dBµV | 50 dBµV | Class A (commercial and industrial equipment) is 79/66 dBµV below 0.5 MHz and 73/60 dBµV above. The sloped section of class B falls by 10 dB over $\log_{10}(0.5/0.15) = 0.523$ decades, which is 19.1 dB per decade. ## Two kinds of noise - **Differential mode (DM)** current flows out on one line and back on the other. In a converter it comes from the pulsed input current that the input capacitor cannot fully absorb. It dominates at low frequency. - **Common mode (CM)** current flows out on both lines together and returns through ground. It comes from fast voltage edges on the switch node driving parasitic capacitance to the chassis or heatsink. It dominates at high frequency. The two need different filter parts: series inductance and line-to-line (X) capacitance for DM, a common-mode choke and line-to-ground (Y) capacitance for CM. ## A worked DM estimate Take a buck converter: $V_{in} = 48$ V, $V_{out} = 12$ V, $I_{out} = 5$ A, $f_{sw} = 200$ kHz, so $D = 0.25$. The input current is a pulse train of height 5 A and duty 0.25. The amplitude of its $n$-th harmonic is $$I_n = \frac{2 I_{out}}{n\pi} \left|\sin(n\pi D)\right|$$ The fundamental at 200 kHz is $I_1 = (10/\pi) \sin 45° = 2.25$ A peak. Almost all of this current circulates in the input capacitor. With $C_{in} = 10$ µF of ceramic capacitance, its reactance at 200 kHz is $$X_C = \frac{1}{2\pi \times 200\,\text{k} \times 10\,\mu} = 0.080\ \Omega$$ so the ripple voltage on $C_{in}$ is $2.25 \times 0.080 = 0.18$ V peak. The LISN impedance is hundreds of times larger, so this voltage appears across the two LISNs in series, and each measures half: 0.090 V peak, or 63 mV RMS. $$20 \log_{10}\left(\frac{63\,400\ \mu\text{V}}{1\ \mu\text{V}}\right) = 96\ \text{dB}\mu\text{V}$$ The class B average limit at 200 kHz is $56 - 19.1 \log_{10}(200/150) = 53.6$ dBµV. A narrowband harmonic reads the same on the average and quasi-peak detectors, so the average limit governs. With a 6 dB design margin, the filter must attenuate $$96 - 53.6 + 6 \approx 48\ \text{dB at 200 kHz}$$ ![The 48 V to 12 V, 5 A, 200 kHz buck in Voltecx with the 10 µF input capacitor Cin.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/conducted-emi-pre-compliance/buck.svg) ![Average-detector spectrum from Voltecx's emi.conducted against the CISPR 32 class B average limit, without a filter and with the filter it sizes.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/conducted-emi-pre-compliance/spectrum.svg) Voltecx's `emi.conducted` on the same buck puts one LISN in the supply line, with the return through ground, so it reads the whole 0.18 V of input ripple rather than half: 102.1 dBµV at 200 kHz, 6 dB above the estimate for two LISNs. With the 6 dB margin it asks for 54.5 dB at 200 kHz, and the damped filter it builds from catalogue parts (each at or above the value the corner needs), which meets Middlebrook's condition, brings the fundamental down to 33.5 dBµV. Moving $f_{sw}$ below 150 kHz would push the fundamental out of the band, but its harmonics stay in. That trick shifts the problem; it does not remove it. ## Sizing the input filter Add an LC section between the LISN and $C_{in}$: a series inductor $L_f$ and a capacitor $C_f$ across the line on the LISN side. Well above its resonance, it attenuates by 40 dB per decade: $$A(f) \approx \left(\frac{f}{f_f}\right)^2, \qquad f_f = \frac{1}{2\pi\sqrt{L_f C_f}}$$ For 48 dB at 200 kHz, $f_f \le 200\,\text{k} / 10^{48/40} = 12.6$ kHz. With $C_f = 4.7$ µF: $$L_f = \frac{1}{(2\pi f_f)^2 C_f} = \frac{1}{(2\pi \times 12.6\,\text{k})^2 \times 4.7\,\mu} \approx 34\ \mu\text{H}$$ The inductor must carry the full DC input current without saturating: 1.5 A at a minimum input of 40 V and 60 W. ## Middlebrook's condition A regulated converter draws constant power, so its input looks like a negative resistance at low frequency: $$Z_{in} \approx -\frac{V_{in}^2}{P}$$ At $V_{in,min} = 40$ V and 60 W, $|Z_{in}| = 26.7\ \Omega$. If the filter's output impedance, seen from the converter, peaks near this value, the loop gain changes and the system can oscillate. R. D. Middlebrook's condition asks that the filter's output impedance stay well below $|Z_{in}|$. A common margin is a factor of 3 (9.5 dB), so here the peak must stay below 8.9 Ω. An undamped LC has an infinite peak, so it always fails. A damping branch, a resistor $R_f$ in series with a capacitor $C_b = n C$ across the filter capacitor, limits it. Following Erickson and Maksimović's chapter on input filter design, the optimum peak with characteristic impedance $R_0 = \sqrt{L_f/C}$ is $$\|Z_o\|_{mm} = R_0 \frac{\sqrt{2(2+n)}}{n}, \qquad R_{f,opt} = R_0 \sqrt{\frac{(2+n)(4+3n)}{2n^2(4+n)}}$$ Taking $C$ as the converter's 10 µF input capacitance, $R_0 = \sqrt{34\,\mu/10\,\mu} = 1.84\ \Omega$. With $n = 1$, the peak is $1.84 \times 2.45 = 4.5\ \Omega$, below the 8.9 Ω target, using $R_f = 1.84 \times 1.45 = 2.7\ \Omega$ and $C_b = 10$ µF. ## A CM estimate Suppose the switch node has 20 pF of parasitic capacitance to a grounded heatsink. The switch node is a trapezoid of 48 V amplitude, so its harmonic envelope above $1/(\pi D T_s)$ is $2 V f_{sw} / (\pi f)$. At 10 MHz (the 50th harmonic, which lies on the envelope here): $$V_{50} = \frac{2 \times 48 \times 200\,\text{k}}{\pi \times 10\,\text{M}} = 0.61\ \text{V}, \qquad I_{cm} = 2\pi f C_p V_{50} = 0.77\ \text{mA}$$ CM current returns through both LISNs in parallel, so each carries half and measures $0.38\ \text{mA} \times 50\ \Omega = 19$ mV peak, about 83 dBµV. Against the 60 dBµV quasi-peak limit, that calls for roughly 30 dB of CM attenuation with margin. The edge's rise time adds a further −20 dB per decade above $1/(\pi t_r)$, which is 32 MHz for 10 ns, so it does not help within the band. ## What a hand estimate misses Real boards add parasitic inductance in the input capacitor, coupling between filter parts, and radiated pick-up into the LISN cables. The estimate is good for choosing a filter topology and its order of magnitude. Leave margin, and measure early with a LISN and a spectrum analyser. ## Try it in Voltecx - `emi.conducted` puts a LISN model (50 µH, 0.1 µF, 50 Ω) on a copy of your circuit, takes the spectrum of the simulated input current through a model of a 9 kHz receiver with peak, quasi-peak and average detectors, and holds it to the CISPR 32 class A or class B limit band by band. When the margin is short, it sizes a damped one- or two-stage filter that meets Middlebrook's condition, and inserts it only when you pass `apply: true`. - `design.auto` runs the same estimate as its emi stage and verifies the filtered circuit again. The result says `preCompliance: true`. It is an estimate, not a compliance measurement, and it depends on the parasitics your circuit has. A schematic has few, so draw the switch-node capacitance and the input-capacitor ESL if you want them counted. `emi.conducted` covers the conducted band only. --- # Flyback transformer design in ten steps, with a worked example URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/flyback-transformer-design-steps/ A flyback "transformer" is really a coupled inductor: it stores energy while the switch is on and delivers it to the output while the switch is off. That changes how you design it. The core has to hold energy in an air gap, the turns ratio sets the voltage stress on both semiconductors, and the leakage inductance turns into clamp loss. This article walks through the design of a 24 W offline flyback in ten steps. ## The specification - Input: rectified universal mains. Take the bulk-capacitor valley at low line as $V_{in,min} = 100$ V and the peak at high line as $V_{in,max} = 375$ V. - Output: $V_{out} = 12$ V at $I_{out} = 2$ A, so $P_{out} = 24$ W. - Switching frequency: $f_{sw} = 100$ kHz. - Expected efficiency: $\eta = 0.85$. - Switch: a 650 V MOSFET. Output rectifier forward drop: $V_f = 0.5$ V. ## Step 1: input power $$P_{in} = \frac{P_{out}}{\eta} = \frac{24}{0.85} = 28.2\ \text{W}$$ ## Step 2: choose the reflected voltage While the secondary conducts, the output voltage is reflected to the primary as $V_{OR} = n (V_{out} + V_f)$. The MOSFET then sees $$V_{DS,max} = V_{in,max} + V_{OR} + V_{spike}$$ A higher $V_{OR}$ gives a larger duty cycle and lower primary currents, but more voltage stress. Take $V_{OR} = 100$ V. With 375 V of input, that leaves 175 V of a 650 V rating for the leakage spike and margin. ## Step 3: turns ratio $$n = \frac{N_p}{N_s} = \frac{V_{OR}}{V_{out} + V_f} = \frac{100}{12.5} = 8$$ The rectifier diode then blocks $V_{out} + V_{in,max}/n = 12 + 375/8 = 59$ V, plus ringing. ## Step 4: maximum duty cycle At the boundary between continuous and discontinuous conduction, volt-second balance on the magnetising inductance gives $$D_{max} = \frac{V_{OR}}{V_{in,min} + V_{OR}} = \frac{100}{100 + 100} = 0.5$$ ## Step 5: magnetising inductance Decide on the conduction mode first. This design runs in discontinuous conduction (DCM) at full load and low line, which keeps the loop simple and removes the diode's reverse recovery. At the boundary, the average input current and the peak current are $$I_{in} = \frac{P_{in}}{V_{in,min}} = 0.282\ \text{A}, \qquad I_{pk} = \frac{2 I_{in}}{D_{max}} = 1.13\ \text{A}$$ $$L_{m,BCM} = \frac{V_{in,min} D_{max}}{f_{sw} I_{pk}} = \frac{100 \times 0.5}{100\text{k} \times 1.13} = 442\ \mu\text{H}$$ Any $L_m$ below this keeps the converter in DCM. Choose $L_m = 400$ µH. In DCM the energy per cycle sets the peak current: $$I_{pk} = \sqrt{\frac{2 P_{in}}{L_m f_{sw}}} = \sqrt{\frac{2 \times 28.2}{400\,\mu \times 100\text{k}}} = 1.19\ \text{A}$$ $$D = \frac{I_{pk} L_m f_{sw}}{V_{in,min}} = \frac{1.19 \times 400\,\mu \times 100\text{k}}{100} = 0.475$$ The secondary conducts for $D_2 = D \cdot V_{in,min}/V_{OR} = 0.475$ of the period. Since $D + D_2 = 0.95 < 1$, the core resets before the next cycle, and the converter is in DCM as intended. ## Step 6: RMS currents For a triangular current pulse of peak $I_{pk}$ and duty $D$, the RMS value is $I_{pk}\sqrt{D/3}$: $$I_{p,rms} = 1.19 \times \sqrt{0.475/3} = 0.47\ \text{A}$$ $$I_{s,pk} = n I_{pk} = 9.5\ \text{A}, \qquad I_{s,rms} = 9.5 \times \sqrt{0.475/3} = 3.78\ \text{A}$$ These secondary values are slightly pessimistic, because they assume the full input power reaches the secondary. ## Step 7: core size by area product The area product method sizes the core from the energy it must store and the copper it must hold: $$A_p = A_e A_w = \frac{L_m I_{pk} I_{p,rms}}{B_{max} J K_u}$$ Take $B_{max} = 0.25$ T for a power ferrite at 100 kHz, a current density $J = 4$ A/mm², and a window share $K_u = 0.25$ for the primary (the secondary, insulation and margins take the rest): $$A_p = \frac{400\,\mu \times 1.19 \times 0.47}{0.25 \times 4 \times 10^{6} \times 0.25} \approx 9.0 \times 10^{-10}\ \text{m}^4 = 900\ \text{mm}^4$$ Pick a core above this with room for safety insulation. For the rest of the example, suppose the chosen core has $A_e = 32$ mm² and a window larger than 28 mm² (the minimum that satisfies $A_p$). ## Step 8: turns The primary turns keep the peak flux density below $B_{max}$: $$N_p \ge \frac{L_m I_{pk}}{B_{max} A_e} = \frac{400\,\mu \times 1.19}{0.25 \times 32\,\mu} = 59.5$$ Choose $N_p = 64$ and $N_s = N_p / n = 8$. The peak flux density is then $400\,\mu \times 1.19 / (64 \times 32\,\mu) = 0.232$ T. ## Step 9: air gap The inductance factor is $$A_L = \frac{L_m}{N_p^2} = \frac{400\,\mu\text{H}}{4096} = 97.7\ \text{nH/turn}^2$$ Neglecting fringing and the core's own reluctance, the gap length is $$l_g \approx \frac{\mu_0 N_p^2 A_e}{L_m} = \frac{4\pi \times 10^{-7} \times 4096 \times 32 \times 10^{-6}}{400 \times 10^{-6}} = 0.41\ \text{mm}$$ Fringing makes the effective gap area larger than $A_e$, so the measured inductance comes out higher. In practice you order the gapped core by its $A_L$ value and trim on the bench. ## Step 10: wire, leakage and clamp **Wire.** The primary needs $0.47 / 4 = 0.12$ mm², a round wire of about 0.39 mm. The skin depth of copper at 100 kHz is about $66/\sqrt{f}$ mm $= 0.21$ mm, so a single 0.39 mm strand is acceptable. The secondary's 3.78 A RMS needs about 0.95 mm², which should be several parallel strands or litz wire. Interleaving the primary around the secondary reduces both leakage and proximity loss. **Leakage and clamp.** The leakage inductance does not couple to the secondary, so its energy must go somewhere at turn-off. An RCD clamp absorbs it. With leakage at 1 % of $L_m$ ($L_{lk} = 4$ µH) and a clamp voltage $V_{cl} = 150$ V: $$P_{clamp} = \frac{1}{2} L_{lk} I_{pk}^2 f_{sw} \frac{V_{cl}}{V_{cl} - V_{OR}} = \frac{1}{2} \times 4\,\mu \times 1.41 \times 100\text{k} \times \frac{150}{50} = 0.85\ \text{W}$$ That is 3.5 % of the output power, which is why low leakage matters. The MOSFET peak is $375 + 150 = 525$ V before ringing, inside the 650 V rating. ![Two switching periods of this flyback at low line, simulated in Voltecx: the primary current i(S1), the secondary current i(D1) and the drain voltage v(drain).](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/flyback-transformer-design-steps/winding-currents.svg) **A simulated check.** The design was simulated in Voltecx at low line: 100 V input, $D = 0.475$, $L_m = 400$ µH, $n = 8$, 1 % leakage, a 0.5 V rectifier and an RCD clamp. It runs in DCM as intended, with idle time in every period. The primary current peaks at 1.10 A rather than 1.19 A: during the idle time the drain rings (the magnetising inductance with the switch's capacitance), and the next on-time starts from a small negative current. The secondary peaks at 11.2 A, and its current and the drain voltage ring with the leakage inductance. With the clamp resistor sized for 0.85 W at 150 V (26.5 kΩ), the clamp settles at 135 V and the resistor takes 0.69 W, so the clamp-loss formula errs on the safe side here. ## What to verify next - Run the design at high line, where the duty cycle is smallest and the switch voltage highest. - Check that the peak flux density stays below saturation at the hottest core temperature, since ferrite saturation flux falls with temperature. - Estimate core loss from the manufacturer's loss curves at the actual flux swing and frequency, and copper loss including AC resistance. The method follows the energy-storage design of coupled inductors in R. W. Erickson and D. Maksimović, *Fundamentals of Power Electronics*, 3rd ed., in its chapters on inductor and transformer design. Core and material data come from the manufacturer's data sheet. ## Try it in Voltecx - The `flyback` and `flybackClosedLoop` examples show an open-loop and a closed-loop flyback with a coupled inductor. - `magnetics.design` designs an inductor or transformer from its simulated current: core, material, gap, turns and wire. A coupled part is checked on its magnetising current. - `design.auto` with `"topology": "flyback"` draws a flyback, designs its magnetics, closes the loop over the input and load corners and, for an isolated design, sizes a TL431 and optocoupler feedback network. `magnetics.design` searches the OpenMagnetics MAS starter set, which is a subset of cores, materials and wires. Its temperature rise is a natural-convection estimate, and saturation is modelled as two straight slopes. Confirm the chosen core, gap and wire against the manufacturer's data sheet. --- # Buck converter PI compensator design: a worked example URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/buck-converter-pi-compensator-design/ A PI controller is the first compensator most engineers reach for, and on a buck converter it works well or badly depending on what it is wrapped around. This article sizes the power stage of a 12 V to 3.3 V, 5 A buck, then designs its loop twice: once in voltage mode, where a PI runs into the LC double pole, and once in peak-current mode, where a PI is the right tool. Every number is worked out so you can check it. ## The power stage Specification: $V_{in} = 12$ V, $V_{out} = 3.3$ V, $I_{out} = 5$ A, $f_{sw} = 200$ kHz. The duty cycle in continuous conduction is $$D = \frac{V_{out}}{V_{in}} = \frac{3.3}{12} = 0.275$$ Choose an inductor ripple of about 30 % of full load, $\Delta I \approx 1.5$ A: $$L = \frac{(V_{in} - V_{out})\,D}{f_{sw}\,\Delta I} = \frac{8.7 \times 0.275}{200\,\text{kHz} \times 1.5\,\text{A}} = 7.98\ \mu\text{H}$$ Take the standard value 8.2 µH. The ripple becomes $\Delta I = 2.39 / (200\text{k} \times 8.2\,\mu) = 1.46$ A. With $C = 100$ µF of ceramic capacitance and an ESR of 5 mΩ, the output ripple has two parts: $$\Delta V_C = \frac{\Delta I}{8 f_{sw} C} = \frac{1.46}{8 \times 200\text{k} \times 100\,\mu} = 9.1\ \text{mV}, \qquad \Delta V_{ESR} = \Delta I \cdot R_{ESR} = 7.3\ \text{mV}$$ The two are not in phase, so the total is below their sum of 16.4 mV. ![The buck power stage in Voltecx: Vin 12 V, switch S1 and diode D1, L1 8.2 µH, C1 100 µF with 5 mΩ ESR, and the 0.66 Ω load, driven open loop at D = 0.275 by a 200 kHz PWM.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/buck-converter-pi-compensator-design/power-stage.svg) ![Two switching periods in steady state, simulated in Voltecx: inductor current i(L1), output voltage v(out) and switch node v(sw).](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/buck-converter-pi-compensator-design/steady-state.svg) The simulation of this circuit gives a peak-to-peak inductor ripple of 1.46 A and an output ripple of 10.9 mV, between the 9.1 mV capacitive part and the 16.4 mV sum. ## The plant: the LC double pole In voltage mode, the control-to-output transfer function of a buck is $$G_{vd}(s) = \frac{V_{in}}{V_M} \cdot \frac{1 + s R_{ESR} C}{1 + s\frac{L}{R} + s^2 LC}$$ where $V_M$ is the PWM ramp amplitude. With $V_M = 1$ V the DC gain is 12 (21.6 dB). The double pole sits at $$f_0 = \frac{1}{2\pi\sqrt{LC}} = \frac{1}{2\pi\sqrt{8.2\,\mu\text{H} \times 100\,\mu\text{F}}} = 5.56\ \text{kHz}$$ and its quality factor at full load ($R = 0.66\ \Omega$) is $$Q = R\sqrt{\frac{C}{L}} = 0.66 \times 3.49 = 2.3$$ The ESR zero is at $1/(2\pi R_{ESR} C) = 318$ kHz, above the switching frequency, so it gives no help. Above $f_0$ the plant phase heads to −180°. Two facts follow. First, the gain peaks by $Q$ at $f_0$, which is +7.2 dB at full load. Second, $Q$ grows as the load gets lighter: at 0.5 A, $R = 6.6\ \Omega$ and only the inductor's DCR and the capacitor's ESR damp the resonance. With 10 mΩ of DCR and 5 mΩ of ESR, the series-loss limit is $Q \approx \sqrt{L/C}/(R_{DCR}+R_{ESR}) = 0.286/0.015 \approx 19$. Plan for a light-load $Q$ near 10. ![Bode plot of the duty-to-output transfer function $G_{vd}$ from Voltecx's design.voltageLoop, at 5 A (R = 0.66 Ω) and at 0.5 A (R = 6.6 Ω, load damping only), with the double pole at 5.56 kHz marked.](https://voltecx-web.nguyenvanqui291.workers.dev/media/blog/buck-converter-pi-compensator-design/plant-bode.svg) In the plot, the load alone leaves $Q = 23$ at 0.5 A. The series losses ($Q \approx 19$) damp it in parallel, $1/(1/23 + 1/19) \approx 10$, which is the value to plan for. ## Attempt 1: a PI in voltage mode The feedback divider sets $V_{out}$ from a 0.8 V reference, so $H = 0.8/3.3 = 0.242$. A PI is $$G_c(s) = K_p + \frac{K_i}{s} = K_p\left(1 + \frac{\omega_z}{s}\right), \quad \omega_z = \frac{K_i}{K_p}$$ Below $f_0$ the plant is flat, so the loop is dominated by the integral term: $$T(f) \approx \frac{V_{in}}{V_M} H \frac{K_i}{2\pi f} = \frac{2.91\,K_i}{2\pi f}$$ The PI adds nothing to cancel the −180° of the double pole. At $f_0$ the loop phase is −90° (integrator) plus −90° (plant), so $f_0$ is where the gain margin is read. To keep the resonant peak 10 dB below 0 dB at the light-load $Q = 10$: $$\frac{2.91\,K_i}{2\pi \times 5560} \times 10 \le 0.316 \;\Rightarrow\; K_i \le 380\ \text{s}^{-1}$$ The crossover is then $f_c = 2.91 \times 380 / 2\pi = 176$ Hz. That is stable, with a phase margin near 90°, but it is about a hundred times slower than the switching frequency allows. A 1 A to 5 A load step would droop for milliseconds. This is the textbook reason why voltage-mode bucks use a Type III compensator. Its two zeros, placed near $f_0$, cancel the double pole's phase, and two poles (one at the ESR zero or at $f_{sw}/2$, one to roll off noise) keep the high-frequency gain down. The crossover can then sit near $f_{sw}/10 = 20$ kHz. ## Attempt 2: a PI in peak-current mode With an inner peak-current loop, the inductor behaves like a current source. To a first approximation the control-to-output transfer function becomes first order: $$G_{vc}(s) \approx \frac{R}{R_i} \cdot \frac{1 + s R_{ESR} C}{1 + s R C}$$ where $R_i$ is the current-sense gain in V/A. Take $R_i = 0.25$ V/A. At full load the pole is at $$f_p = \frac{1}{2\pi R C} = \frac{1}{2\pi \times 0.66 \times 100\,\mu} = 2.41\ \text{kHz}$$ Above $f_p$, the plant magnitude is $1/(2\pi R_i C f)$, which does not depend on the load. That is the property that makes current mode easy to compensate. Target $f_c = 20$ kHz. The plant there is $$|G_{vc}| = \frac{1}{2\pi \times 0.25 \times 100\,\mu \times 20\,\text{k}} = 0.318$$ Place the PI zero at the full-load pole, $f_z = 2.41$ kHz. Above the zero the PI gain is about $K_p$, so the crossover condition is $$K_p \times 0.318 \times 0.242 = 1 \;\Rightarrow\; K_p = 13.0$$ $$K_i = K_p \cdot 2\pi f_z = 13.0 \times 15\,140 = 1.97 \times 10^5\ \text{s}^{-1}$$ The plant contributes −83° at 20 kHz and the PI −7°, so the idealised margin is 90°. The real margin is lower, because a current-mode buck also has a sampling double pole at $f_{sw}/2$ (Ridley's model). With slope compensation that gives that pole a Q of about 0.64, it costs roughly 18° at $f_{sw}/10$, which leaves about 72°. At light load the pole moves down to 241 Hz, but the gain above it is unchanged, so the crossover stays at 20 kHz and the zero simply sits above the pole. ## Checks before you build - **Crossover limit.** Keep $f_c$ at or below $f_{sw}/10$ to stay clear of the sampling effects and of the switching ripple in the feedback path. - **Corners.** Check the margin at minimum and maximum input and at light and full load. A voltage-mode plant changes gain with $V_{in}$; feed-forward of the ramp removes that. - **Digital delay.** A digital controller adds about 1.5 sampling periods of delay. At 20 kHz crossover and 200 kHz sampling, that is $360° \times 20/200 \times 1.5 = 54°$ of phase lag. A digital design needs a lower crossover or a faster sampling rate. - **Measure the loop gain.** The models above are averaged approximations. Confirm the margin by injecting a small signal into the switching circuit, as described in [loop gain and phase margin in simulation](https://voltecx-web.nguyenvanqui291.workers.dev/blog/loop-gain-phase-margin-simulation). The formulas follow R. W. Erickson and D. Maksimović, *Fundamentals of Power Electronics*, 3rd ed. (converter transfer functions, controller design and current-programmed control), and R. B. Ridley's current-mode model. ## Try it in Voltecx - Open the `buckClosedLoop` example (**File > Open Example**), which holds 12 V from 48 V with a PI. - `design.voltageLoop` designs a voltage-mode compensator: a PI, Type II or Type III. It writes `kp` and `ki` into the PI block, or a `tf` block for Type II or III. - `analysis.loopGain` with `"method": "perturbation"` measures the loop gain on the switching circuit, delays included. - `design.robustLoop` designs the loop over every corner of input, load, inductor, capacitor, ESR and modulator delay, and says why when no design passes every corner. The design equations in Voltecx are textbook equations for an ideal converter in continuous conduction, and the report prints the formula it used. Check the result with a simulation at every corner before you trust it. --- # Voltecx beta: power electronics simulation that designs with you and shows its work URL: https://voltecx-web.nguyenvanqui291.workers.dev/blog/voltecx-beta-launch/ Today we are opening the beta of Voltecx, a power electronics simulator from Tecxmate. It is written from scratch in Rust, it runs on your own machine, and every action in it is a named command. You can reach each command from the window, from the command line, from Python, or from an AI assistant. This post explains what Voltecx is for and what it can do today. It also lists, just as plainly, what it cannot do yet. ## Why another simulator Power engineers already have good tools. Most of us work in a mix of them: a SPICE tool for device-level detail, a system-level simulator for converters and drives, MATLAB for control, and a spreadsheet for losses and magnetics. Moving a design between them is manual work, and the reasoning behind a design often lives in someone's notebook. We built Voltecx around three ideas. 1. **Design from a specification.** You give the input range, the output, the load and the limits that matter to you. Voltecx proposes a topology, sizes the parts, closes the loop, checks every corner by simulation and writes a report that says what passed, what failed and what it did not check. 2. **Check every number.** Two independent solvers check each other, and both are compared with closed-form answers, data-sheet values and ngspice waveforms. Every estimate in a report is labelled as an estimate, with its source. 3. **Automate everything.** The menus, the command line, Python, a JSON control channel and the built-in assistant all run the same commands. Anything you can click, a script or an AI agent can do too, and the agent's edits arrive as proposals you accept or reject. ## What works today These numbers come from the repository's own reports, with the date they were measured. - **Accuracy report.** 22 of 22 comparisons are within tolerance. They cover RC, RL and RLC step responses against closed-form answers and against ngspice-47 waveforms, half-wave rectifiers, a 48 V to 12 V buck start-up at 100 kHz on both solvers, and SiC MOSFET double-pulse switching energies against the Wolfspeed C3M0065090D and Infineon IMT65R015M2H data sheets (errors from 6.9 % to 14.3 %, within a 30 % tolerance). See [Simulation](https://voltecx-web.nguyenvanqui291.workers.dev/features/simulation). - **File compatibility.** Voltecx was run against 699 public sample files, including 332 LTspice, 165 SPICE and 130 from other simulators. None of them crashed it. All 332 LTspice files and all 122 files in the other supported write-back format write back byte for byte identical when you have not edited them, and an edit changes only the lines it touches. Some formats open read-only. See [File compatibility](https://voltecx-web.nguyenvanqui291.workers.dev/features/file-compatibility). - **Automatic design.** `design.auto` draws and designs buck, synchronous buck, boost, synchronous boost, buck-boost, SEPIC, flyback, LLC and phase-shifted full-bridge converters. It sizes the magnetics, closes the voltage loop for most of them, checks every corner of your spec, picks parts from a data-sheet-backed library, estimates conducted EMI, and can write firmware, a bill of materials and a KiCad schematic. See [Automatic design](https://voltecx-web.nguyenvanqui291.workers.dev/features/auto-design). - **Analyses.** AC sweep, impedance and loop gain, DC operating point and sweep, parameter sweeps in one and two variables, Monte Carlo with a yield and its confidence interval, worst case, losses, thermal, FFT and THD, and soft-switching checks. See [Analyses](https://voltecx-web.nguyenvanqui291.workers.dev/features/analyses). - **Automation.** More than 170 engine commands, each with a JSON schema. There is a command-line tool, a Python package and a JSON-lines server. See [Automation](https://voltecx-web.nguyenvanqui291.workers.dev/features/automation). - **An assistant inside the app.** The agent panel reads your circuit, runs simulations and proposes changes as ghost parts on the schematic. It never edits your circuit by itself. See [AI assistant](https://voltecx-web.nguyenvanqui291.workers.dev/features/ai-assistant). - **Robustness.** More than 4,500 automated tests pass on the main branch (4,588 at the last local run, 2026-10-15). A fuzz test throws hostile parameters at every command. - **Documentation.** A user manual in English and Traditional Chinese, and reference pages for 137 components. ## What is not done yet We would rather you hear this from us than find it on your own. - **No comparison with other simulators' waveforms yet.** We have compared Voltecx with closed-form answers, data sheets and ngspice only. The file tests prove that a file opens, writes back and runs. They do not prove that the numbers match the original tool. - **No lab measurements yet.** No switching energy, magnetics loss, efficiency or junction temperature has been checked against a built board. - **Automatic design has gaps.** Power-factor correction is not part of `design.auto`. The four-switch buck-boost and the LLC keep an open loop. EMI, layout hints and prices are estimates. A design that passes its spec has passed in Voltecx's models. That is not a safety or compliance result. - **Some imported formats are read-only.** C blocks are kept as text and not run, so a closed loop built in a C block has to be rebuilt. - **Platforms.** The beta is built for macOS, and it is not notarised yet. Linux packages have been built, and only the command-line tool has been tried on them. Windows packages still have to be tested on Windows. - **The browser version** opens, saves and simulates, but it has not been checked feature by feature in a browser. - **The licence agreement** is a draft that a lawyer has yet to review. ## Plans and prices The Free tier runs on your machine and needs no account and no licence key. Today the Pro features (the agent, automatic design and import from other formats) need a licence file, and the agent uses your own Anthropic API key. We have not set prices yet. The [pricing page](https://voltecx-web.nguyenvanqui291.workers.dev/pricing) shows the plans and will show prices when they are set. ## How to try it 1. Sign up on this site for the beta download. 2. Open **File > Open Example > buck** and press **F5**. The scope shows the output settling near 12 V. 3. Try **Design > Auto Design** with a small spec such as 12 V to 3.3 V at 5 A, then read the report's not-checked list. 4. If you use LTspice, open one of your `.asc` files and read the import warnings. The [migration guide](https://voltecx-web.nguyenvanqui291.workers.dev/guides/migrate-from-ltspice) explains what maps and what does not. Tell us what breaks. Every bug report with a file attached makes the next beta better. --- LTspice is a trademark of Analog Devices, Inc.; other names belong to their owners. Voltecx is independent and not affiliated with them. --- # 1. Install URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/01-install/ Voltecx ships as two programs: - **Voltecx** (`powercraft`), the desktop app with the schematic editor and scope. - **powercraft-cli**, the command-line tool. It runs the same engine without a window. You use it for scripts, batch runs, file conversion and the terminal chat. ## System requirements Voltecx states only what its builds and tests support. Anything not listed here has not been checked yet. | Platform | Requirement | |---|---| | macOS | macOS 11 (Big Sur) or later, on Apple silicon (`aarch64`) or Intel (`x86_64`). The app declares this minimum, and macOS will not start it on an older version. | | Windows | 64-bit Windows on x86_64. Packages are built for `x86_64-pc-windows-msvc`. Which Windows versions it runs on has not been verified: a Windows build has so far been tried only under Wine on Linux, not yet on Windows 10 or 11. There is no package for Windows on Arm. | | Linux | 64-bit x86_64 with the GNU C library (`x86_64-unknown-linux-gnu`). The binaries link only `libc`, `libm` and `libgcc_s`, and the app loads the window-system and graphics libraries when it starts (see Linux below). Tested on Ubuntu 24.04 with software rendering and no GPU. The oldest distribution and C library version it runs on have not been established. There is no package for Linux on Arm. | Graphics: the app draws its window with wgpu, which uses the system's graphics driver (Metal on macOS, Vulkan on Linux). When wgpu finds no graphics adapter, the app starts with the OpenGL renderer (glow) instead, so a computer without a suitable GPU driver still works if it has OpenGL; on Linux, Mesa's software renderers were enough in testing. No minimum GPU, memory or disk space has been measured yet. The browser version needs no installation. ## Download Each release has one package per platform. Pick the one for your computer: | Platform | Package | What is inside | |---|---|---| | macOS | `powercraft--aarch64-apple-darwin.zip` or `.dmg` (Apple silicon); `x86_64-apple-darwin` for Intel Macs | `Voltecx.app`, `powercraft-cli`, the licence terms, `CHANGELOG.md` and this manual as Markdown files (`manual/`; in the `.dmg` these are in the `More` folder) | | Windows, portable | `powercraft--x86_64-pc-windows-msvc.zip` | `powercraft.exe`, `powercraft-cli.exe`, the licence terms, `CHANGELOG.md` and this manual as Markdown files (`manual/`) | | Windows, installer | `powercraft--x86_64-pc-windows-msvc.msi`, when one is published; `-zh-TW.msi` is the Traditional Chinese one | `powercraft.exe`, `powercraft-cli.exe` and the licence terms, installed in `C:\Program Files\Voltecx`; no manual | | Linux, tarball | `powercraft--x86_64-unknown-linux-gnu.tar.gz` | `bin/powercraft`, `bin/powercraft-cli`, `install.sh`, a desktop entry, the icons and the file type, the licence terms, `CHANGELOG.md` and this manual as Markdown files (`manual/`) | | Linux, AppImage | `Voltecx--x86_64.AppImage` | The desktop app with its desktop entry and icon, the licence terms, `CHANGELOG.md` and this manual as Markdown files (`manual/`), all inside the image in `usr/share/doc/powercraft/` (`--appimage-extract` unpacks them) | The licence terms are `LICENSE`, `EULA.md`, `EULA.zh-Hant.md`, `PRIVACY.md`, `PRIVACY.zh-Hant.md`, `NOTICE` and `ATTRIBUTION.md`. The manual is always on the Voltecx website too: **Help > Manual** opens it there, so you do not need a package that carries a copy. Each release also has a `SHA256SUMS-.txt` file. To check a download, compute its SHA-256 and compare it with the line in that file. On macOS and Linux run `shasum -a 256 ` (or `sha256sum `). On Windows run `certutil -hashfile SHA256`. ## macOS 1. Open the `.dmg` and drag `Voltecx.app` onto the `Applications` folder shown in the window (or unzip the `.zip` and move it there yourself). Then eject the disk image and start Voltecx from Launchpad or Spotlight; do not run it from the disk image. The command-line tool, manual and licences are in the `More` folder. 2. Start it. If the release is signed and notarised, it opens at once. 3. If macOS says it cannot verify the developer, or that Apple cannot check the app for malicious software, the build is not notarised (beta builds are not yet). Open it once like this: - **macOS 15 (Sequoia) and later:** click **Done** in the warning, open **System Settings > Privacy & Security**, scroll to the line about Voltecx, click **Open Anyway**, then confirm with your password. Start the app again. - **macOS 14 and earlier:** right-click `Voltecx.app`, choose **Open**, then **Open** again. You only do this once per version. 4. If macOS says the app "is damaged and can't be opened", the download's quarantine flag is blocking it. Run this in Terminal, then start the app again: ```sh xattr -dr com.apple.quarantine /Applications/Voltecx.app ``` To use the command-line tool from a terminal, copy `powercraft-cli` to a folder on your `PATH`, for example `/usr/local/bin`. A build that is not notarised also needs the quarantine flag cleared on the tool, once: `xattr -d com.apple.quarantine /usr/local/bin/powercraft-cli`. ## Windows 1. Unzip the package anywhere, for example `C:\Tools\Voltecx`. 2. Double-click `powercraft.exe`. If SmartScreen warns that the app is unrecognised, choose **More info**, then **Run anyway**. The warning appears for programs that have no code-signing certificate. 3. To use `powercraft-cli` from a terminal, add the folder to your `PATH`. The `.msi` installer does this for you. ## Linux Unpack the tarball and run `bin/powercraft`, or make the AppImage executable and run it: ```sh tar -xzf powercraft--x86_64-unknown-linux-gnu.tar.gz ./powercraft--x86_64-unknown-linux-gnu/bin/powercraft chmod +x Voltecx--x86_64.AppImage ./Voltecx--x86_64.AppImage ``` To put Voltecx in the applications menu and make it the app for `.voltecx` files, run `./install.sh` in the unpacked tarball folder. It copies `powercraft` and `powercraft-cli` to `~/.local/bin`, and the desktop entry, the icons and the file type to `~/.local/share` (set `PREFIX` for another folder than `~/.local`). `./install.sh --uninstall` removes them. The AppImage does not register itself; a tool such as AppImageLauncher can do that. The package does not include the window-system and graphics libraries. The app loads them when it starts, so your desktop must provide them. On Debian and Ubuntu: | For | Packages | |---|---| | X11 window | `libx11-6 libxcursor1 libxrandr2 libxi6 libxkbcommon-x11-0` | | Wayland window | `libwayland-client0 libwayland-cursor0 libxkbcommon0` | | Graphics (default, wgpu) | `libvulkan1` and your GPU's Vulkan driver, or `mesa-vulkan-drivers` | | Graphics fallback (OpenGL) | `libegl1 libgl1` | | File dialogs | `xdg-desktop-portal` and the portal for your desktop (GNOME, KDE, GTK) | When the default renderer (wgpu) finds no graphics adapter (a virtual machine, a remote desktop session, an old GPU), Voltecx starts the window with the OpenGL renderer (glow) instead, and remembers that for the next start (`renderer.txt` in the settings folder). Help › About shows which renderer is in use. If the window stays black anyway, start it with the OpenGL renderer yourself: ```sh powercraft --renderer glow ``` `--renderer wgpu` tries wgpu again; when it starts, the remembered fallback is cleared. The AppImage needs FUSE. In a container or on a system without FUSE, run it with `APPIMAGE_EXTRACT_AND_RUN=1`. ## Check that it works 1. Start the app. After you accept the terms, a window with a menu bar and the Start page opens, and the tour begins (chapter 2). A first launch keeps the canvas clear: the part library, the right side bar and the bottom panel are hidden until you need them (**Cmd+B** shows the library, a selection opens Properties, and a run shows the scope). 2. Choose File > Open Example > DC-DC > Buck converter, then press **F5**. A schematic appears and the scope shows waveforms. 3. In a terminal, run `powercraft-cli --version`. It prints the version. Run `powercraft-cli commands` for the list of commands. 4. Open the **Help** menu: **Manual**, **Tutorials**, **Website** and **Release Notes** open the matching page of the Voltecx website in your browser (a build without a website address says so instead). ## Open a file from the command line ```sh powercraft buck.voltecx ``` The Windows installer (`.msi`) and the Linux tarball's `install.sh` register Voltecx as the app for `.voltecx` files, so a double-click or Open with starts it with that file. The macOS app declares the file type too; Finder starts the app from a double-click but does not yet hand it the file (open it with File › Open, or drop it on the window). Other options: `--renderer wgpu|glow`, `--control PORT` with `--control-token-file PATH` (lets an assistant drive the running app, see chapter 11), and `-h` for help. ## Upgrade Voltecx tells you when a newer version is out (chapter 14) but never installs an update by itself. To upgrade, download the new package and install it the same way as the first time, over the old version: - **macOS:** quit Voltecx, then drag the new `Voltecx.app` onto `Applications` and choose **Replace**. Copy the new `powercraft-cli` over the old one if you copied it to a folder on your `PATH`. A build that is not notarised asks to be opened once more (see macOS above). - **Windows, `.msi`:** run the new `.msi`. It replaces the installed version in place, keeping the Start menu shortcut, the `PATH` entry and the file type; you do not uninstall first. An `.msi` older than the installed version refuses to install ("A newer version of Voltecx is already installed"); to go back to an older version, uninstall first. - **Windows, `.zip`:** quit Voltecx, then replace the contents of the folder you unzipped with the new package's files, or unzip the new package to a new folder and point your `PATH` entry at it. - **Linux, tarball:** quit Voltecx, unpack the new tarball and run its `./install.sh` again if you used it before; it overwrites the files it installed. Delete the old unpacked folder. - **Linux, AppImage:** quit Voltecx and replace the old AppImage file with the new one (make it executable again). Your settings carry over, because they are kept in the settings folder (chapter 14), not with the program: preferences, the last session and recovery copies, the key that signs your saves, and the accepted terms. Your circuits are ordinary files and are not touched. When a new version ships new terms, Voltecx asks you to accept them at its first start (see below). ## Uninstall Voltecx has no background service. Removing the program does not remove your circuits, which are ordinary files wherever you saved them. Your settings stay in the settings folder (chapter 14) until you delete it: preferences, the last session and recovery copies, the key that signs your saves, the accepted terms, and any staged update or local crash report. Deleting that folder resets Voltecx to a first start, and it asks for the terms again. - **macOS:** quit Voltecx, then drag `Voltecx.app` from Applications to the Trash. Delete `powercraft-cli` from the folder you copied it to (for example `/usr/local/bin`). To remove the settings, delete `~/Library/Application Support/PowerCraft`. If you stored an Anthropic API key for the assistant, open Keychain Access and delete the item named `PowerCraft`. - **Windows, `.msi`:** open **Settings > Apps > Installed apps**, choose Voltecx and click **Uninstall**. This removes the program, the Start menu shortcut and the `PATH` entry. To remove the settings, delete `%APPDATA%\PowerCraft`. - **Windows, `.zip`:** delete the folder you unzipped, and the `PATH` entry if you added one. Delete `%APPDATA%\PowerCraft` for the settings. - **Linux:** if you ran `install.sh`, run `./install.sh --uninstall` from the tarball folder. Then delete the unpacked tarball folder or the AppImage file. Delete `~/.config/powercraft` (or `$XDG_CONFIG_HOME/powercraft`) for the settings, and the credential-store item named `PowerCraft` if you stored an API key. If you signed in to a Voltecx Cloud account, sign this computer out first (**Help > Licence**) so it stops counting as one of your devices. You can also remove it on the account page. ## Build from source You need Rust 1.90 or newer (the repository's `rust-toolchain.toml` selects it). Then: ```sh cargo build --release -p powercraft -p powercraft-cli ./target/release/powercraft buck.voltecx ``` Linux builds need no extra development packages. The full developer guide is `docs/development.md`. ## The browser version The same app also runs in a browser (`apps/powercraft-web`, built with `trunk`). It opens the `buck` example at start-up. File > Open, Save, Save As and the exports use the browser's file chooser and downloads (see chapter 14), and a run can be stopped with Cancel. Each run is limited to 1,000,000 steps. Use the desktop app for real work. ## Language A new install follows the system's preferred language: a Mac, Windows or Linux set to Traditional Chinese opens in 繁體中文, also when Voltecx starts from the Dock, and any other language opens in English. Choose **View > Appearance > Language > English** or **繁體中文** to pick one yourself. The Chinese font is built in. **Edit > Preferences > Language** has the same choices and **Follow system** (chapter 14). ## The terms, accepted once per version One set of terms covers the desktop app, the command-line tool, the browser version and your account: the end-user licence agreement (`EULA.md`) and the privacy notice (`PRIVACY.md`), in English and Traditional Chinese. Each has a version, the "Last updated" date at the top of the file. The first time you start the desktop app it asks for the language first: the system's language is picked and marked SYSTEM, the other is one click away, and **Continue** leads on to the terms in that language (a new version of the terms later asks only for the terms). Then it shows a welcome card with three short points, links that open the full text of each document in the app (each link names the document's version), **Quit** and **Accept and continue**. **Enter** accepts only while **Accept and continue** has the keyboard focus, and **Esc** does nothing. The language switch under the card (English · 繁體中文) changes the card and the documents. Nothing else runs before you accept. The same screen holds the usage-statistics choice (Edit > Preferences > Privacy). It is separate from the terms and off unless you tick it. The accepted versions are stored in the settings folder (`terms.json`), and the desktop app and the command-line tool share them. You are asked again only when a new version of the terms or the privacy notice ships with an update. ![The first-run screen, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/install/01-terms.png) 1. Read the Terms. 2. The usage-statistics box, which stays off until you tick it. 3. Accept and continue. 4. Quit. The command-line tool (`run`, `script`, `sim`, `info`, `convert`, `chat`, `bench`) asks the same question on its first use in a terminal. For scripts, build servers and company deployments there are two other ways: - `powercraft-cli --accept-terms run ...` accepts and stores the acceptance, so later runs are not asked. - `VOLTECX_ACCEPT_TERMS=` in the environment accepts that one run and writes nothing. The value is the "Last updated" date of `EULA.md` (for example `2026-10-17`). A value naming an older version accepts nothing, so each new version needs a deliberate change in your deployment. The desktop app honours the variable too, for windows started by a test rig. `powercraft-cli serve` never asks, because a script starts it: it refuses with a message until the terms are accepted by one of the ways above. The assistant cannot accept for you. `terms.accept` is refused to the control channel and to scripts, and a click or key press that automation injects does not press **Accept**. `terms.status` shows whether the terms are accepted. ## Licence modules, the free trial and updates A licence unlocks **modules**, as PSIM's add-ons do: Core (every tier), Motor Drive, Digital Control, Thermal, Magnetics, Renewable & Grid, Parts & ICs, EMI & Layout, Cloud AI and Import from other formats. A part whose module you do not have shows a lock badge in the library. You can still place, edit and open it. What stops is a simulation run or a gated command, with a message that names the part and the module. **Help > Licence** lists the modules you have and starts a **free trial**: every module is unlocked until the trial ends, a badge shows the days left, and then Voltecx runs as Free and your files still open. `licence.modules` returns the same list to scripts. Voltecx checks for a new version once a day with a signed request, and always asks before it updates. ## Voltecx Cloud account Instead of a licence file, **Help > Licence** can sign this computer in to a Voltecx Cloud account. Voltecx shows a short code and opens the sign-in page in your browser. There you either enter your email address and open the link we send, or press **Continue with Google** or **Continue with Microsoft** and sign in with that account (only an email address the provider has verified is accepted). The first sign-in makes the account and starts the 30-day trial. Voltecx then keeps the licence up to date by itself and works offline until its grace date. While Voltecx Cloud cannot be reached, the Scope, Problems, Console, Library and run history carry a green **Works offline** mark at their title; point at it to see why that panel needs nothing from the cloud. The account page in the browser (`/account` on the cloud server) lists the computers signed in to your account, each with a **Sign out** button, and, for an organisation you own or administer, its seats and members: add a member by email address, choose member or admin and whether they hold a seat, or remove one. Sign in to it the same way, by emailed link or with Google or Microsoft. The cloud account is not open yet. ### Share a report as a link Signed in, **Help > Licence** can share a report page (the `.html` file a report writes) as a link, like a shared document. Press **Share a Report Page** and pick the page. Choose who may open it: **Only me, signed in on the web**, or **Anyone with the link**. Then choose when the link expires (7, 30 or 90 days, or never). The report leaves this computer and is kept on Voltecx Cloud until you delete it, so Voltecx asks you to tick that you agree before **Share** works. The Markdown file beside the page goes with it. The link is copied to the clipboard. **Shared Reports** lists your links: copy one, **Revoke Link** to stop it at once (and **Restore Link** to bring it back), or **Delete Link**. The page opens in the browser without scripts or files from anywhere else. Each account can share 100 reports and 200 MB, with up to 20 uploads a day. Scripts use `report.share`, `report.shares`, `report.updateShare` and `report.unshare`. ## Licence Voltecx is proprietary software. You may use it for personal and commercial work under the end-user licence agreement, which is in the package as `EULA.md` (English) and `EULA.zh-Hant.md` (Traditional Chinese). It does not allow reverse engineering, redistribution or resale. Both texts are marked as drafts that a lawyer has yet to review. The files you make with Voltecx stay yours. The Free tier needs no login and no licence key. The Pro features (the agent, Auto Design and PSIM import) need a licence file, which you load in **Help > Licence**. The package also holds `LICENSE` (the copyright line), `NOTICE` and `ATTRIBUTION.md` (the licences of the third-party parts). **Help > About Voltecx** shows the copyright line and the licence. The agent panel and `powercraft-cli chat` are optional. They use your own Anthropic API key and send your messages and circuit data to Anthropic only when you use them (chapters 11 and 12). --- # 2. Your first circuit URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/02-first-circuit/ This chapter gets a buck converter on screen three ways. Start with the first one, which takes a minute. The other two show how to make your own circuit. ## When the app starts While Voltecx loads, a launch screen shows the version and a progress bar. Its status lines are the real start-up steps and what each one read: the circuits restored from your last session, the parts in the device library, the cores and materials of the magnetics catalogue, the example circuits and the lessons. It closes by itself as soon as loading is done (it stays at least 0.6 s so it does not flash), and any key or click closes it at once. It is not shown when you open a file by double-clicking it, with `--no-session`, in a new window or when the app is driven over its control channel. **Edit > Preferences > Show launch screen** turns it off, and **Reduce motion** (or the system's own Reduce motion setting) keeps its artwork still. With no circuit open, the editor shows the **Start page** across the whole window beside the activity bar, whose **Start** item marks it. The side bars and the dock stay out of its way until a circuit opens, or until you open one from the activity bar while the page shows: ![The Start page, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/start-page/01-start.png) 1. **The button row.** **Open and run an example** opens Help > Examples. **New circuit**, **Open file** and **Import PSIM, PLECS or SPICE** are the same as the menu items; hover one for its shortcut, or for the file kinds Import reads. 2. **Examples** shows four example circuits as cards, each with its schematic, its title and a line of specs (kind, input to output, switching frequency); click one to open and run it. **All N examples** opens Help > Examples. 3. **Design a converter from a spec**, marked **CLOUD**: **Design from spec** opens Auto Design (chapter 16), which runs on Voltecx Cloud and opens the designed circuit here. Beside it, the **Ask the assistant** card takes a request in a sentence (click an example request under the box, then **Design it** or Enter); the agent (chapter 12) asks what is missing and runs automatic design. Without an API key the card says what the agent needs, with **Add an AI key** (it opens Preferences at the AI Assistant section). 4. **Recent** lists your recent files across the page, each with its folder and how long ago it changed (**2 h ago**, **Yesterday**, then the date). The file of your last run shows the time of the run; hover it for one signal's mean and peak-to-peak over the end of the run. Click a row to open the file. 5. The footer has **Tutorials**, **Keyboard Shortcuts** and **What's new** (the release notes), and **Show at launch**, which turns the page off (also in Preferences); the editor then shows an empty canvas with one line: **File > New Circuit** and its key start a circuit. On a first launch, once you accept the terms, a five-step **tour** points at what to do first: open an example, move around and edit the canvas, run it, read the results, and design a converter with Auto Design. The keys a card names are the ones your keymap binds, Classic or Default, and follow any key you changed. Each card has **Back**, **Next** and **Skip tour** (or **Esc**). A step you already did is marked done and skipped: running before step 3 jumps to step 4. The tour waits while a dialog is open, and it never starts in a window a script or an agent opened. **Help > Tour** replays it. For more than the tour, click **Guided Lessons** in the activity bar. A lesson lists its steps with a progress bar on top. The open step says in one sentence what it does and shows the values it uses as chips (12 V in · 3.3 V out · 5 A). Its button does the step for you, with those values: it places the parts, sets the stop time, runs the simulation, or opens Auto Design with the spec filled in. **Show me** outlines the toolbar button or panel the step uses, if you would rather do it yourself. The lesson watches for the result: the step reads "Waiting for: …" until it happens, then shows a green check, and only then is **Next** enabled. **Skip this step** moves on anyway, and **‹ Lessons** goes back to the list. After an upgrade, a note under the heading says what version you have, with **What's new** and **Dismiss**. In a narrow window the example cards go two to a row and the Cloud and assistant cards stack. Over an open circuit, **View > Start Page** or the **Start** item shows the page, and the same item takes you back to the circuit. ## The window | Area | What it is | |---|---| | Top | Menu bar, and under it the toolbar: New, Open, Save, Undo, Redo, Run and Stop, and the zoom. Hover a button for its name and keys. **View > Toolbar** hides it; the menu bar then shows its own **Run** button. | | Above the schematic | One tab per open circuit: its name, the file it came from (marked *imported* when that is not a `.voltecx` file), a dot while it has unsaved changes, and a number when two tabs would read the same. Click a tab to switch. | | Left | The part library, sorted by kind. Click a part to place it. The search box filters the list. Hover a part for its **Guide** button, or press **F1** over it, to open its component guide. | | Centre | The schematic. **View > Tool Dock** floats the tool dock at its foot (off by default; every tool also has a key): the tools (Select or Pan, Wire, Probe, Net Label, Text; the one in use is filled with the accent colour); chapter 3. Under the schematic, the optional parts bar: the most used parts as symbol icons, one click each. It is off by default; **View > Parts Bar** shows it. | | Right | The secondary side bar, with two tabs: **PROPERTIES**, the parameters of the selected part, and **ASSISTANT**, the agent (Cmd+L, chapter 12). Selecting a part opens it on Properties. Each parameter has a small **?**: hover it for one sentence about the parameter, click it to open that parameter in the component guide. Hide or show the bar with Cmd+Alt+B or its ×. | | Bottom | The dock: the scope (results and measurements), the Problems list and the Design panel, one tab each. | | Very bottom | The status bar, with the latest message, the simulation state and the zoom. | ![The window, marked 1 to 8](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/first-circuit/01-window.png) 1. Menu bar. 2. Run. 3. The circuit tab. 4. The part library. 5. The schematic. 6. Properties. 7. The dock with the scope. 8. The status bar. ## The component guide Every part has a guide: **Help > Component Guide**, **F1** (over a library row, or with a part selected), the **Guide** button of a library row, or the **?** beside a parameter. On the left is an index of every part with a search box. On the right is the part's page: - **The symbol with its named pins**, a one-line summary, and two buttons: **Place** puts the part in the circuit, and **Open example** opens a small circuit that shows it at work. - **Use for** and **Not for.** Each "Not for" entry links to the part to use instead. For example, the capacitor's page points bulk energy storage to the supercapacitor. - **Parameters**, as Symbol, Meaning, Default and Unit. The symbol is the name scripts and agents use. A default in red is required: the run stops until you set it. Hover a row for the whole description and the typical range. The rest are under **More parameters**. - **Formulas**: the key equations for the part, each with the textbook or standard it comes from. - **Quick check**: a small calculator for those formulas. Its fields start at the values of the part you selected, or at a typical example. Change any field and the results update at once. Values take engineering notation (`470u`, `2.2k`). - **Model logic**: what the simulator actually does with the part, such as what it stamps, how it starts, and what "off" or an unset value means. - **How it works**, **More parameters** and **Tips** start closed. Formulas, the quick check and the model logic cover the 40 most used parts so far: the passives, sources, switches and diodes, magnetics, the PI, PID, transfer-function, PWM and other basic control blocks, and the meters. The other parts have the rest of the page. Agents read the same data: `component.describe` returns the formulas, the quick check and the model logic, and `component.quickCheck {"component": "C1"}` computes the quick check from a placed part's values. ## Way 1: open a built-in example 1. Choose File > Open Example > DC-DC > Buck converter (the example `buck`). The example is a 48 V to 12 V converter at 100 kHz. 2. Press **F5** (or the **Run** button). The status bar shows `simulating...`, then the scope fills with waveforms. 3. The scope's **Measurements** row shows mean, RMS, min, max and peak-to-peak for the signals it shows. After the start-up transient, `v(out)` averages close to 12 V (that is D times Vin). If you see that, the whole chain works: the model, the solver and the scope. The other examples are `rc`, `rl`, `rlc`, `rectifier`, `buckClosedLoop`, `boost`, `halfBridge`, `inverter3`, `flyback`, `buckThermal` and `inverter3Thermal`, and the motor drives `imVf`, `imIfoc`, `pmsmFoc`, `pmsmSmo` and `dcMotor` (chapter 10). Open them the same way. ## Way 2: ask for a converter by specification The command `circuit.template` builds a new, laid-out circuit from a few numbers. It sizes the inductor and capacitor from textbook equations and tells you which formulas it used. 1. Press **Cmd+K** to open Quick Open. Type `template` and choose **Circuit From Template**. ![Quick Open with Circuit From Template, marked 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/first-circuit/02-palette.png) 1. **Circuit From Template**. 2. A form opens. Pick the topology, type the numbers (input voltage, output voltage, output current, switching frequency) and press **Run**. The other fields have defaults. The parameters it builds are the same as this JSON: ```json {"topology": "buck", "vin": 48, "vout": 12, "iout": 5, "fsw": 100000} ``` 3. A new circuit opens. Press **Cmd+0** to fit it to the window, then **F5** to simulate. Topologies: `buck`, `boost`, `buckBoost`, `halfBridge`, `fullBridge`, `inverter3`, `flyback`, `rcLowPass`, `rlc`. Optional keys: `ripplePct` (inductor current ripple, default 20 %), `vripplePct` (output voltage ripple, default 1 %), `fout` (inverter output frequency), `name`. The values in the new circuit are circuit variables (`Vin`, `D`, `fsw`, `Lf`, `Cf`, `Rload`). You can change one place and sweep it later (chapter 6). ## Way 3: draw it yourself This small example is an RC low-pass filter: a 10 V source, a 1 kohm resistor and a 1 uF capacitor. The same steps build any circuit. 1. **File > New Circuit** (Cmd+N) makes an empty circuit. 2. Place the parts. Move the pointer over the schematic and press a part key, or click the part in the library (**Cmd+B** shows it): `V` places a DC voltage source, `R` a resistor, `C` a capacitor, `G` a ground. These are the keys of the Classic keymap, which a new installation uses; in the Default keymap they are `Shift+V`, `Shift+R`, `C` and `Shift+G` (chapter 3). A key or a click in the library puts the part on the pointer: click on the schematic to put it down there, or press **Esc** to drop it. 3. Drag the parts to arrange them (or select one, press **Shift+M**, move the pointer and click). They snap to the grid. Press **Cmd+R** to rotate the selected part a quarter turn, **X** to mirror it. Right-click a part to see these actions and their keys. 4. Wire them (chapter 3 has the details): press **W**, click one pin, then click the pin it should join. Join `V1.p` to `R1.p`, `R1.n` to `C1.p`, and `V1.n` and `C1.n` to the ground. The ground is net `0`, and every circuit needs one. 5. Set the values. Click a part, then use the Properties panel on the right (double-click a part to open it). Type `10` for the source voltage, `1k` for the resistor and `1u` for the capacitor. Press Enter or click away to commit a field. 6. Choose **Simulation > Settings**. Set **Stop time** to `5m` and **Max time step** to `1u`, and press **Apply and run**. ![Simulation Settings, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/first-circuit/03-settings.png) 1. Stop time. 2. Max time step. 3. Apply and run. 7. Press **F5**. The scope picks its first traces itself (chapter 5): the voltage of the node between R1 and C1 is among them, next to the currents. Signals are named after nets, so the wire tool's automatic name appears as `v(n1)` or similar. To show a signal yourself, press **Shift+P** and click the wire between R1 and C1, or tick it in the scope's **Signals** list. You should see the capacitor charge toward 10 V with a time constant of 1 ms. Every step is undoable (**Cmd+Z**). Save with **Cmd+S**. Voltecx saves a `.voltecx` file, which is plain JSON text. A `.pcraft` file from an older version opens the same way. If the app closes before you save, it offers to restore your unsaved work at the next start (chapter 14). ## The same thing from the terminal ```sh powercraft-cli run \ --cmd file.openExample --params '{"name":"buck"}' \ --cmd simulation.run --params '{"solver":"fast"}' \ --cmd scope.measure --params '{"signals":["v(out)","i(L1)"],"t0":"3m"}' \ --out buck.voltecx ``` Each command prints one line of JSON. `scope.measure` returns min, max, mean, RMS, peak-to-peak and last value for every signal. The file `buck.voltecx` opens in the app (`powercraft buck.voltecx`). ## If something goes wrong - **The scope is empty.** You have not run the simulation yet (press F5), or no signal is ticked: press **Shift+P** and click a wire, or tick one in the **Signals** list. - **An error appears in red in the status bar.** It is one plain sentence; hover it for the full text, or click **Details** to open Problems (or the Console, which prints the full message). It goes away after your next successful edit or after about 8 seconds. Chapter 8 explains the common ones (a floating pin, no ground, a singular matrix). - **The scope says "Results out of date · Re-run (F5)".** The circuit changed after this run. Hover the pill to see what changed (for example `R1.r 1k→2k`), and click it, the **Out of date · Re-run** item at the left of the status bar, or press F5 to run again. - **The run is slow.** Lower `tEnd`, raise `maxStep`, or switch to variable step (chapter 4). --- # 3. Wiring and shortcuts URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/03-wiring-and-shortcuts/ ## Placing parts - **Pick Symbols or Parts at the top of the library.** The switch at the top of the library picks what it lists: **Symbols**, the generic parts by kind, or **Parts**, the real parts with a data sheet in the Catalogue parts tables, then the Device models and your vendor models. The library remembers the choice between sessions. A search lists both, whichever side is on. - **List or Metrics on the Symbols side.** By default the Symbols side lists names only: each symbol's icon, name and key. The button beside the search box, **Show default values**, adds under each name the values the symbol starts with once placed, written as on the schematic (`100 µH`, `10 V, 50 Hz`). A symbol with real parts in the catalogue also links to them (**108 real parts**), which opens its table on the Parts side. **Show names only** switches back. Hover a symbol to see every basic parameter it starts with. The library remembers the choice, and a search keeps it. In a narrow library the values drop from the right first. - **Click a part in the library.** It follows the pointer onto the schematic: click where it goes to put it down. The Rotate and Flip keys turn it on the way, and **Esc** or a right click drops it. Chosen from the keyboard (**Enter** in the search box, or on a focused row), or with no schematic on view, it lands near the middle of the view, in free space. On the Symbols side the library sorts the parts by kind: Sources, Sensors & meters, Passives, Switches & diodes, Magnetics, Machines & mechanical, Control, Thermal and Other. Machines & mechanical, Control and the Device models start folded. A group appears only when it has parts. Click a group header to fold or unfold it. Hover a part to see the hint. - **Search the library.** Type in the search box and the groups give way to one flat list of matches, with the Catalogue parts tables that match under it, on either side of the switch. The search looks at the part's type name (`resistor`, `spmsm`) and its display name, in English or Traditional Chinese, in upper or lower case. A rating searches the device models: `30 V` (or `30V`, `1.2 kV`) finds the parts of that voltage class, `40 A` the parts rated for at least 40 A, and `infineon 30 V` the maker's 30 V parts. If nothing matches, the list says **No parts match**. A search for the probe or the scope (`probe`, `scope`, `oscilloscope`) says which key starts the probe instead: the scope is a tool, not a part. - **Compare real parts in the Catalogue parts tables.** Switch the library to **Parts**: it lists the parts with a data sheet in six tables: **Switches** (Vds, Id, Rds(on), Qg and a Model chip, Ideal or Real), **Diodes** (Vrrm, If, Vf, Qrr/Qc), **Bipolar transistors** (BF, VAF, IKF and IS: the values of the maker's published Gummel–Poon SPICE model, not data-sheet ratings), **Capacitors** (C, V, ESR, ripple current), **Magnetics** (L, Isat, DCR) and **Power modules** (V, I, Rth(j-c)). Each row shows the part number over its maker and technology (`Infineon · SiC MOSFET`), and the generic Voltecx part heads each table with an **Ideal** chip. The unit of a column is under its name; the values are the ones the catalogue cites from the data sheet, and a value the sheet does not give shows **—**, never a number. Rds(on) and Vf are read off the data sheet's 25 °C conduction curve at the rated current. Click a column header to sort, and again to reverse; the generic parts stay on top. The chips over a table (**Vds ≥ 600 V**, **SiC**, **GaN**…) filter it, and the search box filters the tables too: it understands words and simple limits such as `650 V SiC`, `Rds < 50 mΩ`, `Vds ≥ 600 V` or `10uF 50V` (a value alone is at least that for volts and amperes, at most that for ohms, coulombs and K/W, and within the part's tolerance for farads and henries). Double-click a row, or drag it onto the schematic, to place the part with its data: a semiconductor gets its device model, a bipolar transistor its maker's whole Gummel–Poon card (level `gp`: the static values, junction capacitances and transit times, so a saturated switch shows its storage time) and part number, a capacitor its C, ESR and part number, an inductor its L, DCR and saturation. The icon at the right of a table's header shows it as a plain list instead; the choice, the sort and the chips are kept for each table. Under the pointer a part shows two icons in a column of their own at the right end of its row, never over its values: **Guide** opens the Component Guide on it, and **Data sheet** opens its data sheet when the library links one; a right click on the row offers both too. A table shows about nine rows before it scrolls. In a narrow side bar the columns drop from the right, then the table scrolls in its own box. Scripts and agents get the same rows with `library.query {category, filters, sort}`. - **Click a part in the parts bar** under the schematic (off by default; turn it on with **View > Parts Bar**). The bar holds the parts most circuits need: resistor, inductor, capacitor, transformer, the DC, sine and pulse voltage sources, the current source, ground, the ideal switch, diode, MOSFET, IGBT, voltmeter, ammeter, and the constant, gain, sum, PI, comparator, carrier and PWM blocks, and an induction machine. A click puts the part on the pointer, as a click in the library does: click on the schematic where it goes, turn it on the way with the Rotate and Flip keys, or drop it with **Esc** or a right click. With no schematic on view, or chosen from the keyboard, it lands near the middle of the view, in free space. Hover an icon for its name and its key. - **Use the Insert menu.** **Insert** has one submenu for each category. Choosing a part there places it near the middle of the view, in free space. The Insert items are also in Quick Open, as `insert.`. - **Use the Library menu.** **Library** has the submenus Passive, Sources, Switches, Magnetics, Control, Thermal and Meters. Each lists the parts of one category (Switches includes the diodes and the relay, and Meters is the Sensors & Meters category). Choosing a part places it the same way. The `relay` is an electromechanical relay: a coil that pulls in and drops out at set voltages after a delay, and one changeover contact (`com`, `no`, `nc`). - **Press a part key with the pointer over the schematic.** The part follows the pointer, snapped to the grid, and the status bar says *Placing Capacitor: click to put it down · R rotates · X mirrors · Esc or right-click cancels* (with this keymap's Rotate and Flip keys). Click to put it down. Before you click, the Rotate and Flip keys turn it. **Esc** or a **right-click** puts it away, as a right-click ends a wire in progress or a move; that right-click opens no menu. Another part key swaps the part on the pointer. Putting it down is one Undo step. From a menu, Quick Open or automation the part is placed at once. - **Right-click empty canvas and choose Place Part.** The part lands where you right-clicked. | Key | Part | |---|---| | `R` | Resistor | | `L` | Inductor | | `C` | Capacitor | | `D` | Diode | | `G` | Ground | | `V` | DC voltage source | | `I` | DC current source | | `S` | Switch | | `M` | MOSFET | | `T` | IGBT | | `U` | Ammeter (current sensor) | These are the keys of the **Classic** keymap, which a new installation starts with: one plain letter places one part. With the **Default** keymap the resistor, inductor, ground and DC source take **Shift** (**Shift+R**, **Shift+L**, **Shift+G**, **Shift+V**) and the MOSFET, IGBT, current source and ammeter have no key (see [Keymaps](#keymaps)). **Insert** or **Shift+A** (Edit › Place Again) places another copy of the part you placed last, from the library, a part key or the Insert menu, under the pointer. Each press is one Undo step. A new part starts with a typical value for every value it needs (a resistor 10 Ω, an inductor 100 µH, a capacitor 10 µF, a DC source 12 V, a sine source 10 V at 50 Hz, a carrier 10 kHz), so a circuit simulates as soon as it is wired. Change them in the Properties panel. Each new part gets a name with a number (`R1`, `R2`, ...). You can rename a part in the Properties panel. A new part is selected, so you can press **Cmd+R**, **X** or **Y** at once to turn it. ## Drag and drop - **Drop a file on the window.** Voltecx routes it by extension, then by content: a `.voltecx` circuit opens in its own tab, an LTspice, PLECS or SPICE file is imported, and a scope CSV goes to Import Measurement (run a simulation first, so there is a trace to compare with). A PDF or a file Voltecx does not know is refused with a line that says why. While a file is held over the window, an overlay says "Drop to open or import". - **Drag a part from the library onto the schematic.** A ghost of the part follows the pointer, and on the drop the part is placed at the grid point nearest the pointer, with the same command as a click. ![The drop overlay while a file is held over the window, marked 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/wiring/04-drop-files.png) 1. The overlay: let go to open or import the file. ## Selecting and moving - Click a part to select it. **Shift**-click or **Cmd**-click adds a part to the selection or takes it out. Click empty space to clear the selection. - Drag on empty space to draw a selection rectangle. Drawn left to right, it selects the parts and wires wholly inside it. Drawn right to left, its outline is dashed and it selects every part and wire it touches. Hold **Shift** to add them to the selection. **Delete** then removes the parts and cuts the wires in one step: a net the cut wires split moves its loose side to a new net. Hold **Cmd** (Ctrl on Windows and Linux) instead to zoom to the box you draw. - **Drag a part to move it.** It snaps to the grid. If several parts are selected, they all move. One drag is one undo step. If you drop a part so that one of its pins lands exactly on a pin of another part, the two pins are connected, as in PSIM and LTspice; the move and the connection are still one undo step. Placing a part with a pin on a pin does the same. - **A new part never lands on another.** A part you add without choosing a spot, or one an assistant adds, takes the nearest free grid spot when its spot is taken. A part you drag or paste stays exactly where you put it, even on another symbol; the Problems tab then warns that the two overlap, and its **Fix** (Move apart) moves the second one to the nearest free spot. - **Or press Shift+M** (**M** in the Default keymap). The selected parts follow the pointer, and the status bar reads *Moving 2 part(s) · click to place · Esc or right-click to cancel*. Click to put them down, or press **Esc** (or right-click) to put them back. This is one undo step too. - Hold **Alt** (Option on a Mac) while you drag to switch snapping off for that drag. The part then moves in steps of one eighth of a grid unit. - Hold **Alt+Shift** (Option+Shift on a Mac) while you drag a part to lift it off its wires, as LTspice's Move does: on the drop its pins leave the nets that reach parts you did not move, and the wires left behind re-route among the parts still on them. Wires between the moved parts stay. You can press or release the keys during the drag, and the canvas shows the wiring as it will be. The move and the unplugging are one undo step. **Shift** alone always adds to the selection, on a part as on empty space. - **Edit › Preferences › Editor › Wires follow moved parts** (on by default) sets which of the two a plain drag does. With it off, every drag lifts the parts off their wires, and **Alt+Shift** held during a drag keeps the wires for that one drag. **G** (grab, keeps the wires) and **M** (move alone) do what they say whatever the setting. - Arrow keys nudge the selection by one grid step. **Shift + arrow** nudges it by five. - **Cmd+R** rotates the selection a quarter turn clockwise (in the Default keymap **R** does too). - **X** (or **Cmd+E**, or **Cmd+Shift+F**) mirrors it left to right. **Y** mirrors it top to bottom. Each is one step, so one undo takes it back. - **Cmd+A** selects every part. **Cmd+F** opens a search field at the top of the window. As you type, the parts whose name, kind or a parameter value contains the text are selected and the view zooms to them. Enter or Esc closes the field and keeps the selection. **Edit > Find Next** (**F3** in the Classic keymap) then selects the matches one at a time and zooms to each, starting again after the last; the status bar says which one it is ("2 of 5: L2"). - The search field's second row replaces text (**Edit > Find and Replace**). Type the new text in **Replace** and pick where it applies: **Values** (parameter values and expressions; `100u` finds an inductance written as 100 µH), **Names** (part names; their labels, probes, scope signals and expressions follow) or **Nets** (net names; their labels, probes and `v(net)` scope signals follow). The count next to **Replace All** says how many changes it would make before you press it. **Replace All** makes every change as one step, so one **Cmd+Z** takes it back. A change that would give an invalid name, or a name another part or net already has, is shown in red and nothing changes. - **Cmd+C**, **Cmd+X**, **Cmd+V** copy, cut and paste. A pasted part gets a fresh name (`R1` becomes `R2`). With the pointer over the schematic, the copies land at the pointer (from the right-click menu, where you right-clicked). Pins that the copied parts share stay wired to each other, but a copy is not connected to the rest of the circuit: it joins ground only when you copied a ground symbol with it, and a named net only through a label you copied with it. The status bar says which pins were joined. **Cmd+D** duplicates. - **Delete** or **Backspace** removes the selection (the selected parts, or the selected wire or label, see below). - **Cmd+Z** undoes. **Cmd+Shift+Z** or **Cmd+Y** redoes. Every edit is one history step, including the ones made by commands and by an assistant. The **Edit** menu and the toolbar name the step: **Undo Move Component** takes back the move, and **Redo Move Component** brings it again (a long step name, such as an assistant's prompt, is shortened). With nothing to undo, the item reads plain **Undo** and is greyed out. After **Apply to circuit** in a field solve, or **Changes made** in a design, an **Undo** link beside the message takes that one step back while the circuit is still at it; a later edit removes the link. - **Edit › Undo List** opens a tab beside Properties in the right column that lists every step, oldest first. The current step is highlighted and the undone ones (the steps Redo brings back) are dimmed. Hover over a step to see what it changed (parts added or removed, values changed, pins connected), and click a step to go straight to it, as that many undos or redos would. The later steps stay until your next edit, which replaces them. The Properties tab takes the column back while the Undo List stays open behind its own tab; right-click the tab and choose Close Undo List to close it. - **Esc** ends what is in progress (a wire, a move, a dialog, then the wire tool) and lets go of a selected wire or label. With nothing in progress it clears the selection. In the wire tool, the first **Esc** drops the wire you are drawing and the second leaves the tool. **Right-click a part** for a menu with Cut, Copy, Rotate, Flip, Flip Vertically, Duplicate, Disable (or Enable), Create Subsystem, Delete and Properties. Each entry shows its keys. Right-clicking on one of its pins adds **Disconnect Pin**. **Right-click empty canvas** for Undo, Redo, Paste, Place Part, Wire Tool, Select All and Fit to Window. **Right-click a wire** for Rename Net, Delete Wire and Draw Net as Labels, and **a net label** for Rename Net and Draw Net as Wires; after a run both menus also have Probe. With two or more parts selected the part menu also has **Align**. The menu bar has the same entries under the same names: **Circuit > Align** (Align Left to Distribute Vertically) and **Circuit > Net** (Connect, Disconnect, Draw Net as Labels, Draw Net as Wires, Straighten Wire, Rename Net, for the selected wire or label), and so does Quick Open. **View > Zoom to Box** makes the next drag zoom to the box you draw, as a Cmd-drag on empty canvas does. ![The right-click menu of L1, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/wiring/02-context.png) 1. Rotate. 2. Mirror left–right (the item under it mirrors top–bottom). 3. Properties, each with its key. **Edit > Select by Criteria** selects every part of a kind that meets a parameter condition, such as every resistor of 10 kΩ or more: give `{"kind": "resistor", "param": "r", "op": ">=", "value": "10k"}`. With a part selected, the dialog starts from its kind. `op` is one of =, !=, <, <=, >, >= and contains; `enabled` and `dnp` pick disabled or not-fitted parts. A value written as an expression (`2*rbase`) has no number before a run, so it is listed as not compared instead of guessed. **Edit > Check Elements** lists every part of the sheet shown (or of the subsystem you are in) in one table: its name, its kind, its parameters as typed (`r=4.7k`, `l=2*lbase`), whether it is simulated and fitted (Not simulated, DNP), and what the circuit's check finds about it, in red for an error and amber for a warning (hover for every finding; a part with none shows a tick). Click a row to select the part and zoom to it, and use the arrow keys to step through the rows. Click Name, Kind or Findings to sort (again to reverse); **Problems Only** lists just the flagged parts, and **Copy table** puts the table on the clipboard as tab-separated text. The findings are the Problems tab's, so they update as you edit. **Edit > Find in Files** runs the same search as Find over every open circuit and, with **Include This Folder** ticked, over every circuit file in the folder of the circuit shown and its subfolders, without opening them. Type a part name, a value (`4.7k`) or a net name and press **Search** or Enter. The matches are listed under each circuit, with its file path or "Open tab"; parts inside a subsystem say which one. Click a part to bring its circuit forward (a file is opened) with the part selected. A file that cannot be read, such as a protected one, is counted under the summary, and hovering there says why. A circuit that has never been saved has no folder, so only the open circuits are searched. While parts are selected, the right end of the status bar lists the keys that act on them, in your keymap: rotate, mirror, move, grab, delete and all shortcuts (in Classic, **Cmd+R**, **X**, **Shift+M**, **Shift+G**, **Delete** and **?**). Letter keys never act while you type in a text field. The part keys, **W**, **N** and **Shift+T**, and the keys that edit the selection (**Delete**, **Backspace**, **Shift+M**, **X**, **Y** and the arrows), act only while the schematic has the keys, so a key pressed after a click in Properties, the library or the scope never changes a part you cannot see. Keys follow focus, not the pointer: a click on the schematic or the scope gives it the keys, and so does **F6** landing on it; until your first click they follow the pointer. Pressed while another panel has the keys, the status bar says where the key acts. Their **Cmd** keys act anywhere. While a menu is open, the keys belong to it: **Esc** closes it and no shortcut acts through it. ## Disabling a part To try a circuit without a part, switch the part off instead of deleting it, as with "disable element" in PSIM or "comment out" in Simulink. - Right-click the part and choose **Disable**, or press **Cmd+Shift+E**, or choose **Circuit > Enable/Disable**. With several parts selected, this disables all of them. If every selected part is already disabled, it enables them all, and the menu entry reads **Enable**. - In the Properties panel, the **Enabled** checkbox does the same for one part. - Each change is one undo step. A disabled part stays on the schematic. It is drawn in grey with dashed lines and a slashed circle on it, and it keeps its wires and parameters. The simulation, **View > Problems** and C code generation leave it out, as if it were not there. Inside a subsystem the same rule holds: a disabled part in the subsystem is left out of every instance, and a disabled instance leaves the whole subsystem out. If you expand a disabled instance, its parts come out disabled too. The pins it was connected to may now be open. The problems list (chapter 8) shows such findings as information, ends the message with "because `C1` is disabled", and offers **Enable `C1`** as the fix. Problems that were there before you disabled the part keep their severity. When you export, a SPICE netlist writes the part as a comment line (`*C1 out 0 1e-6`). Remove the `*` to switch it back on. LTspice and PLECS files keep no disabled state that Voltecx knows of, so writing back leaves the part in the file unchanged and gives a warning. A new part that is disabled is not added. The SVG and PNG exports draw the part in grey, as the canvas does. ### Enable conditions A part or a subsystem instance at the top level can also be switched by a variable, so one schematic holds its variants (an optional snubber, a second stage, a test load). Give it a condition with `circuit.setEnableCondition {"component":"X2","condition":"stage2"}`: an expression of the circuit variables, such as `stage2` or `mode == 2`. A run leaves the part out while the condition's value is 0.5 or less, exactly as if it were disabled, and its warnings say so ("`X2` is left out of this run: its enable condition is false"). Change the variable (`circuit.variables {"set":{"stage2":1}}`, or a parameter sweep over it) and the next run puts the part back. The part itself stays enabled and is drawn as usual. A condition never switches on a disabled part, and `null` removes it. The SPICE export reads it too: at the circuit's variable values, a part whose condition is false is written as a comment, like a disabled part, and named in the export's warnings. The problems list reads it at the same values: a part whose condition is false gets an info `enable.conditionOff` (fix: remove the condition), a pin it leaves floating is an info that ends "because the enable condition of `X2` (`stage2`) is false", and a condition a run cannot evaluate (it names a variable you removed) is an error `enable.conditionError`. C code generation (Tools > Code Generation and `file.exportCode`) reads it at the same values: a control block whose condition is false is left out of the generated code, the reply's warnings name it ("`DBG` is left out of the generated code: its enable condition `debug` is false at the circuit's variable values"), and a sense divider left out this way gives no ADC full scale. ## Wiring **View > Tool Dock** shows the schematic tools in the tool dock, a bar that floats at the foot of the schematic. It is off by default, so nothing covers the drawing; the keys work either way: ![The tool dock at the foot of the schematic, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/wiring/01-tools.png) 1. Select (**Esc**). The **▾** beside it also lists **Pan** (**H**): with it a drag moves the view, as Space held does, and a click selects nothing. While Pan is the tool, the first button shows it. 2. Wire (**W**). 3. Probe (**Shift+P**). 4. Net Label (**N**). 5. Text (**Shift+T**; **T** in the Default keymap). There is one workbench, with every tool, before and after a run: there are no Edit and Simulation modes to switch between. A run opens the scope in the panel under the schematic. To give the scope the whole window, click **Maximize Scope** (the upward chevron beside the scope toolbar's window button, or **View > Maximize Scope**); the tool in use stays, the dock stays at its foot, and **Restore Scope** gives the schematic back. To draw a wire: 1. Press **W** to pick the wire tool. A strip at the top left of the schematic sums it up: *Wire · click a pin or wire to start · click to add a corner · double-click or Enter to finish · Esc drops the wire, Esc again leaves Wire*, and the status bar says `W wire tool: click or drag from a pin to another pin or a wire to connect them; Esc ends`. (Clicking a pin in the normal tool also starts a wire.) 2. Click the first pin. The status bar says `wiring from R1.p: click another pin`. A dashed L from the pin to the pointer shows where the wire will go. 3. Click the second pin. Voltecx joins them into one net. The wire is routed for you, and a dot marks a junction. 4. Press **Esc** to give up a wire in progress; the wire tool stays on for the next one. Press **Esc** again to stop wiring. A right-click also gives up the wire in progress, without opening the menu. **Drag to wire.** You can also press on a pin and drag. Let go on another pin to connect the two, or on a wire to join that wire's net. If you let go on empty space, the wire stays in progress, so you can still click the pin you want. **Corners.** While a wire is in progress, whether it started on a pin or on a wire, click empty space to put a corner there. A dot marks each corner, and the dashed preview runs through them. End the wire on a pin or a wire with a click, or point at one and press **Enter** or double-click. The corners become the joined net's bends, one undo step after the connection. Enter or a double-click over empty space does not end the wire, because a wire always ends on a pin or a wire; the status bar says so. Inside a subsystem a click on empty space gives the wire up instead, because bends belong to the top level. **Join a wire (T-junction).** While a wire is in progress, click an existing wire (or a net label). The pin joins that wire's net, and the junction dot appears where the wires meet. **Pins on top of each other.** When two pins sit on the same spot and a wire starts at one of them, a click on that spot picks the other one, so you can still connect them. Rules to remember: - A wire joins two pins. Clicking a third pin on the same net joins that one too. - A wire joins pins of one kind only: electrical, control, thermal, magnetic or mechanical. A wire between two kinds is refused, and the status bar says which, for example *cannot connect an electrical pin to a control pin*. When it is a power pin to a control input, the status bar also offers **Insert Voltage Sensor**: one click puts a voltage sensor between the two pins, its `+` on the power net, its `−` on a ground symbol of its own and its output on the control pin, as one undo step. - A ground symbol puts its net on ground (net `0`). Every circuit needs at least one ground. - A pin with nothing connected is a **floating pin**. The check in **View > Problems** reports it, and so does the problems list in chapter 8. - Wires are made of nets, not of drawn lines. If you move a part, the wires follow. Voltecx routes every wire itself. The corners you click while wiring, and the corners you make by dragging a wire, are bends it passes through. You can point at a wire, select it and delete it (below). - To name a net, point at one of its pins and press **N**. A small form asks for the net name, filled in with the current one; type the new name and press Enter. Under the name the form says what it does to the circuit: **Joins the net g1 already on PWM1 out** when that name is in use (same name, same net), or **Starts a new net**. Its **Kind** lists the five kinds with what each draws: **Net** (names the net, wires stay), **Link** (goto / from, no wire), **Rail** (a rail symbol at every pin), **Port** (a pin of this sheet or block) and **Ground** (a local ground symbol); left unpicked, the pin decides. Or pick the **Net Label** tool in the tool dock and click pins one after the other; **Esc** ends it. A net label on an electrical pin only names the net: the wires stay, and the flag shows on that pin. Goto and From labels on control pins join their pins by name and draw the net as flags instead of wires. **Draw Net as Labels** in a wire's right-click menu draws any net as flags. Net and link labels look like the net labels of the EDA tools engineers use: the name in plain text on a short wire stub from the pin, above a level stub and past the end of an upright one. Only a port keeps an outlined flag (a hexagon), because it leaves the sheet; a rail keeps its bar and ground its three bars. - Ground is drawn locally by default, as in KiCad and PSIM: every grounded pin gets its own ground symbol (three bars), and no ground wire runs around the drawing. A ground part you place yourself keeps its wires: a ground net with a ground part on it is wired, as you drew it. To switch, right-click a ground symbol and choose **Draw Net as Wires** (one ground symbol, at the lowest pin), or right-click a ground wire and choose **Draw Net as Labels**. The choice is saved with the circuit. A rail net (a net with a rail label on one of its pins) shows its rail symbol at every pin in the same way. Neither changes what is connected. Files saved before this change open with the new default: their ground is local unless a ground part sits on it. ## Wires and labels under the pointer - **Hover** a wire or a net label: its whole net lights up (every wire and every label of it), and a tooltip gives the net's name and how many pins are on it. - **Click** a wire to select that piece of wire, or a label to select it. It is drawn in the accent colour, the Properties panel shows the net's name and its pins, and the status bar says what the keys do. **Esc** lets go. Double-click a wire or a net label to rename its net, as **Rename Net** in their right-click menus does. The window shows the name selected, so you type the new one and press **Enter**: every pin on the net, its labels and its wires take the new name in one undo step, and nothing is added to the drawing. Probes and math traces that read the old name (`v(sw)`) keep reading the net. A name another net already has is refused, because a rename never joins two nets; join them with a net label (`schematic.renameNet {"net": "sw", "name": "SW_NODE"}`). - The probe tool (**Shift+P**) takes a click on a net label as a click on its net. - While a simulation runs, a probe click puts the trace on the scope's live preview at once; it does not wait for the run to end. - **Shift+click** a wire or pin of one net, then click a second net: the scope shows the voltage between them, `v(a)-v(b)`. It is added as a math signal named `v_a_b` (one **Cmd+Z** takes it back) and recomputed after every run. Probing the same pair again takes it off the scope. **Esc** drops the first net and keeps the probe on; Esc again leaves it. ## Annotate designators **Circuit › Layout › Annotate Designators** renumbers designators in reading order, so R1 is the top-left resistor and the numbers run left to right, row by row (on a drawing of several sheets, sheet by sheet). Names that are not letters and a number, such as `Vin` or `Rload`, stay; pins, labels, probes, scope signals and expressions follow, and the netlist is the same. A form asks how: - **Only these parts**: starts with the selection; leave it empty for every part. The parts not listed keep their names, and their numbers are skipped. - **Start number**: `101` gives R101, R102, ... - **Order**: rows (the default) or columns (left to right first, each column top to bottom). - **Keep these designators**: parts that keep their names this time. A part locked with `schematic.lockDesignator {"components":["R10"]}` always keeps its name; its number is skipped. - **Preview only**: shows the old → new list and changes nothing. The renumbering is one undo step. Agents call `schematic.annotate {"components"?,"start"?,"order"?,"locked"?,"preview"?}`; `preview` returns `{"renames":[{"from","to"}]}`. ## Moving a part's designator and value A part's designator and value go beside it on their own, clear of wires and other labels. To put them somewhere else, as you would move a reference or value field in KiCad or Altium, drag the designator or the value with the Select tool: an outline follows the pointer, snapped to the grid, and the label stays where you let go, designator over value, on the canvas and in every export. The move is one undo step, and the netlist does not change. A renamed part keeps its label's place. Agents call `schematic.movePartText {"part":"L1","offset":[dx,dy]}` (the label's top left, in grid units from the symbol's centre); without `offset` the label goes back to its automatic place. ## Showing parameters on the schematic Each parameter in Properties has an eye beside its `?`. It is open while the parameter is written under the part's designator on the schematic, and struck through while it is not. Click it to show or hide that parameter. A part starts with its key values ticked (an inductor's inductance, a PI controller's Kp and Ki). When you tick more, each shown value is named, for example `C 100 µF, Esr 5 mΩ`, and a parameter left at its default shows the default. With every eye closed, only the designator shows. The choice applies on the canvas and in every export, is saved with the circuit and is one undo step. The netlist does not change. Agents call `schematic.showParams {"part":"C1","show":{"esr":true}}`; `{"part":"C1","reset":true}` goes back to the key values. ## Tidy the schematic **Compact layout (preview).** Studio 1 brings an industry-style layout for circuits built round one IC, such as the application circuit `circuit.applicationCircuit` builds. For now you start it from the command line or the assistant: `schematic.autoLayout {"style":"compact"}`. The IC stands in the middle. The power parts (bootstrap capacitor, catch diode, inductor, output capacitors, load and feedback divider) stand beside the pins they connect to, in signal-flow order. The compensation and soft-start parts sit in a row under the IC, joined to their pins by net labels. The supply is drawn as a power port at each pin it reaches, and every grounded pin has its own ground symbol, so no wire runs across the sheet. A circuit without an IC keeps the usual layout. Only the drawing changes; the netlist stays the same, and **Edit › Undo** takes it back. **Circuit › Layout › Tidy Schematic** makes a drawing readable in one undo step. Control blocks that sit inside the power stage move above it together, keeping their arrangement. Symbols drawn on top of each other move apart. Every grounded pin gets its own ground symbol instead of one ground wire. Every control or measurement signal that reaches a power part (a gate signal, a sensor reading), runs through the power stage, or is 20 grid units or longer is drawn as net labels instead of a wire. Only the drawing changes: the parts and their connections stay exactly as they were. A window then shows the drawing **before and after** side by side, each with its overlapping symbols and wire crossings, the nets and parts the step changed, and **Netlist identical** under the after side; **Keep** closes it and **Undo** takes the step back. A drawing that is tidy already is left as it is, and the status line says so. Nothing is wrapped into a subsystem for you: to make a controller of several blocks one module, select its blocks and use **Circuit › Subsystem › Create Subsystem** (an assistant gets that call offered in the command's reply). ## Electrical rules check `schematic.erc` reads the top level of the schematic and lists what cannot be right, without changing anything. Run it before a simulation and before a board sync. Every finding names the part, pin or net and gives where it sits on the sheet (`at`, in grid units), so a list can select it. In the app, **Tools › Electrical Rules Check** opens a window with the findings, errors first. While it is open the check runs again after every edit or undo, so a fixed finding leaves the list at once, and the parts, pins and nets it names are outlined on the canvas. Click a finding to show it on the schematic: the editor goes to the top level, selects the part, highlights the net and centres the pin. The window reads the top level only, as the command does. | Code | Severity | Meaning | |---|---|---| | `pin.conflict` | error | Two pins that both set the net's value: output with output, output with a power output, power output with power output, or an open-drain output with an output or a power output (it pulls low against their level). Open drains together are a wired OR and do not conflict | | `net.undriven` | error | A signal net with an input and nothing that can drive it (no output, power output or passive pin) | | `net.powerUndriven` | error | A net (not ground) with a library IC's supply pin (a power input: VCC, VDD, VIN; not a bootstrap pin) and nothing that supplies DC: only supply pins, that IC's own pins and capacitors | | `pin.unconnected` | error or warning | A pin on no net: an error for a signal input, which floats; a warning for the rest | | `net.singlePin` | warning | A net with one pin (ground and signal nets are left out; an unread signal is one for the scope) | | `designator.duplicate` | error | Two parts with one designator; a warning when only the letter case differs | | `powerFlag.unconnected` | warning | A pin carries a power flag but is on no net, so the flag supplies nothing | | `net.noPullUp` | warning | A net (not ground) with an open-drain or open-collector output and no resistor to pull it up, so it never goes high | | `pin.ncConnected` | warning or error | An IC pin with no internal connection (`NC`) wired to other pins: a warning; an error for a `DNC` (do not connect) pin | Pins get a type from their part: a signal pin is an input or an output as `circuit.problems` reads it, the **+** pin of an ideal voltage source or a battery is a power output, a library IC's supply pin is a power input, a library IC's open-drain or open-collector output is an open collector (for a part that offers both, such as the comparator or the fast optocoupler, its `openDrain` or `totemPole` value decides), an IC pin named `NC`, `N/C` or `NC1` is not connected (`DNC`: do not connect), and every other pin, such as a resistor's end or a subsystem instance's pin, is passive. Unused outputs, optional block inputs, inputs fed by a bus, a machine's star point and unused breaker poles are skipped. Board-only parts such as mounting holes are left out. A supply that comes from off the sheet, such as a bench supply or the far side of a connector, gets a **power flag**: `schematic.powerFlag {"pins":["CIN.p"]}` draws a small flag at that pin, and the pin's net is then not `net.powerUndriven`. `"flagged": false` removes it. The flag is display only: the netlist does not change. Do not flag a net to hide a source that should be on the schematic. The KiCad export writes one `PWR_FLAG` on each flagged net, so KiCad's ERC agrees; the flag is off the BOM and the board, and the KiCad sync reads it as no part and no net. Agents call `schematic.erc {"listPins"?}`; it returns `{"findings":[{"severity","code","message","component"?,"pin"?,"net"?,"pins"?,"at"?}],"counts":{"error","warning"},"total","truncated"}`, and with `listPins` the type of every pin. ## Removing a connection - **Delete a wire.** Select a piece of wire and press **Delete** or **Backspace** (or right-click it and choose **Delete Wire**). If the rest of the net still holds together, nothing changes and the status bar says so. Otherwise the net splits in two: the side with the ground symbol keeps the net (without one, the larger side does), and the other side gets a new net name, or is left open if it is a single pin. It is one undo step. - **Take one pin off.** Right-click the pin and choose **Disconnect Pin**, or select the part, open Properties and empty the pin's field in the Ports list. Selecting a net label and pressing **Delete** takes its pin off the net too. - Agents use `circuit.disconnect` (`{"component":"R1","port":"p"}` or `{"pins":["R1.p","C1.n"]}`), or the `disconnect` op of `circuit.apply`. ## Parameters Double-click a part, press **E** with the pointer over the schematic, or open **View > Secondary Side Bar > Properties**: the keyboard goes straight to its first value. The panel lists the parameters by a readable name (**On-state resistance**), with the key small under it (`ron`), the unit beside the field and the full description under the pointer. An empty field shows the value used when it is left empty, greyed: `1meg`, `required`, `off` for a feature that is off until set, or `no limit` for an output limit that is not set. A parameter that takes one of a few words (a carrier's shape, a controlled source's mode) is a list to pick from. Type a value and press Enter (or click away) to commit. ![L1 selected and its Inductance field in Properties, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/wiring/03-properties.png) 1. `L1`, selected. 2. Its Inductance field in Properties. The panel shows the values an ideal model needs first. The rest (losses, parasitics, delays, temperature, datasheet data) wait under **Advanced (N)**, folded; it stays open or closed for the rest of the session. An advanced value that is set always shows among the first ones, so nothing set is ever hidden. A required value that is not set is listed in the Problems tab before a run, all of them at once, each with a fix that puts a typical value in. - A value can be a number with an SI suffix (`4.7u`), a circuit variable (`Vin`), or an expression. - **Suffixes**: `f p n u m k meg g t` (femto to tera). Following SPICE, a bare `M` or `m` means **milli**, so `1M` is 0.001, not a million. Write mega as `meg` (`1meg`). A value that ends in a bare `M` shows a hint with a one-click **Use 1meg**, and `circuit.setParam` returns a `warnings` entry. Expressions also accept `sqr`, `sign`, `hypot` and `**` for the power. - **Circuit > Variables** lists the circuit variables in one table: each name, its expression and its resolved value. A parameter that points at a variable changes everywhere the variable is used. A sweep (chapter 6) needs variables. ## Text notes Notes put a title or a remark on the schematic. Pick the **Text** tool (**Shift+T**, **T** in the Default keymap, or the **T** button in the tool dock) and click where the note should start; a window asks for the text, its size and its colour (ink, red, blue, green or grey). A note can have several lines. - Click a note to select it, drag it to move it (one undo step), and double-click it to edit it. **Delete** removes the selected note. - Notes are saved in the file (`schematic.notes`), drawn in the SVG export in their size and colour and written into the TeX export as plain text. The PNG export letters them too, in its small pixel font. - Text boxes in an imported PSIM schematic become notes at their place. - Agents use `schematic.addText {"text","at":[x,y],"size"?,"color"?}`, `schematic.editText {"index",...}` and `schematic.removeText {"index"}`. ## Sheets A flat circuit can be drawn over several sheets, the way a real converter is drawn: the power stage on one, its control on another, the auxiliary supply on a third, joined by net labels. **Circuit > Sheets > Add Sheet** adds a sheet and shows it; the tabs under the canvas then list the sheets (hover one to see how many parts and notes it holds). Click a tab to show that sheet, **+** to add another, and right-click a tab to rename it or to remove it (only an empty sheet can be removed). - Parts and text notes you place go on the sheet shown. To move parts, select them and right-click **Move to Sheet ›**, then pick the sheet. - Sheets are only a drawing: nets are joined by name, so the netlist and the simulation are the same however the parts are spread. A net that ends up with pins on two sheets is drawn with net labels on both, so each sheet shows where it continues; rail, net and goto/from labels join across sheets. - **File > Print** and **Export Schematic** with a page write one page per sheet, each titled with its sheet's name (`buck / Control`) and numbered *n of m*. A plain figure is the sheet shown. - A file drawn on one sheet is saved as before. A file with sheets is format version 3; a file from before sheets opens with everything on sheet 1. - Agents use `schematic.addSheet {"name"?}`, `schematic.moveToSheet {"components":[...],"sheet"}`, `schematic.renameSheet {"sheet","name"}`, `schematic.removeSheet {"sheet"}` and `schematic.showSheet {"sheet"?}` (without `sheet` it lists them). ## Subsystems **Circuit > Subsystem > Create Subsystem** (Cmd+G) turns several parts into one block with named pins. The dialog asks for the parts and a name, for example `{"components":["S1","D1","L1"],"name":"stage"}`. The nets that cross the boundary become the pins. Select the block and choose **Circuit > Subsystem > Expand Subsystem** to turn it back into its parts. Use a subsystem for a gate driver, a filter or any repeated stage. **Circuit > Subsystem > New Subsystem** starts a block from nothing. Give it a name and its pins, separated by commas or spaces (`ref, fb, duty`), and choose **Power** for electrical pins or **Control** for signal pins. **New subsystem** places the empty block in view with its pins unconnected and opens it, so you draw its inside right away; a part you wire to a net named like a pin is on that pin. One undo takes the block away. Pins can be changed later in Properties (below). **Circuit › Layout › Group into Blocks** groups a whole converter at once: each design step's parts go into a subsystem named after it (POWER_STAGE, EMI_FILTER, PROTECTION, SENSING, CONTROLLER, GATE_DRIVE). The top level then shows the sources, the blocks and the loads in power-flow order, with sensing, controller and gate drive in a row under them joined by net labels, and each block's key values over it (for example `L1 22µH · PWM 100kHz`). The role of a part is read from its kind and name: a dead-time block, `Rg1` or `Cboot` is gate drive, a meter or `Rfb2` is sensing, a fuse or TVS is protection, `Cx`, `Cy` or a common-mode choke is the EMI filter, other control blocks are the controller and the remaining power parts the power stage. Sources, loads, grounds and test points stay on the top level. The grouping is one step: Cmd+Z takes it back. The netlist stays the same, and probes and scope signals follow the parts (`i(L1)` becomes `i(XPWR.L1)`). **Double-click a subsystem** (or select it and choose **Circuit > Subsystem > Edit Subsystem**) to edit the parts inside it. The canvas then shows its parts, and a bar above the canvas shows where you are, for example `closed_loop › PI_Id`. Select a part and change it in Properties, move it, wire it or add parts, as at the top level; every change applies to the subsystem's definition (so to every instance of it), can be undone with Cmd+Z, and the next run uses it. Press **Cmd+Up** (Ctrl+Up on Windows and Linux), click the **‹ Back** button at the left of the bar (it shows its shortcut), or click a name in the bar to go back out. **Esc** never leaves a subsystem: it only ends what is in progress and then clears the selection, so an Esc meant for a wire cannot take you out. When you enter a subsystem, the status line says which key leaves: *⌘↑ leaves the subsystem · Esc cancels only*. **Pins.** Inside a subsystem, with nothing selected, Properties lists its **Ports**. Double-click a pin's name to rename it, or right-click it for **Rename**, **Move Up**, **Move Down** and **Remove**; **Add Port** adds a pin. A pin is the net of the same name inside, so a rename renames that net too, and **Add Port** with the name of a net inside brings that net out. Every change applies to the definition and to each instance at once, as one undo step. The nets outside stay as they are: a moved pin moves down the side of each instance's box, and a removed pin's wires outside come off. A rename is refused when another pin or a net inside already has the name, so it never joins two nets. A big subsystem opens at a zoom where its labels stay readable (75 %, so designators are 9 pt), not shrunk until everything fits: you see its top-left corner, where the signals come in, and scroll or drag to see the rest. While part of the inside is off screen, the minimap shows in the corner of the canvas; click or drag in it to move the view. Press **F** with nothing selected to fit the whole inside anyway. ![Inside the CONTROLLER subsystem made by Group into Blocks, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/wiring/05-subsystem.png) 1. **‹ Back**, with its shortcut, Esc. 2. The path: each name is a way back to that level. 3. The minimap, while part of the inside is off screen. A subsystem block has no parameters of its own until its definition declares some (see Masked subsystems below): Properties then says so and points you inside. Net labels cannot be placed inside a subsystem yet: leave the subsystem to label nets. Inside, a wire that would join a port to another net keeps the port's net, and joining two ports is refused. After a run, the probe works inside too (an inner net is recorded as `X1.m`, a port as the net outside). ### Masked subsystems One definition can serve instances with different values, as a PLECS or Simulink mask does: a half-bridge whose instances run at different switching frequencies, or a PI block with its own gains. Declare a parameter on the definition with **Circuit > Subsystem > Subsystem Parameters > Define Parameter** (`circuit.defineSubsystemParam {"subsystem":"stage","name":"fsw","default":"100k","unit":"Hz","label":"Switching frequency","labelZh":"切換頻率"}`). Inside the subsystem, type its name where a value goes (`1/fsw`, `rtop`). Select an instance and Properties lists the parameters under **Subsystem parameters**, with the default greyed: type a value for this instance, or clear the field to go back to the default (**Circuit > Subsystem > Subsystem Parameters > Reset to Default**). A value may be an expression over the circuit's variables, so a sweep of a variable reaches inside the instances; set **expr** to false to accept numbers only. A default may use the parameters declared before it (`rbot` = `rtop/2`). **Expand Subsystem** puts the instance's values into the parts it expands into. Files that use parameters are saved as format version 2; files without them stay version 1. ## Buses A bus carries several control signals on one wire: the three phases (abc), the dq pair, or a set of gate signals. Place a **Bus Mux** (Insert > Control) to join up to eight signals into one bus, a **Bus Demux** to split it again, and a **Bus Selector** to pick some elements (`index` = `1, 3`). Element-wise blocks (gain, sum, product, abs, min, max, limiter, integrator, PI, comparator, logic gates, dead time, delay) take a bus on any input and give a bus of the same width; a scalar on another input serves every element. Clarke, Park, the three-phase PWM, the three-phase sine source and SVPWM take or give a three-phase bus on their first pin (`a`, or `ga` for the PWM's gates) with the other pins of the group left open. A bus is drawn thicker than a wire, with a slash and its width. It is wiring only: before a run each bus is taken apart, so the circuit simulates exactly as the same drawing with separate wires (open the example **Three-phase inverter with buses**). After a run, probe an element by its net name: a demux output's name, or `{bus}_{k}` for one nobody named. A bus on a pin that takes none (an electrical pin, a block that is not element-wise) is reported when you run. A PLECS model's vector signals import as buses when they fit (chapter 9). ### Example: the three-phase inverter on buses The example **Three-phase inverter with buses** (`inverter3Bus`) is the three-phase inverter drawn with one wire for each three-phase set. The sine source `Ref` gives the three duty references on the bus `dabc`, the three-phase PWM takes them on its pin `a` and gives the three gate signals on its pin `ga` as the bus `g`, one `not` block inverts all three at once into the bus `gn`, and two demuxes split `g` and `gn` into the gate labels of the legs. From a terminal: ```sh powercraft-cli run --cmd file.openExample --params '{"name":"inverter3Bus"}' \ --cmd simulation.run --params '{}' \ --cmd scope.measure --params '{"signals":["dabc_1","ga","i(La)"]}' ``` The run records the bus elements as `dabc_1`, `dabc_2` and `dabc_3` (the bus had no names for them) and the demux outputs by their own names (`ga`, `gb`, `gc`, `gan`, …). A control signal is recorded by its net name alone, without `v( )`. `dabc_1` has a mean of 0.500 and `i(La)` an RMS value of 15.696 A, the same as the example **Three-phase inverter** (`inverter3`) drawn with separate wires, to the last digit. ![The three-phase inverter on buses, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/buses/01-inverter.png) 1. `Ref`: the three-phase sine source gives the three duty references on one bus, `dabc`. 2. `PWM`: the three-phase PWM takes them on its pin `a` and gives the three gate signals as the bus `g`. 3. `N`: one `not` block inverts all three into the bus `gn`. 4. `DG`: a demux splits `g` into `ga`, `gb` and `gc`. 5. `DGN`: a demux splits `gn` into `gan`, `gbn` and `gcn`. ### Limits - A bus is for control signals only. A bus on an electrical or thermal pin, or on a block that is not element-wise and has no pin group, stops the run with the block, the pin and the bus width. - A mux takes 2 to 8 inputs (`n`), and a demux gives 2 to 8 outputs; a demux's `n` must be the width of its bus. A bus is at most 64 elements wide (a mux input that is itself a bus adds all its elements). - The inputs of an element-wise block must have the same width, or be scalars; buses of different widths on one block stop the run. - A bus fed back into itself through a mux is refused ("the buses do not settle"). - Each element-wise block on a bus becomes one copy per element (`G1[1]`, `G1[2]`, …) before the solvers compile the circuit, so a message from the run can name such a copy. ## Parameter hints Hover over a parameter name in the Properties panel to see what it means. With **View > Appearance > Language > 繁體中文** the hint is in Traditional Chinese. (Chapter 14 has the other settings.) ## Moving around Navigation works as in Figma. A two-finger scroll on a trackpad moves the view; Cmd+scroll or a pinch zooms about the pointer. **H** picks the **Pan** tool: a left drag moves the view, and a click selects nothing. **Esc** goes back to the **Select** tool. Hold **Space** to pan in any tool: the tool dock shows Pan while Space is held, and letting go gives your tool back. An empty circuit says how to place the first part; the status bar's first tip shows how to move around under the pointer: *Two fingers or H pan; pinch, ⌘-scroll or a mouse wheel zooms* (with Preferences › Scroll wheel on Trackpad: *Two fingers, a mouse wheel or H pan; pinch or ⌘-scroll zooms*). | Action | How | |---|---| | Zoom | Pinch, Cmd+scroll (Ctrl+scroll on Windows and Linux), Cmd+Plus (or Cmd+=) and Cmd+Minus; a mouse wheel when **Scroll wheel** is Auto or Mouse; Cmd-drag on empty space zooms to the box drawn | | Fit everything | Cmd+0, Home or Shift+F (**View > Fit to Window**), or double-click empty space | | Zoom to the selected parts | F (**View > Zoom to Selection**) | | Pan | A trackpad's two-finger scroll, always; the Pan tool (**H**) and a left drag; hold Space and drag in any tool, or drag with the middle button; Shift+wheel pans sideways; a mouse wheel when **Scroll wheel** is Trackpad. A right drag does nothing: the right button only opens the context menu | | Select tool | **Esc**, or the arrow in the tool dock | | Next or previous open circuit | Ctrl+Tab and Ctrl+Shift+Tab, or Alt+PageDown and Alt+PageUp | | Tab and side bar menus | Right-click a circuit tab: Close, Close Others, Move to New Window, Show in Finder (Explorer, folder; for a circuit saved to a file). File › Export › Rebuild Script writes the circuit as a script of engine commands that builds it again (run it with `script.run`; the script names what it does not rebuild yet, and a circuit with a subsystem or IC is refused). File › Save All saves every open circuit with unsaved changes to its own file (a circuit that has no file yet is named in the status line; use Save As for it), and File › Close All closes every circuit, asking about each one with unsaved changes as Quit does. File › Save As Older Version writes a copy of the circuit as an older file format version (`file.saveAsVersion {path, version}`), so an older Voltecx opens it: below version 3 every sheet's parts go onto one sheet at their places (the netlist is the same) and the reply lists what was dropped; a circuit with subsystem parameters cannot go below version 2 and is refused by name. The open circuit keeps its own file and everything in it. Right-click a tab of the bottom panel: Close, Close Others, Maximize (or Restore), Collapse Panel (or Expand Panel: the panel folds down to its tabs, and a click on a tab opens it again; at the right or left there is none), Panel Position, Hide Panel. Right-click the side bar's title: Hide Side Bar; a tab of the secondary side bar: Close Secondary Side Bar | | Context menu | Right-click a part: Cut, Copy, Rotate, Flip, Flip Vertically, Duplicate, Disable (or Enable), Create Subsystem, Delete, Properties (on a pin also Disconnect Pin). Right-click empty canvas: Undo, Redo, Paste, Place Part, Wire Tool, Select All, Fit to Window. Right-click a wire: Rename Net, Delete Wire, Draw Net as Labels. Right-click a net label: Rename Net, Draw Net as Wires. Probe on either after a run | **Scroll wheel.** **Edit > Preferences > Scroll wheel** sets what a mouse wheel does on the schematic and on the scope's plots. Two fingers on a trackpad always pan, whatever the setting. **Auto** (the default) zooms about the pointer with a mouse wheel, and treats a wheel that scrolls in fractions of a line (a Windows precision touchpad, smooth scrolling on Linux) as the touchpad it is, so it pans. **Mouse** zooms with every wheel; **Trackpad** moves the view with the wheel too. Shift with the wheel pans sideways, and pinch and Cmd+scroll (Ctrl+scroll) zoom about the pointer in every mode. On a Mac the trackpad and the Magic Mouse report smooth scrolling and pan; an ordinary mouse wheel zooms. The status bar's tip and **Help > Keyboard Shortcuts** say which mode is on. The first time a mouse wheel zooms under **Auto**, a note says so once and names the setting that makes the wheel pan. **The same gestures on the scope.** The scope's plots follow the same rules, with one difference: with **Zoom Box** on (the default) a drag draws a box and zooms to it, and you hold Space or drag with the middle button to pan; with **Pan** on a drag pans. Cmd-drag zooms to a box in any mode, a double click fits, and the right button only opens the menu. Over a plot, an axis, a legend entry or a cursor, the status bar says what a drag or a click does there. **Help > Keyboard Shortcuts** lists every gesture under **Mouse and trackpad**. **First use.** The first time you click on the schematic, a note names the gestures nothing on screen shows: a drag on empty space selects a box, Space-drag pans, a double-click opens a part's Properties, and Option+Shift-drag (Alt+Shift-drag on Windows and Linux) lifts a part off its wires. The first click on a scope plot does the same for the scope: drag an axis or turn the wheel over it to zoom that axis alone, double-click to fit, click a legend entry for its measurements, and step the active cursor with the arrow keys. Each note comes once, never while the tour shows its cards, and can be read again in **View > Notifications**. **What the pointer says.** The pointer shows what a drag does: the move arrows over a part, a crosshair over a pin (a wire starts there), the four-way arrow over a wire (a drag bends it), and the open hand with the Pan tool or while Space is held (closed while you drag). The status bar names the thing under the pointer and what a click or a drag on it does, for example *R1: drag to move · double-click for Properties · right-click for actions*. Zoomed out, a pin picks up the pointer only within a quarter of its part, so small parts stay easy to grab, and the pin under the pointer shows as a filled dot. While the schematic has the keys it has a thin focus edge: the part keys (**R**, **L**, **C**, **M**…) act there. The library's tooltip names a part's own placing key. **Zoom to Selection** fits the selected parts to the window with a small margin. With nothing selected, it fits the whole circuit. Shift+F is a second key for Fit to Window. The menu bar leaves it out, so it does not list the same action twice; Quick Open and Help > Keyboard Shortcuts list it as View > Zoom to Fit. **Minimap.** Choose **View > Minimap** to show a small overview in the bottom-right corner of the schematic. It draws the parts (the selected ones in the accent colour), the wires and a rectangle for the area you see. Click or drag in it to move the view there. On a circuit (or a subsystem's inside) with more than 60 parts the minimap shows by itself; turning it off in **View > Minimap** keeps it off, and **Edit > Preferences > Minimap on large circuits** turns the automatic minimap back on. It stays hidden when the schematic area is smaller than 360 by 240 points. **Zoomed out.** Part names stay at least 11 points high at every zoom, so a large circuit still says what each part is. Below 50 % the values and pin names are left out, and below 30 % each subsystem is drawn as one box with its subsystem's name in it (its designator stays beside it). Below 15 % only the shapes and the subsystem boxes are drawn. None of this changes the circuit. **Grid spacing.** **View > Grid Spacing** sets how coarse the grid is: 1, 2, 5 or 10 grid units. The grid dots, dragging a part and placing a part with a key all snap to it. The minimap and the spacing are remembered the next time you start the app. **Net names.** Each net you named (VIN, SW, GND, a gate signal) writes its name once along each connected run of its wire, just above a horizontal piece and in the net's colour, the way a printed Altium or KiCad sheet reads. Names the editor made up (n12, and ground's 0) are not written, and a net drawn as labels shows its name in the labels already. **View > Net Names** turns them off or on; the setting is saved with the circuit, so **File > Export > Schematic** writes the same names. Name a net with **Net label…** on its wire's right-click menu. **Part text.** Under its designator each part writes its value, its part number or both: **View > Part Text > Value**, **Part Number** or **Value and Part Number** (the default), saved with the circuit and used by the export too. A resistor, capacitor or inductor writes `100 µF · EEHZC1V101P` with both. A switch or diode writes its part number (its Part number parameter, or the library device it uses), else its ratings (the Voltage rating and Current rating parameters, `100 V, 40 A`), else its on-resistance; **Value** skips the part number. A rating you have not entered is never shown. **Symbol style.** A resistor is drawn as a box, the IEC 60617 symbol that KiCad and Altium use by default. **View > Symbol Style > IEEE 315 (Zig-Zag Resistor)** draws it as a zig-zag instead, and **IEC 60617 (Box Resistor)** goes back. Only the drawing changes: the pins stay where they are, so no wire or connection moves. The setting is saved with the circuit and used by **File > Export > Schematic**. An inductor is a row of semicircles in both standards. **IC colours.** **View > IC Colours** fills every IC and subsystem box in yellow with a dark-red outline, as industry schematic sheets draw them. Only the drawing changes, and the setting is saved with the circuit and used by **File > Export > Schematic**. The print theme stays black and white. ## Shortcut table | Shortcut | Action | |---|---| | Cmd+N, Cmd+O, Cmd+S, Cmd+Shift+S | New, Open, Save, Save As | | Cmd+W | Close the circuit (asks first when it has unsaved changes, chapter 14) | | Cmd+Shift+N | New window (chapter 14) | | Control+Cmd+F on a Mac, F11 elsewhere | Enter or exit full screen | | Cmd+Z | Undo | | Cmd+Shift+Z, Cmd+Y | Redo | | Cmd+X, Cmd+C, Cmd+V | Cut, Copy, Paste | | Cmd+A | Select all parts | | Cmd+D | Duplicate | | Cmd+F | Find and replace | | F3 | Find the next match (Classic keymap) | | E, F4 | Show the selected part's properties | | Delete, Backspace | Delete the selection, or the selected wire | | Cmd+Shift+E | Disable the selected parts, or enable them again | | Cmd+R | Rotate a quarter turn (R too in the Default keymap) | | X, Cmd+E, Cmd+Shift+F | Mirror left to right | | Y | Mirror top to bottom | | Shift+M | Move the selection with the pointer (click to put it down; M in the Default keymap) | | Shift+G | Grab the selection with its wires (G in the Default keymap) | | Insert, Shift+A | Place another copy of the part placed last, at the pointer | | Cmd+G | Create a subsystem (opens a dialog) | | W | Wire tool | | Esc | Select tool | | H | Pan tool: a left drag pans the view | | Space (hold) | The hand in any tool, until you let go | | Shift+P | Probe: click a wire, pin or part to put its voltage or current on the scope (P is Insert > Part) | | R, L, C, D, G, V, I, S, M, T | Put a resistor, inductor, capacitor, diode, ground, DC voltage source, DC current source, switch, MOSFET or IGBT on the pointer; click to put it down | | Shift+T | Text tool (T in the Default keymap) | | Right click while placing | Cancel the part on the pointer, as Esc does | | N | Place a net label on the pin under the pointer | | ` (backtick) | Highlight the whole net of the wire, label or pin under the pointer (View > Highlight Net, as KiCad's `` ` ``); press it again, or click the canvas, to clear it | | B | Bus tool (Circuit > Bus Tool, as KiCad's Place Bus) | | Q | Mark the pin under the pointer no-connect, so the ERC no longer reports it open (Circuit > Net > No-Connect Flag, as KiCad's Q); press it again over the pin to clear the mark | | Esc | Stop wiring or moving, leave the wire tool, close a dialog, let go of a selected wire, or clear the selection | | Arrows, Shift+Arrows | Nudge by 1 or 5 grid steps | | Alt while dragging | Drag a part without snapping | | Alt+Shift (Option+Shift) while dragging a part | Lift it off its wires (LTspice Move); with **Wires follow moved parts** off, keep them | | Tab, Esc, Down / Up (or `]` / `[`) | Accept, dismiss, next and previous suggestion on the canvas, once you clicked it (chapter 12) | | F5, Cmd+Enter | Run the simulation | | Shift+F5, Cmd+. | Stop | | F6 or Cmd+Alt+Enter, F7 or Cmd+Shift+Enter | Pause, Continue | | F8, Cmd+Shift+A | Animate (Shift+F8 in the Default keymap, where F8 is File > Sync with KiCad) | | F2, Cmd+Shift+R | Rename the selected part | | Cmd+K | Quick Open | | ?, Cmd+/ | Keyboard shortcut list | | Cmd+, | Preferences (chapter 14) | | Cmd+L | Show the agent's chat with the keyboard in it, or hide the secondary side bar (chapter 12) | | Cmd+Alt+B | Show or hide the secondary side bar on the right (Properties and Assistant tabs) | | Cmd+B | Show or hide the side bar on the left | | F1, Cmd+I | Component guide | | Cmd+Plus (or Cmd+=), Cmd+Minus, Cmd+0 (or Home) | Zoom in, zoom out, fit | | F, Shift+F | Zoom to the selection, zoom to fit | | Ctrl+Tab, Alt+PageDown | Next circuit | | Cmd+Shift+D | Design panel (beta) | On Windows and Linux, read **Ctrl** for **Cmd**. **Ctrl+Tab** is the Control key on every system. A MacBook sends brightness and volume for F1–F12 unless you hold **Fn**, and has no Insert key, so every F-key and Insert action has a second key. In the web app the browser keeps Cmd+W, Cmd+N, Cmd+Shift+N, Cmd+T and Ctrl+Tab, so the menus there leave those keys out: use the menu, or Alt+PageDown and Alt+PageUp for the circuits. **Coming from another tool.** With the Classic keymap one letter places a part, as in LTspice and PSIM: **R** a resistor, **C** a capacitor, **G** a ground. **Ctrl+R** rotates as in LTspice, **Ctrl+E** mirrors as in LTspice and **X** / **Y** mirror as in KiCad, **W** wires, **N** labels a net, **F5** runs, and **H** and Space pan as in Figma. The menus show every key of an item: in the Default keymap **Circuit > Rotate** reads `R ⌘R`, in Classic `⌘R`. ## Keymaps **Edit > Preferences > Input and shortcuts** and the top of **Help > Keyboard Shortcuts** have a **Keymap** list with four choices: **Default**, **KiCad**, **Altium** and **Classic**. Point at the list or at a choice to read what it changes; the shortcut window and the menus always show the keys of the keymap in use. A new installation starts on **Classic**, the set described above: it suits engineers used to other power-electronics simulators, where one plain letter places one part. **Default** is based on KiCad's keys: **R** rotates, **G** grabs, **L** labels a net and **A** picks a part, so the parts on those letters take Shift. Where the two differ: | Action | Classic | Default | |---|---|---| | Resistor, inductor, ground, DC voltage source | R, L, G, V | Shift+R, Shift+L, Shift+G, Shift+V | | DC current source, MOSFET, IGBT, ammeter | I, M, T, U | none | | Find Next | F3 | none (Edit > Find Next) | | Rotate | Cmd+R | R, Cmd+R | | Move off the wires | Shift+M | M | | Grab with the wires | Shift+G | G | | Text tool | Shift+T | T | | Select tool | Esc | Esc | | Edit the selected part's value in place (KiCad's Edit Value) | Enter, double-click | V, Enter, double-click | | Net label | N | L | | Pick a part (Insert > Part) | P | A | | Power port on the pin under the pointer (KiCad's Place Power Symbol) | none (Circuit > Net > Power Port) | P | | Next and previous grid spacing | none (View > Grid Spacing) | N, Shift+N | | Rename a part (KiCad's Edit Reference) | F2, Cmd+Shift+R | U, F2, Cmd+Shift+R | | Animate | F8, Cmd+Shift+A | Shift+F8, Cmd+Shift+A | | Sync with KiCad (KiCad's Update PCB from Schematic) | none (File > Sync with KiCad) | F8 | Every other key is the same in both: **`** highlights the net under the pointer, **B** picks the Bus tool, **Q** marks the pin under the pointer no-connect, **W** wires, **Shift+P** probes, **X** and **Cmd+E** mirror, **C**, **D** and **S** place a capacitor, diode and switch. In both keymaps a right-click cancels the part on the pointer, as Esc does. Switching rewrites your bindings to the chosen keymap and puts any keys you changed aside; **Undo** beside the list puts the keymap and your keys back. Keys you change afterwards apply on top of the keymap, and **Reset** returns a key to the keymap's. The choice is remembered with the other preferences. ### KiCad and Altium **KiCad** is the Default keymap plus KiCad's **Cmd+F1** (Ctrl+F1), which lists the keys, and **F3**, which finds the next match; Default leaves both out because a MacBook sends F-keys only with Fn, and **Cmd+/** or **?** list the keys too. The Default keys already do what KiCad 9's schematic editor does with **L** (net label), **A** (add a part), **N** and **Shift+N** (grid), **U** (Edit Reference), **V** (Edit Value: the selected part's value opens in place, as Enter does), **F8** (Update PCB from Schematic: here File > Sync with KiCad, which keeps the exported KiCad project in step), **W**, **M**, **G**, **R**, **X**, **Y**, **E**, **Delete** and **Insert**, as KiCad's own manual names them, and with KiCad's **Cmd+Z**, **Cmd+Y** (**Cmd+Shift+Z** on a Mac), **Cmd+S**, **Cmd+F**, **Cmd+X**, **Cmd+A**, **Cmd+D** and **Home** (**Cmd+0** on a Mac), and with its schematic editor's **B** (Place Bus) and **Q** (Place No Connect Flag), as its hotkey list names them. **P**, KiCad's Place Power Symbol, puts a power port on the pin under the pointer in Default and KiCad (Circuit > Net > Power Port): the net-label dialog opens with the kind set to rail, you type the rail's name (`VIN_48V`), and the net is drawn as rail symbols at every pin instead of a supply wire. Two ports with the same name are one net. A ground stays a part (**Shift+G**). In Classic, P keeps the Part tool and the power port has no key. Two KiCad keys have no Voltecx action. **F**, KiCad's Edit Footprint, zooms to the selection, because footprints are chosen on the board. **J**, KiCad's junction, does nothing, because Voltecx draws a junction wherever wires meet. **Altium** adds Altium Designer's keys beside the Default ones, where they take no key Voltecx needs: | Action | Altium keymap adds | |---|---| | Zoom in, zoom out | PgUp, PgDn | | Fit to window | Cmd+PgDn | | Run the simulation | F9 | | Show or hide the grid | Cmd+Shift+G | Altium's **Space** (rotate), **Ctrl+W** (wire) and **F1** (key list) keep their Voltecx meaning: Space pans, Ctrl+W closes the browser tab in the web app, and F1 opens the Component Guide. The keys come from KiCad's and Altium's public documentation only. ## Change a shortcut Open **Help > Keyboard Shortcuts** (**?** or Cmd+/). The window lists the mouse and trackpad gestures first (including double-clicks, Backspace and the scope's cursor and axis drags), then every binding by menu. Type in **Filter shortcuts** to keep only the rows whose action, menu or keys contain every word you type, in English or Chinese: `zoom`, `scope`, `F5`. A second key such as **R** for Rotate in the Default keymap has its own row. Click **Change** beside an action and press the new keys. **Reset** puts the original back, and **Reset All** (shown once you have changed a key) puts every binding back, and **Undo** beside the Keymap list brings yours back. A key already in use is refused where both would act: the scope's keys work only with the pointer over the scope and the drawing keys only over the canvas, so one key can do one thing in each. After a refused key the row keeps recording: its field, framed in red, shows the refused keys and *Press the new keys…*, so press other keys or Esc to stop. Backspace, Tab, `[` and `]` without a modifier are kept for deleting and for the canvas suggestions. The clipboard keys and Space-to-pan cannot be changed; in Preferences their rows read *Fixed* beside a lock instead of **Change**. Keys the system keeps are refused: Cmd+H, Cmd+Q and the like on a Mac, and Alt+F4, Alt+Tab, Alt+Space and Ctrl+Alt+Delete everywhere, so your keys work on every machine you use; an F-key you pick on a Mac is taken with a note that a MacBook needs Fn for it. Your bindings are remembered. To take your keys to another computer or share them with a colleague, click **Export Keys…** in the same window: it saves the keymap and every binding you changed as a small `.json` file. **Import Keys…** on the other machine reads such a file and uses its keymap and bindings in place of yours, and **Undo** beside the Keymap list brings yours back. A file with a key Voltecx cannot read is refused whole, and the status bar names the file and the binding. In the web app, **Export Keys…** downloads the file; importing needs the desktop app. ## Quick Open Press **Cmd+K**, type a few letters of a command's name or id (`sweep`, `explain`, `template`) and press Enter. This is the quickest way to reach a command that has no menu item. A command that needs parameters opens a form (or, for a command without one, a box where you type them as JSON). The words can come in any order and each may be the start of a word, part of one, or have one letter wrong: `run sim` finds **Simulation > Run Simulation**, `exp wave` finds **File > Export > Waveforms (CSV)**, `simulaton` still finds the simulation commands, and Chinese text such as `匯出波形` works whatever the interface language. The best matches come first, then the commands you ran from the palette lately. With nothing typed, the palette lists the last five commands you ran from it at the top. A greyed-out command says why it is not available now (for example, run a simulation first). The palette also opens examples and recent files. What you type lists the matching examples first, then the matching recent files, then the commands, each under its heading: `buck` finds the buck examples and a recent `buck_v2.pcraft`. With nothing typed, your recent files come first, then the commands. Start with `>` to search the commands only. The highlighted row is the best match of any section, so `run sim` still highlights **Simulation > Run Simulation** under the examples. The right side previews the highlighted row. An example shows its schematic and its main waveform, as in **Help > Examples**. A recent file shows its schematic and the waveform of the result saved in it (a file saved as a bundle keeps its result; a plain file says it has none). A command shows its menu path, its id, its keys, whether it can run now and its parameters. | Key | In the palette | | --- | --- | | Up, Down | Move through the rows; the preview follows | | Enter | Open the example or file, or run the command | | Cmd+Enter | Open the example or file and run its simulation | | Esc | Close the palette | ## The menu bar on a Mac On macOS the menus are in the system menu bar at the top of the screen, as in VS Code, not in a row inside the window. They are the same menus, in the language you picked, and they follow your own shortcuts. - **Voltecx** holds **About Voltecx**, **Settings…** (⌘,; **Preferences** before macOS 13), **Services**, **Hide Voltecx** (⌘H), **Hide Others**, **Show All** and **Quit Voltecx** (⌘Q). Quit asks about unsaved circuits first, as **File > Quit** does elsewhere. - **Edit > Undo, Redo, Cut, Copy, Paste and Select All** act on a text field while you type in one, and on the circuit otherwise. - **Window** has **Minimize**, **Zoom** and the list of this window and a detached scope. A window opened with **File > New Window** runs as its own program, so it lists its own windows only. - **Help** has the system's search field: type a few letters to find a menu item. The menu bar shows the ⌘ keys. Keys without ⌘ (**R**, **W**, **F5**, **Shift+M**, **Ctrl+Tab**) work as before; Quick Open and **Help > Keyboard Shortcuts** list them. With the toolbar hidden, run with **Simulation > Run Simulation** or **F5**. --- # 4. Simulation settings URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/04-simulation-settings/ Open **Simulation > Settings** (`simulation.settings`). The form shows the current settings; change the fields you want and press Enter. The settings are saved with the circuit. **Copy JSON**, the icon beside Cancel, copies the same settings as a JSON object for a script, the console or an agent, where you only send the keys you want to change and the others keep their values: ```json {"tEnd": "10m", "maxStep": "50n", "solver": "fast", "fixedStep": true} ``` The same settings as a form: ![The settings window, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/simulation-settings/02-settings.png) 1. Stop time. 2. Solver. 3. Fixed step. 4. Copy JSON. 5. Apply and run. ## The settings | Key | Default | What it does | |---|---|---| | `tEnd` | `1m` | End time of the run, in seconds | | `maxStep` | `100n` | The step the solver uses. In fixed-step mode it is the step; in variable-step mode it is the largest step | | `solver` | `fast` | `fast` or `reference` (below) | | `integration` | `trapezoidal` | `trapezoidal`, `backwardEuler` or `exact` (below) | | `fixedStep` | `true` | `true` for a constant step, `false` for an error-controlled step (below) | | `minStep` | `0` | Variable step only. The smallest step. `0` means `maxStep / 1024` | | `relTol` | `1e-3` | Variable step only. Relative error tolerance | | `absTolV` | `1e-6` | Variable step only. Absolute tolerance on capacitor voltages, in volts | | `absTolI` | `1e-9` | Variable step only. Absolute tolerance on inductor currents, in amperes | | `maxSteps` | `20meg` | The most solver steps one run may take, up to `2g` (2 000 million) | | `saveFrom` | `0` | Record from this time on. The run still simulates from 0 | | `printStep` | `0` | Keep about one sample per interval (and a switching edge). `0` keeps every step | | `printEvery` | `0` | **Record every Nth step**: keep one solver step in N, evenly spaced, and the last step. `0` or `1` keeps every step | | `switchingLossFromCircuit` | `false` | **Draw switching loss**: `true` makes each switch draw its `eon`, `eoff` or `err` energy (or its device tables' energy) from the circuit, so the terminal powers include it. `false` only adds it to the loss totals | | `thermalStep` | `0` | Multi-rate: the thermal network's own step (below). `0` steps it with the circuit | | `thermalStart` | `ambient` | Where the thermal network starts: `ambient`, `steady` or `{"": °C}` (below) | | `fastRefactor` | `true` | **Reuse pivot order** (fast solver): a step that lands on an event reuses the pivot order of its switch state instead of factoring the matrix in full. A reused pivot that is too small, or factors that grow too much, factor in full after all. Faster on converters with many events per period (LLC, phase-shifted bridge). Turn it off to reproduce a run made before it was on by default; the two differ at rounding level | | `stopOnOverTemperature` | `false` | **Stop when too hot**: `true` ends the run the first time a junction passes its `tjMax` (the part's, else its device's), and the reply's `stoppedBy` says so. `false` lets the run go on and only warns (see Analyses, Over-temperature) | | `record` | `auto` | **Recorded signals**: `all` records every signal; `inUse` only the ones something reads (below); `auto` records all of them unless that would pass 64 MB on a run the app shows, then only the ones in use | Times accept SI suffixes: `"10m"`, `"50n"`. Note that `m` is milli: an end time of one second is `1`, one minute is `60`, and `1m` is one millisecond. The same goes for counts: write 60 million steps as `60meg` or `60e6`, because `60M` means 60 milli. ## Test bench ports: supply and load on connectors A board's input and output are connectors on the schematic (J1, J2), not a battery and a load resistor. What drives each one in a simulation is set under **Properties › Simulation › Test bench ports** and saved with the circuit. Each port row shows its connector and pins, a kind (**DC supply** with **Voltage** and **Source resistance**, **Resistive load** with **Resistance**, or **Current load** with **Current** and an optional **Step at** / **Step to**), its values and **Remove**. A value can be a number (`12`, `4.7m`) or an expression over the circuit's variables (`vin`), so a sweep of `vin` sweeps the supply. A row whose connector has an open pin, or whose expression does not evaluate, says why under it. Picking another kind keeps the old port until the new kind's first value is typed. **Add port** gives a free connector a port once its first value is typed, and **Make Port from Part** turns a DC source, load resistor or DC current source drawn on the schematic into a port on a connector across the same nets; on the schematic, right-clicking one such part offers the same as **Make test bench port**. Each change is one undo step and runs `testbench.setPort`, `testbench.removePort` or `testbench.fromPart`; the run stamps the port as `J1.bench`, so `i(J1.bench)` is the supply's current. The same section shows under the fields of the **Simulation > Settings** form, so the run and what drives it are set up in one place; a port edit there applies at once, as in Properties, and the form's **Apply** applies only its own fields. With **View › Studio Layout (Preview)** on, the gear first on the **Transient** tab's toolbar, **Simulation setup**, opens that form. In the Studio layout the form lists the analyses down its left side (**Transient**, **Steady state**, **AC sweep**, **Loop gain**, **DC operating point**, **Parameter sweep**, **Worst case**, **Monte Carlo**) in place of the **Analysis** row: the one picked is what **Apply and run** runs once the settings are applied. Transient and Steady state run at once; every other analysis opens its own form. ## Switching loss in the circuit A switch with switching energies (`eon`, `eoff`, `err`, or a device's tables) books that energy at each switching event in its loss totals (`analysis.losses`). By default the circuit does not give the energy up, so the terminal powers and the efficiency read from them do not include it; `design.efficiency` adds it back from the tables. With **Draw switching loss** on (`switchingLossFromCircuit: true`) the circuit gives it up: the source delivers more, or the output gets less. Then the terminal powers, the efficiency read from them and `analysis.losses` agree. In the example buck with 60 µJ per period, energy in equals energy out plus stored energy, conduction and switching losses to within 0.5 % of the energy in (`crates/refsolve/src/loss_sink_tests.rs`). How it is drawn: the switch takes the energy as an extra voltage drop while it conducts, like a small extra resistance. The drop is set when a conduction interval starts and kept for the whole interval: it is the energy the switch booked per charge it conducted over about its last 256 periods, plus what it still owes spread over 16 intervals, and at most half the blocking voltage and twice its typical value. A turn-on's energy is drawn in the same interval, a turn-off's or a recovery's in the device's next one, so a period's energy is drawn within about one period, and the end of a run may leave some still to draw. A blocking switch draws nothing. A hard turn-on is booked one step after the switch closes, at the current it carries then, so the discharge of a capacitance across the switch (`coss`, a snubber) is not read as load current. A diode with simulated reverse recovery (`qrr`) already takes its recovery energy through its reverse current, so its `err` is not drawn a second time. Switches at the `dynamic` gate level simulate the transition itself and need none of this. In an open-loop converter the drop lowers the output, as real switching loss does; a closed loop corrects for it. It is off by default for now: in the light-load corners of some flybacks that `design.auto` draws, the drawn loss interacts with the control loop and those corners settle more slowly than the verification allows. Turn it on to check a design's terminal efficiency directly. ## Two solvers - **fast** is the everyday solver. It is built for switching circuits. It reuses matrix factorisations while the switches stay in the same state, so long runs are quick. - **reference** is a deliberately simple solver. It is slower, and it always takes fixed steps. Its job is to be an independent check. When you doubt a result from the fast solver, run the same circuit with `"solver": "reference"` (the Run command also accepts `{"solver": "reference"}`) and compare. The two solvers agree to within small tolerances on the built-in examples, and the test suite checks both against analytic answers and against ngspice. ## Fixed step or variable step **Fixed step** advances by `maxStep` every time (a step is only shortened to land exactly on a switching edge). It is predictable. Its cost is `tEnd / maxStep` steps, so the right step size matters: - A good starting point for a switching converter is `maxStep = 1 / (fsw * 200)`, which is 200 steps per switching period. The template command uses this rule. - If the waveform looks jagged, or a ringing circuit is wrong, make the step smaller. - If the run is slow, make the step larger and look at the result again. **Variable step** (`"fixedStep": false`) works like SPICE. The solver estimates the local error at each step, takes big steps where the waveform is smooth and small steps where it changes fast. It still lands exactly on every switching event. Steps are chosen from the ladder `maxStep * 2^-k` and are never smaller than `minStep`. Use variable step when: - the circuit has fast transients followed by long quiet stretches (start-up, a load step, a resonant tank); - the parts are non-ideal and ring (small parasitic capacitances, saturation, reverse recovery). Stay with fixed step when you want identical sample spacing, for example before an FFT. To tighten the accuracy, lower `relTol` (for example `1e-4`). To stop the solver from taking tiny steps at a hard edge, raise `minStep`. ## Exact steps With `"integration": "exact"` the fast solver does not approximate the circuit between switching events: it solves it. A circuit of resistors, capacitors, inductors, coupled inductors, transformers, linear sources and ideal switches, diodes, MOSFETs, IGBTs and thyristors is linear for as long as no switch changes state, and its waveform over a step then has a closed form (a matrix exponential). The solver builds that model once for each switch state it meets, steps with it, and finds the instant a diode stops or starts conducting on the solution itself, to a billionth of `maxStep`. Gate edges are landed on as always. What changes: - The waveform no longer depends on the step. The open-loop buck example gives the same `v(out)` to within 2·10⁻⁸ (relative) at `maxStep` 50 ns, 500 ns and 2 µs; trapezoidal steps at 50 ns are within 1.2·10⁻⁷. A ring faster than the step (a snubber, a leakage inductance) is solved exactly, not damped or aliased. - `maxStep` now only sets how densely the result is **recorded** (and how often the controls run). Choose it for the plot you want: about 20 samples per switching period draw the ripple to within about 1 %, while the values at the samples stay exact. - A switching inside a step is looked for every sixteenth of `maxStep`. A current that crosses zero and comes back within less than that is missed, as it would be with a step that long. - At the same `maxStep` an exact step costs about three times a trapezoidal one, but it can take far longer steps for the same accuracy. In `crates/fastsolve/tests/exact_bench.rs` the flyback example at 1 µs runs nine times faster than trapezoidal steps at 20 ns and is 70 times closer to a run at 1 ns. The other solver and the other parts: the reference solver always integrates trapezoidally. A circuit with a part that is not piecewise linear (a saturating inductor or a core, a thermal network, reverse recovery, a machine, a level-1 MOSFET, a behavioural source, a protection device) runs with trapezoidal steps instead, and a warning names the part. So does a circuit with more than 64 capacitors and inductors. How it works, and the references: `docs/design/pwl-solver.md`. ## Large circuits The fast solver switches to a **sparse** matrix factorisation by itself when a circuit has more than 40 unknowns and at most one eighth of the matrix entries are non-zero. Most large circuits look like this: a long RC ladder, a many-phase converter, a big imported netlist. A circuit with 40 unknowns or fewer keeps the dense factorisation and gives exactly the same numbers as before. A large sparse circuit gives the same waveforms as the dense method to within rounding. If the sparse factorisation ever fails, the solver falls back to the dense one, so you see the same error messages as before. There is nothing to set. ## Thermal parts on the schematic The thermal library has, besides `rth`, `cth` and `ambient`, four parts with pins `a` (hot side) and `b` (cold side): - `foster`: a data sheet's Foster table, `r` (K/W) and `tau` (s). Into a side with no heat capacity of its own (an ambient, or resistances and heatsinks on to one) it stays a Foster chain, which then adds to them exactly; into a side that stores heat (a `cth`, a `cauer` ladder, a device's junction ladder) it becomes the equivalent Cauer ladder, as a device's own chain does. `form` = `foster` or `cauer` forces one. - `zth`: points `t`, `z` read off the data sheet's Zth(t) curve; a Foster chain of up to `terms` stages (8 at most) is fitted when the circuit is built, then it acts like `foster`. End the points where the curve has levelled off. - `cauer`: a ladder of `r` and `c`, each node with its heat capacity to the reference. - `heatsink`: a catalogue heatsink's sink-to-ambient resistance. Place it with `thermal.placeHeatsink {part, watts, airflow, a, ambient}`: it reads `parts/heatsinks.json` at that heat and airflow, as `design.thermal` does, so the cooling `design.thermal` picks goes on the schematic with one command. An extrusion goes on with `thermal.placeHeatsink {part, lengthMm, airflow, a, ambient}` at a cut length its data sheet rates, its resistance read between the sheet's airflows. The catalogue gives no heat capacity for these heatsinks, so the part has none. On a circuit with no thermal network yet, `design.thermal {apply: true}` places the whole network it picked in one undo step: each device's `thermal` net and junction-to-case path, the pad and heatsink (or the board copper), one ambient part, and a steady thermal start. It refuses a circuit that already has a thermal network. - `coolingFan`: a fan that blows across heatsinks. Place it with `thermal.placeFan {part, airflow, cools}`: `airflow` is the air speed across the heatsinks (from the fan's curve and duct, not its free-air flow), and for each heatsink in `cools` the command reads its data sheet again at that airflow and writes `fanRth` (and the rise table `fanCurveW`, `fanCurveK`). The fan has no pins. While it is fitted and simulated the run uses those values; mark it DNP, switch its simulation off or leave it out of a project variant, and the heatsinks keep their own `rth`. So comparing two variants shows what the fan buys, and the electrical result is the same in both. `bom.export` lists it under `part`, with the data sheet when that is a catalogue fan (Delta AFB0812SH, AFB0912VH, AFB1212SH-F00), and `board.addFootprints` places the footprint its `footprint` parameter names, every pad on no net. None of these parts has default values: a part without its data-sheet numbers stops the build and says which are missing. ### Example: a MOSFET on a Foster chain and a catalogue heatsink An always-on MOSFET (`ron` 0.1 Ω) passes 24 V into 4.9 Ω, so it dissipates 2.30 W into the thermal net `j`. A four-stage Foster table runs from `j` to the case, and `thermal.placeHeatsink` mounts a Same Sky HSE17-252525P on the case at that heat, in still air, with a 40 °C ambient: ```sh powercraft-cli run --cmd file.new --params '{"name": "heatsinkDemo"}' \ --cmd circuit.addComponent --params '{"name": "Vin", "kind": "dcVoltageSource", "params": {"v": 24}}' \ --cmd circuit.connect --params '{"component": "Vin", "port": "p", "net": "in"}' \ --cmd circuit.connect --params '{"component": "Vin", "port": "n", "net": "0"}' \ --cmd circuit.addComponent --params '{"name": "On", "kind": {"kind": "control", "block": "constant"}, "params": {"value": 1}}' \ --cmd circuit.connect --params '{"component": "On", "port": "out", "net": "g"}' \ --cmd circuit.addComponent --params '{"name": "Q1", "kind": "mosfet", "params": {"ron": 0.1, "thermal": "j"}}' \ --cmd circuit.connect --params '{"component": "Q1", "port": "d", "net": "in"}' \ --cmd circuit.connect --params '{"component": "Q1", "port": "s", "net": "out"}' \ --cmd circuit.connect --params '{"component": "Q1", "port": "gate", "net": "g"}' \ --cmd circuit.addComponent --params '{"name": "R1", "kind": "resistor", "params": {"r": 4.9}}' \ --cmd circuit.connect --params '{"component": "R1", "port": "p", "net": "out"}' \ --cmd circuit.connect --params '{"component": "R1", "port": "n", "net": "0"}' \ --cmd circuit.addComponent --params '{"name": "ZJC", "kind": {"kind": "thermal", "element": "foster"}, "params": {"r": "0.05, 0.1, 0.2, 0.15", "tau": "1e-4, 1e-3, 1e-2, 1e-1"}}' \ --cmd circuit.connect --params '{"component": "ZJC", "port": "a", "net": "j"}' \ --cmd circuit.connect --params '{"component": "ZJC", "port": "b", "net": "case"}' \ --cmd thermal.placeHeatsink --params '{"part": "HSE17-252525P", "watts": 2.3, "a": "case", "ambient": 40}' \ --cmd simulation.settings --params '{"tEnd": "500m", "maxStep": "5u"}' \ --cmd simulation.run --params '{}' \ --cmd scope.measure --params '{"signals": ["T(j)", "T(case)"]}' ``` The Foster numbers are round illustrative values, not a part. The reply to `thermal.placeHeatsink` gives `rth` 11.97 K/W: the data sheet's rise of 24.0 K at 2 W and 35.8 K at 3 W, read on the straight line between them at 2.3 W. It also cites the data sheet (revision 1.01, 2025-11-17) and names the ambient part it added (`HS1_Ta1`). After 0.5 s, `T(case)` is 67.59 °C (40 °C + 2.30 W × 11.97 K/W) and `T(j)` is 68.74 °C, 1.15 K higher across the chain's 0.5 K/W. The chain stays a Foster chain here, because the heatsink holds no heat. ![The example circuit after thermal.placeHeatsink, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/thermal-parts/01-heatsink.png) 1. `Q1`: its losses flow into the thermal net `j`. 2. `ZJC`: the four-stage Foster chain from `j` to the case. 3. `HS1`: the heatsink `thermal.placeHeatsink` placed, `rth` 11.97 K/W. 4. `HS1_Ta1`: the 40 °C ambient it added. ### Paralleled devices: `nParallel` One switch, diode or MOSFET on the schematic can stand for N identical devices in parallel: set `nParallel` (a whole number from 1 to 1024; the default 1 changes nothing). The element's current is shared, so every loss table is read at one device's current, `ron` and `roff` are one device's values (the element's are `ron/N` and `roff/N`) and the switching and conduction energies are N devices' worth. The junction chain of a library device is one device's Zth,jc divided by N (R/N, the same time constants), so the junction node reads one device's temperature while the heat into the case is the total. Two IGBTs of 0.5 K/W on one case at 2.0 K/W, 10 W in all: `Tj` = ambient + 10 W × (0.5/2 + 2.0) K/W, and the case sits at ambient + 10 W × 2.0 K/W. Ideal-current sharing is assumed: no mismatch of `vth`, `ron` or layout between the devices. An exponential diode and a MOSFET with gate dynamics refuse `nParallel` above 1; place the devices side by side there. `bom.export` buys the part N times (a line `N x part number`, each device rated for I/N), and `design.thermal` puts the total loss on the heatsink and one device's P/N through each junction's own case, with N in its device table. #### Example: three paralleled SiC MOSFETs per switch The example `halfBridgeParallelSic` (**File › Open Example › DC-DC**) is a synchronous half-bridge from 400 V to 200 V at 50 kHz into 6.67 Ω, so 30 A in the inductor. Each of its two switches is one MOSFET symbol with `nParallel` 3 and `device` `wolfspeed/c3m0065090d`: three Wolfspeed C3M0065090D from the device library (data sheet Rev. 08), whose conduction, body-diode and switching-energy tables and four-stage Foster junction-to-case chain (RthJC 1.0 K/W) come with the library entry. Both switches sit on one heatsink net `hs`, 0.5 K/W to a 40 °C ambient, and the run starts at its thermal steady state (`thermalStart` `steady`). The heatsink, load and filter values are illustrative. ```sh powercraft-cli run --cmd file.openExample --params '{"name": "halfBridgeParallelSic"}' \ --cmd simulation.run --params '{}' \ --cmd analysis.losses --params '{"t0": "0.5m"}' \ --cmd analysis.thermal --params '{}' ``` Over the last 0.5 ms of the 1 ms run: | | Loss, the three devices | Loss per device | `Tj` at the end | |---|---|---|---| | `Q1` (hard-switched) | 25.9 W | 8.6 W | 67.5 °C | | `Q2` (synchronous rectifier) | 11.8 W | 3.9 W | 62.7 °C | The heatsink `T(hs)` sits at 58.8 °C: 40 °C plus the heat of all six devices times 0.5 K/W. Each junction sits one device's loss times 1.0 K/W above it: `T(Q1.j)` reads one device's temperature, not the sum. The same circuit with one device per switch at a third of the current (`nParallel` 1, the load, the inductor and the heatsink's resistance three times larger, the capacitor a third) gives each device the same loss and the same `Tj`; `crates/engine/tests/parallel_sic.rs` checks that, and that this table is what the run gives. The Problems tab checks the device's Foster table too. Embed a copy of the device with its four stages in the wrong order (`device.get`, reverse `thermalJc`, `device.add`) and `circuit.problems` warns `thermal.device_order`: "the junction-to-case Foster table of device `wolfspeed/c3m0065090d` has time constants that do not rise", with the hint to re-enter the stages from the data sheet, fastest first. It has no one-click fix, because the table is the device's own data. ### Thermal data checks The Problems tab (chapter 8) checks the data a data sheet fills in: a `foster` table whose time constants do not rise (fix: sort the stages, each resistance stays with its own time constant), a `zth` curve whose times do not rise or whose impedance falls (fix: drop unusable points, sort by time, raise each impedance to the largest before it), a `zth` fit that misses the curve by more than 5 % of its largest impedance (fix: fit with the fewest terms that reach the limit, up to 8), and lists of different length or with a value that is not positive. A device's own Foster table in the circuit is checked for order, without a fix. ### Limits of the thermal parts - `thermal.placeHeatsink` places only the parts in `parts/heatsinks.json`. An unknown part, a heat beyond the data sheet's table or an airflow slower than any of its curves is an error, never a guess. Between two airflow curves it reads the slower one. - The heatsink's `rth` is read once, at `watts`, and stays fixed during the run. When the heat changes, place it again at the new heat. - The catalogue gives no heat capacity for its heatsinks, so a placed heatsink has none and its temperature follows the heat at once: in the example `T(case)` is at 67.59 °C from the first step. For the warm-up, add a `cth` from the heatsink's data sheet when it gives one. - A `zth` fit has at most 8 stages and is only as good as its points: end them where the curve has levelled off. - `nParallel` shares the current equally. The case, and so the heatsink, is one node: it gets the total heat of all N devices. ## Multi-rate: a slower thermal step A circuit with a thermal network (device junctions, Foster or Cauer chains, heatsinks) steps that network with every circuit step by default. Thermal time constants are milliseconds to seconds, and the circuit's step is nanoseconds to microseconds, so most of that work changes nothing you can see. **Thermal step** (`thermalStep`, in **Properties › Simulation** and `simulation.settings`) lets the thermal network step at its own, slower rate: - The circuit keeps its own step (`maxStep`, event landing, everything else as before). - The thermal network steps only on its own grid, every `thermalStep` seconds. Over each interval it receives the average power the devices dissipated in it, so it gets exactly the energy they lost. A circuit step that crosses a grid instant is split there. - Between grid instants the junction temperatures the devices read (for their loss tables and on-resistance) and the recorded `T(…)` signals hold their last value, so they lag by at most one thermal step and show as small steps in the scope. Both solvers do the same, so they still agree with each other. Pick about a tenth of the fastest thermal time constant: for `inverter3Thermal` (fastest Foster stage 0.5 ms) that is `50u`, which stays within 1 % of the single-rate run in junction and heatsink temperature, device energy and phase current. `thermalStep` must be `0` or between `maxStep` and `tEnd`. The device energies `E(…)` are still summed at every circuit step. ```json {"thermalStep": "50u"} ``` ## Thermal warm start A short run starts cold; use `thermalStart` `steady` to see the operating temperature. Every thermal node starts at the ambient's temperature by default, and a heatsink takes tens of seconds to minutes to warm up, so a run of a few tens of milliseconds shows only the fast rise of the die, never the junction temperature the converter runs at. **Thermal start** (`thermalStart` in `simulation.settings`) changes where the network starts: - `ambient` (the default): every node at ambient, as before. - `steady`: a pre-run of a few switching periods measures each loss source's average power into the thermal network. The network's DC steady state with those powers (heat capacities open) gives the starting temperatures. The losses depend on the temperature (on-resistance rises with Tj), so the pre-run measures again at the new temperatures, up to 8 rounds, until no node moves by 0.1 K. A search that ends with a node still moving by 0.5 K or more is an error naming that node, never a start. An inverter whose modulator turns an angle at a constant speed (a dq current loop, as in `inverter3Thermal`) repeats over its line period, not its switching period: the pre-run settles for two line periods and each round measures over one whole line period, so every switch of a leg is measured over the same complete cycle. The pre-run first finds the electrical steady state, so the losses are not those of the start-up. The run itself then starts from t = 0 with its usual electrical initial conditions and the network at those temperatures. The reply to `simulation.run` has `thermalStart {method, rounds, residualK, temperatures}`: the rounds taken, the last round's largest change in kelvin and every node's starting temperature. - `{"": °C, …}`: those thermal nodes start at those temperatures, the rest at ambient. A node is named as in its `T(…)` signal without the `T()`, for example `Q1.j` for a device junction. An unknown node, or an ambient (a fixed temperature), is an error that names it. Both solvers pre-run with their own steps and agree. A network with a heat capacity that reaches ambient only through another capacity has no steady state, and `steady` says which node. The setting is saved with the circuit (left out at ambient). ```json {"thermalStart": "steady"} {"thermalStart": {"Q1.j": 95, "hs": 80}} ``` In the app, **Thermal start** in **Properties › Simulation › Advanced** (with nothing selected) picks **Ambient** or **Steady state**. Under it, **Start temperatures per node** is the table of the third form: type a node's name, then its temperature in °C, and the row joins the table; edit a row's temperature in place, or **Remove** it. While the table holds nodes, Thermal start reads **Per node**; removing the last row, or choosing Ambient or Steady state, clears it. After a run the status line says how the network started, for example `simulated 40000 steps, 15 signals; thermal start: steady state after 2 rounds, last change 0.015 K` for `buckThermal` with a 2 ms end time. ![Thermal start set per node on buckThermal, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/thermal-start/01-thermal-start.png) 1. Thermal start: Per node, because the table holds a node. 2. Start temperatures per node. 3. The junction `tj` starts at 95 °C. ## Long runs (1 s, 1 min) A converter switching at 100 kHz needs a small step, so a run of one second or one minute takes tens or hundreds of millions of steps and records a lot of data. Four settings in **Properties › Simulation** (and in `simulation.settings`) make such runs practical. A line under the fields estimates the run from the end time, the step and these settings, for example `≈ 60 M steps · ≈ 1.8 GB for 93 signals · run ≈ 2 min to 8 min`. The run time comes from a short timed probe of the circuit (a few hundred to a few thousand steps, at most 0.5 s, once per change; not in the browser), so it is an order of magnitude, as `simulation.estimate`'s `runTime` is. When the middle of that range is over a minute, the line turns to the warning colour and suggests a larger Max time step, the averaged mode, fewer recorded signals or the fast solver: - **Max steps** (`maxSteps`, default `20meg`) is the most steps one run may take. A run that needs more stops with an error (a fixed-step run before it starts), and the message says to raise Max steps (or to use a larger `maxStep`, or a shorter `tEnd`). You can raise it up to `2g`. The estimate turns red when the run is over Max steps. A command's own `maxSteps` (for example `simulation.run {"maxSteps": 1000}`) can only lower the setting, never raise it. - **Save from** (`saveFrom`) skips the start-up in the recording. The solver still simulates from time zero, so the circuit reaches the same state, but only samples at or after Save from are kept. The first kept sample is the first step at or after that time, and the scope's time axis starts there. If a converter takes 0.9 s to settle and you want to look at the last 100 ms, set the end time to `1` and Save from to `0.9`: the recording is a tenth of the size. - **Print step** (`printStep`, in seconds, like PSIM's print step) keeps about one sample per interval instead of every step. The solver still takes every step, so the accuracy is the same; only the recording is thinner. A plain one-sample-per-interval rule would miss every pulse that falls between two samples, so the recorder also keeps the first step in each interval where a switch changed state. Every interval that holds a switching edge shows one, so no train of pulses disappears from the recording. The trade-off: between those samples the ripple is not recorded, and when several edges fall in one interval only the first is kept. For a scope view of individual switching periods, use a print step a few times shorter than the switching period, or `0`. A run recorded with Save from or Print step is not split into slices in the browser; it runs in one go. - **Record every Nth step** (`printEvery`, a whole number, under Advanced) keeps one solver step in N: steps N, 2N, 3N and so on, and always the last step. Unlike Print step it counts steps, not time, and it keeps no extra switching edge, so with a variable step the samples sit closer together where the solver took short steps. The kept samples are the full run's own samples at those steps, not averages. With Save from and Print step set too, a step is kept only when all three keep it. `0` or `1` keeps every step, and the file leaves the setting out. A run with it is not split into slices in the browser. ### Recorded signals: only the ones in use A large circuit has hundreds of signals: every node voltage, every branch current, every control signal, the nets inside each subsystem. A run records all of them at every kept step, although a scope shows a few. **Recorded signals** (Properties › Simulation › Advanced, `simulation.settings {"record": ...}`) records only the signals in use: - the signals on the scope tabs, the probes, and what the math signals read (through other math signals and probes); - the traces the quick view shows, its power pairs and its XY axis (the app passes them to `simulation.run` as `alsoRecord`); - what power and efficiency read: each DC source, battery, resistor or power load to ground (its net's voltage and its current), and the source, load, inductor, capacitor and nets of the converter the circuit is recognised as, which are also what the Test Bench measures; - what the design checks and the mode and current-flow views read: each switch's gate signal, the currents of the switches, diodes and inductors and the voltages of their nets, the CMTI rates of isolated parts, and every temperature. The solver still computes every signal, so the results are the same; only the recording is smaller. **Automatic** (the default) records every signal while that recording stays under 64 MB and the signals in use past it. Below 64 MB, recording everything costs little: on the 365-signal `hvdcMmc` example, a 0.5 s run takes 0.29 s and 56 MB with every signal, 0.23 s and 22 MB with the 30 in use. Past 64 MB the full recording takes most of the session's memory, an earlier run that large is moved to disk as soon as the next one arrives, and past 40 million values the recorder thins it to every Nth step. The signals in use keep every step much longer: a 2 s run of `hvdcMmc` keeps 100 001 samples of 30 signals in 31 MB, against 50 001 samples (every second step) of 365 signals in 89 MB. Automatic applies to runs a view shows, which is every run started in the app. A run from a script, the command line or an agent (no `alsoRecord`) records every signal under Automatic, because what it reads afterwards is not known before the run; set **Signals in use** to trim it there too. A signal the run left out is listed in the scope's signal list with a redo arrow after its name ("not recorded in this run; run again to see it"). It is never drawn: there are no samples, and nothing stands in for them. Tick it and it is in use: the next run records it. Commands that read it (`waveform.get`, `scope.measure`) say it was not recorded in this run instead of returning data, and the run reply lists every left-out signal in `unrecorded`. `simulation.estimate` gives `signals` (recorded) and `allSignals`; the estimate line under the fields says `for 30 of 365 signals (in use)`. The recorder keeps at most 40 million values (about 320 MB). When the estimate is over that, it says so in the warning colour, and the run keeps one step in N to fit. Which step of each N it keeps moves from block to block (an equidistributed sequence), so the kept samples fall at every phase of the switching period and a steady state draws the same ripple from the start of the run to its end. Keeping exactly every Nth step would sample the ripple at a few fixed phases when N and the steps of a period share a factor, and the band drawn would jump wherever that changed. A larger Print step or a later Save from keeps more detail where you need it. **Steady State** (the button under the settings, or **Simulation › Steady-State Analysis**) skips the start-up altogether: it solves for the state at the start of a period that comes back after one period (a shooting-Newton search: a few trial periods instead of the hundreds or thousands a large bulk capacitor, a resonant tank or a heatsink needs to settle), checks it by running on until the waveform repeats, then shows the last period in the scope. Save from and Print step do not apply to it; the period it shows has every step. ### Hours of a battery: `simulation.batteryRun` A real battery charges or discharges over hours. A switching run of one hour at a 1 µs step is 3.6 billion steps, which is why the `batteryCharger` example shrinks its pack to 1 mAh. `simulation.batteryRun` runs the real pack in under a second of solver time: - The converter runs on its averaged model, as `simulation.run {"model": "averaged"}` does, so the circuit must be one the averaged model knows: a buck, boost, buck-boost, SEPIC or flyback. A circuit that is already averaged (a system of averaged drives and rails with no switching converter, such as `amrRobotSystem`) runs as drawn, on its own step, with `"model": "asDrawn"`. - It runs in short bursts, each until every battery's current settles. Between the bursts the time jumps on by seconds to minutes, and only the batteries' charge and RC branches move, by the battery's own equations at the settled current. - The controller stays in the circuit. Its constant-current, constant-voltage or other logic is what each burst settles to, so a CC/CV charge keeps its knee and its falling current. - The jump adapts to how fast the current changes, and it lands exactly on `stopCurrent`, `stopSoc` and every corner of a source's waveform or a load's `profile` (a mission profile's load steps). Choose **Simulation › Long Battery Run**, type the end time and press **Run** (the tutorial [Long battery runs](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/22-long-battery-run/) walks through it), or run it from the console (View › Console, chapter 13), a script or the command line: ```sh powercraft-cli run \ --cmd file.openExample --params '{"name": "batteryChargerLongRun"}' \ --cmd simulation.batteryRun --params '{"tEnd": 5400}' ``` | Parameter | Default | What it sets | |---|---|---| | `tEnd` | (required) | The end time in seconds, up to 120 days: a whole charge or discharge | | `battery` | the only battery | The battery that stops the run and is reported | | `stopCurrent` | none | End once that battery's current falls to this magnitude after it was above it: a charger's termination current | | `stopSoc` | none | End once its state of charge reaches this value, 0 to 1 | | `maxSocStep` | 0.01 | The most one jump may move any battery's state of charge | | `tolerance` | 0.02 | The relative error of the battery current a jump may leave | | `maxJump` | `tEnd`/100 | The longest jump, in seconds | | `cycle` | none | The period of a repeating mission, in seconds (below) | | `model` | `averaged` | `asDrawn` runs a circuit that is already averaged as it is | | `solver`, `maxSteps` | as `simulation.run` | `maxSteps` counts the whole run | The reply is `simulation.run`'s summary plus `batteryRun`: the battery, `bursts` and `jumps`, `simulatedSeconds` (the time the solver stepped) and `jumpedSeconds`, `longestJump`, `unsettledBursts`, `stoppedBy` (`tEnd`, `stopCurrent`, `stopSoc` or `cancelled`), and the end time `t`, `soc`, `current` (discharge positive, in A) and `voltage`. On `batteryChargerLongRun` (four Molicel INR-21700-P45B cells, 4.5 Ah, charged from 20 %) the 5400 s run takes 39 674 steps in 155 bursts and 153 jumps, the longest 54 s; the solver steps through 0.79 s of it. The pack charges at 4.5 A for about 44 minutes, then holds 16.8 V while the current falls, and ends full at 16.80 V with 0.4 mA flowing. A switching run of the same charge would need about 2.7 billion steps. `docs/accuracy.md` ("Long battery run") checks the mode against the battery's own equations under an ideal CC/CV charger, on a 4s 5 Ah pack charged at 1 C to C/20: the change from constant current to constant voltage at 2442 s against 2449 s, the termination at 3282 s against 3264 s, and the charge at termination 95.1 % against 95.1 %, on both solvers. What it does not show: - **The switching ripple.** Every recorded signal has samples only where the solver ran, with a straight line across each jump. To see the ripple, run a switching window (below). - **Other slow states.** A supercapacitor or a heatsink moves only during the bursts, not across the jumps, and the battery's `temp` is a parameter, not a state. #### A repeating mission: `cycle` A robot doing the same task over a shift never settles from one moment to the next, but it does from one task to the next. Give `cycle`, the task's period, and every burst runs whole cycles, a battery's current is its mean over one cycle, and every jump is a whole number of cycles, so every waveform that repeats with the cycle keeps its phase. The corners inside a cycle are crossed, not landed on, so every waveform of the mission must repeat with `cycle`. Every `integrator` block (an energy meter, a charge counter) moves on across a jump by its change over a cycle, following that change's trend as the battery's current does; a `pi` controller's state stays. The last cycle always runs on the solver, so the recorded signals end where the run does. `amrRobotSystem` repeats its 40 s task (`Ttask`), so a shift is one command: ```sh powercraft-cli run \ --cmd file.openExample --params '{"name": "amrRobotSystem"}' \ --cmd simulation.batteryRun --params '{"tEnd": 7200, "cycle": 40, "model": "asDrawn", "maxSocStep": 0.05, "maxJump": 1800}' ``` Two hours, 180 tasks, run as 13 tasks on the solver (7 bursts) and 6 jumps of up to 45 tasks: 520 001 steps where 180 plain tasks take 7.2 million. The pack gives 342.9 kJ, within 0.01 % of 180 times one task's 1904.7 J, and its charge falls from 80 % to 70.5 %, 1 % more than 180 times one task's drop because the current rises as the pack's voltage falls. `Meter.runtime` then reads 13.7 h. When a circuit has a battery and its run is far too long for switching steps (a stop time of 60 s or more), or a real pack (0.5 Ah or more) has a stop time of 1 s or less, in which its charge barely moves, Problems shows an info, **battery.longRun**, that points to `simulation.batteryRun`. #### A switching window: `simulation.batteryZoom` `simulation.batteryZoom {"at": 1800, "span": 0.005}` runs the long run to `at`, then the switching circuit itself for `span` seconds (up to 10 s; a few milliseconds show the ripple), from the state the long run reached. Every capacitor voltage, inductor current, battery charge and RC branch and controller state carries over by name. It takes the same stop and accuracy parameters as `simulation.batteryRun`. The result is the window alone, on its own time axis from `at`; its reply adds `batteryRun` (the long run to the window) and `zoom` (`from`, `span`, `carried`, `steps`). `from` is earlier than `at` when `stopCurrent` or `stopSoc` ended the long run first. `simulation.continue` extends the window with more switching. In the window it is **Simulation › Battery Run Switching Window**: its form takes the start time (`at`) and the window length (`span`). On `batteryChargerLongRun`, `at` 1800 reaches a state of charge of 70 % at 4.5 A and 15.9 V, carries 6 states over and runs the 5 ms window in 2752 switching steps. ## The result as a file beside the circuit **Simulation › Save Result Beside Circuit** writes every run you start from the window to a file next to the circuit, named after it: `buck.pcraft` gives `buck.csv` in the same folder. The file holds every recorded signal and every sample of the run, one column per signal after `time`, so a spreadsheet or another tool reads the latest run without an export dialog. Each run replaces the file. Turning the switch on writes the result on screen at once, and the status line names the file. A circuit that has no file yet is told to save first; nothing is written for it. A password-protected circuit's result is never written as a plain file. The switch is a preference of the app, off by default. From a script or the CLI, `file.saveResult {"format": "csv"}` does the same once; `format` can also be `mat` (MATLAB), `raw` (LTspice) or `cff` (COMTRADE), and `path` names another file. ## Run, stop, pause, continue The **Simulation** menu has these four items with their keys. **Stop** and **Pause** are grey while no run is going. ![The Simulation menu, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/simulation-settings/01-menu.png) 1. Settings. 2. Run. 3. Stop. 4. Pause. 5. Continue. | Command | Shortcut | What it does | |---|---|---| | `simulation.run` | F5 | Starts a run from time zero | | `simulation.stop` | Shift+F5 | Stops and keeps the partial result | | `simulation.pause` | F6 | Pauses. The solver state is kept | | `simulation.continue` | F7 | Carries on from the pause. `{"duration": "5m"}` runs a further 5 ms | | `simulation.step` | | **Simulation › Next Time Step**: runs a paused or finished run on by one Max time step and keeps it there, so you can walk through a switching edge one step at a time. `{"steps": 10}` takes ten steps (up to 10,000). If the scope is zoomed to the run's end, the zoom moves on with each step, and the status bar says where the run is ("Stepped to 200.3 µs"). Grey until a run is paused or finished, and the grey item says so | | `simulation.steadyState` | | Finds the periodic steady state and shows its last period. `{"period": "10u"}` | | `simulation.tune` | | Changes a gain, a part value or a circuit variable in the paused or finished run, from its present time on. `{"component": "PI", "key": "kp", "value": 0.05}` or `{"variable": "Pref", "value": 6000}` | | `simulation.undoTune` | | Takes the last tuning back | | `simulation.bake` | | Writes the tuned values into the circuit as one undoable step | | `simulation.startFromEnd` | | **Simulation › Start From End State**: writes the last run's end state into the circuit as one undoable step, each capacitor's end voltage as its `v0`, each inductor's end current as its `i0`, each integrator block's end output as its `x0` and each PI block's end integral (its output less `kp` times its input) as its `y0`, so the next run starts where this one stopped and the saved file keeps that state. `{"components": ["C1"]}` writes only those parts. A part the run did not record is listed under `skipped` and keeps its value; parts inside subsystems and the states of other blocks (`tf`, `ztf`) are not written. The values are the recorded samples (about 7 significant digits) | **Watch it run.** The scope draws the waveforms while the run goes, growing from the left over the whole span from 0 to End time. On a circuit's first run, with nothing on the scope yet, it picks the signals it would pick after the run (the output voltage and the inductor current first) from the samples so far; when the run ends it picks again from the whole run, unless you changed the shown signals meanwhile. The run card over the plots shows the progress, and the status bar keeps **Simulating** and **Cancel**; with the scope out of sight the status bar shows the progress itself. **Tune while it runs.** Right-click a number in Properties and pick **Tune**: the parameter gets a slider in the Tune window (**View › Tune**). Let go of the slider while a run is going and the run pauses, takes the new value and runs on to its end time; capacitor voltages, inductor currents and controller states carry over, so the scope shows the response to the change alone. A dotted line in the scope marks each change. With the run finished, the change holds from its end and **Continue** (F7) runs on with it. **Undo Tuning** takes the last change back, and **Bake Tuned Values** writes the values into the circuit. Resistors, capacitors, linear inductors, sources, meter gains and the constant, gain, sum, limiter, comparator, integrator, PI, sine, step and lookup blocks, and the frequency and phase of carrier and PWM blocks, can be tuned (a frequency change keeps the carrier's position, so a frequency-controlled converter such as an LLC can be stepped in one run); a change that alters the circuit's structure (an ESR that adds a node, a model) is refused. A circuit variable can be tuned too (`{"variable": "Pref", "value": 6000}`): every value written as an expression of it is evaluated again and keeps its formula, so a power reference steps the current reference block `Pref/(1.5*Vpk)` feeds; the reply's `changed` lists the parts it reached, and a variable that reaches a value that cannot change while running (a PWM's duty step) is refused. `simulation.tunings` lists the changes, and `simulation.run {"tunes": [...]}` replays them from t = 0. The run happens in a background thread, so the window stays responsive. The status bar shows how long it has been running. `simulation.steadyState` takes `period` (if you leave it out, the engine uses the longest period among the PWM blocks, carriers, sine sources and sample-and-hold blocks), `tolerance` (default `1e-4`), `maxPeriods` (default 2000) and `method` (`auto`, the default, or `stepping`). Use it when you want the periodic steady state and do not care about the start-up. With `auto` the search first solves for the steady state with Newton's method on the state at the period boundary: the capacitor voltages, inductor currents, integrator and PI integrals and free temperatures (T. J. Aprille and T. N. Trick, "Steady-state analysis of nonlinear circuits with periodic inputs", Proc. IEEE 60(1), 1972). Each of its trial periods is simulated by the chosen solver, and every one counts against `maxPeriods`. When it does not converge it hands its best state to `stepping`, which runs period after period until the state at two boundaries in a row changes by less than `tolerance`; either way the answer passes that same test. The reply says which one found it (`method`: `shooting` or `stepping`), the `residual` (the relative change of the state over the last period), `periods` (all periods simulated) and `newtonIterations`. On the LLC half-bridge example it takes 10 to 11 periods where stepping takes about 160; on a boost PFC with 4.7 mF it takes 12 line periods where stepping takes about 100. After a shooting search the `losses` totals in the reply do not add up every period it simulated; read the losses from the last period's waveforms. In the app, **Steady-State Analysis** in the arrow beside Run on the toolbar (or **Simulation › Steady-State Analysis**) runs the same search and shows the last period on the scope. ![The LLC half-bridge after Steady State, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/steady-state/01-llc.png) 1. `v(out)`: a mean of 48.25 V over the period shown. 2. The window the scope shows: one 10 µs period, from 93.8 µs to 103.8 µs. ### Example: the LLC half-bridge ```sh powercraft-cli run --cmd file.openExample --params '{"name":"llcHalfBridge"}' \ --cmd simulation.steadyState --params '{}' \ --cmd scope.measure --params '{"signals":["v(out)"]}' ``` The reply says `"method": "shooting"`, `"newtonIterations": 3`, `"periods": 10` and a `residual` of 2.4e-5, and the scope holds the last 10 µs period: `v(out)` has a mean of 48.25 V and a ripple of 0.11 V peak to peak. The same call with `{"method": "stepping"}` takes 156 periods to pass the same test. ### Limits of the steady-state search - The Newton search solves for at most 64 states (capacitor voltages, inductor currents, integrator and PI integrals, free temperatures). A larger circuit, or a `maxPeriods` too small for one Jacobian (one period per state) and a few steps, goes straight to stepping, and the reply says `newtonIterations` 0. - The search takes at most 3 Jacobians and 16 Newton steps. When those do not converge, it hands its best state to stepping, which may still need many periods. - The other state of the control blocks (carrier phases, held samples, edges) is not solved for: each period starts from where the last one ended. - After a shooting search the `losses` in the reply do not add up the periods it simulated; read the losses from the last period's waveforms. ## Limits to know - The engine keeps at most 40 million recorded values per run (about 320 MB). A longer run is thinned out automatically, and a warning says so. Print step and Save from (above) keep the recording small instead. - A run takes at most Max steps (`maxSteps`, 20 million by default, up to 2 000 million). - In the browser version each run is limited to 1,000,000 steps. Raising Max steps does not lift this limit: increase Max step, shorten End time or use the desktop app. The run goes a few milliseconds at a time, so the page keeps responding, the progress bar moves and Cancel stops it. The samples computed so far are kept. A run with a very large recording is not cut into pieces and runs in one go. Editing the circuit while it runs ends the run. - A very small `maxStep` over a long `tEnd` is slow: 100 ms at 10 ns is ten million steps, and ten times more steps takes about ten times longer. `cargo xtask bench` measures this on your machine. ## Reading a failed run If the run stops with an error, the message names the node or element and suggests a step or a circuit change. Chapter 8 lists the common ones. --- # 5. The scope URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/05-scope/ The scope is the **Scope** tab of the bottom dock, next to **Problems** and **Design**. It shows the waveforms of the last run and measures them. - The tab shown changes only when you change it. A run, a check or an edit never switches tabs. When something is wrong, the **Problems** tab shows a count in red (errors) or amber (warnings), and the status line says where to look. Click that line to open Problems. - The **×** beside a tab closes it. **View > Scope**, **View > Problems** and **View > Design** open them again. With every tab closed the dock is hidden. **Run** in the menu bar and **F5** still work. - Drag the dock's top edge to resize it. The height stays the same whichever tab you show. - **Maximize** at the right of the tab bar (or **View > Maximize Bottom Panel**, **Cmd+Shift+M**, or a double-click on a tab) lets the dock fill the window. **Restore** gives the canvas its space back at the height you had. - **View > Panel Position** puts the dock at the **Bottom**, **Right** or **Left** of the window, as in VS Code; right-click a tab or the tab bar for the same choice. You can also drag the tab bar, or a tab, to an edge of the window: the place the dock will take shows in the accent colour, and letting go moves it there. At the right or left the dock is a column the height of the window, with its tabs on top; drag its inner edge to resize it. The scope then lists the signals above the plots and the measurements below them, and the terminal fits its columns to the width. The position and the width are kept for the next start. Each circuit tab keeps its own scope view: its signals, cursors, XY mode and axes come back when you return to it. ## Choosing signals Signals are named after what they measure. Hover over a signal in the list to see what it is. | Name | Meaning | |---|---| | `v(out)` | Voltage of net `out` against ground | | `i(L1)` | Current through element `L1` | | `E(S1)` | Energy lost in switch or diode `S1` since the start of the run, in joules | | `T(node)` | Temperature of a thermal node, in °C (circuits with a thermal model) | | `w(shaft)`, `wm(M1)`, `Te(M1)`, `theta(M1)` | Shaft speed, rotor speed, torque and rotor angle (motor drives) | | `duty`, `err` | A control signal: the output of a control block, named after it | The **Signals** list shows every signal the last run recorded. Tick a signal to draw it. The box above the list filters it: type part of a name (`L1`) or of what the signal is (`energy`, `ground`). The line under the box says how many signals it lets through. From a terminal, `waveform.list` prints the same list. ![The scope after a run, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/scope/01-scope.png) 1. A shown signal. 2. The Signals list. 3. The measurements. 4. Keep as reference. The list is in groups by kind: **Voltages**, **Currents**, **Control signals** (gate signals, duties, controller outputs, flags), **Losses & energy** (`E(…)` and power meters), **Thermal** (`T(…)`), **Mechanical** (shaft and rotor), **Math**, **References** (runs kept with **Keep as reference**) and **Imported** (a measurement from **File > Import > Measurement**). The kind comes from what the signal measures: a voltage or current meter's output goes with the voltages or currents whatever its net is called, and a PWM block's duty input with the control signals. Each header shows the group's count; a group with nothing in it is left out. - Click a header to close or open its group. Each circuit remembers which groups you closed. A closed group still lists the signals it has on the scope, so a shown trace never disappears from the list. - Right-click a header for **Show all** or **Hide all**: every signal of the group goes on the scope or off it. - While the filter box has text, every group with a match opens; clear the box and the groups close again as you left them. Signals inside parts are hidden from the list: the node `V1:x1` and the element `V1.rs` that a source's series resistance adds, and the nets inside a subsystem. Tick **Show internal signals** at the end of the list to see them. They are listed in a closed sub-group per part (`X1`, `PI_Id`) inside their group, so a large controller does not flood the list. ### The first traces after a run When nothing is ticked, a run picks up to four signals for you, in this order: an output voltage (a `v(…)` whose net name contains `out`), inductor currents (`i(L…)`), other voltages, other currents, then the rest. It skips: - signals inside parts, - **flat** signals, such as a DC source, - **switching** signals, which would draw as a solid block: a switch node, a gate or PWM signal, the pulsed current of a switch or diode. A signal counts as switching when, at least 10 times, it jumps from one sample to the next by more than a quarter of its whole range and by more than four times its typical step. If nothing qualifies, the plot stays empty and says how to pick a signal: press **Shift+P** and click a wire, or tick a signal. The signals you tick stay ticked from run to run. If you rename a net, the trace follows it to the new name, and the status line says so. A trace whose signal is no longer recorded is taken off, and the status line names it. Scope › **Add Signal** brings the Scope tab forward and puts the cursor in the filter box: type, then tick. ## Probing on the schematic After a run, press **Shift+P** (or choose **Simulation > Probe**, or right-click empty canvas > **Probe**) and click on the schematic, as with the probe of LTspice or PSIM: - a wire or a pin: its net's voltage `v(net)` (on a control signal, the signal itself), - a part: its current `i(part)` (for a meter or sensor, its output signal). The trace goes on the **Quick** tab and the scope comes forward. Click the same thing again to take it off. Ground is 0 V and has no trace. **Esc** ends probing. ### Cross-probing The schematic and the scope point at each other, as in LTspice or PLECS: - **Schematic to scope.** Select a part (or a wire or net label) and every shown trace that reads it is drawn bold, with its legend entry in bold: `i(L1)` for L1, `v(out)` for a wire of net `out`, and a math signal for any part or net it is computed from. - **Scope to schematic.** The **⌖** button of a row in the signal list selects the part or net that signal reads and zooms the canvas to it. A click on a trace's legend entry above the plot selects it too (without zooming), as well as showing the Measurements table. A part inside a subsystem is selected by its instance at the top level. Agents get the same mapping from `waveform.source {"signal":"v(out)"}`, which answers with the net, part or pin (and a math signal's inputs). **XY Mode** (**Scope > XY Mode**) plots every shown signal against one of them instead of against time. Pick that signal in the **X:** list beside the button. XY needs at least two shown signals; with one, the plot says so. XY mode is always off when Voltecx starts. Pick **XY Mode** again to go back to time. ## Axes and colours Every plot has its unit on the y axis (**V**, **A**, **%**, or none) and four to eight tick labels on round 1-2-5 steps with SI prefixes (`500mV`, `1.5ms`), however tall the plot is, with unlabelled minor gridlines between them; a short dock still keeps its labels readable apart. The labels carry as many digits as their step needs, so no two read the same: a 105 V output with a volt of ripple reads `105V 105.5V 106V`, and a deep zoom at 89.4 ms reads `89.401ms 89.402ms`. In the **Quick** tab, voltages, currents, duty cycles and the other signals go on separate plots stacked on one time axis, so a 100 V trace and a 1 A trace do not flatten each other. A signal that feeds a PWM block's duty input is a ratio, so its axis, legend and Measurements values read in percent (`24%`, not `240m`); exports and scripts keep the ratio itself. A plot that holds traces in two units (after you move one with **Plot 1**, **Plot 2**, …, or in a named scope) labels its left axis with the first unit and adds a right axis with the second, on the same scale: a gridline at 10 reads 10 V on the left and 10 A on the right. Each legend value carries its own trace's unit. The **Plot 1**, **Plot 2**, … button beside a shown signal moves it to the next plot (its own screen), as in a named scope. In a named scope with stacked plots the y axes are named the same way (**Plot 2 [A]**). Each signal keeps its colour everywhere: in the list, the plot, the legend and the tables. The first eight colours differ; a ninth trace repeats the first colour, dashed. Right-click a trace's legend entry for its **Trace Style**: a **Colour** from the eight trace colours (**Automatic** gives back the colour of its place in the list), a **Line Width** (**Thin**, **Normal** or **Thick**), **Show Samples** (a dot on each sample once you zoom in far enough to tell them apart) and a **Display Name** for the legend. The signal keeps its own name in the list, the measurements, math and scripts. **Reset Style** puts the trace back as it was. The style is view state, kept by signal name: `ui.set` with `{"traceStyles": {"v(out)": {"color": 3, "width": "thick", "markers": true, "name": "Output"}}}` sets it (colour 0 is the first trace colour). Over time the x axis fits the data exactly, in the dock and in a plot's own window: it ends where the run ends, with no margin past it. ### Reading a value and a dense trace **Hover readout.** Move the pointer over a plot: a thin crosshair snaps to the nearest sample, a dot marks each trace there, and the header row reads the time (`t 2.003 ms`) and each trace's value beside its name in the legend. Every plot over time shows the same moment. Click a legend entry to show the Measurements table with its Max, Min, Pk-Pk and Avg. **Junction limit.** A junction temperature trace, `T(.j)`, of a part with a known maximum junction temperature (its `tjMax` parameter, else its device's data-sheet rating) gets a dashed line at that limit in the trace's colour, labelled **Tj max 150 °C**. The times the trace is above the limit are shaded red. The hover readout adds the margin to the limit (`10 K below Tj max`, or `10 K above Tj max` once it is over). It works the same in the quick view and in a saved scope. **Envelopes.** A switching trace over a long run has more cycles than the plot has pixels, so it would fill a solid block. The scope draws it as its envelope instead: a light fill between two thin lines, the highest and the lowest value of each pixel column, with the cycle average (the mean over the column) as the bold line on top, and says **envelope: zoom in to see each cycle** in the plot's header. The legend and the hover readout read the cycle average. Its **Zoom to 5 Cycles** button (also **Scope › Zoom to 5 Cycles**) narrows the time window, about its middle, to five periods of the shown trace: the period is measured from the trace's repeating swing, which for a switching ripple is the switching period. A trace with no repeating swing in the visible window (an RC charge, a DC level) says so instead. **The steady state after a run, and the overview strip.** When a shown trace has more cycles than the plot has pixels, the plots open after the run on its **last 5 switching periods**, so the ripple reads at once, and a thin **overview strip** above them shows the whole run with a shaded box where the plots are. Drag the box to move the view, drag its edges to make it wider or narrower, or click the strip to jump there. The strip is hidden when the whole run already reads as lines. The first plot's header holds **Whole run** and **Last cycles** (also **Scope › Whole Run** and **Scope › Last Cycles**): the choice is kept, and the next run opens the same way. A zoom you make while the run is still going is kept when it ends. A time window you zoomed or panned to is also kept when you run the same circuit again, and **⌘[** still steps back through the views before it; a view you never moved follows the new run. ![After a 4 ms buck run: the overview strip of the whole run, the last 5 periods below it](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/scope/05-overview.png) **Stepping through the cycles.** With the pointer over the scope and the cursors off, **←** and **→** move the view one window width back or on, and **Shift+←** and **Shift+→** one switching period, so you can page through the run cycle by cycle. With the cursors on, **←** and **→** step the active cursor instead (see [Cursors](#cursors)). ## Tabs The scope has a **Quick** tab and one tab for each scope saved in the circuit. - **Quick** shows whatever you tick. It is view state: it is not saved in the circuit. - The **+** button (`scope.new`) makes a named scope. Its signals are saved in the circuit file, and its creation and edits are undoable like any other edit. Use one tab per question: *input stage*, *loop*, *thermal*. - Each scope can use up to eight **y axes**. The axis button beside a signal moves it to the next axis. Signals on the same axis share a scale, so a 48 V trace and a 5 A trace do not squash each other. - `scope.addSignal`, `scope.removeSignal`, `scope.delete` and `scope.list` do the same from the command line. ## The toolbar The row above the plots, after the scope tabs, holds the icon buttons used most, in three groups: zoom, cursors and measurements, and export. Rest the pointer on a button for about a third of a second to see its name, its key and one line on what it does; the main toolbar and the activity bar on the left show the same kind of tooltip. At its end are **Keep as reference**, **References**, **Measurements** and the window button, also icons. Nothing hides behind an overflow menu: **Scope > Zoom Axis > Time Only** and **Value Only**, **XY Mode**, **Logic Lanes**, **Add Plot**, **Remove Plot**, the plot windows and **Save Image** are in the **Scope** menu. Each plot's own header has a small FFT icon, **Spectrum**, that shows that plot as the spectrum of the visible window and back. The keys work while the pointer is over the scope; they are listed in **Help > Keyboard Shortcuts** and can be changed there. Every button is also in the **Scope** menu and Quick Open. ![The scope toolbar, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/scope/02-toolbar.png) 1. Zoom to Fit. 2. Cursors. 3. FFT of the visible window. 4. Copy Image. 5. Open in Separate Window. | Button | Key | What it does | |---|---|---| | Zoom In / Zoom Out | I / O (also Cmd+Plus / Cmd+Minus, as on the canvas) | Halve or double the visible range about its middle | | Zoom to Fit | F (also Cmd+0 and Home, as on the canvas) | Show the whole run and every shown signal | | Autoscale Y | Shift+A | Fit each plot's y axis to its traces, keeping the time window | | Scope › Y Axis Includes Zero | | Each plot over time fits its y axis to its traces' own range, so a ripple on 47.55 V shows as a ripple; with this ticked every plot keeps 0 in its range too, so a 19 V to 20 V trace reads as about 20 V | | Pan | | A drag on the plot moves the view | | Zoom Box | Z | A drag on the plot draws a box and zooms to it, with a crosshair pointer (the default, as in PLECS and LTspice); click again for Pan | | Time Only / Value Only (**Scope > Zoom Axis**) | Shift+X / Shift+Y | Zoom and pan change only that axis; pick again to free both | | Cursors | C | Two measurement cursors and their readout (see below) | | XY Mode (Scope menu) | | Plot the signals against one of them instead of against time | | Logic Lanes (Scope menu) | | Draw 0/1 and state signals as logic-analyzer lanes under the plots (see below) | | Measurements to show | | Pick the columns of the Measurements table | | FFT of the visible window | | Pick a shown signal: its spectrum over the visible window (`analysis.fft`) | | Add Plot / Remove Plot (Scope menu) | | Move a signal of a crowded plot onto a plot of its own, or merge the lowest plot into the one above | | Copy Image | | Put a picture of the plots, as shown, on the clipboard | | Save Image (in Export data, and the Scope menu) | | Save the plots as PNG (what you see) or SVG (vector, from `scope.export`) | | Export data | | Export CSV of the visible window or of the whole run, copy the visible window as CSV, or open the `scope.export` form | | Open in Separate Window / Dock Back | | Move the scope into a window of its own, or back into the dock (see below) | Other ways to look around: | Action | How | |---|---| | Zoom | Pinch, or Ctrl + mouse wheel, over the plot | | Pan | Hold Space and drag, or drag with the middle mouse button (or drag the plot with the Pan tool) | | Box zoom with the Pan tool | Hold Cmd (Ctrl on Windows and Linux) and drag | | Reset the view | Double-click the plot | | Right-click menu | Right-click a plot for Zoom to Fit, Autoscale Y, Cursors, Copy Image, Save Image and Export CSV (Visible Window), each with its key, then Ask Assistant | In a named scope, **Add Plot** and **Remove Plot** edit the scope (`scope.addSignal`, `scope.removePlot`): one undo step per click, saved with the circuit. In the **Quick** tab they only move the signals' y axes. Right-click a plot for its own **Move Plot Up**, **Move Plot Down** and **Remove This Plot** (its signals join the plot above it, or the one below for the top plot). In a named scope each is one undo step (`scope.movePlot`, `scope.removePlot`); the plot's amplitude cursors, spectrum and own window go with it. Its **Y Scale** submenu draws that plot on **Linear**, **Log** (the size of each value on decades: 1 mA, 10 mA…) or **Decibels (dB)** (20·log10 of the size, in dBV for a voltage and dBA for a current). A decaying current then reads as a straight line, and a small ripple next to a large step stays visible. Values more than 120 dB under the plot's peak (a zero crossing, a zero at the start) sit at the bottom of the axis. Only the drawing changes: the legend, the cursors and the measurements still read the signal's own values, and **Axis ranges** still takes Y min and Y max in volts or amperes (above zero on Log or dB). A plot on Log or dB has no amplitude cursors. The scale goes with the plot when it moves. A plot that holds traces in two units (volts and amperes, say) has a **Second Y Scale** entry under **Y Scale**. On, the traces in the second unit read on the right axis at a scale of their own: they are drawn divided by a round ratio (1, 2, 2.5 or 5 times a power of ten), picked so their peak fills about as much of the plot as the first unit's peak, and a gridline at 5 V reads 5 mA on the right. A 10 mA current under a 10 V step is then no longer a flat line at zero. The zeros of both axes stay level. Only the drawing changes: the legend, the cursors and the measurements read each signal's own values, and **Axis ranges** and the amplitude cursors keep the left axis's unit. A junction limit line shows on the left axis only. The entry is greyed out on a plot of one unit and on Log or dB, and the setting goes with the plot when it moves. Its **Data Points** opens the recorded samples of that plot's traces as a table: a row per time step, a column per trace headed in its colour. It lists the samples between the two time cursors, or those in the visible window when the cursors are off, and follows them as they move or as you zoom. The rows are the recorded samples themselves, never the thinned points the plot draws, and they use the cursor readout's **Number Format**. **Copy** puts the rows on the clipboard as tab-separated text at full precision, ready to paste in a spreadsheet (up to 100 000 rows; **Export CSV** writes any number). **Scope > Plot Grid** puts the docked plots in **One Column** (the stack, the default), **Two Columns** or **Three Columns**. The plots fill each row left to right in the stack's order, so the rows follow from the number of plots; a last row with fewer plots shares the whole width among them. As in the stack, the plots share one time window and only the bottom row draws the time axis (the logic lanes do when shown, full width under the grid). A dock too narrow for the columns (each cell needs about 400 points) uses fewer. Below the columns, **Fit All Rows** (the default) shares the dock's height among every row; **Two Rows in View**, **Three Rows in View** or **Four Rows in View** gives each row that share of the height instead, so with more rows the plots stay readable and the rest scroll (wheel or scroll bar). Fewer rows than chosen fill the dock. View Presets keep the rows with the columns. **Scope > View Presets** keeps how the scope looks under a name and brings it back with one click. A preset keeps the time window, each plot's **Y Scale**, **Y Axis Includes Zero**, the **Plot Grid**, the **Trace Style**s and the cursors (where they stand, the spacing lock, **Values at Cursors**, the readout's number format, whether they float and whether the amplitude cursors follow a trace). Type a name and press **Save View** (a name already in the list is replaced); click a preset to apply it, or its bin to delete it. **Reset Scope View** puts all of these back to how a new scope starts and fits the whole run, and keeps the presets. Presets belong to you, not to the circuit: they stay between sessions and apply to any result, up to 16 of them. `ui.set {"scopeViewPresets": [...]}` sets them. **Scope > Export > Print Scope** opens the page that prints, with its preview: the title (the circuit's name to start with; type another), a line with the scope's name and the time window, then the plots as the scope stacks them, black on white with the traces in colour. Pick **A4** or **Letter**, **Landscape** or **Portrait**, and **Visible Window** (what the scope shows) or **Whole Run**; the preview changes at once and is exactly what prints. **Print** writes the page as a PDF and opens the system's print dialog on it; in the browser it downloads the PDF. Scripts run `scope.print` with a `path`. The plots are thinned to the width of the panel, so a long run draws quickly; the thinning keeps each signal's minimum and maximum, so spikes stay. Zoomed in between two samples, a trace is still drawn across the whole window from the samples on either side. The measurements below always use the full-resolution data. ## A window of its own PSIM shows results in SIMVIEW, a window beside the schematic. Voltecx can do the same: - **Open in Separate Window**, the last button of the scope's toolbar (or **View > Detach Scope**), moves the whole scope into its own window: the scope tabs, the toolbar, the signal list, the plots and the measurements. Its title is **Scope — *circuit name***, and it follows the circuit tab you pick in the main window. - The dock's **Scope** tab then takes no room (see "The dock while the scope is away" below). - **Dock Back** (the same toolbar button in the scope window, or the dock's Scope chip), choosing **View > Detach Scope** again, or closing the scope window puts the scope back in the dock and shows it. The signals, zoom, cursors and XY mode stay as they were. - While the scope window has focus, the scope's keys (the table above), **F5** (Run) and the full-screen key work in it. - The first time, the window opens at 1200 × 720. After that it opens where you left it, at the size you left it, also on a second monitor. It cannot be made smaller than 480 × 320. It uses the colour theme of the main window. - Quitting Voltecx closes the scope window too. If it was open, it opens again at the next start. - **Edit > Preferences > After each run > Whole scope in one window** makes every run you start from the menu, the toolbar or **F5** open the scope window, or bring it to the front, as PSIM does with SIMVIEW. A run started by an agent or a script leaves the windows alone. (Settings from before this choice existed keep their meaning: the old "Show results in a separate window after each run" on is this choice.) ## Each plot in a window of its own As on Windows, where PSIM-style tools give each plot its own window, Voltecx can put every plot of the scope (each y-axis group) in a window of its own: - **Edit > Preferences > After each run** has three choices: **Keep in the dock** (the scope opens in the panel under the schematic), **Whole scope in one window** (the default: the scope window above, opened or brought to the front by each run, as PSIM opens SIMVIEW) and **Each plot in its own window**. With the last, every run you start from the menu, the toolbar or **F5** opens each plot of the scope tab shown in its own window when the run ends. A run started by an agent, a script or the control channel leaves the windows alone; automation asks for them with **Scope > Plot Windows > Detach All Plots**. - Each window is titled with its signals and the circuit (**v(out), i(L1) — buck**; after three signals it counts the rest, **+2**). - **Tiling.** New windows are laid out in a grid over the whole work area of the screen the main window is on (without the menu bar and the Dock on a Mac), covering the main window: one plot takes the whole area, two sit side by side, three and four make 2 × 2, five and six make 3 × 2, seven and eight 3 × 3, filled row by row in plot order. A window is never smaller than 320 × 180; if a grid cell is smaller, the window keeps that size and stays on the screen. - A second run reuses the windows that are open (there is never more than one window per plot) and leaves them where you moved them; they come to the front. Only windows that open take their tile. - **Scope > Plot Windows > Tile Plot Windows** lays the open plot windows out in the grid again (all plots, if none is open). **Scope > Plot Windows > Detach All Plots** opens every plot in a window. **Scope > Plot Windows > Dock All Plots** puts them all back in the scope. The three are also in Quick Open (**Cmd+K**) and in the **Plot windows** list at the end of the scope toolbar. **Detach**, in the **More** menu at the right of each docked plot's header, and the **Dock** button of a plot window still move one plot at a time. - Each window's place and size are kept (`plotWindows` in the session) and restored at the next start. A place that no screen shows any more (a monitor that was unplugged) opens in the middle of the main window's screen instead. - On a Mac the work area comes from the system's screen list. Elsewhere Voltecx uses the size of the main window's monitor, and without that the main window itself. ## The dock while the scope is away While the scope is in its own window, or every plot is in a window of its own, the scope takes no room in the dock: - If no other dock tab (Problems, Design, Console) is open, the whole dock folds away and the canvas gets the space back. - If other tabs are open, the **Scope** tab becomes a small **SCOPE** chip with the pop-out mark. Click it to bring the scope's window (or the plot windows) to the front; right-click it for **Dock Back**. While the Scope is the tab you picked, the dock shows one line, **Results opened in the scope window · Bring to front** (or **in the plot windows**), instead of another tab, so a run never leaves you on an empty Problems tab; click another tab to see it. A run with **Whole scope in one window** brings the window forward and picks the Scope tab. - Docking back (Dock Back, Dock All Plots, or closing the window) shows the scope in the dock again, at the height the dock had. ## Cursors ![Cursors on, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/scope/03-cursors.png) 1. The button. 2. The readout at each cursor. 3. The measurements between the cursors. Turn on **Cursors**. Two vertical lines appear: cursor 1 solid and cursor 2 dashed, each numbered at the top of the plot (the `t1` and `t2` of the readout). Drag each to a point in time. The **Cursors** readout shows both times, the time between them (`Δt`) and its inverse (`1/Δt`, handy for a period). The summary cards and the signal table then measure **between the cursors**; a click on a signal's name (or **Values at the window's ends** on its right-click menu) shows its value at each cursor (`@t1`, `@t2`), their difference (`Δ`), and the minimum and maximum between them. Put the cursors one switching period apart (`1/Δt` reads the switching frequency) to read the ripple of one period; a `Δ` near 0 then means the circuit is in steady state. A click on a plot moves the nearer cursor to that time; ⌘/Ctrl-click and clicks in **Zoom Box** mode are left to zooming. With the pointer over the scope and the cursors on, the **←** and **→** keys step the active cursor (the one you last dragged or clicked) to the previous or next sample of the run, for an exact reading at a switching edge; with the cursors off they move the view a window width. Elsewhere the arrow keys nudge the selected parts as before. **Scope › Move Cursor › Cursor to Maximum** and **Cursor to Minimum** move the active cursor to the largest or smallest sample, in the visible window, of the trace read first (the first in the readout; **↑** and **↓** over the scope pick another). Use them to read a peak current, an overshoot or the bottom of a ripple without hunting for it. **Cursor to Next Peak** and **Cursor to Previous Peak** step the active cursor to the nearest local maximum after or before it, one switching period's ripple peak at a time; a flat top counts once, at its first sample. The reply names the trace, the time and the value. **Scope › Move Cursor › Lock Cursor Spacing** keeps Δt: with it on, moving either cursor (a drag, **←** **→**, **Home**, **End** or a jump above) moves the other by the same amount, so one switching period or one line cycle slides along the run. At the run's ends both cursors stop together rather than squeeze the spacing. Choose it again to move the cursors one at a time. With the cursors on, each plot puts a dot where a cursor crosses a trace and the trace's value beside it, in the trace's colour: cursor 1's values left of its line and cursor 2's right of it, spread so none covers another. The plot with the time axis also shows each cursor's time at its foot. A plot too short for all its labels keeps the dots and leaves the values to the cursors readout. **Scope › Values at Cursors** turns the dots and labels off and on (view state `cursorValues`). **Scope › Amplitude Cursors** (Shift+V over the scope) adds two horizontal cursors to each plot over time, a third and two thirds of the way up. Drag one to a level, or Shift-click a plot to move its nearer one there. The **Amplitude Cursors** readout shows each plot's two levels (`y1`, `y2`) and their difference (`Δy`) in the unit of the plot's left axis: the peak-to-peak ripple, an overshoot, a step. The levels are view state: `ui.set` with `{"levelCursors": {"0": [4.9, 5.1]}}` sets the first plot's pair, and `null` for a plot takes its pair off. **Scope › Amplitude Cursors Follow Trace** ties each plot's two amplitude cursors to a trace: each stands where its time cursor crosses the trace (turning the time cursors on if they were off), so every cursor reads as a crosshair on the curve and moves with it as you drag or step the time cursor. The trace followed is the one `[` and `]` step to (the edge signal in the readout) where the plot shows it, else the plot's first trace; the readout's **Follows** row names it, and `y1`, `y2` and `Δy` read its values at the two times. While it is on, the amplitude cursors are not dragged by hand; turning it off leaves them where they stood. It is view state (`levelFollow`). Right-click the **CURSORS** or **AMPLITUDE CURSORS** heading to set how both readouts write their numbers: **SI Prefixes** (`12.35 mV`, the default) or **Scientific** (`1.235e−2 V`), and **Significant Digits** from 3 to 7 (4 by default). Scientific notation keeps every row in one form, which helps when you copy values into a spreadsheet or compare a microamp leak with an amp load. The format is view state: `ui.set` with `{"cursorFormat": {"notation": "scientific", "digits": 6}}` sets it. The legend and the measurements keep their own format. The same menu has **Float Over Plots**: both readouts move out of the results panel into a card over the plots, so the numbers stay beside the curves while you drag the cursors, also with the panel folded away or in Results mode. Drag the card anywhere inside the plots; its **Dock in Results Panel** button (or the same entry again) puts the readouts back. It is view state: `ui.set` with `{"cursorFloat": true}`. The same reading is available as a command: `scope.cursors` with `{"t1": "3m", "t2": "3.01m"}`. ## Logic lanes Gate signals, flags and the state of a state machine read badly as analog traces. **Logic Lanes** (**Scope > Logic Lanes**) draws them as a logic analyzer does, in one strip under the plots, on the same time axis: - A signal whose samples are only 0 and 1 is a thin **logic lane** (a voltage or a current only when it has both). - A signal with whole-number values on 2 to 16 levels (a state index, an enum, a counter) is a **bus lane**: an outline that crosses at each change, with the value printed in each segment wide enough for it. For a `stateMachine` block the state names are printed instead of the numbers. - Every other signal stays an analog trace in its plot. Right-click a signal in the list and pick **Lane** to override the detection: **Detected**, **Analog trace**, **Logic lane** or **Bus lane**. - **Cursor 1 snaps to its edges** and **Cursor 2 snaps to its edges** (same menu) put a cursor on the nearest edge of that signal, and keep it on an edge while you drag. With the cursors on two lanes, `dt` is the time from edge to edge: a PWM period, a dead time, the delay from a flag to a gate. A logic lane's edge is where it crosses the middle of its range; a bus changes halfway between two samples. - **Trigger on its rising edge**, **Trigger on its falling edge** and, for a bus, **Trigger on the value** set the view window on the first such edge, as a scope's trigger does. The window keeps the width shown, with a tenth of it before the trigger, and is set again after each run. A dashed line marks the trigger. **Clear the trigger** removes it. It is all view state, so the assistant or the CLI (`powercraft-cli app set`) switches it with `scopeLogic`: ```json {"scopeLogic": { "on": true, "kinds": {"duty": "analog", "fault": "logic"}, "names": {"state": ["Idle", "Precharge", "Run"]}, "cursorLanes": ["gate_hi", "gate_lo"], "cursorEdge": "rising", "trigger": {"signal": "takeover", "on": "rising", "after": 0, "span": 4e-4, "pre": 0.1} }} ``` `kinds` overrides the detection per signal (`analog`, `logic`, `bus`), `names` gives a bus its value names, `cursorEdge` is `any`, `rising` or `falling`, and a trigger waits for `rising`, `falling` or `value` (with `value`) at or after `after` seconds, `span` seconds wide (the width shown when left out), `pre` the share before the trigger. ## Markers and edge search A saved scope keeps any number of **named markers** (A, B, C… or a label you choose, up to 64). Under the cursor readout, the **Markers** section has **Add marker at cursor 1**, and lists the markers in time order with the time from the one before (`Δ`); **✕** removes one. Each plot and the lane plot draws them as dotted lines with their label at the top. They are saved in the circuit with the scope, and adding or removing one is undoable; it does not mark the result out of date. **Edges of** picks a trace, and **◀ Previous edge** / **Next edge ▶** move cursor 1 to its previous or next edge. Over a plot, the keys **[** and **]** do the same, so you can walk a gate signal edge by edge. An edge is a crossing of halfway between the trace's minimum and maximum: a logic change, or for an analog trace (an inductor current) the crossing of that middle level. To cross another level, use the command with `threshold`. A bus lane's right-click menu has **Value format**: **Automatic** (names where it has them, else numbers), **Hexadecimal**, **Binary**, **Unsigned**, **Signed** or **Names**. The format is saved with the scope. The same as commands: | Command | Params | What it does | |---|---|---| | `scope.addMarker` | `{"scope": "S1", "t": "1.2m", "label": "A"}` | Adds a marker (the label is optional). | | `scope.removeMarker` | `{"scope": "S1", "label": "A"}` | Removes it. | | `scope.markers` | `{"scope": "S1"}` | The markers in time order and the `dt` between every pair. | | `scope.findEdge` | `{"signal": "g", "from": 0, "direction": "next", "edge": "rising", "threshold": 0.5}` | The time of the next (or `prev`) `rising`, `falling` or `any` crossing of `threshold` after `from`, interpolated between samples; `found: false` and `t: null` when there is none. | | `scope.setFormat` | `{"scope": "S1", "signal": "state", "format": "hex", "bits": 8}` | A bus lane's format: `hex`, `binary`, `unsigned`, `signed`, `enum` or `auto`. `bits` pads hex and binary and says where the sign bit of a signed value is. | ## Notes on the plots Right-click a plot of a saved scope and choose **Add Note Here** to pin a note to the trace nearest the pointer, at the time you clicked. The note starts as that trace's value and time there (`2.5 V @ 1 ms`), selected, so you can keep it as a marked data point or type over it (up to 80 characters); **Enter** or **Add** places it. The plot draws a dot on the curve with the text in a box beside it, joined by a short line in the trace's colour; the boxes keep inside the plot and off each other. A note stays on its trace and time when you zoom, re-run or rename the part. The plot's **Notes** submenu lists the notes on its traces, each with **Edit Note** and **Remove Note**. Notes are saved in the circuit with the scope (up to 32), and each change is undoable; it does not mark the result out of date. In the quick view **Add Note Here** is greyed out: make a scope first with **Scope › New Scope**. | Command | Params | What it does | |---|---|---| | `scope.addNote` | `{"scope": "S1", "signal": "v(out)", "t": "1.2m", "text": "overshoot"}` | Pins a note to a signal the scope shows. | | `scope.notes` | `{"scope": "S1"}` | The notes in the order placed, each with its `index`. | | `scope.editNote` | `{"scope": "S1", "index": 0, "text": "peak"}` | Changes a note's text. | | `scope.removeNote` | `{"scope": "S1", "index": 0}` | Removes it. | ## Animating the circuit After a run, **View › Overlays › Animate** (F8 in the Classic keymap, Shift+F8 in the Default keymap, or the flow button next to Run and Stop) plays the result back on the schematic, as Falstad's applet and iCircuit do: - **Current flow.** Dots move along every wire with the current: the direction is the sign of the current, the speed grows with its size on a logarithmic scale (so a 10 mA gate loop still moves next to a 20 A power loop), and the spacing stays the same. A wire with next to no current has no dots. - **Node voltages.** With **Voltage colors** on, each power wire takes the colour of its node voltage: blue below 0 V, grey at 0 V, red above, scaled to the run's largest voltage. The legend in the timeline bar shows the run's lowest and highest voltage. - **Switch states.** An ideal switch, MOSFET or IGBT whose gate signal is above 0.5 (the solver's own threshold) is drawn on: in the accent colour on a shaded box, and an ideal switch with its contact closed. A diode or thyristor is drawn on while its current is above a thousandth of its peak in the run. - **Values under the pointer.** Hover a wire to read its node voltage and the current in that piece of wire; hover a part to read its current, the voltage across it and whether it conducts. The **timeline bar** under the canvas has: | Control | What it does | |---|---| | Play / Pause | Plays the run back, or holds the current instant. The window redraws only while it plays. | | Time slider | Scrubs through the run. The scope's first cursor follows it, and dragging that cursor in the scope moves the playback time. | | Speed | Simulated time per real second, on a logarithmic slider from 1 ns/s to 10 s/s. **Presets**: one switching period per second (the default; the period comes from the first switch's gate signal), ten periods per second, the whole run in 10 s, 1 ms per second. | | Loop | The whole run, the window the scope shows, one switching period around the playback time, **one operating mode** (the mode Tk the playback time is in) or a **dragged span** of the modes row. The last three also zoom the scope to that window. | | Voltage colors | Turns the node voltage colouring and its legend on or off. | | Operating modes | The row under the time slider: the last whole switching period split into T1 [t0, t1], T2 [t1, t2]… wherever a switch or diode changes state, the playback time marked in it. Hover a band for its interval, duration, share and what conducts; click it to jump there; drag across the row to limit playback and the scope to that span. The layers icon turns the modes off; the save icon writes the table (CSV) and one schematic PNG per mode beside it. | Inside a subsystem, the animation shows the instance's own signals (`X1.R1`, `X1.n1`). A disabled part carries no current. **Operating modes, as in a paper.** While the modes are on, the parts and nets that carry no current in the mode the playback time is in are drawn faint, so the canvas shows that mode's equivalent circuit, and the scope shades T1, T2… over its plots (the current mode a little darker) once it is zoomed to a few hundred periods or fewer, from the run's first sample to its last. The names sit in a strip along the top of each plot, which the y axis leaves free of the traces; where a trace still runs through it (a short plot, or after a zoom) the name is left out, and resting the pointer on the strip names the mode under it. A part conducts in a mode when its mean current over the mode, less a tenth at each end for the commutation, is above 1 % of the run's largest current; a switch or diode by its own state. Intervals shorter than 1 % of the period are folded into the next. The tutorial [Operating modes](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/20-operating-modes/) walks through the buck and the flyback. **How the currents are put on the wires.** The result records the current of each part (`i(R1)`), not of each wire. Each net is drawn as a tree of wire pieces, so the current in every piece follows exactly from what the pins on either side draw (Kirchhoff's current law). A pin whose current is not recorded (a subsystem instance's pin, a transformer's secondary, a three-phase source's neutral) takes what is left over on its net: exact when it is the only such pin on the net, shared equally when there are several. Nets drawn as net labels have no wires, so they show no dots. **The scope follows the playback.** While the animation is on, every time plot (in the dock, in the scope's window and in each plot's own window) draws its traces only up to the playback time, like a live oscilloscope, and the rest appears as the playback reaches it. The axes keep the whole run's range, so they do not rescale as the traces grow; a kept reference and overlaid runs stay drawn in full. Turn the animation off to see the whole run again. X-Y plots are drawn whole. **While a run is going.** The scope draws the run as it goes. About four times a second it asks the solver for the signals you are showing, thinned to the width of the plot, and draws them in place of the result until the run ends; then the finished result takes over. The time axis spans the whole run from the start (**Save from**, or 0) to the end time, so the traces grow from left to right like a scope sweep and only their right end moves; the y axis fits the values so far. A zoom or pan made during the run is kept, and when the run ends the view stays where it is (**Zoom to Fit** shows the whole result). Run and Cancel work as before, and the preview changes neither the run nor its result. The circuit animation plays finished runs and paused runs only. **When a run ends.** The run card over the plots turns into the run's summary on one line: the run's number, what was simulated in how long with which solver, **Compare with Run N**, **Keep as reference** and its ×. With the scope in view, the card is the only notice; with the scope out of view (another dock tab, or the dock hidden), a "Run N finished" toast with **Show results** appears over the canvas, at most one at a time. Every run also lands in the Notifications list (the status bar's bell). **Long runs stay smooth.** The scope keeps an index of each shown signal, built once per result, so panning and zooming a run of millions of samples draws only what fits on the screen, with the same extremes, mean and RMS as a scan of every sample. **From automation.** `result.snapshot {"t": "3.995m"}` returns what the animation shows at that time: `nodes` (net → volts), `branches` (part → amperes) `switches` (part → on) and `states` (state machine → `{index, name}`, for a wired `state` pin). The playback itself is view state: `ui.set {"animate": {"on": true, "t": 0.003995, "speed": 1e-5, "playing": true}}` (fields `on`, `playing`, `t`, `speed` in s/s or `null` for the default, `range` `run|window|period|mode|span`, `voltage`, `modes`, `window` `[from, to]` for the span). `simulation.modes {period?, from?, to?, min?}` returns the modes T1…Tn with their start, end, duration, share, conducting switches and diodes, conducting path and idle parts and nets; `simulation.exportModes {path}` writes the table as CSV, Markdown or a LaTeX tabular, and `file.exportSchematic {path, mode: k | "all"}` draws mode k (or each mode) as its equivalent circuit. ## Measurements The panel right of the plots has five tabs: **Summary**, **Signals**, **Power**, **Phasors** and **Runs** (with the number of runs). The tab you pick is kept with the window's view state (`ui.set {"resultsTab": "power"}` picks one from automation). Every figure is measured over the visible range, or **between the cursors** while they are on. One line under the window picker at the top of Summary and Signals says which and what the window holds: `Steady state · last 5 of 400 periods · duty 26.0% · visible 0 s – 4 ms` (or `2712 periods`, `cursors 312.4 µs – 42.02 ms`), and the copy icon at the picker's end copies the table (the steady state when the run switches and the window spans more than five switching periods, the PWM duty when there is a 0/1 signal). Zoom in on the steady-state part of the run, or put the cursors around it, to measure only that part. A scope tab keeps its own columns; the **Quick** tab's choice is the start for a new scope. ### Summary The **Summary** tab reads the window at a glance: three cards in a row, then the signal table, then the latest three runs with **All N runs** (the Runs tab). Numbers are monospaced, with a smaller unit. | Card | What it shows | |---|---| | **Output** | The mean of the output voltage (the load's voltage, else `v(out)`); with a target from the Test Bench spec (`vout`), `target 12 V`, green with ✓ inside the tolerance (`vout.tolPct`), amber with **Check** outside it. Hover for how far off it is | | **Ripple** | Its peak-to-peak ripple and the ripple as a share of the mean. When the circuit switches and the window spans more than five switching periods, the card reads the last five (the context line says **Steady state**; hover the card for the cycles), so a window that starts at t = 0 does not count the start-up as ripple; the window's own p-p stays in the table. Green or amber against `ripple.maxPp` when the spec gives one | | **Efficiency** | Pout ÷ Pin, with the loss under it and Pin and Pout on hover (see **Power**); "—" with the reason when the input and load cannot be found | Without a limit in the spec there is no verdict. **Copy ▾** at the end of the context line copies the table as CSV or as tab-separated text. ### The signal table The table (on Summary, and alone on **Signals**) has one row per shown signal, in two groups: **Power stage** (voltages and currents, `v(…)` and `i(…)`) and **Control signals** (logic, duty, feedback and other unitless signals). Each row starts with a dot in its trace's colour; the picked columns (**mean**, **RMS** and **p-p** by default) share the panel's width and their numbers are right-aligned. A 0/1 PWM signal reads `duty 26.0%` instead of a mean. A control signal has no unit (hover its name). Hover a column header for what it means (**p-p** = ripple, max − min). Frequency, period and duty are never a column of dashes: picked in **Measurements to show**, they read on a line under the rows of the signals that have them (`frequency 100 kHz duty 26.0%`), and nowhere for a signal that does not oscillate. Each row ends in two icons: **FFT**, the spectrum of that signal over the visible window (`analysis.fft`, 20 harmonics), and **Add to plot** (greyed while the signal is already shown). A click on the signal's name shows the values at the window's ends; a right click on it opens the rest: - **Add measurements**: columns for this signal alone (they read on the line under its row). - **Frequency and duty**: this signal's frequency and duty under its row. - **Values at the window's ends** (or a click on the signal's name): its value at each end (`@t1`, `@t2`), their difference (`Δ`), and the minimum and maximum, under its row. - **Copy values**: its row as tab-separated text. The plots take the scope's width first. While they would get less than half of it (or less than 360 points), the panel (with the cursor readout and the run history) folds to a strip on its own, even when you asked for it; the **Measurements** button in the toolbar shows or hides it, and Voltecx remembers that choice. In a narrow window (a dock under about 1100 points wide) the signal list and the Measurements panel become labelled strips at the scope's edges (**Signals · 3**, **Measurements · 4**), so the plots keep the width; click a strip to open its pane, and the signal list's **‹** (Collapse Signals) folds it again. Each stacked plot keeps at least 96 points with its header; plots past that scroll. The bottom plot also gets the height of the time axis (**t (s)**) under it, so all the plots draw their traces in frames of one height. Each plot names its traces in a row above it (a short line in the trace's colour, dashed for a reference or an earlier run), so no legend covers the traces. When the names do not all fit, the ones that do not are folded into **+N** at the row's end: rest the pointer on it to read them, or click it to open the Measurements table. The picker groups the columns: | Group | Columns | |---|---| | **Basic** | mean, RMS, min, max, p-p, **peak \|x\|** (largest magnitude, with when: `10V @5ms`), **valley** (lowest value, with when) | | **AC** | **AC RMS** (RMS of the signal less its mean: the ripple), **mean \|x\|** (the average of the magnitude: the rectified average of a diode or AC current, where the plain mean reads about 0), **crest** factor (peak / RMS), **frequency**, **period**, **duty**, **THD** | | **Transient** | **overshoot** and **undershoot** (% of the step), **rise 10–90 %**, **fall 90–10 %**, **settling** time; the **settling band ±** (2 % by default) is set under the group | | **Power** | the columns of the power rows: **P**, **S**, **Q**, **Q₁**, **PF**, **Vrms**, **Irms** | The transient columns treat the signal as a step response: from its value at the start of the window to its **final value**, the mean over the last 5 % of the window (so switching ripple does not pick a random point). Overshoot is how far it goes past the final value, undershoot how far it first goes the wrong way. Rise time is for a rising step and fall time for a falling one. Settling time is measured **from the start of the window** (put cursor C1 at the step) until the signal stays inside the band around the final value. A signal that does not move from start to end by at least 30 % of its peak-to-peak range is not a step, and its transient columns read `—`. So do THD of a signal without a fundamental (frequency, period and duty of a signal that does not oscillate are simply left off the line under its row), and a settling time when the signal is still outside the band near the end of the window. A spread that is only rounding noise next to the signal's size reads `0`. The copy icon › **Copy Table as TSV** (pastes into a spreadsheet) or **Copy Table as CSV** puts the table on the clipboard, for a spreadsheet or a report: one row per signal, a `unit` column (V, A) and plain numbers in SI units (`0.0012`, not `1.2m`), every picked column (min, max, frequency and duty included), empty where there is no value. Each column is as wide as its widest number, unit included, so no number is ever cut. When the panel has no room for every picked column, the ones that do not fit (RMS first) read on the line under each row instead. The **Efficiency** chip in the Columns row adds **Power and efficiency** under the table: the input and the output found in the circuit (as on the Power tab), each with its voltage × current and P, then η = Output ÷ Input and the loss. ### Power The **Power** tab first shows the power Voltecx finds in the circuit as four cards, **Input power**, **Output power**, **Loss** and **Efficiency**, with the parts it used: the input is a DC source (or battery) to ground, the output a resistor or power load to ground (nets named `in…` and `out…` are preferred). In an isolated converter the secondary ground `sgnd` counts as ground too, and the load's power is read across its own two nets. The isolation tie and a bleeder between the two grounds are not loads, nor is the resistor of an RC snubber. Input power adds up every source that delivers power (a supply and the backup that takes over), and output power every load on the output net. When the circuit has none, or their voltage and current were not recorded, the tab says why; add the pairs by hand in the line **Power from** [voltage] × [current] **Add power**. The table of pairs appears with the first one. The power rows give the power of a voltage and a current over the same window: **P** = mean(v·i) in W, **S** = Vrms·Irms in VA, **Q** = √(S²−P²) in var, **Q₁** in var and **PF** = P/S. **Q** has no sign and holds the distortion power too, so a distorted current at unity power factor still shows some; **Q₁** is the signed reactive power of the fundamentals of v and i (V1rms·I1rms·sin(φv − φi), read at the voltage's fundamental over whole periods): positive when the current lags the voltage, negative when it leads, and "—" when neither signal has a fundamental. Pick a voltage and a current in the two lists and press **Add power**, or right-click a voltage in the signal list and choose **Power with** › a current. **×** removes a row. With two rows or more an **Efficiency** line appears: pick the output row and the input row, and it shows η = Pout/Pin. The sign of P follows the signals: a current measured into a part gives positive power into it. If η says the input power is negative, the current points the other way. For exact figures on AC or switching signals, measure over whole periods. The **Phasors** tab draws the fundamental of each signal you pick as an arrow from one centre: pick signals in **Add to phasors** (up to 12). The first one is the reference at 0°; an angle that leads it turns counter-clockwise, one that lags turns clockwise. Each phasor is read over **Whole cycles** periods (1 by default) that end at the window's end, so dc and harmonics fall out, and the fundamental is found on the reference as the THD finds it. Voltages, currents and other signals are each scaled to their own largest phasor. The table under the diagram gives each signal's peak, rms and angle, and **×** takes a signal off. **Replay** steps the diagram through the run, one window after another up to the window's end (a start-up, a load step, a phase jump); drag the slider to stop at one, and the line under it says where that window ends. The figures are those of `scope.phasors`. The same from the command line: `scope.power {"v": "v(in)", "i": "i(V1)", "t0": "3m", "t1": "4m"}` gives `p`, `s`, `q`, `q1` (with `f1`, the fundamental it was read at), `pf`, `vrms` and `irms`. `scope.efficiency {"in": {"v": "v(in)", "i": "i(V1)"}, "out": {"v": "v(out)", "i": "i(Rload)"}}` gives `pin`, `pout`, `efficiency`, `efficiencyPercent` and `loss`. ### Math signals A math signal is computed from the others after every run and is then a signal like any other: it shows in the signal list marked **ƒ**, plots, measures and exports. **+ Math** above the signal list opens the `scope.addMath` form with an expression to start from; right-click a voltage and choose **Math: power v·i** › a current for the instantaneous power `v·i`, shown at once. Right-click a math signal to remove it. The **Math** section at the foot of the signal column lists the circuit's math signals as `name = expression`, each with a **×** to remove it and, under it, the reason when the latest run cannot compute it; type an expression in its box and press **Add** (or Enter) to add one, named `math1`, `math2`, …, and shown at once. To change one, double-click its row (or right-click it, or the signal in the list, and choose **Edit expression**), change the expression and press Enter: it keeps its name, its place and its plots, and Esc leaves it as it was. A math signal can use only the ones above it. Math signals are saved with the circuit (and undo like any edit). Math traces kept by an older version in its session become math signals of the circuit that is open when the session comes back (the status bar says which, and why one could not be kept). An expression uses the signals as listed (`v(out)`, `i(L1)`), numbers with SI prefixes (`2k`, `10u`), `+ - * / ^` (the typeset `−`, `×`, `÷` and `·` work too), and functions such as `abs`, `sqrt`, `min`, `max`, `exp`, `sin`. Four operators work over time (`avg` in two forms): | Operator | Result | |---|---| | `ddt(x)` | The derivative of `x` | | `integ(x)` | The running integral of `x` from the start of the run (energy from power, charge from current) | | `avg(x, T)` | The moving average of `x` over the last `T` seconds (`T` a number, such as `1/50k`) | | `avg(x)` | The running mean of `x` from the start of the result: at each time, the average of everything so far (the first sample is its own mean) | | `lpf(x, fc)`, `lpf(x, fc, 2)` | `x` through a low-pass filter with its −3 dB point at `fc` hertz. Order 1 (the default) is a single pole, `y += (1 − e^(−2π·fc·dt))·(x − y)` per sample interval; order 2 is a second-order Butterworth (Q = 1/√2, a step overshoots 4.3 %). Both start at rest at the first sample and follow the run's own time steps. `fc` may not exceed the Nyquist limit 1/(2·shortest step). This is a textbook filter: it does not reproduce any particular instrument's bandwidth-limit filter | For example `v(sw)*i(L1)`, `integ(v(in)*i(V1))` or `avg(abs(i(L1)), 20u)`. A division by a value that crosses zero leaves a gap at that sample, and so does any sample with no value (`sqrt` of a negative, `ln(0)`): the **Math** section then says under the signal how many of its samples have no value and when the first one is, and `scope.addMath` and `scope.list` give the same as `nonFinite {count, samples, firstTime}`. From the command line: `scope.addMath {"expr": "v(out)*i(Rload)", "name": "pout"}`, `scope.editMath {"name": "pout", "expr": "v(out)*i(Rload)/2"}`, `scope.removeMath {"name": "pout"}`; `scope.list` lists them, with the reason when the latest run cannot compute one (it names a signal that run does not have). ### From the command line `scope.summary {"t0": "3.99m", "t1": "4m"}` gives what the side panel shows: every signal's row (`mean`, `rms`, `min`, `max`, `pp`, `at1`, `at2`, `delta`, its `group` and, for a 0/1 signal, `duty`), the `output` card (with `target`, `tolPct` and `rippleMaxPp` to override the spec), the `duty` (only from a 0/1 signal that switches, at least two periods over the run), the automatic `power` (or `powerWhy`; both are empty when the only load sits across the source, which is no converter), and `periods`, the window in switching periods. When the result switches and the window spans more than five periods, `output` also has `steadyRipplePp`, `steadyRipplePercent` and `steadyRippleStatus`, read from `steadyFrom` over the last `steadyCycles` (5) periods. `scope.measure` gives everything at once. Each statistics row has `min`, `max`, `mean`, `rms`, `peakToPeak`, `last`, and also `peak` and `peakTime`, `valley` and `valleyTime`, `acRms` and `crest`. Extra options: ```json {"signals": ["v(out)", "i(L1)"], "t0": "3m", "t1": "4m", "thd": {"fundamental": 50, "harmonics": 50}, "power": {"v": "v(in)", "i": "i(V1)"}, "switching": {"signal": "v(sw)"}, "oscillation": true, "step": {"band": 0.02}} ``` | Option | Result | |---|---| | `thd` | Total harmonic distortion of each signal | | `power` | Real power, apparent power, reactive power and power factor from a voltage and a current signal | | `product` | The mean of the product of two signals (for example instantaneous power) | | `switching` | Duty cycle (and frequency) of a switching waveform; `threshold` sets the level | | `oscillation` | Frequency, period, duty, 10–90 % rise and fall times and cycles of each signal | | `step` | Initial and final value, overshoot and undershoot (%), rise, fall and settling time of each signal; `band` is the settling band (0.02 = ±2 %) | For a spectrum, use `analysis.fft` with `{"signal": "v(out)", "t0": "3m", "t1": "4m", "harmonics": 20}`. Choose a window that holds a whole number of periods. Each harmonic also has `phaseDeg`, its phase in degrees against a cosine that starts at `t0` (a sine reads −90), so two signals taken over the same window compare directly; a harmonic too small to have a phase gives `null`. The spectrum view's harmonics table shows the same phase in its **Phase (°)** column and in Copy Table as CSV. The agent's `waveform_stats` tool returns the statistics, `oscillation` and `step` together. The spectrum view takes its fundamental as the largest bin after DC. When a harmonic or the switching ripple is larger than the fundamental (a distorted grid current, a lightly loaded inverter), type the fundamental in the header's **f1** field, in Hz (`50`, `60`, `1.2k`); the THD and the share of the fundamental are then measured against it, as `analysis.fft` does with `fundamental`. Type `0` or `auto`, or pick **Find the fundamental automatically** in a result's right-click menu, to go back. The time range **One cycle ending at cursor 2** takes one period ending at the second cursor: the typed fundamental's period, else the signal's own. Put cursor 2 at the end of the cycle you want to read; with the engine this is `analysis.fft` with `fundamental`, `t0` one period before `t1`, and `t1` at the cursor. ## Comparing runs Each run is kept, so this run can be compared with the last one, or with the run from ten changes ago. The **Runs** tab of the panel (or the activity bar's **Runs**, which then takes the list over) reads like a pull-request list: two quiet lines per run, newest first, and the Summary tab shows the latest three. Each row has a **Compare** checkbox, a title, a muted line under it and, while the pointer is over the row, the icons **Show on scope**, **Compare with now**, **Restore**, **Tag** (**Rename** once tagged; an emptied tag untags) and **Delete**. **Show on scope** stays visible while that run is on the scope. - **Title.** The tag you gave the run, or what changed since the run before, in a few words: `R1 1 kΩ → 2 kΩ`, `Ideal mode` or `Real mode`, `added Rstep`, or `3 changes` when several things changed. The first run says **First run**; the latest run has a **latest** pill. Several re-runs in a row with no changes fold into one line, `Runs 12–17 · no changes (6)`; click it to see them. A long title is cut to one line; drag the side bar's edge to widen it. - **The line under it.** The run's number, how long ago it ran, and one summary of its key results: the largest change from the run before (`▼ v(out) −1.1 %`), green when it came closer to the spec target, amber further, or `3 results changed`. - **Click the row** to open it: every key result with its value and its change from the run before, and a table of every change, **Before** and **After**. A value that was not set reads `(default)`. Parts added or removed and new connections are listed too. Click again to close it. - **Tick two runs' Compare** to see them side by side. ![The Run History, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/scope/04-run-history.png) 1. A run's row, opened. 2. Compare. 3. The latest run. 4. The largest change of its results. 5. What changed since the run before. | Action | How | |---|---| | Show a run on the scope | **Show on scope**, the eye icon on its row. Its traces of the shown signals are drawn over the latest run in the same colour, fainter and dashed. Older runs are fainter still. The legend names the run (`v(out) · Kp=6`). The latest run is the plot itself, so it has no such box. | | Compare two runs | Tick **Compare** on two rows. Both are drawn on the scope, and a table under the list puts them side by side: each shown signal's mean, RMS, min, max and final value in each run, and the difference. **Stop comparing** ends it. **Compare circuits** opens the two runs' circuits side by side, with what changed highlighted (**Compare Circuits**, see *Import and export*). | | See what changed in the circuit since a run | **Compare with now**, an icon on its row: that run's circuit and the circuit now, side by side, with the changes highlighted and listed. | | Go back to a run's values | **Restore**, the clock icon on its row (`runs.restore`). The circuit's parameter values, circuit variables and simulation settings are set back to what that run used, as one step that **Edit → Undo** takes back. Parts added or removed since then stay as they are. A run read from a file keeps its waveforms but not its values, so it cannot be restored. | | Name and keep a run | **Tag**, the tag icon on its row: type a name such as `Kp=6`, press Enter. A tagged run is kept until you untag it, and the tag becomes the row's title. **Rename** changes the tag. **Untag**, or an empty name, removes it. | | Delete a run | **Delete**, the trash icon on its row. The latest run is the plot itself and stays. | | Drop the untagged runs | **Clear untagged** (`runs.clear`). Tagged runs stay. | From the command line: `scope.addMath {"expr": "v(out)*i(Rload)", "name": "pout"}`, `scope.editMath {"name": "pout", "expr": "v(out)*i(Rload)/2"}`, `scope.removeMath {"name": "pout"}`; `scope.list` lists them, with the reason when the latest run cannot compute one (it names a signal that run does not have). ## Reference traces **Keep as reference** in the scope toolbar keeps the latest run as a reference: it is drawn dashed under every later run, in a colour and dash of its own, and named in the legend and the hover label (`v(out) · Ref 1`). Keep as many as you like, up to 8 per circuit. A reference is a tagged run of the run history, not a copy: keeping one tags the run (`Ref 1`, `Ref 2`…, or the tag it already has), so it is kept, saved in a bundle, and measured in the **Δ vs latest** table like any overlaid run. The **References (n)** list next to the button holds them: | Action | How | |---|---| | Show or hide one | The box in front of it. A hidden reference is still kept. | | Change its colour and dash | Click its line sample. | | Rename it | **Rename**, type, press Enter. The name is the run's tag. | | Remove it | **×**. The run goes back to the untagged runs (unless you had tagged it yourself). | | Remove them all | **Clear all**. | An imported measurement (File > Import > Measurement) is listed there too, as **Measured**. From the command line, `scope.references` does the same: `{"action": "add"}` (or `"run": "r2"`, `"name": "Kp=6"`), `{"action": "list"}`, `show {id, shown}`, `rename {id, name}`, `style {id, style}`, `remove {id}` and `clear`. Untagging a run with `runs.untag` ends its reference too. ## Export - **Save Image** (toolbar or Scope menu) asks where to save. A `.png` is a picture of the plots as shown: axes, labels, legend and cursors. A `.svg` is a vector picture from `scope.export`, with axes, tick labels and a legend, for a report or a thesis. - **Copy Image** puts the same PNG picture on the clipboard, ready to paste into a document or a chat. - **Export data > Export CSV (Visible Window)** and **Export CSV (Full Run)** ask where to save, then write the shown signals with `scope.export`: full-resolution samples, one column per signal after `time`. Pick the MAT-file or LTspice raw type in the dialog (or type a `.mat` or `.raw` name) for a binary file instead: MATLAB and `scipy.io.loadmat` read the `.mat` (time in double, signals in single precision, the names in `names`), LTspice and its Python readers the `.raw`. **Copy CSV (Visible Window)** puts the CSV text on the clipboard. - **Scope > Export > Waveform Data** (`scope.export`) writes a PNG, SVG, CSV, MAT-file (`mat`) or LTspice `.raw` (`raw`) from the command line or an agent: `{"format": "mat", "path": "buck.mat", "t0": "3m", "t1": "4m"}`. You can limit the signals, the window and the image size. The PNG and the SVG have the same axes, tick labels with units and legend, ready for a report. Automation writes under its granted roots and never opens a dialog. - **File > Export > Waveforms (CSV)** writes every recorded signal to a CSV file. Its command, `file.exportWaveforms`, is an alias of `scope.export` with `"inline": true`: it also takes `"format": "mat"` or `"raw"` and then returns the file as base64. Scripts and agents should call `scope.export`. - The CSV opens in a spreadsheet, MATLAB or Python; for millions of samples the MAT-file or `.raw` is smaller and quicker to load. ### Example: the buck example as CSV, MAT-file and LTspice raw ```sh powercraft-cli run --root work --cmd file.openExample --params '{"name": "buckIdeal"}' \ --cmd simulation.run --params '{}' \ --cmd scope.export --params '{"format": "csv", "path": "buck.csv"}' \ --cmd scope.export --params '{"format": "mat", "path": "buck.mat"}' \ --cmd scope.export --params '{"format": "raw", "path": "buck.raw"}' ``` The run records 13 signals at 80001 points. The CSV is 10.7 MB, while the MAT-file and the `.raw` are 4.80 MB each, less than half. In MATLAB, `load buck.mat` gives `time` (80001×1, double precision), one single-precision column per signal under a MATLAB name (`v(out)` becomes `v_out_`, `i(L1)` becomes `i_L1_`), and `names` with the signal names as Voltecx writes them. In Python, `scipy.io.loadmat("buck.mat")["v_out_"]` reads the same column. In the app the same files come from the **Scope** menu: ![The Scope menu's Export submenu, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/waveform-files/01-export-menu.png) 1. **Export**, the submenu. 2. **Waveform Data** (`scope.export`): a PNG, SVG, CSV, MAT-file or `.raw`. 3. **Export CSV (Visible Window)**: pick the MAT-file or LTspice raw type in the dialog for a binary file. 4. **Export CSV (Full Run)**: the same for the whole run. ### Limits of the waveform files - Export only: Voltecx does not read MAT-files or `.raw` files back. - The signals are written in single precision, as they are recorded; time is written in double precision. - HDF5 is not written: no pure-Rust writer for it builds for the web app. - Compressed MAT-file variables, AC (complex) `.raw` data and ASCII `.raw` files are not written. - In a MAT-file, characters other than letters, digits and `_` become `_`, a name that does not start with a letter gets `s_` in front, names stop at 63 characters, and a repeated name gets `_2`, `_3` and so on. `time`, `names` and `vars` are reserved. To compare with a measurement from a bench oscilloscope, load its CSV with `waveform.compare` (see [`docs/workflows/debugging.md`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/workflows/debugging/)). It lines up the two traces (by cross-correlation or on the first edge, like the scope's trigger), finds the time shift and reports the RMS and peak error and the rise and settling times. Chapter 9 lists the scope CSV layouts it reads and how File > Export > Measurement Comparison writes the figure and table for a report. **Match the scope's bandwidth limit before comparing.** A capture taken with the scope's bandwidth limit on (often 20 MHz) shows less overshoot and slower edges than the simulation, so the comparison blames the model for the instrument. Give `waveform.compare` the same bandwidth: `waveform.compare {"path": "ringing.csv", "map": {"v(sw)": "CH1"}, "bandwidthHz": "20Meg"}` passes the simulated signals through a single pole at 20 MHz (`"bandwidthOrder": 2` for a Butterworth) before the metrics, and the result says which bandwidth it used. To see it on the scope, add the math signal `lpf(v(sw), 20Meg)`. A capture taken with the limit off needs neither; to see ringing, take it that way. ### Capture from a networked oscilloscope **Scope > Capture from Oscilloscope** (`scope.capture`) reads waveforms straight from a scope on the network, with no VISA driver: give its address (`host`), the channels (`[1, 2]`) and, if needed, the port (5025 by default). Voltecx asks `*IDN?` to tell a Rigol DS/MSO, a Keysight InfiniiVision or a Tektronix MSO apart (set `vendor` for a scope that answers otherwise), then reads each channel's scaling and data. The result is a CSV with `Time (s)` and one `CHn (V)` column per channel, which goes straight into `waveform.compare` like an imported file. - Binary transfer (the default) is fast and has the scope's 8-bit resolution. `encoding: "ascii"` is slower and gives the same values. - The scope sends the record it shows. Stop the acquisition first if it is running fast, so every channel comes from the same trigger. - `timeout` (5 s by default) bounds the connection and every reply, so a scope that stops answering ends the capture with an error. - For a scope on a USB cable, set `transport: "usbtmc"` and `device` to its USB vendor and product id in hexadecimal (`1AB1:04CE`), with `:SERIAL` after them when two identical scopes are attached. Leave out `host` and `port`. The reads are the same, with no VISA or vendor driver. If the id is wrong, the error lists the USB instruments that are attached. On Linux, a permission error means your user needs a udev rule for the instrument. When a USB scope stops answering within `timeout`, Voltecx also aborts the waiting transfer on the scope, so the next capture starts clean; the error says whether that worked. If it says the abort failed, unplug the cable and plug it in again before the next capture. - Only the desktop app and `powercraft-cli run` open the connection, and only when you run the command. The browser build and `powercraft-cli serve` do not. **Scope > Capture and Fit to Measurement** (`scope.captureAndFit`) does the capture and the model fit in one step: it reads the channels as above, then moves the parameters you list until the simulation matches the capture, as `debug.fitToMeasurement` does (see Chapter 9). Give the capture settings under `capture`, the signals as `map` (`{"v(out)": "CH1"}`) and the parameters with their ranges as `params`. The scope dates its samples from its trigger; if the circuit's start is the capture's first sample instead, set `timeShift: "start"`. Every setting is checked before the scope is read, so a typo in `map` costs no capture. The CSV stays out of the result unless you ask for it with `keepCsv: true`. ### Cross-check in ngspice **Simulation > Cross-check in ngspice** (`simulation.crossCheck`) runs the open circuit in ngspice, if it is installed on your computer, and compares it with the Voltecx run: a second opinion from a simulator that is not ours. Voltecx writes the SPICE netlist (the same export as File > Export > SPICE Netlist), runs `ngspice -b` on it in a temporary folder, reads its waveforms back and compares every node voltage and every source and inductor current both runs have, with the same metrics as `waveform.compare` (RMS and peak error, relative RMS). - Voltecx looks for `ngspice` on `PATH`. If it is somewhere else, set the environment variable `POWERCRAFT_NGSPICE` to the program. Without it the menu item is disabled, and `command.list` and the error say why. - Everything the SPICE export cannot translate (control blocks, voltage meters, parts SPICE has no element for) is listed in `warnings`. The two runs then simulate different circuits there, so read the comparison with that list in mind. A circuit made of R, L, C, sources, diodes and switches driven by a fixed PWM translates fully. A MOSFET at its ideal level goes out as a SPICE switch with its `ron` and its `coss` across it, and a capacitor's `esr` as a resistor in series; the MOSFET's body diode (its conduction while off) is not written, and a warning says so. - `tEnd` shortens the comparison (it is at most the circuit's stop time), `signals` picks signals by their Voltecx names (`v(out)`, `i(L1)`), and `timeout` (60 s by default) bounds the ngspice run. - Only the desktop app and `powercraft-cli` run it; the browser build cannot start programs. ## Tips - Measure after the start-up transient. A buck converter needs a few hundred switching periods to settle. Set `t0` to a time after that. - If a trace looks like a staircase, you zoomed in beyond the step size. Lower `maxStep` in the settings. - A signal missing from the list was not recorded. Run the simulation again after you add parts. --- # 6. Analyses URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/06-analyses/ An analysis runs the simulator, or a frequency-domain method, and returns numbers. Open the **Analysis** menu, or press Cmd+K and type the command name. A form asks for the parameters, filled in from the scope (the first visible trace and the visible time window) and the circuit's first variable. **Advanced (JSON)** takes the JSON shown in this chapter. The result appears in a window as a table (and, for sweeps and frequency responses, a small plot); **Copy** copies it as CSV. Sensitivity, Worst Case and Optimize have no form yet and take JSON. The same command works from `powercraft-cli run --cmd --params ''`, and from an assistant. ![The Analysis menu, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/analyses/01-menu.png) 1. Parameter Sweep. 2. AC Sweep. 3. Loop Gain. 4. Operating Point. 5. Losses, which stays grey until a run has finished. Choose the right tool: | You want to... | Use | |---|---| | See how a result changes as one value goes from A to B | `analysis.paramSweep` | | Find which of several values matter, and how they interact | `analysis.doe` | | See the spread caused by part tolerances (random) | `analysis.monteCarlo` | | Plot gain and phase against frequency | `analysis.acSweep` | | Measure an impedance (a filter's output impedance, a source's) | `analysis.impedance` | | Check a control loop's phase margin and crossover | `analysis.loopGain` | | Find the noise at a sense or reference output, and which part makes it | `analysis.noise` | | Find the values that give the best result | `analysis.optimize` | | Find which part matters most | `analysis.sensitivity` | | Adjust values until the waveforms meet a spec, then stop | `analysis.tuneToSpec` | | Guarantee a spec over all tolerances | `analysis.worstCase` | | Get the losses of each switch and diode | `analysis.losses`, `analysis.thermal` | | See harmonics | `analysis.fft` | | Check each part's stress against its rating | `analysis.stress` | | Check that each switch turns on at zero voltage, and size the dead time | `analysis.softSwitching` | | Hold a line current to the grid harmonic limits of IEEE 519 | `analysis.gridHarmonics` | | Check that an inverter rides through a grid sag or swell (IEEE 1547) | `analysis.rideThrough` | | Check that an inverter stops within 2 s when the grid is lost (IEEE 1547) | `analysis.antiIslanding` | | Check that an inverter rides through a grid frequency disturbance (IEEE 1547) | `analysis.frequencyRideThrough` | | Check that an inverter follows the frequency-droop active power (IEEE 1547) | `analysis.frequencyDroop` | | Check that an inverter follows the volt-var reactive power curve (IEEE 1547) | `analysis.voltVar` | | Check that an inverter curtails its active power along the volt-watt curve (IEEE 1547) | `analysis.voltWatt` | | Check that an inverter holds its power factor setting (IEEE 1547) | `analysis.constantPf` | | Check that an inverter follows the watt-var reactive power curve (IEEE 1547) | `analysis.wattVar` | | Measure a three-phase converter's dq and sequence impedance and check it against a weak grid (SCR) | `analysis.dqImpedance` | | Check that an inverter holds its reactive power setting (IEEE 1547) | `analysis.constantQ` | | Check that an inverter rides through a grid phase-angle jump (IEEE 1547) | `analysis.phaseJumpRideThrough` | | Check that an inverter trips in time on an abnormal grid voltage (IEEE 1547) | `analysis.voltageTrip` | | Check that an inverter trips in time on an abnormal grid frequency (IEEE 1547) | `analysis.frequencyTrip` | | Check that an inverter returns to service only inside the enter-service ranges, after the delay (IEEE 1547) | `analysis.returnToService` | | Estimate the conducted EMI and size an input filter | `emi.conducted` | Run the simulation first for the commands that read a result (`analysis.fft`, `analysis.losses`, `analysis.thermal`, `analysis.stress`). The sweeps, the frequency analyses and the optimisers run their own simulations. ## Analyses saved with the project An analysis can be kept in the project as a document of its own: its kind (transient, AC sweep, DC sweep, parameter sweep or operating point), its settings, the signals it shows and its latest result, saved in the file. `analysisDoc.add`, `analysisDoc.run`, `analysisDoc.update` and `analysisDoc.remove` make, run, change and remove one; each is one undo step. With **View › Studio Layout (Preview)** on, the project tree's **Simulation** folder lists them after its documents, in the project's order; hover a row for what it runs. A click on a transient that has run shows its waveforms in the **Transient** tab, with its run laid over the latest one when it is an earlier run. A click on an AC sweep, DC sweep, parameter sweep or operating point that has run opens its kept result in an **Analysis** tab named after the document: its plots, tables and summary, as the result window shows them, with **Run Analysis** beside its name to run it again. Each analysis document has a tab of its own, so several can be open at once: right-click one's tab for **Open to the Side** to compare two results side by side. A result with plots has a **Signals** panel beside them: clear a signal's box to hide it in every plot. Click a plot to put **Cursor A** there and right-click for **Cursor B**; the panel shows where each cursor is (the frequency on a frequency axis), and the table under the plots gives each shown signal at A and at B, the difference B − A, and its least and greatest value between the cursors (over the whole sweep until both are placed). **Clear cursors** removes them. Each analysis document starts with every signal shown and no cursors, keeps its own while its tab is open, and starts afresh once its tab is closed. A click on one that has not run runs it, and its result shows in that tab when the run ends. Right-click a row for **Run Analysis** and **Remove Analysis**. Right-click the **Simulation** folder for **New Analysis**, then pick a kind (**Transient**, **AC Sweep**, **DC Sweep**, **Parameter Sweep** or **Operating Point**): the new document gets the kind's name and the next free number (**AC Sweep 2**), shows in the folder without running, and is one undo step. A field solve can be kept the same way. An extraction setup (`analysisDoc.add {kind: "extraction"}`) keeps `field.peec`'s settings by name (**Extraction Setup 1**), and a sweep object (`kind: "fieldSweep"`) keeps `field.sweep`'s; a sweep that names a setup with `setup` is attached to it and starts every point from the setup's settings as they are when it runs. `analysisDoc.duplicate` copies any analysis under the next number of its name (**Setup1** gives **Setup2**), without its result, as one undo step. They are listed in the **Simulation** folder with the others, and a click runs them; the **New Analysis** menu does not offer them. ## Parameter sweep Change a circuit variable over a list or a range and measure one result each time. The sweep runs the points in parallel on all your cores. ```json {"variable": "D", "values": [0.2, 0.25, 0.3], "measure": {"signal": "v(out)", "stat": "mean", "t0": "3m"}} ``` The **Tools > Parameter Sweep** form (chapter 13) fills in this command for you and shows the result as a table. Instead of `values`, give `start`, `stop` and `points`. `stat` is one of `mean`, `rms`, `max`, `min`, `pp`, `last`, `ripplePct` and `meanProduct` (the mean of `signal` times `signal2`, for power). The variable is a circuit variable (**Circuit > Variables**; the example buck has `Vin`, `D` and `fsw`) or a part's parameter written `Part.param`, such as `L1.l`. To get several numbers from each run, give `measure` as a list; the reply adds a `table` with a column per measurement. To see the waveforms too, like LTspice's `.step`, add `keepWaveforms`: the scope then overlays each point's trace in its own colour, named with the point (`v(out) · L1.l = 47u`). ```json {"variable": "L1.l", "values": [47e-6, 100e-6, 220e-6], "measure": [{"signal": "i(L1)", "stat": "pp", "t0": "3m", "name": "ripple"}, {"signal": "v(out)", "stat": "mean", "t0": "3m"}], "keepWaveforms": ["v(out)"]} ``` The kept waveforms may hold 256 MB (64 MB in the browser): a sweep that would need more is refused before it runs, with what to change. They stay until the next sweep that keeps waveforms, or **Simulation > Clear Sweep Waveforms** (also **Clear sweep waveforms** under the Parameter Sweep window's results). **Show on scope** there puts the kept signals on the scope, one curve per run, after the circuit has been run once. `analysis.paramSweep2d` and `analysis.monteCarlo` take the same `measure` lists and `keepWaveforms`. ### Example: three inductors, two numbers each, one overlay ```sh powercraft-cli run --cmd file.openExample --params '{"name":"buck"}' \ --cmd analysis.paramSweep --params '{"variable":"L1.l","values":[47e-6,100e-6,220e-6], "measure":[{"signal":"i(L1)","stat":"pp","t0":"3m","name":"ripple"},{"signal":"v(out)","stat":"mean","t0":"3m"}], "keepWaveforms":["v(out)"]}' \ --cmd sweep.list --params '{}' \ --cmd sweep.waveforms --params '{"points":[0],"maxPoints":2000}' ``` The sweep's `table` has the columns `L1.l`, `ripple` and `mean(v(out))` (a measurement without a `name` is called `stat(signal)`): | `L1.l` | `ripple` (A) | `mean(v(out))` (V) | |---|---|---| | 47 µH | 1.927 | 11.995 | | 100 µH | 0.911 | 11.996 | | 220 µH | 0.423 | 11.993 | `kept` in the reply says what was kept: 3 points of `v(out)`, 2.9 MB of the 268 MB budget, none `dropped`. The scope overlays the three traces as `v(out) · L1.l = 47u`, `v(out) · L1.l = 100u` and `v(out) · L1.l = 220u`. Three commands reach the kept family without the scope: - `sweep.list` gives the command that made it, what was moved, the signals and each point's `index`, `label` and values. - `sweep.waveforms` gives the samples: `signals` (default: the kept ones), `points` (indexes from `sweep.list`, default every point, at most 200), `t0`, `t1` and `maxPoints` (samples per point and signal, default 2000, from 4 to 20000). - `sweep.clear` (**Simulation > Clear Sweep Waveforms**) frees them. With a `measure` list, `analysis.paramSweep2d` adds `zs`, one grid for each measurement, and `analysis.monteCarlo` adds `measureStats`, the count, mean, standard deviation, minimum and maximum of each. Their other figures (the heat map, the histogram, the yield) are those of the first measurement. A 2-D point is labelled `R1.r = 4.8, D = 250m` and a Monte Carlo run `#3 L1.l = …`. In the app the scope overlays the kept family on the latest run (solid). With the Measurements panel folded, the legend names every point: ![The scope after the sweep, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/sweep-overlay/01-overlay.png) 1. `v(out) · L1.l = 47u`, dashed. 2. `v(out) · L1.l = 100u`. 3. `v(out) · L1.l = 220u`. ### Limits of sweeps that keep waveforms - At most 16 measurements and 16 kept signals per sweep, and at most 1000 runs. - The kept waveforms hold at most 256 MB (64 MB in the browser). A sweep estimated to need more is refused before it runs, for example: "keeping 2 signal(s) for 1000 points takes about 1280 MB, over the 268 MB the kept sweep waveforms may hold; keep fewer signals or points, or record less per run". When the runs come out larger than the estimate, points are kept in order while they fit, and `dropped` and `note` say how many were not. - One family is kept at a time: the next sweep that keeps waveforms replaces it. It is kept apart from the run history (so a large sweep does not push out your runs), it is not saved in the file and it is not part of undo. ## Two-variable sweep `analysis.paramSweep2d` runs one simulation for each point of a grid of two targets and measures one number, or a list of them, at each point. Each target is a circuit variable or a part's parameter (`R1.r`), and the two must differ. The points run in parallel. Give `x` and `y`, each with a `variable` and either `values` or `start`, `stop` and `points`, and a `measure` as in the parameter sweep. ```json {"x": {"variable": "Vin", "start": 36, "stop": 60, "points": 4}, "y": {"variable": "D", "values": [0.2, 0.25, 0.3]}, "measure": {"signal": "v(out)", "stat": "mean", "t0": "3m"}} ``` The reply is a matrix, and the result window draws it as a heat map. The command has no menu item. Run it from the console, a script or an assistant. ## Design of experiments **Analysis > Design of Experiments** (`analysis.doe`) varies up to eight factors at once, each a circuit variable or a part's parameter (`L1.l`) between a `low` and a `high` value, runs one simulation for each point of the plan, and measures one number, or a list of them, at each point. The runs go in parallel on all your cores, a run starting only while the machine has memory for it, and the results come back in run order. Three plans: - **Full factorial** (`"design": "fullFactorial"`, the default): every combination of each factor's `levels` (2 by default, up to 10), the first factor changing fastest. Three or more levels let the model fit curvature. - **Fractional factorial** (`"fractionalFactorial"`): a two-level `2^(k−p)` fraction for screening many factors in few runs. `fraction` sets `p` and uses the standard generators of the NIST/SEMATECH e-Handbook of Statistical Methods (§5.3.3.4.7); or give your own `generators`, such as `["D=ABC"]`, where A, B, C … are the factors in order. Some interactions are then aliased with main effects; the reply lists the generators so you can tell which. - **Latin hypercube** (`"latinHypercube"`): `runs` points (10 per factor by default) that use every slice of each factor's range once, drawn from `seed`, so the same seed gives the same runs. ```json {"factors": [{"name": "D", "low": 0.3, "high": 0.5, "levels": 3}, {"name": "L1.l", "low": "80u", "high": "120u"}], "design": "fullFactorial", "measure": {"signal": "v(out)", "stat": "mean", "t0": "1m"}} ``` The result window shows what ran, the **main effects** (the change from each factor's low to its high value), the **fitted model** (least squares in coded units, −1 at low and +1 at high, with every factor, every two-factor interaction and, for factors set at three or more values, every square, as far as the runs can tell them apart) with its R², the **response surface** of the model over two factors as a heat map (`"surface": {"x": "D", "y": "L1.l"}`; the first two by default, the others held at the centre of their range), and the table of runs. **Copy CSV** copies the whole table. A good order: screen many factors with a fraction, then run a full factorial or a Latin hypercube on the two or three that matter. ## Monte Carlo Random draws within part tolerances. It reports the mean, the standard deviation, and the smallest and largest value of the measurement. ```json {"vars": [{"name": "L1.l", "tol": 0.2}, {"name": "C1.c", "tol": 0.1, "distribution": "gauss"}], "runs": 50, "seed": 1, "measure": {"signal": "v(out)", "stat": "pp", "t0": "3m"}} ``` The `seed` makes a run repeatable. Each entry of `vars` names a circuit variable or a part's parameter (`L1.l`) and its tolerance `tol` as a ratio (0.2 is ±20 %; for `gauss` it is three standard deviations). `distribution` is `uniform` (the default) or `gauss`. The older shape `{"variables": {"L1.l": {"tolerance": 0.2}}}` still works, and the reply then has a `deprecated` line that shows the new one. The reply also has a histogram, the percentiles (1, 5, 25, 50, 75, 95 and 99) and the worst run. Add `limitMin`, `limitMax` or both, and each run passes when its value is inside the limits. The reply then has a yield: the share of runs that passed, with a Wilson score interval (`confidence`, 0.95 by default). A run that failed to simulate counts against the yield. `bins` sets the number of histogram bins. ## AC sweep, impedance and loop gain Choose **Analysis > AC Sweep**. Name the source (here `Vin`), check the output, the sweep range (From, To) and the rest, and press **Run**. ![The AC Sweep form, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/analyses/02-form.png) 1. Source. 2. Output. 3. From (the start frequency). 4. Run. These give gain and phase against frequency for a power stage, an input filter or a control loop. Each takes a log-spaced sweep: `fStart` (default 10 Hz), `fStop` (default 100 kHz), `points` (default 50, from 2 to 1000). ```json {"source": "V1", "output": "v(out)", "fStart": 10, "fStop": "100k", "points": 100} ``` - **`analysis.acSweep`** gives `output / stimulus`. The stimulus is an independent voltage or current source (`source`). Without `source` it takes the circuit's one DC voltage source, else its one sine or pulse voltage source, else its one DC current source, and the reply names it in `source` and `injection`; when there are several candidates, or none, it lists them and asks. The output is `v(node)`, `v(a,b)`, `i(element)` or a signal name. - **`analysis.impedance`** injects a current into `node` and reports `Z = (v(node) - v(ref)) / I`. Example: `{"node": "out"}`. - **`analysis.loopGain`** breaks a control signal (`signal`) and reports `T = -return / forward`. Read the crossover frequency where `magnitudeDb` crosses 0, and the phase margin as the distance of `phaseDeg` from -180 degrees at that frequency. Three methods: | `method` | How it works | Use it for | |---|---|---| | `linear` (default, except a loop gain of a switching circuit) | Complex nodal analysis at each frequency. Fast and exact for a linear circuit | Passive filters, analog stages, a converter averaged by hand | | `perturbation` | Adds a small sinusoid to the running transient simulation and measures the response | Switching converters, where you want the real, sampled behaviour, delays and all | | `periodic` (default for `analysis.loopGain` on a circuit that switches) | Finds the periodic steady state, then linearises one switching period about it and reads the response from that model | Switching converters: the same answer as `perturbation`, in two switching periods a frequency instead of a settled run | The result holds arrays `frequency`, `magnitudeDb`, `phaseDeg`, `real` and `imag`, and `warnings`. For perturbation, extra keys report the periods, steps and amplitude used. For `linear` on a circuit with switches, `states` fixes each switch on or off (`{"S1": "on"}`), so you analyse one switch state. Perturbation takes longer, because every frequency needs its own settled run. Start with fewer points. On a circuit that switches, `perturbation` moves the sweep's frequencies to whole fractions of the switching frequency (fsw/2, fsw/3 and so on), where the response repeats from one perturbation period to the next, and its solver steps land on the PWM's edges, so a small duty perturbation is resolved at the circuit's own `maxStep`. With `untilCrossover` it measures from the top down and stops once the loop gain has stayed at 1 or more for an octave below where it last rose through 1: an output filter's resonance can lift the gain above 1 again just above the crossover. A point that does not settle is left out and listed in `unsettled`. A frequency the step budget cannot measure is refused before the run starts. **How `periodic` works.** It first finds the periodic steady state at the switching period, the way `simulation.steadyState` does. About that steady state it builds the sampled-data model of one period (G. C. Verghese, M. E. Elbuluk and J. G. Kassakian, "A general approach to sampled-data modeling for power electronic circuits", IEEE Trans. Power Electron. PE-1(2), 1986). - The matrix that carries the state from one period boundary to the next takes one simulated period per state variable, each started from the steady state with that variable moved. - Each frequency then takes two more periods: one with a cosine on the stimulus and one with a sine. Every period is simulated with its switching instants found by the solver, so the model includes how each switching instant moves with the state and the stimulus. The reply is the response at the stimulus frequency, which is what `perturbation` measures (the zeroth harmonic transfer function; N. M. Wereley and S. R. Hall, Proc. 29th IEEE CDC, 1990). On the closed-loop buck and boost examples it matches a fine-step `perturbation` within 0.2 dB and 1° up to a third of the switching frequency, in about 1/100 of the solver steps. **Which solver.** `solver` (`reference` or `fast`) picks the transient solver that runs the periods; without it the method uses the circuit's own (Simulation Settings). The fast solver lands its steps on every switching instant and locates each diode's and body diode's commutation inside its step, so each period has a step grid of its own; the method integrates every period over its own steps, and the two solvers agree within 0.2 dB and 1° on the buck and boost loops. The reference solver puts a commutation that is not on a PWM edge on its step grid, so use the fast solver for resonant and soft-switched circuits (an LLC, a phase-shifted full bridge) at their own `maxStep`. The reply names the solver in `solver`. **Validated.** Against `perturbation` at a fine step (2 ns, 200 ns for the PFC), up to a third of the switching frequency: the LLC half bridge (`llcHalfBridge`, input to output), the phase-shifted full bridge (`psfb`, loop gain) and the boost PFC's voltage loop (`pfcBoost` broken at `ipk`, up to a third of the 50 Hz line), each within about 0.1 dB and 1.2° on the fast solver, with 1/25 (the PFC, whose period map spans the 20 ms line period) to 1/2000 of the solver steps of the fine-step perturbation. `docs/accuracy.md` lists every point. It takes `amplitude` (default 1 % of the operating value), `tol` (the steady state's tolerance, default `1e-6`), `maxPeriods` (for the steady-state search, default 2000), `solver` and `frequencies`. At or above half the switching frequency a switching circuit's response also depends on the stimulus's phase, and the reply warns about it. ### Example: the loop gain of the closed-loop buck ```sh powercraft-cli run --cmd file.openExample --params '{"name": "buckClosedLoop"}' \ --cmd analysis.loopGain --params '{"signal": "duty", "fStart": 100, "fStop": "20k", "points": 12}' ``` The circuit switches, so `analysis.loopGain` takes `periodic` without being asked. The reply says `"method": "periodic"`, 2 `periods` at each of the 12 frequencies and 11211 solver `steps` in all, and the loop crosses over at 380 Hz with 115° of phase margin and 46 dB of gain margin. The same call with `"method": "perturbation"` needs more than 20 million solver steps and stops at the default `maxSteps`. **Analysis > Loop Gain** with `Signal` set to `duty`, 100 Hz to 20 kHz and 12 points makes the same call. The circuit switches, so it takes the periodic method: ![The Loop Gain result for the closed-loop buck, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/periodic-loop/01-form.png) 1. The sweep: 12 points, 100 Hz to 20 kHz. 2. The crossover: 380 Hz. 3. The phase margin: 115.0°. The gain margin, 46.0 dB, follows on the same line. To pick the signal on the schematic instead of typing it, press **Pick** beside the Signal field. The form steps aside, and dashed circles mark the control signals that a block or a meter drives, which are the places the loop can be broken. A click on a circle fills the field and brings the form back. A pick replaces a voltage injection set in the form. Esc stops picking and leaves the field as it was. Twelve points step over the output filter's resonance at 1.59 kHz, where this loop's gain rises above 0 dB again. With 80 points over the same range the reply has `"crossings": 3` and a warning, and reads the margins where the gain falls through 0 dB last, at 1751 Hz: 45° of phase margin, the one that sets the damping (44.5° by hand). A loop that crosses 0 dB more than once is always read at its last fall, so sweep densely around a resonance: the phase turns fast there. Give `pmMinDeg` and `gmMinDb` (or store a spec with them through `spec.set`, as `design.auto` does) and the reply judges the margins: `checks` lists each margin with its least value and `pass`, and the cards read PASS or FAIL with "needs at least 45°". A margin the sweep has no crossing for is not judged (`pass` null). Under the cards one line says how the loop gain was measured: the method, the frequencies and the periods each took, the solver steps and the solver, as "Periodic method · 12 frequencies × 2 periods · 16659 solver steps · fast solver". In the Loop Gain form the line under Method says what the picked method does; left empty it reads "Automatic: periodic when the circuit switches, linear otherwise." ### Limits of the periodic method - The circuit needs a periodic steady state at the switching period, found within `maxPeriods`. The period is the longest one among the PWM blocks, carriers, sine sources and sample-and-hold blocks. - It takes at most 200 state variables. - It refuses, and says why, where its answer would be wrong: - a PWM or carrier whose frequency is wired (variable-frequency control, as an LLC's oscillator): the switching period moves with the stimulus. Use `perturbation`. - a frequency at or above half the frequency of a line source (an AC source or sine reference) that moves the operating point while the circuit switches many times per line period: on the boost PFC its voltage loop, below 25 Hz, is measured, and its current loop is refused. Study a fast loop at a fixed operating point, the line replaced by a DC source, with `perturbation` at a fine `maxStep`. - a steady period that does not repeat from the steady state: a control block keeps state the method neither restores nor linearises. The integrals of `integrator` and `pi` blocks, the states of `tf` blocks (a Type II or Type III network) and the states of `ztf` blocks (a digital compensator) are covered. Use `perturbation` for anything else. - a steady state in which no switch changes state over the period: the converter is held off there (a soft start, an enable or a protection), so there is no operating point to linearise about. - an answer that changes by more than 4 % when the stimulus is halved: a switching instant moves in steps (the reference solver on the phase-shifted full bridge) or the stimulus is too large. Use the fast solver, a smaller `maxStep` or a smaller `amplitude`. - At or above half the switching frequency the response also depends on the stimulus's phase. The reply warns, and the values there are the response to a cosine stimulus, not a transfer function. - `tSettle`, `stepsPerPeriod`, `skipUnsettled` and `untilCrossover` belong to `perturbation` and are refused with `periodic`. ### When the periodic method refuses: the analyser fallback When `analysis.loopGain` is called with no `method` on a circuit that switches and the periodic method refuses it (a block it does not linearise, or a converter held off at the steady state it finds), the loop is measured the way a frequency-response analyser measures the board: sinusoidal perturbation at whole fractions fsw/k up to fsw/4, at most 16 points, from the top of the sweep down until the gain has risen through 0 dB, 1 % agreement between periods and at most 80 periods a frequency, after `tSettle` (the circuit's `tEnd` unless the call gives one). The reply has `"method": "perturbation"` and a `fallback` object with `from`, `why` (the periodic method's refusal) and `how`. A refusal no method can get round, a loop that mixes with a line source's sidebands, is not covered: it is reported as an error. Naming `"method": "periodic"` turns the fallback off. Every perturbation reply carries `sweep`, each frequency reached with `settled` true or false, so a plot can mark the points left out. When the step budget runs out part-way, the points measured until then are the answer: `partial` is true and `stopped` says where and why. ### Model against measurement `design.voltageLoop` with its loop check measures the designed loop on the switching circuit and adds a `modelVsMeasured` line: the measured phase margin less the model's, with a note on the two things the averaged model treats differently. One is the output capacitor's ESR zero, 1/(2π·ESR·C), which the model leaves out and which adds atan(fc/fESR) of lead at the crossover. The other is the model's modulator delay of `delayTs`·Ts, 360·fc·`delayTs`/fsw degrees of lag, where the switching circuit has its own. ## Noise Choose **Analysis > Noise**. `analysis.noise` gives the noise at an output over a log-spaced sweep, as SPICE's `.noise` does: it solves the DC operating point, linearises the circuit there (every switch and diode in its state at that point, unless `states` names one) and adds up the noise of every part at the output. ```json {"output": "v(out)", "input": "V1", "fStart": 10, "fStop": "100k", "points": 50, "temperature": 27} ``` - `output` is `v(node)`, `v(a,b)` or a control signal. `outputDensity` is the noise density there in V/√Hz at each `frequency`, and `outputRms` the RMS noise over `fStart` to `fStop` (the density is integrated as a straight line on log-log axes between points, so a white or a 1/f² stretch is exact with few points). - With `input` (an independent voltage or current source) the reply also has `gainDb`, the gain from that source, and `inputDensity` and `inputRms`, the noise referred to it (V/√Hz for a voltage source, A/√Hz for a current source). - `sources` lists the parts that make noise, largest share first: each has its `kind`, its current noise `density` in A/√Hz and its `share` of the output noise power over the band. What makes noise: | Part | Noise | |---|---| | Resistor, and the series and parallel resistances of a part | thermal, 4kT/R at `temperature` (default 27 °C) | | A switch or MOSFET channel that conducts | thermal noise of its on-resistance | | A diode, body diode or bipolar junction that conducts, a bipolar transistor's collector current | shot, 2q·I at the operating point | | A level-1 MOSFET | channel, 8kT·gm/3 | Everything else is noiseless, and the reply's `notModelled` says what that leaves out in this circuit: controlled sources, behavioural sources and control blocks carry no noise, no part has an op-amp's input noise (en, in), and flicker (1/f) noise is not modelled. A junction's small-signal resistance uses the part's own temperature (its `tj` or 25 °C), not `temperature`. Tests check the thermal noise of a resistive divider (4kT·(R1 ∥ R2)) and its value referred to the source, that an RC low-pass integrates to kT/C whatever R is, that a diode fed by a current source has 2qI·rd², and a diode bias network with an RC filter against ngspice's `.noise` (densities and the output total within 2e-7). ### Example: the noise of the RC example ```sh powercraft-cli run --cmd file.openExample --params '{"name": "rc"}' \ --cmd analysis.noise --params '{"output": "v(out)", "input": "V1", "fStart": 0.01, "fStop": "1g", "points": 400}' ``` `outputDensity` starts at 4.07 nV/√Hz (the 1 kΩ resistor, √(4kTR)) and falls above the 159 Hz corner; `outputRms` is 64.4 nV, √(kT/C) for 1 µF. Referred to `V1`, the noise is the resistor's 4.07 nV/√Hz at every frequency. ## DC operating point, DC sweep and transfer function These three find the circuit at DC. A capacitor is open and an inductor is a short. They read the circuit and never change it. `analysis.op` solves the operating point. It reports every node voltage as `v(node)`, every branch current as `i(element)`, the state of each switch and diode, and the power in each element. It also gives the power the sources deliver and the power the resistive parts take. Sources hold the value they have at time 0. Give `time` to use another moment. Give `states` to fix a switch, for example `{"S1": "on"}`. A switch you do not name follows its gate at that time. A node with no DC path to ground is named in `warnings`. ```json {"states": {"D1": "off"}} ``` `analysis.dcSweep` solves the operating point once for each value of one source or one circuit variable. Give `source` or `variable`. Give the values as `values`, or as `start`, `stop` and `step`. Use `output` or `outputs` to choose the signals to return. Without them the reply holds every voltage and current. Each point starts from the switch states of the point before it. ```json {"source": "V1", "start": 0, "stop": 5, "step": 0.5, "output": "i(D1)"} ``` `analysis.transfer` gives the small-signal gain from a source to an output at the operating point. It also gives the resistance the source sees and the resistance at the output with the sources off. A resistance of `null` means the circuit is open there. ```json {"source": "V1", "output": "v(out)"} ``` Machines and mechanical parts are not solved at DC. Run a transient for them. The `.op`, `.dc` and `.tf` lines of an imported SPICE file run these commands through `analysis.runImported`: choose **Simulation > Run Imported Analyses**, which runs them with the file's `.tran`, `.step`, `.ac` and `.meas` lines and is greyed out while the circuit has none. ## Optimise, sensitivity and worst case Three commands answer "how do I make the design better?". They share one way of describing **variables** (what to change) and **metrics** (what to measure). ```json {"vars": [{"name": "D", "lo": 0.2, "hi": 0.45}], "metrics": {"vout": {"signal": "v(out)", "stat": "mean", "t0": "3m"}}, "objective": {"expr": "vout", "sense": "max"}, "constraints": [{"expr": "vout", "op": "<=", "value": 12}], "maxEvals": 60, "apply": false} ``` - **`analysis.optimize`** searches within bounds. It stops after `maxEvals` runs (at most 500) or when the search has converged. With `"apply": true` it writes the best values into the circuit as one undo step. - **`analysis.sensitivity`** changes each variable by a small amount and ranks how much each metric moves. Start here when you do not know what to adjust. It costs two runs per variable plus one. - **`analysis.worstCase`** takes a tolerance for each variable. With `"method": "corners"` it tries every combination of the extremes (up to 8 variables). With `"method": "sensitivity"` it uses a linear estimate plus a root-sum-square value. For `analysis.worstCase` each entry of `vars` is either `{"name": "L1.l", "tol": 0.2}` (the value times 1 ± 0.2; `tol` strictly between 0 and 1) or `{"name": "Vin", "min": 36, "max": 60}` (an absolute range). A variable is a circuit variable (`D`) or a parameter written `part.parameter` (`L1.l`). A good order of work is: sensitivity first, optimise the one to three variables that matter, then worst case. The full guide, with a buck walk-through and common traps, is [`docs/workflows/optimize.md`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/workflows/optimize/). ### One way to name targets, tolerances and measurements The sweeps, the 2-D sweep, Monte Carlo, optimise, sensitivity and worst case read their targets the same way: a circuit variable (`D`) or a part's parameter (`L1.l`). A part's parameter is written into each run's own copy of the circuit, so the open circuit does not change. Monte Carlo and worst case take the tolerances as the list `vars`, and every measurement takes the same `stat` list (`mean`, `rms`, `max`, `min`, `pp`, `last`, `ripplePct`, `meanProduct`). On the `buck` example: ```sh powercraft-cli run --cmd file.openExample --params '{"name":"buck"}' \ --cmd analysis.worstCase --params '{"vars":[{"name":"L1.l","tol":0.2},{"name":"Vin","min":36,"max":60}], "metrics":{"vout":{"signal":"v(out)","stat":"mean","t0":"3m"}}}' ``` The reply (`method` `corners`, 5 runs) gives `vout` 11.996 V at nominal, 8.995 V at its lowest (`Vin` 36 V, `L1.l` 120 µH) and 14.994 V at its highest (`Vin` 60 V, `L1.l` 80 µH). **Limits.** - A part's parameter must already be set on the part: `L1.x` is refused with the parameters `L1` has. A bare part name (`L1`) is refused with a hint to write `L1.l`, and a name listed twice is refused. - At most 32 entries in `vars`. Monte Carlo takes `tol` from 0 to 1; worst case takes it strictly between 0 and 1, or `min` and `max` instead (Monte Carlo has no `min`/`max` form). - The older Monte Carlo and worst-case shape `variables` still works and adds a `deprecated` line to the reply; giving both `vars` and `variables` is an error. ## Tune to a spec `analysis.tuneToSpec` is the "simulate, look, adjust, repeat" loop as one command. You say which waveform measurements must meet which bound, and which values it may change. It searches until every target is met, or until a limit stops it. ```json {"targets": [{"signal": "v(out)", "stat": "mean", "t0": "3m", "op": ">=", "value": 11.9}, {"signal": "v(out)", "stat": "pp", "t0": "3m", "op": "<=", "value": 0.1}], "vars": [{"component": "R2", "key": "r", "min": 1, "max": 100}], "limits": {"maxIterations": 20, "maxSims": 60}} ``` The part names in this example (`R2`) are only an illustration. Use the names in your own circuit. - A **target** is a measurement as in `analysis.optimize` (`signal`, `stat`, `t0`, `t1`) plus `op` (`<=`, `>=` or `=`) and `value`. For `=`, `tol` sets the tolerance (1 % of the value by default). - A **variable** names a part and a parameter (`component`, `key`) that holds a plain number, with the range `min` to `max`. A range of ten times or more is searched on a log scale. Up to 16 targets and 16 variables. - **Run settings.** `tEnd` and `solver` override the simulation settings for the search, as in `analysis.optimize`. - **Limits.** `maxIterations` (default 20, at most 200), `maxSims` (default 60, at most 1000) and `maxSeconds` (desktop only). A run ends with `stopReason` `met`, `maxIterations`, `maxSims`, `maxSeconds`, `cancelled` or `failed`. - The reply has `met`, the list of `iterations` with the values and measurements, `before`, `after`, and `ops`. `ops` are the best values found, written as `circuit.apply` edits. Every simulation runs on a private copy, so the circuit does not change during the search. The circuit is edited only when you pass `"apply": true` **and** the spec is met, as one undo step labelled "Tune to spec". When a limit or a cancel stops the search, the circuit is untouched, and the best values are still returned in `ops`. The command runs as a background job, so you can watch its progress and cancel it. In the desktop app, the agent panel offers it as the **Tune** form (chapter 12). ## Losses, thermal and FFT - `analysis.losses` returns the average conduction and switching loss of each switch and diode over a window: `{"t0": "3m", "t1": "4m"}`. It also lists the winding and core loss of each inductor (`dcr`, `rcore` or a linked core), coupled inductor (`rw1`, `rw2`, `rcore`) and transformer (`rw1`, `rw2`, `rcore` or a linked core). - `analysis.lossChart` draws where the watts go at full load (see *The loss chart* below). - `analysis.thermal` returns the temperatures of circuits that have a thermal network. A switch or diode junction with a limit also gets `limit` (°C), `limitFrom`, `marginK` (the limit minus the peak), `pass` and `crossedAt`; the result window shows the limit and margin columns, with a junction past its limit in red. ### The loss chart **Analysis › Loss Chart** (`analysis.lossChart`) shows where the input power goes at full load. It runs `design.efficiency` itself (at half and full load, so you need no run first) and draws its full-load loss table in a window: - **A Sankey.** The output runs straight across the top. The losses leave the input under it, one lane for each kind of loss (conduction, switching, gate drive, winding copper, core, capacitor ESR, and the rest that no part explains), then fan out to the parts. - **One bar per part**, largest first, stacked by kind of loss in the Sankey's colours, with a legend. Hover over a bar to see its split. - **Notes** under the chart when a loss is left out. On a soft-switched bridge the device tables price switching loss that the run does not draw, so the chart leaves the switching and gate drive out and keeps the run's own input. ![The loss chart of the buck example, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/loss-chart/01-chart.png) 1. The chart, headed by the efficiency and the total loss. 2. **Copy CSV** copies the flow, one row per band: `from,to,category,watts`. 3. **Show data** holds the numbers (the reply without its pictures). On the buck example 57.4 W goes in and 55 W comes out (95.7 %). Of the 2.47 W lost, D1 takes 2.43 W in conduction, S1 34.5 mW, C1 1.83 mW in its ESR, and 2.38 mW is not explained by any part. A three-phase inverter needs no `bind` either. When the circuit is no converter `design.efficiency` knows, but its only DC source drives phases that each run through one resistor (and any series inductors) to a star point nothing else touches, those resistors are the load, and the output is what they dissipate together. On the `inverter3` example, Analysis › Loss Chart shows 7.39 kW in and 7.38 kW out (99.88 %). Of the 8.59 W lost, each of the six switches takes 1.23 W in conduction and 1.22 W is not explained by any part. With a second DC source, or a phase with no resistor or two, name the load in `bind` (below). Every watt on the chart is a number of the loss table: nothing is scaled or rounded away. The chart is refused, with the reason, when the input differs from the output plus the losses by more than 0.5 % of the input, when a loss is not a finite number or is negative, or when there is no loss at all. You get an error, never an empty chart. | Param | Meaning | |---|---| | `format` | `svg` (default), `png` or `json`. The PNG is 1920 px wide at 192 dpi, so it prints at the SVG's 10 in, and it is lettered in English whatever `lang` is. | | `lang` | `en` (default) or `zh-Hant`, for the labels of the SVG. | | `efficiency` | A `design.efficiency` reply you already have, charted instead of running it again. | | `bind`, `tEnd` | Passed to `design.efficiency`: `bind {source, load, outNet, fsw?}` names the parts of a circuit it does not recognise by itself. | The reply has `pinW`, `poutW`, `lossW`, `gapW`, `efficiency`, the `nodes` and `links` of the flow, `parts` (largest first, each with `byCategory`) and `notes`. The design summary folder (`report.designSummary`, chapter 16) has the same chart as `loss-chart.svg`. ```sh powercraft-cli run --cmd file.openExample --params '{"name":"buck"}' \ --cmd analysis.lossChart --params '{"format":"json"}' ``` ### Over-temperature A switch or diode's junction limit is its `tjMax` parameter (°C), else the `tjMax` of its device: the highest junction temperature of the data sheet, filled for the library devices whose data sheet states it and absent otherwise. A run watches every junction that heats a thermal network and has a limit. When one passes it, the run's warnings name the part, the peak, the limit and the time it first crossed; the reply lists it in `overTemperature`; and `circuit.problems` shows `thermal.overTemperature` for as long as the result belongs to the circuit as it is. With `simulation.settings {"stopOnOverTemperature": true}` the run ends at the first crossing instead, and `stoppedBy` says why. ### The thermal overlay **View › Overlays › Thermal Overlay** draws the last run's temperatures on the schematic. It turns on by itself after a Real run that has temperatures (see *Temperatures after every run* below) and stays off once you turn it off. Each part with a junction temperature (a switch or diode on a thermal node: its `thermal` parameter, or a device with its own thermal chain) gets a plate beside it with its peak temperature, `112 °C`; while the scope's cursors are on, the plate shows the value at the first cursor instead. The part's body is tinted on a colour scale (viridis, which reads in grey and with every common colour-vision deficiency) from the coolest temperature of the run, the ambient, up to the lowest `tjMax`, or up to the hottest part when no part has a limit. A part past its own `tjMax` is drawn in the error colour, with a warning mark on its plate and an outline round it; the plate stands in for the over-temperature problem's own mark, and hovering it shows the problem's text. The scale sits in the corner of the canvas that covers the fewest parts and wires (bottom-left when it is free), with its two ends in °C and a tick at the `tjMax`; past the tick it runs on in the error colour. On a small canvas the bar is narrower, and a click on the scale folds it to its title (click again to show it). When you change the circuit after the run, the overlay dims and the scale's title says it is stale; run again to bring it up to date. ![The thermal overlay on the thermal buck with a heatsink too small for Q1, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/thermal-overlay/01-overlay.png) 1. Q1 is past its 150 °C limit. 2. D1 sits on its own heatsink, below its limit. The colour scale is in the bottom-left corner. From automation the overlay is view state: `ui.set {"thermalOverlay": true}`, or `ui.menu.invoke {"id": "view.thermalOverlay"}` to toggle it. ### Temperatures after every run Every Real run shows its temperatures, even when the circuit has no thermal network. `thermal.summary` gives each part that loses power a temperature: | Source | Temperature | |---|---| | `simulated` | The circuit's thermal network, as the run recorded it (the peak). | | `heatsink` | The part's `thermal` net carries a placed heatsink (`thermal.placeHeatsink`): ambient + loss × (Rth j-c of its library device + the heatsink's Rth). | | `datasheet` | The RthJA its data sheet gives on the smallest board it names (`parts/heatsinks.json`, cited): ambient + loss × RthJA. | A part with none of these shows `—` and **needs Rth**: nothing is guessed. The loss is the one `runs.compareFigures` reads (the second half of the run), so the Ideal against Real table and the temperatures agree. The ambient is the call's `ambient`, else the spec's hottest ambient, else the circuit's ambient part, else 40 °C (the reply's `ambientFrom` says which). A part that stands for `nParallel` devices puts each one's share through its own path. The run card shows: - a banner when some parts have no thermal model: *No thermal model on N parts. Temperatures use ambient + Rth from the data sheet.* **Add heatsinks** opens `Design › Design Steps › Thermal`, which picks a catalogue heatsink and pad (or board copper) for each device; apply it there in one undoable step; - a chip with the hottest part, its temperature and its margin to `tjMax`: red over the limit, amber within 25 K, green beyond. A click turns the thermal overlay on; - **Temperature per part**: each part's temperature with a bar of its rise against its `tjMax`, and its margin. On the overlay an estimate's plate reads `≈ 85 °C`, and the scale starts at the ambient. ```json {"cmd": "thermal.summary", "params": {"ambient": 40}} ``` returns `parts` (hottest first: `part`, `lossW`, `tC`, `source`, `rthKW`, `tjMax`, `marginK`, `over`, `cite`, `needs`), `hottest`, `unmodelled`, `estimated` and `needsRth`. - `analysis.fft` returns the frequency and amplitude of each harmonic, the fundamental and the THD: `{"signal": "i(L1)", "t0": "3m", "t1": "4m", "harmonics": 20}`. Without `t0` and `t1` it reads the last 5 periods of the fundamental before the end of the run, or as many whole periods as a shorter run holds (a part of a period smears the fundamental into its neighbours): the period comes from `fundamental` when you give it, otherwise from the signal's crossings of its mean in the second half of the run (the whole run when that half has too few), and with no period found it reads the last 20 % of the run. The reply says which in `window` (the times read) and `windowFrom` (`given`, `fundamental`, `signal` or `last20pct`). ## Stress and part choice `analysis.stress` measures each part's peak and RMS current, peak voltage, `di/dt`, `dv/dt` and loss, and compares them with the rating it should have (after derating). A diode whose device carries its data sheet's surge rating is also held, without derating, to IFSM (its peak current) and I²t (the largest ∫i²dt over the rating's 10 ms half sine): the `surge` entry of the row's `device` gives both with their margins and the sheet's table, and a shortfall is an issue that puts the part in `underRated`. Diodes without a rating, thyristors and capacitors (Voltecx has no surge-voltage data for them) are listed under `surgeNotChecked`. `library.search`, `device.recommend` and `device.validate` then find parts in the library that cover that stress at the lowest loss. The guide is [`docs/workflows/part-selection.md`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/workflows/part-selection/). ## Soft switching and dead time `analysis.softSwitching` reads every gate edge of every MOSFET, IGBT and switch. At each turn-on it takes the voltage across the switch and its current, and calls the edge ZVS (at most 5 % of the voltage the switch blocks, or its body diode conducting), partial, or hard (at least 90 %). At each turn-off it checks whether the current was near zero (ZCS). Per switch it gives the share of ZVS edges, the worst turn-on voltage and the energy lost to hard turn-ons, ½·Co(er)·V², from `coss`, `cossTable` or the Coss curve of the assigned device. For each leg it measures how long the switch node took to swing, compares that with the dead time the gates show, and says whether the dead time is too short (the switch turns on before its voltage is zero) or too long (a diode conducts afterwards), with a value to use. It reads the last result and runs the simulation when there is none. Set `coss` on the switches and use the variable step to see the transitions: with no capacitance the node swings within one step. With `{"sweep": {"variable": "Rload", "values": [2, 5, 10, 20]}}` it runs a copy once per value and reports, per switch, where ZVS is kept and where it is lost: the ZVS boundary over load. `analysis.paramSweep` measures one signal statistic per run, so use the sweep of `analysis.softSwitching` for this. ## Grid harmonic limits (IEEE 519) `analysis.gridHarmonics` holds a line current of the last run to the current distortion limits of IEEE Std 519-2014, Table 2 (systems of 120 V to 69 kV). Give the current (`signal`), the window on whole line cycles after the start-up (`t0`, `t1`, `fundamental`) and the short-circuit ratio Isc/IL at the point of common coupling (`iscRatio`, or `isc` with `il`). The ratio picks the row of the table; each odd order 3 to 50 is held to the limit of its band in percent of IL, each even order to a quarter of it, and the total demand distortion (TDD, the rms of the orders 2 to 50 over IL) to the row's TDD limit. IL is the maximum demand current; without `il` the measured fundamental is used, and the reply says so. For a converter of pulse number q above 6, `pulseNumber` raises the limits of the orders kq ± 1 by √(q/6) when every other order stays below 25 % of its limit (IEEE Std 519-1992, 10.4); `allowance` says whether it applied. The tables above 69 kV are not modelled. The standard assesses 10-minute and 3-second statistical values; a simulation gives one steady-state spectrum, compared with the limits as they stand. On the example `electrolyzer12Pulse`, `{"signal": "ia", "t0": 0.08, "t1": 0.12, "fundamental": 50, "iscRatio": 1500, "pulseNumber": 12}` shows the 11th and 13th within their raised limits, but the 23rd (about 3.8 % of IL) above 2.5·√2 = 3.5 %: a bare twelve-pulse rectifier needs a filter or a higher pulse number to meet Table 2. ## Voltage ride-through (IEEE 1547) `analysis.rideThrough` (**Analysis › Voltage Ride-Through Check**) checks a grid sag or swell in the last run against the voltage ride-through requirements of IEEE Std 1547-2018, clause 6.4.2. Sag the grid in the circuit first (the `grid3` source's `sagDepth`, `sagStart` and `sagEnd`; a negative `sagDepth` is a swell) and run on for at least half a second after it. Give the phase-to-neutral voltages at the inverter's connection (`voltages`, 1 or 3 signals), its phase currents in the same order with positive into the grid (`currents`), and its category (`category`, `I`, `II` or `III`); the nominal voltage and frequency come from the circuit's only `grid3` unless you give `vll` and `fundamental`. Each phase voltage is a one-cycle rms value over the nominal. The disturbance is the first stretch outside continuous operation (0.88 to 1.10 p.u.) after the start-up. It is a sag when a phase is below 0.88 p.u. as it starts, and its applicable voltage is then the least phase voltage; otherwise it is a swell, and its applicable voltage is the greatest. The median applicable voltage picks the row of Table 14 (Category I), Table 15 (Category II) or Table 16 (Category III); the reply's `sag.kind` says which it was: | Category | Voltage (p.u.) | Region | Minimum ride-through time | |---|---|---|---| | I and II | above 1.20 | cease to energize | none (may trip) | | I and II | 1.175 to 1.20 | permissive operation | 0.2 s | | I and II | 1.15 to 1.175 | permissive operation | 0.5 s | | I and II | 1.10 to 1.15 | permissive operation | 1 s | | I | 0.70 to 0.88 | mandatory operation | 0.7 s + 4 s/p.u. × (V − 0.70) | | I | 0.50 to 0.70 | permissive operation | 0.16 s | | I | below 0.50 | cease to energize | none (may trip) | | II | 0.65 to 0.88 | mandatory operation | 3 s + 8.7 s/p.u. × (V − 0.65) | | II | 0.45 to 0.65 | permissive operation | 0.32 s | | II | 0.30 to 0.45 | permissive operation | 0.16 s | | II | below 0.30 | cease to energize | none (may trip) | | III | above 1.20 | cease to energize | none (may trip) | | III | 1.10 to 1.20 | momentary cessation | 12 s | | III | 0.70 to 0.88 | mandatory operation | 20 s | | III | 0.50 to 0.70 | mandatory operation | 10 s | | III | below 0.50 | momentary cessation | 1 s | Three checks follow. `duration`: the sag or swell against the table's time. `current`, in mandatory operation of Category II or III only: the least apparent current in the sag must be at least 80 % of the pre-disturbance apparent current or active current, whichever is less (clause 6.4.2; the available active power is taken as the pre-disturbance power). `restore`: 0.4 s after the voltage returns, the active current must be back to at least 80 % of its pre-disturbance level (clause 6.4.2.7, a DER without dynamic voltage support). The `verdict` is `pass`, `fail`, `incomplete` when nothing failed but the sag was shorter than the table asks or the run ended too soon, or `notRequired` where the table asks no ride-through. Table 14's rows and every table's high-voltage rows were taken from reproductions of the tables, listed in the reply's `sources`: check them against the standard. Frequency ride-through (below) and consecutive disturbances are not checked yet. On the example `microgridIslanding`, set `BrkGrid.topen` to 100 s so the grid stays connected, `G1.sagDepth` 0.3, `sagStart` 0.5 and `sagEnd` 5, run for 5.6 s, and check the PV inverter with `{"voltages": ["vba", "vbb", "vbc"], "currents": ["ipvra", "ipvrb", "ipvrc"]}`. The battery's droop holds the bus at about 0.74 p.u. (Category II asks 3.8 s), and the PV inverter's constant current reference keeps its current and is back at once: `pass`. ## Anti-islanding (IEEE 1547) `analysis.antiIslanding` (**Analysis › Anti-Islanding Check**) checks an island in the last run against the unintentional-islanding requirement of IEEE Std 1547-2018, clause 8.1.2: the DER shall detect the island and cease to energize within 2 s of its formation. Open the grid's breaker in the circuit and run for at least 2 s after it. Give the phase-to-neutral voltages at the inverter's connection (`voltages`, 1 or 3 signals) and its phase currents in the same order (`currents`); the island time is the `topen` of the circuit's only breaker unless you give `islandAt`, and the nominal voltage and frequency come from the circuit's only `grid3` unless you give `vll` and `fundamental`. The inverter counts as ceased once its one-cycle rms current falls to `ceaseShare` (1 % by default, a setting of the check, not a value of the standard) of its pre-island value and stays there to the end of the run. The `verdict` is `pass` when it ceased within 2 s, `fail` when it ceased later or still energizes 2 s after the island, and `incomplete` when the run ends sooner. The run-on time errs long by up to one cycle. The hardest island for passive detection is a parallel RLC load matched to the inverter's power and tuned to the line frequency with a quality factor of 1.0 (IEEE Std 1547.1-2005 clause 5.7.1). The reply sizes it per phase (star) from the inverter's pre-island power as `testLoad` (R = V²/P, L = V²/(2π·f·P·Qf), C = Qf·P/(2π·f·V²); `qf` changes Qf). Build it in place of the circuit's loads, trim L or C until the grid carries no fundamental current before the island, and run again. The trip itself, the reconnection delay and the test's power and imbalance cases are not checked. On the example `microgridIslanding`, run for 2.6 s and check the PV inverter with `{"voltages": ["vba", "vbb", "vbc"], "currents": ["ipvra", "ipvrb", "ipvrc"]}`: it follows the island the battery forms and still delivers 6 kW at the end, so it fails, as a grid-following inverter without islanding detection should. Give it a frequency trip that zeroes its current references and the check passes. ## Frequency ride-through (IEEE 1547) `analysis.frequencyRideThrough` (**Analysis › Frequency Ride-Through Check**) checks a grid frequency disturbance in the last run against the frequency disturbance ride-through requirements of IEEE Std 1547-2018, clause 6.5.2. Move the grid's frequency in the circuit first: the `grid3` source's `fDev` (Hz, negative for an under-frequency), `fStart`, `fEnd` and `fRate` (Hz/s; `none` steps it). Give the phase-to-neutral voltages at the inverter's connection (`voltages`, 1 or 3 signals; the frequency is measured on the first, one value per cycle between rising zero crossings), its phase currents in the same order (`currents`) and its category (`category`, `I`, `II` or `III`). The disturbance starts at the grid's `fStart` unless you give `disturbanceAt`. Table 19 gives its frequencies in hertz for a 60 Hz system, so the check needs a 60 Hz fundamental. Table 19 (the same for all three categories): 58.8 to 61.2 Hz is continuous operation; 57.0 to 58.8 Hz and 61.2 to 61.8 Hz are mandatory operation for at least 299 s; below 57.0 Hz and above 62.0 Hz no ride-through is required (the table lists no row from 61.8 to 62.0 Hz). Within these regions the DER rides through a rate of change of frequency up to Table 21's: 0.5 Hz/s for Category I, 2.0 Hz/s for II and 3.0 Hz/s for III (clause 6.5.2.5). The check reports three things: `rocof`, the largest RoCoF (the change of the frequency over `rocofWindow`, 0.1 s by default) against Table 21; `energized`, the least one-cycle rms current from the disturbance on against `ceaseShare` (1 % by default) of the pre-disturbance current; and, for an excursion into mandatory operation, `duration` against 299 s. `rocofWindow` and `ceaseShare` are settings of the check, not values of the standard. The frequency and its RoCoF count only up to the moment the inverter ceases, since after that its own loss of current moves the voltage they are measured on. The `verdict` is `pass` when the inverter stayed energized (in mandatory operation, for at least 299 s), `fail` when it ceased while the standard asks it to ride through, `incomplete` when nothing failed but a mandatory excursion lasted less than 299 s, and `notRequired` when the frequency or the RoCoF went beyond what its category rides through. The table rows and limits were taken from reproductions of Tables 19 and 21 (listed in `sources`): check them against the standard. In continuous operation the `vPerHz` check reports the largest per-unit ratio of voltage (the highest phase over `vll`/√3) to frequency (over the fundamental) the inverter saw before it ceased: clause 6.5.2 asks it not to trip only up to 1.1 V/Hz, so above that the verdict is `notRequired` (the limit as quoted from clause 6.5.2 in NERC's 1547-2018 reliability guideline). The active power the inverter keeps or modulates (clause 6.5.2.7, Table 22: `analysis.frequencyDroop` below) and phase-angle jumps (clause 6.5.2.6: `analysis.phaseJumpRideThrough` below) are not checked here. On the example `microgridIslanding`, set the variable `fline` to 60, `BrkGrid.topen` to 100 s so the grid stays connected, and on `G1` `fDev` −1, `fStart` 0.5, `fEnd` 100 and `fRate` 1.5. Run for 1.6 s and check the PV inverter with `{"voltages": ["vba", "vbb", "vbc"], "currents": ["ipvra", "ipvrb", "ipvrc"]}`: its phase-locked loop follows the grid down to 59 Hz at 1.5 Hz/s and it keeps its current, so Category II passes and Category I (0.5 Hz/s) asks nothing. ## Frequency-droop active power (IEEE 1547) `analysis.frequencyDroop` (**Analysis › Frequency-Droop Check**) checks the active power an inverter delivers through a grid frequency excursion in the last run against the frequency-droop (frequency/power) operation of IEEE Std 1547-2018, clause 6.5.2.7 and Table 22. Move the grid's frequency as for the ride-through check, and give the phase-to-neutral voltages (`voltages`), the inverter's phase currents out of it in the same order (`currents`) and its rated active power (`ratedW`, the base of the per-unit droop; there is no default). The frequency and the power are one value per cycle of the first voltage. Outside the deadband the droop asks, from the pre-disturbance power p_pre in per unit: above 60 + `dbOf` Hz, p = max(p_pre − (f − (60 + `dbOf`)) / (60 · `kOf`), `pMinW`); below 60 − `dbUf` Hz, p = min(p_pre + ((60 − `dbUf`) − f) / (60 · `kUf`), `availableW`). The defaults are Table 22's: deadbands 0.036 Hz, droops 0.05 and a 5 s open-loop response time (`responseTime`), taken from EPRI OpenDER (listed in `sources`): check them against the standard. Without `availableW` the inverter is taken to have no headroom above its pre-disturbance power. The check reports `power`, the last cycle's power against the droop at the last cycle's frequency, within `tolerancePct` (5 % of `ratedW` by default, a setting of the check, not a value of the standard), and `response`, the time from the frequency leaving the deadband to 90 % of the power change, against `responseTime`. For a frequency step that time is the open-loop response time; a ramp adds its own duration. The `verdict` is `pass`, `fail`, `incomplete` (the run ended before the response time and before the power reached 90 % of its change) or `notRequired` (the frequency stayed in the deadband). On `microgridIslanding` set up as for the ride-through check, with `G1` `fDev` 0.5 and `fRate` 50, the PV inverter keeps its 6 kW and fails: the droop asks 0.155 pu less at 60.5 Hz. Scale its current references by the droop of the loop's frequency `wpv` (an `expr` block per phase) and it passes. ## Volt-var reactive power (IEEE 1547) `analysis.voltVar` (**Analysis › Volt-VAR Check**) checks the reactive power an inverter delivers through a grid voltage change in the last run against the voltage-reactive power (volt-var) mode of IEEE Std 1547-2018, clause 5.3.3 and Table 8. Change the grid's voltage (`G1` `sagDepth`, `sagStart`, `sagEnd`; a negative depth is a swell), and give the phase-to-neutral voltages (`voltages`), the inverter's phase currents out of it in the same order (`currents`) and its nameplate apparent power (`ratedVA`, the base of the per-unit reactive power; there is no default). The voltage and the reactive power are one value per nominal cycle: the applicable voltage is the mean of the phases' rms over the nominal phase voltage (`vll`/√3), and the reactive power is positive when the inverter injects it (its current lags the voltage). The curve is piecewise linear through (V1, Q1) to (V4, Q4), flat outside, with its voltages shifted by `vRef` − 1. `category` picks Table 8's defaults: Category A 0.90, 1.00, 1.00, 1.10 p.u. with ±0.25 pu and a 10 s open-loop response time; Category B (the default) 0.92, 0.98, 1.02, 1.08 p.u. with ±0.44 pu and 5 s. They were taken from EPRI OpenDER (listed in `sources`): check them against the standard. `v1` to `v4`, `q1` to `q4` and `responseTime` replace them. The check reports `reactive`, the last cycle's reactive power against the curve at the last cycle's voltage, within `tolerancePct` (5 % of `ratedVA` by default, a setting of the check, not a value of the standard), and `response`, the time from `disturbanceAt` (default the grid's `sagStart`) to 90 % of the reactive power change, against `responseTime`. The `verdict` is `pass`, `fail`, or `incomplete` when the change is still under way as the run ends before the response time. On `microgridIslanding` at 60 Hz with its breaker kept closed and `G1` `sagDepth` 0.05 from 0.5 s, the bus settles near 0.95 p.u. and Category B asks about 0.2 pu of injection: the PV inverter as shipped injects none and fails. Drive its q-axis current from the bus voltage's d component through the curve (`srfPll`, `abc2dq`, an `expr` and `dq2abc` blocks) and it passes. ## Volt-watt active power (IEEE 1547) `analysis.voltWatt` (**Analysis › Volt-Watt Check**) checks the active power an inverter delivers through a grid voltage rise in the last run against the voltage-active power (volt-watt) mode of IEEE Std 1547-2018, clause 5.4.2 and Table 10. Raise the grid's voltage (`G1` `sagDepth` negative, `sagStart`, `sagEnd`), and give the phase-to-neutral voltages (`voltages`), the inverter's phase currents out of it in the same order (`currents`) and its rated active power (`ratedW`, the base of the per-unit curve; there is no default). The voltage and the active power are one value per nominal cycle, as for the volt-var check. The curve is a power limit: P1 at V1 and below, P2 at V2 and above, linear between, and the inverter delivers the lesser of the limit and the power it has available (`availableW`, default its power before the change). Table 10's defaults, the same for Category A and B, are V1 1.06 p.u., P1 1.0, V2 1.10 p.u., P2 the lesser of 0.2 and the inverter's least active power over its rating (`pMinW`, default 0), and a 10 s open-loop response time. They were taken from EPRI OpenDER (listed in `sources`): check them against the standard. `v1`, `p1`, `v2`, `p2` and `responseTime` replace them. The check reports `power`, the last cycle's active power against what the curve allows at the last cycle's voltage, within `tolerancePct` (5 % of `ratedW` by default, a setting of the check, not a value of the standard), and `response`, the time from `disturbanceAt` (default the grid's `sagStart`) to 90 % of the power change, against `responseTime`. The `verdict` is `pass`, `fail`, or `incomplete` when the change is still under way as the run ends before the response time. On `microgridIslanding` at 60 Hz with its breaker kept closed and `G1` `sagDepth` −0.1 from 0.5 s, the bus settles between 1.06 and 1.10 p.u. and the curve limits the 6 kW PV inverter to part of its output: as shipped it keeps its current, so its power rises, and it fails. Limit its d-axis current through the curve from the bus voltage's d component (`srfPll`, `abc2dq`, an `expr` and `dq2abc` blocks) and it passes. ## Constant power factor (IEEE 1547) `analysis.constantPf` (**Analysis › Constant Power Factor Check**) checks the reactive power an inverter exchanges in the last run against the constant power factor mode of IEEE Std 1547-2018, clause 5.3.2. Give the phase-to-neutral voltages (`voltages`), the inverter's phase currents out of it in the same order (`currents`), its rated apparent power (`ratedVA`, the base of the tolerance; there is no default), the power factor setting (`pf`, 0.1 to 1) and its excitation (`excitation`, `absorbing` or `injecting`). The active and reactive power are one value per nominal cycle, as for the volt-var check, and reactive power is positive when the inverter injects. At the setting the inverter's reactive power is ±P·√(1 − pf²)/pf of its active power P, negative when absorbing. The defaults, unity, absorbing and a 5 s response time, were taken from EPRI OpenDER (listed in `sources`): check them against the standard. The check reports `reactive`, the last cycle's reactive power against the setting at the last cycle's active power, within `tolerancePct` (5 % of `ratedVA` by default, a setting of the check, not a value of the standard), and `response`, the time from `disturbanceAt` (when the setting or the active power changes; default the grid's `sagStart`) to 90 % of the reactive power change, against `responseTime`. Without a change the response is `notRun` and only the last cycle counts. The `verdict` is `pass`, `fail`, or `incomplete` when the change is still under way as the run ends before the response time. On `microgridIslanding` at 60 Hz with its breaker kept closed and a setting of 0.9 absorbing from 0.5 s, the 6 kW PV inverter as shipped stays at unity and fails. Give it a q-axis current of √(1 − 0.9²)/0.9 of its d-axis current from 0.5 s (`srfPll`, `constant`, an `expr` of `time` and `dq2abc` blocks) and it absorbs about 2.9 kvar and passes. ## Watt-var (IEEE 1547) `analysis.wattVar` (**Analysis › Watt-Var Check**) checks the reactive power an inverter exchanges in the last run against the active power-reactive power (watt-var) mode of IEEE Std 1547-2018, clause 5.3.4. Give the phase-to-neutral voltages (`voltages`), the inverter's phase currents out of it in the same order (`currents`), its rated active power (`ratedW`, the base of the curve's P) and its rated apparent power (`ratedVA`, the base of the curve's Q and of the tolerance); neither has a default. The curve has three points: `p1`, `p2`, `p3` per unit of `ratedW` and `q1`, `q2`, `q3` per unit of `ratedVA`, positive when the inverter injects. Below P1 it holds Q1, above P3 it holds Q3, and it is linear between. Table 9's defaults are P1 the greater of 0.2 and `pMinW`/`ratedW`, P2 0.5, P3 1, Q1 = Q2 = 0, and Q3 −0.25 for `category` A or −0.44 for B (the default), with a 5 s response time; they were taken from EPRI OpenDER (listed in `sources`): check them against the standard. When the last cycle takes active power (a battery charging), the curve's charging side applies: `p1Load`, `p2Load`, `p3Load` (P'1 to P'3, per unit of `ratedChargeW`, the rated charge power, from 0 down to −1) and `q1Load`, `q2Load`, `q3Load` (Q'1 to Q'3). Their defaults, from EPRI OpenDER too, are P'1 0, P'2 −0.5, P'3 −1, Q'1 equal to Q1, Q'2 0 and Q'3 0.44 (injecting); between P'1 and P1 the curve is linear, and below P'3 it holds Q'3. A charging last cycle without `ratedChargeW` is refused. The check reports `reactive`, the last cycle's reactive power against the curve at the last cycle's active power, within `tolerancePct` (5 % of `ratedVA` by default, a setting of the check, not a value of the standard), and `response`, the time from `disturbanceAt` (when the mode is enabled or the active power changes; default the grid's `sagStart`) to 90 % of the reactive power change, against `responseTime`. Without a change the response is `notRun` and only the last cycle counts. The `verdict` is `pass`, `fail`, or `incomplete` when the change is still under way as the run ends before the response time. On `microgridIslanding` at 60 Hz with its breaker kept closed and the mode enabled at 0.5 s (`ratedW` and `ratedVA` 6000), the 6 kW PV inverter runs near its rating, where the Category B curve asks it to absorb about 0.44 of 6 kVA. As shipped it stays at unity and fails. Give it a q-axis current of 0.44 of its d-axis current from 0.5 s (`srfPll`, `constant`, an `expr` of `time` and `dq2abc` blocks) and it passes. ## Constant reactive power (IEEE 1547) `analysis.constantQ` (**Analysis › Constant Reactive Power Check**) checks the reactive power an inverter exchanges in the last run against the constant reactive power mode of IEEE Std 1547-2018, clause 5.3.5. Give the phase-to-neutral voltages (`voltages`), the inverter's phase currents out of it in the same order (`currents`), its rated apparent power (`ratedVA`, the base of the setting and of the tolerance; there is no default) and the setting (`qSet`, −1 to 1 per unit of `ratedVA`, positive when the inverter injects). The setting asks the same reactive power whatever the active power; keep it within the inverter's nameplate reactive power ratings, which the check does not know. The active and reactive power are one value per nominal cycle, as for the volt-var check. The defaults, 0 pu and a 5 s response time, were taken from EPRI OpenDER (listed in `sources`): check them against the standard. The check reports `reactive`, the last cycle's reactive power against `qSet`·`ratedVA`, within `tolerancePct` (5 % of `ratedVA` by default, a setting of the check, not a value of the standard), and `response`, the time from `disturbanceAt` (when the mode is enabled or the setting changes; default the grid's `sagStart`) to 90 % of the reactive power change, against `responseTime`. Without a change the response is `notRun` and only the last cycle counts. The `verdict` is `pass`, `fail`, or `incomplete` when the change is still under way as the run ends before the response time. On `microgridIslanding` at 60 Hz with its breaker kept closed and a setting of −0.25 pu (absorbing 1.5 kvar of 6 kVA) from 0.5 s, the 6 kW PV inverter as shipped stays at unity and fails. Give it a q-axis current of 0.25 of its rated d-axis current from 0.5 s (`srfPll`, `constant`, an `expr` of `time` and `dq2abc` blocks) and it passes. ## Phase-angle jump ride-through (IEEE 1547) `analysis.phaseJumpRideThrough` (**Analysis › Phase-Jump Ride-Through Check**) checks whether an inverter rode through a jump of the grid's phase angle in the last run, as IEEE Std 1547-2018 clause 6.5.2.6 asks. Make the grid jump with the `grid3` parameters `jumpDeg` (degrees, positive leads), `jumpAt` (s) and `jumpPhases` (the phases it touches, `abc` by default), and give the phase-to-neutral voltages in the order a, b, c (`voltages`) and the inverter's phase currents in the same order (`currents`); `disturbanceAt` defaults to the grid's `jumpAt`. Each phase's angle change is that of its one-cycle fundamental phasor after the jump against the cycle before it, each an eighth of a cycle clear of it, and the positive-sequence change is that of (Va + a·Vb + a²·Vc)/3. The clause asks a three-phase inverter to ride through positive-sequence changes of up to 20° while each phase changes by less than 60°, and a single-phase one changes of up to 60°; beyond them the `verdict` is `notRequired`. Positively damped current oscillations, or a momentary cessation of at most 0.5 s, are acceptable. The check reports `angle`, `cessation` (the longest stretch with the one-cycle rms current at or below `ceaseShare`, 1 % of the pre-jump current by default, against 0.5 s; it must end) and `damped` (the largest deviation of the current from its pre-jump value is smaller over the second half of the rest of the run than over the first, or within `settleShare`, 5 %). Both shares are settings of the check, not values of the standard, and the clause text was taken from a reproduction (listed in `sources`): check it against the standard. The `verdict` is `pass`, `fail` or `incomplete` (the run ended before the check could judge it). On `microgridIslanding` set to 60 Hz with its breaker kept closed and `G1` `jumpDeg` 15 at `jumpAt` 0.5 s, the grid's terminals see the full 15° but the bus, behind the 1 mH feeder, sees about 12°, so measure where the inverter connects. The PV inverter re-locks and passes. Cut its current references one cycle after the jump (a `step` block times each reference) and it ceases for good and fails; a 30° jump asks nothing. ## Voltage trip (IEEE 1547) `analysis.voltageTrip` (**Analysis › Voltage Trip Check**) checks whether an inverter ceased to energize and tripped in time on an abnormal grid voltage in the last run, as IEEE Std 1547-2018 clause 6.4.1 asks. Sag or swell the grid as for the ride-through check (`grid3` `sagDepth`, `sagStart`, `sagEnd`), give the phase-to-neutral voltages (`voltages`) and the inverter's phase currents in the same order (`currents`), and its category (`category`, `I`, `II` or `III`, Tables 11, 12 and 13). Each of the four shall-trip functions has a threshold and a clearing time: OV2 (1.20 p.u., 0.16 s, fixed), OV1 (1.10 p.u.; 2 s, or 13 s in Category III), UV1 (0.70 p.u. for 2 s in Category I or 10 s in Category II; 0.88 p.u. for 21 s in Category III) and UV2 (0.45 p.u. for 0.16 s; 0.50 p.u. for 2 s in Category III). The Area EPS operator may set other values within the table's ranges of allowable settings: give them as `tripSettings`, for example `{"uv1": {"pu": 0.88, "s": 2}}`; a value outside the range is refused with the range. An undervoltage function reads the least one-cycle rms phase voltage and an overvoltage one the greatest. A function asks for the trip once its voltage has stayed beyond the threshold for the whole clearing time; of those, the earliest deadline decides (`trip`). The inverter counts as ceased once its one-cycle rms current stays at or below `ceaseShare` (1 % of the pre-disturbance current, a setting of the check, not of the standard). The `verdict` is `pass` when it ceased within the clearing time, `fail` when it ceased later or still energizes at the deadline, `incomplete` when the run ends before the deadline (run longer), and `notRequired` when no voltage stayed beyond a threshold for its clearing time; whether it then had to ride through is `analysis.rideThrough`'s question. The table values were taken from a reproduction of Tables 11 to 13 (listed in `sources`): check them against the standard. Frequency tripping (Table 18) is `analysis.frequencyTrip`; reconnection is not checked. On `microgridIslanding` with its breaker kept closed and `G1` sagging to 0.3 p.u. (`sagDepth` 0.7) at 0.5 s, UV2 asks the PV inverter to stop within 0.16 s. It has no voltage trip and keeps its current, so the check fails; a sag to 0.6 p.u. for 0.3 s asks no trip of a Category II inverter. ## Frequency trip (IEEE 1547) `analysis.frequencyTrip` (**Analysis › Frequency Trip Check**) checks whether an inverter ceased to energize and tripped in time on an abnormal grid frequency in the last run, as IEEE Std 1547-2018 clause 6.5.1 asks. Move the grid frequency as for the frequency ride-through check (`grid3` `fDev`, `fStart`, `fEnd`, `fRate`) and give the phase-to-neutral voltages (`voltages`) and the inverter's phase currents in the same order (`currents`). Table 18 is the same for every category and is written in hertz for a 60 Hz system, so the fundamental must be 60 Hz. The four shall-trip functions and their defaults are OF2 (62.0 Hz, 0.16 s), OF1 (61.2 Hz, 300 s), UF1 (58.5 Hz, 300 s) and UF2 (56.5 Hz, 0.16 s). The Area EPS operator may set other values within the table's ranges of allowable settings: give them as `tripSettings`, for example `{"uf1": {"hz": 59, "s": 180}}`; a value outside the range is refused with the range. The frequency is measured on the first voltage, one value per cycle, and the clause applies only while some phase is above 30 % of its nominal voltage. A function asks for the trip once the frequency has stayed beyond it for the whole clearing time; of those, the earliest deadline decides (`trip`). The inverter counts as ceased once its one-cycle rms current stays at or below `ceaseShare` (1 % of the pre-disturbance current, a setting of the check). The `verdict` is `pass`, `fail`, `incomplete` or `notRequired`, as for the voltage trip check. The table values were taken from a reproduction of Table 18 (listed in `sources`): check them against the standard. Reconnection is `analysis.returnToService`'s. On `microgridIslanding` at 60 Hz with its breaker kept closed and `G1` stepped to 62.5 Hz (`fDev` 2.5) at 0.5 s, OF2 asks the PV inverter to stop within 0.16 s. As shipped it keeps its current and fails; with a latched frequency trip on its phase-locked loop it ceases at once and passes. The same step back after 0.1 s (`fEnd` 0.6) asks no trip. ## Return to service (IEEE 1547) `analysis.returnToService` (**Analysis › Return to Service Check**) checks how an inverter came back after a trip in the last run, as IEEE Std 1547-2018 clause 6.6 asks through clause 4.10.2: it may energize again only once the applicable voltage and the frequency are inside the enter-service ranges of Table 4, and after the return-to-service delay. Give the phase-to-neutral voltages (`voltages`) and the inverter's phase currents in the same order (`currents`). Table 4 is the same for every category and is written in hertz for a 60 Hz system, so the fundamental must be 60 Hz. The default ranges are 0.917 to 1.05 p.u. and 59.5 to 60.1 Hz. The Area EPS operator may set others within the table's ranges of allowable settings: give them as `enterService`, for example `{"vMinPu": 0.88, "fMaxHz": 60.5}`; a value outside the range is refused with the range. The delay (`delayS`) defaults to 300 s and is counted from when the voltage and the frequency came back inside the ranges; a simulation seldom runs that long, so give the delay the inverter's logic uses. The inverter counts as ceased while its one-cycle rms current is at or below `ceaseShare` (1 % of the greatest in the five cycles before, a setting of the check) and as returned once it rises above that again. The `verdict` is `pass` when it returned inside the ranges after the delay, `fail` when it returned outside them (`checks` `range`) or sooner (`checks` `delay`), `notReturned` when it stays ceased to the end of the run (`permittedAt` says when it could first have returned), and `notRequired` when it never ceased. The table values and the 300 s default were taken from a reproduction (listed in `sources`): check them against the standard. With `permitService: false` (the operator's permit service setting disabled) the inverter must stay ceased: staying ceased passes and any return fails (`checks` `permit`). Give `ramp` to check the ramp-up after the return as well (clause 4.10.3 c): the active output must rise linearly or in a stepwise linear ramp to full output over `periodS` (default 300 s), with steps of no more than 20 % of the rating (`ratedVA`; without it the apparent output before the trip stands in, which is stricter when the inverter ran below its rating). `checks` `step` holds the greatest rise within a cycle, and `ramp` how far the output runs ahead of the straight line to full output, where one 20 % step is allowed. Either over 20 % fails the verdict. The 300 s and 20 % values were taken from a restatement of the clause (listed in `sources`). `ramp` is only checked when given. A small inverter may instead enter service after a randomized delay (clause 4.10.3): once the ranges have held for the delay, it waits a further random time up to `maxS`. Give `randomDelay` `{"maxS": 120}` to check it: `maxS` is 1 to 1000 s, and the option is refused together with `ramp` or for an inverter of 500 kVA or more (`ratedVA`, or else the apparent output before the trip). A single run cannot check the random draw, so the check holds the return to its window: `checks` `random` holds how long past the delay it returned (`randomDelay.extraS`), which must be 0 to `maxS`, and `randomDelay.latestAt` says when it should have returned at the latest. These values were taken from an open implementation of the clause (EPRI OpenDER 2.2.0, listed in `sources`). On `microgridIslanding` at 60 Hz with its breaker kept closed and `G1` at 62.5 Hz from 0.5 s to 0.8 s (`fDev` 2.5, `fEnd` 0.8), a latched frequency trip stops the PV inverter at once. Released at 1.1 s, about 0.25 s after the measured frequency is back inside the range, it passes a 0.2 s delay and fails a 0.4 s one; released at 0.65 s, while the grid is still at 62.5 Hz, it fails the range. Asked to ramp up, the instant return fails its full-power step (`stepPct` about 100); with its enable ramped over 0.15 s the output rises about 11 % per cycle, so it passes `{"ramp": {"periodS": 0.15}}` and fails a 0.3 s ramp for running about 42 % ahead of the line. With `delayS` 0 and `{"randomDelay": {"maxS": 1}}`, the release at 1.1 s passes, and one at 2.2 s, about 1.35 s after the frequency came back, fails as too late. ## dq impedance and the weak-grid check `analysis.dqImpedance` (**Analysis › dq Impedance**) measures a three-phase converter's output impedance in the dq frame (Zdd, Zdq, Zqd, Zqq) and its positive- and negative-sequence impedance, from small-signal injections at its three terminals. The form starts on the circuit's three-phase grid (or the selected part with pins a, b and c) as **Three-phase part**, and at that grid's frequency as **Grid frequency**; give **Terminal nets** instead to name the three nets yourself. Under **Grid impedance**, give the grid inductance, or a **Short-circuit ratio** (one or several) with the **Rated line voltage** and **Rated power**, and the grid resistance or its X/R ratio: the check then reports, for each case, the margin of the eigenloci of Zgrid·Yconverter, whether the system is stable, and the critical SCR below which the margin turns negative. The linear method works at the converter's operating point, with its switches in the states you give, and leaves out the PLL's frequency coupling. The perturbation method measures the switched converter on the transient solver around its grid-periodic operating point, PLL and dq control included, so Zdd and Zqq differ. With it, **Three-phase part** names the grid source the converter hangs on. The result window draws Zdd, Zdq, Zqd and Zqq as a Bode plot (magnitude in ohms and phase). It writes one line per grid case, green when stable and red when not, with the margin and the frequency it is read at, then the critical SCR. Under them is the generalised Nyquist plot: the two eigenloci of Zgrid·Yconverter for each case, their mirrors for negative frequencies, the unit circle and −1. A stable system's loci never encircle −1. ## Conducted EMI and the input filter `emi.conducted` (**Design › Automate › Conducted EMI**) is a pre-compliance estimate, not a compliance measurement. It puts a LISN (50 µH, 0.1 µF, 50 Ω) on a copy of the circuit on the input, runs it, and reads peak, quasi-peak and average through a 9 kHz receiver model against CISPR 32 class A or B (`limit`). When the supply's return is not the ground node, both lines get a LISN and the reply splits the result into differential mode (`before.dm`) and common mode (`before.cm`). The [conducted EMI tutorial](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/09-conducted-emi/) walks through it. The input is the circuit's DC voltage source, or, when it has none, its sine source: an AC mains input such as a diode bridge and PFC (`source` names it when there are several). On an AC input the LISN goes on L and N, the run settles for whole mains periods (`tSettle` is rounded up), and then reads 8 windows of whole switching periods at equal phases of the next mains period, since the switching changes over the mains cycle. The receiver envelopes of the 8 windows are joined: peak is the largest, average the mean and quasi-peak the detector's value over the mains period. Each window must fit in an eighth of the mains period (2.5 ms at 50 Hz). `before.inputVoltageV` and `inputCurrentA` are then RMS values (`inputRms`), the filter capacitors start uncharged, and the touch-current limit is held at the source's own frequency and voltage unless `mainsHz` and `mainsV` say otherwise. Each limit in `crates/engine/src/emi/limits.json` names its document, the artificial network it is measured with (`lisn`) and the receiver bandwidth (`rbwHz`), each with its source; the reply's `setup` repeats them. The limits are: | `limit` | Standard | Port | Detectors | Network, receiver | |---|---|---|---|---| | `cispr32A`, `cispr32B` | CISPR 32:2015 Annex A | AC mains | quasi-peak, average | 50 µH / 50 Ω, 9 kHz | | `cispr11A`, `cispr11B` | CISPR 11:2015+A2:2019 group 1 (class A up to 20 kVA) | AC mains | quasi-peak, average | 50 µH / 50 Ω, 9 kHz | | `cispr25Class1` … `cispr25Class5` | CISPR 25 Ed. 5 (2021), voltage method | DC supply line | peak, average, quasi-peak | 5 µH + 1 Ω / 50 Ω, 9 kHz | **The CISPR 11 and CISPR 25 values come from secondary sources** (articles that reproduce the standards' tables; `limit.source` names them) **and were not checked against the standards' text.** The reply marks them `"provenance": "secondary"` and a note says so; check them against the standard before relying on a margin. CISPR 11 class A above 20 kVA is not included (its values were not found). CISPR 25 applies only inside its broadcast bands (nothing between them); its quasi-peak line comes from one source only, and its bands above 30 MHz are in the file but not assessed, because the conducted measurement ends at 30 MHz. Its network's sources give no coupling capacitor, so Voltecx couples the receiver through a DC block (1 % of 50 Ω at 150 kHz) and says so. Where a limit gives a peak line, the peak reading is held to it; otherwise peak is only a screen against the quasi-peak line. MIL-STD-461G CE102 is not included: its limit is a figure whose breakpoints are not available. The limits are the mains-port tables, so an AC input is measured as they intend; a DC input held to them is a pre-compliance screen, and a note says so. When the margin is below `targetMarginDb` (6 dB), it sizes a filter, measures again with it and, with `"apply": true`, inserts it in one undo step: - **Differential mode:** one or two damped LC stages, held to Middlebrook's condition against the converter's input impedance (`zinOhm`, or the measured V/I). - **Common mode** (two LISNs and a path to ground): a common-mode choke in both lines and a Y capacitor from each line to ground. The Y capacitors are limited by your product's safety standard, so Voltecx needs that limit and has no default: give `yCapMax` (farads per line), or `touchCurrent` with `mainsHz` and `mainsV` (it then allows `touchCurrent/(2π·mainsHz·mainsV)` per line). The choke is a catalogue part (`parts/common_mode_chokes.json`, each row read from its data sheet) whose worst-case common-mode inductance reaches the corner; the Y capacitor is the largest catalogue Y2 part under the limit. The choke's stray inductance stays in the differential path. With a common-mode stage the LC stages are sized from the differential readings only. ```json {"limit": "cispr32B", "touchCurrent": "", "mainsHz": 50, "mainsV": 230, "apply": true} ``` The reply's `filter.commonMode` names the choke and Y capacitor with their data sheets, and `improvementCmDb` and `improvementDmDb` give the gain in each mode. Without a limit a note says so and only the LC stages are sized. When no catalogue choke reaches the inductance, the stage takes the rated choke with the most (`commonMode.reaches` is false) and the measurement shows what it falls short by. **The filter is built from real parts.** The LC stages are not ideal values: each element is a catalogue part, chosen with the same rules `bom.export` uses, and the filter is sized again around it. | Element | Catalogue | What the circuit gets | |---|---|---| | Series inductor | Coilcraft XAL and AGP4233 (the parts library's inductors, `crates/library/data/inductor.ndjson`), at or above the inductance, rated for the input current (RMS at a 40 K rise, peak under the saturation current, with `analysis.stress`'s derating) | the set's inductance, its typical DCR (`dcr`) and the part number (`part`, `2 × XAL7070-472MEC` for two in series) | | Line capacitors on a DC input | `parts/capacitors.json`, as many in parallel as reach the capacitance left at the input voltage's DC bias; a part with a published self-resonant frequency first | the capacitance at the DC bias, the data-sheet ESR and the part number | | Line capacitors on an AC input | X2 film from `parts/safety_capacitors.json` | the capacitance, the ESR from the data sheet's dissipation factor and the part number | | Damping resistor | the nearest E96 value of a Vishay chip-resistor family | the E96 value | With the real L and C the corner, the damping and Middlebrook's check are worked out again. `filter.catalogue` lists each part with its data sheet, its self-resonant frequency (`srfHz`) and the ESL or winding capacitance that follows from it; an element no catalogue part reaches stays ideal and is listed under `catalogue.missing` with the reason. `filter.insertionLoss` gives the LC stages' insertion loss from 1 to 30 MHz with ideal parts and with the parts' ESR, DCR, ESL and winding capacitance: above the parts' SRF the filter stops gaining, and the measurement with `parasitics` on (below) uses the same elements, so the margin in the upper bands is the parts' own. **Sized until it meets the target.** The filter is measured, and while its margin misses `targetMarginDb` it is sized again for what it lacked (a second LC stage when one is not enough, a larger choke), up to four rounds; `rounds` lists each. `pass` is true only when the worst margin meets the target, Middlebrook's check passes and the loop keeps its phase margin. With `"apply": true` a filter that misses any of these is **not** applied: `applied` stays false and `applyRefused` says what fell short and what to change (raise `yCapMax` if the safety standard allows, relax the target, fix the coupling at the source). **A DC input drawn with its return on ground** has no common-mode path, because the LISNs use ground as the chassis. Give `cChassis`, the switch node's (or heat sink's) capacitance to the chassis, and the measured copies are drawn as the board stands on the bench: the converter's return moves to its own net, `cChassis` joins `chassisNode` (default the switch node of `layout.hints`) to ground, both lines get a LISN, and the reply splits `before.cm` and `before.dm`. An AC input whose bridge sits on the ground node is lifted the same way; without `cChassis` a note says its common mode reads far too high. Your circuit is never changed by this. A common-mode stage cannot be drawn into a circuit whose return is the ground node, so `apply` is then refused with that reason: draw the return as its own net first. ```json {"cChassis": "50p", "yCapMax": "4.7n", "apply": true} ``` **The loop with the filter.** With `apply` (or `pmMinDeg`) the command measures `analysis.loopGain` on copies of the circuit without and with the filter (whole fractions of fsw between fsw/200 and fsw/5) and runs a load step on each (the load resistor halved half-way through the run). `loopPmBefore` and `loopPmAfter` are the phase margins; below `pmMinDeg` (the call's, else the stored design spec's, else 45°) the filter is refused. `stability.zoCurve` is the filter's |Zo(f)| to hold against `stability.zinOhm`. A circuit without a pi or tf block driving its PWM has no loop to measure, and a note says so. `"loopCheck": false` skips the measurement. **A measured scan.** `measured` overlays a receiver's or spectrum analyser's export on the limit and the prediction: `{"csv": ""}` or `{"path": "scan.csv"}`, with the `detector` it was taken with (`peak`, `qp` or `av`). Each line holds a frequency (Hz, or MHz or kHz when the header says so) and a level in dBµV. `measured.bands` gives each band's measured and predicted worst margin and their difference (`deltaDb`, positive when the prediction was optimistic). ## Devices: vendor parts and your own datasheet tables The device library holds two kinds of built-in parts. A generic device is an illustrative set of values for a class of part. A vendor part is a real part number whose values were read from the manufacturer's datasheet. `library.deviceModels` and `library.search` mark every device as `vendor`, `generic` or `user`. The library panel shows the manufacturer in front of a vendor part. Every vendor part carries its source: the manufacturer, the datasheet URL, the revision, and the figures or tables the values came from. The curves were digitised coarsely, and the notes of the part say how and under which test conditions. Some datasheets give a curve at one temperature only. The notes then say so. ### IGBT power modules The library also holds IGBT power modules: half bridges (Infineon EconoDUAL 3, 650 V to 1700 V, 300 A to 900 A) and six-packs (EconoPACK 3, EasyPACK 1B and 2B, 25 A to 100 A). A module is an `igbt` device with a `module` field: its `topology` (`halfBridge` or `sixPack`), its `package`, and its switch positions with the pins of each collector, emitter, gate and auxiliary emitter, as the data sheet's circuit diagram shows them. The loss tables are those of one IGBT and its diode, and every position of the case has them: the output characteristic at VGE = 15 V, Eon and Eoff over the collector current, the diode's forward characteristic and its Erec, each at the data sheet's temperatures, and the IGBT's Foster chain from the r/τ table of its transient thermal impedance figure. `rthCh` is the case-to-heat-sink resistance per IGBT with the data sheet's grease. A module without a baseplate (EasyPACK) is rated junction to heat sink, so its chain already ends at the heat sink: `chainToHeatsink` is true and it has no `rthCh`. `library.search` with `"module": true` lists only modules, with `false` only discrete parts; each row has `module` (null for a discrete part). To use a module, give its id to the IGBTs of a leg or bridge, and to their anti-parallel diodes: a diode that names an IGBT device takes that device's diode tables. `design.parts` ranks modules with the discrete IGBTs and names the module it proposes in `module`. The library has discrete IGBTs too (TRENCHSTOP 7 and 5, 650 V and 1200 V, TO-247). Their energies are given at one temperature (175 °C) as curves; the 25 °C energies are table values only, and the notes say so. Where a data sheet's curve and its table differ, the notes give both. MOSFETs from Taiwanese makers cover synchronous rectification, point-of-load and PFC: Advanced Power Electronics (APEC) at 40, 60, 80, 100 and 650 V, PANJIT at 30, 100 and 650 V, and Excelliance MOS at 60 and 80 V, Niko-Sem at 40, 60, 80 and 100 V, and Sinopower at 30, 40, 60 and 100 V. Their data sheets give no switching energy, so these parts carry gate and output charges instead. SiC MOSFETs span 650 V to 3300 V: onsemi EliteSiC at 650 V, 1200 V and 1700 V, ROHM at 650 V (SCT3060AL), 1200 V (SCT4036KE) and 1700 V (SCT2H12NZ, a 1.15 Ω part for auxiliary supplies), and a GeneSiC 3300 V part. An onsemi part whose sheet gives its energies only in the table carries that one point at the table's voltage and current; the others carry the curves of their figures. The ROHM sheets print a three-stage Foster network, which the parts carry as printed, and say their Eon includes the body diode's recovery. The SCT2H12NZ carries no body-diode curve: its figure and its table disagree by 15 % at the table's current, and the notes say so. To bring a part of your own, write its datasheet tables as CSV text and run `device.import`: ```json {"command": "device.import", "params": {"format": "csv", "name": "mine/part-1", "text": "..."}} ``` `device.export` writes any library part in the same layout, which is the easiest way to see an example. `"format": "json"` takes the Voltecx device JSON instead. The import reads the text strictly. A bad table is refused with a message that names the line. The part then goes through the same checks as `device.validate`, and it is added to the open circuit, or to the session library when no circuit is open. The text is a list of rows. Blank lines and lines that start with `#` are ignored. The rows about the part come first. Each one is a name, a comma and a value, and the value is the rest of the line, so it may hold commas: `id`, `kind` (`mosfet`, `igbt` or `diode`), `manufacturer`, `part`, `source`, `vMax` in volts, `iMax` in amperes, `notes` and, when the datasheet gives them, `tjMax`, the highest junction temperature in °C, `vgsMax`, the gate-source (gate-emitter) rating in volts, and `vgsMin`, its negative limit in volts (below zero, given only with `vgsMax`); `vgsOn`, the turn-on gate voltage the datasheet recommends, in volts (`design.gateDrive` then drives the switch at it unless the circuit sets `von`); `module`, a power module's case and pinout as one line of JSON (the `module` field of the device JSON); and `lineRectifier,true` for a standard-recovery mains rectifier, which `device.recommend` and `design.parts` give only to a diode reverse-biased at mains rate (a bridge diode), and take first there. The `source` row is required, and it should say which datasheet, revision and date the numbers come from. The tables come next. A row `section,` starts a table, and the row after it names the columns. The unit is part of each column name, so a value in the wrong unit cannot be read as the right one. | Section | Columns | One curve per | |---|---|---| | `conduction`, `diodeConduction` | `tj_c`, `i_a`, `v_v` (or `v_mv`) | temperature | | `switching` | `tj_c`, `v_v`, `i_a`, and any of `eon_j`, `eoff_j`, `err_j` (or `_mj`, `_uj`) | test voltage and temperature, for each energy | | `thermal` | `r_k_per_w`, `tau_s` (or `tau_ms`, `tau_us`) | one Foster stage per row | In a `switching` table, leave a cell empty when a row has no value for that energy. A `thermal` table may instead have the single column `rth_jc_k_per_w` with one row. The import then assumes a time constant of 1 ms and adds a line to the notes that says so. Currents must rise along a curve. Values are plain numbers with no unit text. The limits are 256 KiB of text, 5000 data rows, 200 points per curve, 10 thermal stages and 16 temperatures. Many low-voltage MOSFET datasheets give no switching energies. For such a part, add a `charges` section with one row and any of the columns `qg_c`, `qgs_c`, `qgd_c`, `qsw_c`, `qgth_c`, `qoss_c` (or `_nc`), `coss_pf` with `vcoss_v`, `vplateau_v`, `vth_v`, `gfs_s`, `rgint_ohm`, `qgvgs_v` (the gate voltage `qg` was measured at) and `qg2_c` (or `qg2_nc`) with `qg2vgs_v` (a second total charge at another gate voltage). With `qgvgs_v` and either the second charge or the plateau with `qgs` and `qgd`, Qg can be scaled to another drive voltage along the straight part of the gate-charge curve above the plateau. When `eOn` and `eOff` are both empty, the loss commands estimate them from these charges with the gate-charge method. The gate current is set by the driver voltage, the plateau and the gate resistance (external plus internal). The switching time is Qsw over that current, and the energy is V·I·t/2, plus Qoss·V at turn-on. The driver is the MOSFET's `von`, `voff`, `rgon` and `rgoff` when the circuit sets them, otherwise 10 V, 0 V and 2 Ω. Every loss report says when it used this estimate. A vendor's PLECS thermal description file (`.xml`, the format PLECS reads for loss and thermal data) imports with `"format": "plecs-xml"`: its switching-energy and conduction tables and its Foster or Cauer junction-to-case chain become the device's tables (a Cauer ladder becomes the Foster chain with the same impedance). The file carries no voltage or current rating, so give `vMax` and `iMax` from the data sheet. The reply's `warnings` list what was not mapped: tables computed with a formula (kept as tabulated, the formula and its variables are not applied), curves at 0 V, points below 0 A, and any element the reader does not know. Details are in `docs/formats/plecs-thermal.md`. ```json {"command": "device.import", "params": {"format": "plecs-xml", "text": "", "rgOn": 10, ...}` runs the double-pulse bench on one library MOSFET or GaN HEMT in a scratch circuit (the open circuit is never touched) and compares the simulated turn-on and turn-off energies with the data sheet's Eon and Eoff tables. The device needs gate data and those tables. Give the gate resistor `rgOn` (and `rgOff`), and the data sheet's test gate voltage `vgsOn`/`vgsOff` when the part states no recommended one; the command refuses to guess it (a GaN part with a 7 V gate rating does not get the 15 V default). `v`, `i` and `tj` default to the first Eon curve's voltage, current points (at most 8) and temperature. `lStray` is the power-loop inductance (default 0, the ideal-board limit), `lcs` the common-source inductance of the gate loop, and `qrr`/`trr` the body-diode recovery from its data sheet. The reply holds, per current, `eOnSim`/`eOnTable`/`eOnErr` and `eOffSim`/`eOffTable`/`eOffErr` (joules; an error is a fraction, simulated minus table over table). Read the errors: a large one means the gate drive or the loop inductance you gave is not the one behind the table, not that the part is wrong. `sweep {"lStray": [...]}` or `{"rgOn": [...]}` (at most 8 values) repeats the run per value, which shows how much a board's loop inductance or a gate resistor costs in switching energy. ## Radiated EMI **Design › Automate › Radiated EMI** (`emi.radiated`) is a pre-compliance estimate, not a measurement: use it to see how far you are from the limit and which layout change helps most, then measure. It estimates the field from 30 MHz to 1 GHz with Paul's formulas: the switch node driving its capacitance to the chassis and the cable as a common-mode antenna, and the hot loop as a small loop, against CISPR 32 class A or B. The form takes the limit, the distance (3 m or 10 m) and the board's numbers. Leave a field empty to take the circuit's value: the swing and the loop current come from the first hot loop of `layout.hints`, and the switch node's capacitance to the chassis is the sum of the capacitors drawn from the switch node to ground when the input's return is not ground (ground is then the chassis, as with two LISNs). The loop area (1 cm²), the capacitance to the chassis (10 pF) and the cable length (1 m) are typical values when nothing gives them. **A switch on a heat sink.** A MOSFET, IGBT or diode whose tab pin is a hot loop's switch node (the tab is a MOSFET's drain, an IGBT's collector and a diode's cathode, as their data sheets draw it; a boost's diode, with its anode on the switch node, has its tab on the quiet output) and whose case sits on a heat sink through an insulating pad couples the switch node to the heat sink through its tab. Draw the thermal network (the switch's `thermal` net, an `rth` to the case, an `rth` for the pad with its library `part`, then a `heatsink`; `design.thermal {apply: true}` draws all of it, the pad's `part` being the interface it picked) and the estimate takes the tab's capacitance, ε0·εr·A/d: the pad's dielectric constant and thickness from its data sheet, and the package's largest exposed tab from its outline drawing (TO-247). `inputs.cSwSource` is `heatsink`, and `commonMode` has a row with `via: "tab"` naming the switch, the pad and the heat sink. With a routed board the tabs add to the chassis fills. The heat sink is taken as earthed; if it floats, give `cSw`. A grease, a pad the library does not hold, or a package with no tab size is named in a note and left out. The result window shows the verdict first, then **Assumed values** in an amber box: each value the estimate did not get from you or the circuit, with a field. Type the board's value (`40u` for 40 mm², `22p`, `2`) and press **Run Again**. Below it, **Inputs** says where every number came from (given, layout hints, the circuit, the input source, assumed). With a routed board, **Hot loops at** the worst line lists each loop in the differential-mode sum (power and gate loops) with its area, peak current, where that current came from (**Current from**: given, layout hints, same as the first hot loop, or the run) and field, and a gate loop names the switch it drives, and **Common-mode paths at** that line lists each switch node's path to a chassis fill or, through a switch's tab, a heat sink, with its capacitance, swing and field; both tables are largest first, and a row the simulation left out of the sum says **Not in the sum**. **Cables and connectors** lists where each cable leaves the board, nearest the switch node first: the connector, its nets, its role (input, load or other), the board side and the distance from its nearest pad to the switch node's copper. It does not change the estimate, which still uses the cable length in **Inputs**. **Layout changes** lists the changes that raise the worst margin most. ### From the routed board Give the routed board and the estimate reads it through `layout.extract`: `path` (a `.kicad_pcb` of this circuit), `text` (its text) or `board` (a Voltecx `.vxpcb` text). Then: - **Every power loop counts.** The loop area is the sum of every complete power loop on the board, each weighted by its own current: `iLoop` when you give one, else that loop's own peak current from `layout.hints`, matched by the loop's name, else the first hot loop's current, with a note naming the loop. `loops` lists each loop with its area, its current and where that came from, and its own field at the worst line. - **Gate loops, with the driver's current.** Give `iGate`, the gate driver's peak current from its data sheet, and every complete gate loop joins the sum as a loop of its own (kind `gate`). Without it, a current run whose switches have a modelled gate (a MOSFET at the dynamic level) gives each gate loop its own switch's peak gate current: the current the driver puts into the gate, `i(.cgs) − i(.cgd)`, at its peak over the run's second half (`currentSource` `run`, `inputs.iGateSource` `run`, and `switch` on the row). With the switches driven as signals, or with no current run, the gate loops are left out. The gate pulse is taken with the power loop's duty and edge, so the gate loops' share is an upper bound. - **Common mode from the copper.** The switch node's capacitance to the chassis is the parallel-plate capacitance of every hot loop's switch-node copper to a chassis or heat-sink fill, summed. The fill is `chassisNet`, else any net named PE or starting with CHASSIS, EARTH, HEATSINK or SHIELD. `commonMode` has one row per switch node and fill: its capacitance, its swing, and its share of the common-mode current and field. - **Each leg at its own timing.** When the last run recorded `v()` for each of those switch nodes, each node's frequency, phase and duty are read off the run (`inputs.cmTiming` is `simulated`; the duty is the time above half the swing, `legDuty`, and replaces the request's `duty` for that node's trapezoid): legs in antiphase cancel at the odd harmonics, complementary legs (one high while the other is low, as in a full bridge) cancel at every harmonic, and a leg that switches slowly, such as a totem-pole's line-frequency leg, adds no line at the switching harmonics. Without such a run the nodes are added in phase, the worst case (`inPhase`). - **A slow leg's loop leaves the differential-mode sum.** The same run gives each power loop in `loops` its `switchNode`, `timing`, `legHz` and `inSum`. A loop whose switch node switches below half the switching frequency, or not at all, carries no current at the switching harmonics: it leaves the loop-area sum (`inSum: false`, no field of its own) and a note names it. The loops left in the sum add as phasors when the board and the run say how: - **Loops with their phase and their direction.** Each power row also gets `phaseDeg`, its leg's phase, and `circulation` (+1 or −1): which way its current change goes round the board at the switch node's rising edge. The direction comes from the order of the loop's parts in `layout.extract`, the rails' mean voltages in the run and the inductor current's sign at every rising edge. When every loop in the sum has both, the loops add as phasors (`inputs.dmTiming` is `simulated`), each loop's current pulse at its own leg's duty (`legDuty`): two legs in antiphase whose loops are drawn as mirror images cancel at the even harmonics, and two drawn alike cancel at the odd ones. The cancellation shrinks as the frequency rises, since the loops sit apart on the board: the estimate adds k·Σ|z|ρ (k = 2πf/c, |z| each loop's weighted area, ρ its distance from the loops' common centre), so it is never below the field in any direction, and never above the amplitude sum (the array factor, Balanis, *Antenna Theory*, 3rd ed., chapter 6). Otherwise (no run, a loop with no inductor on its switch node, or an inverter leg whose current changes sign over the line period) the loops are added in amplitude, the worst case (`amplitude`). - **Where the cables leave.** With a routed board (a KiCad board, or Voltecx's own `.vxpcb` given as `board` or by its `path`), `cables` lists each connector where a cable leaves the board, its role (input, load or other) and its distance to the switch node's copper, nearest first. It does not change the estimate: the board does not say how long the cable is, so `cableLength` stays yours or assumed. ### Near-field map of the board `emi.nearField` maps the magnetic near field over the routed board, to see which loop to fix before you take a probe to it. The board window's **Near field** button draws the same map on the board (chapter 22). - **The sources.** Each complete power loop from `layout.extract` is its own copper path carrying its own current: `iLoop`, else its peak current from `layout.hints`, matched by name. Gate loops carry `iGate`; without it, a current run whose switches have a modelled gate (a MOSFET at the dynamic level) gives each gate loop its own switch's peak gate current, as in `emi.radiated` (`currentSource` `run`, with a note that the gate loops' field is then an upper bound). With neither, the gate loops are listed in `skipped`. - **The field.** The quasi-static Biot–Savart field of each loop's straight pieces (Griffiths, *Introduction to Electrodynamics*, example 5.5) on a plane `heightMm` above the top copper. The default 10 mm is an assumed probe height, not a standard's. The current is the loop's trapezoid at one switching harmonic (Paul, section 3.2): `fHz` takes the harmonic nearest it, by default the first at or above 30 MHz, where the CISPR 32 radiated scan starts. - **Off a null of the spectrum.** The trapezoid's spectrum is zero at every harmonic n where n times the duty is a whole number (at 50 % duty, every even harmonic). When the default harmonic falls in such a null, the map moves to the strongest harmonic of the lobe it starts, and `steppedFromHarmonic` and a note give the harmonic it moved from. When the loops take their own legs' duties from the run (two or more add as phasors), the null is looked for in their spectra at those duties, each at its own peak current and added in amplitude: a harmonic is a null only where every loop's own spectrum is, and the note names the duties. A harmonic counts as a null when it is more than 20 dB below that strongest one: a threshold of Voltecx's own, not a standard's. A harmonic you ask for with `fHz` is kept; when it is in a null, a note names the strongest harmonic near it, since the map then shows far less than the board radiates around that frequency. - **Loops with their phase and their direction.** With a current run, each power row in `loops` also gets `switchNode`, `timing`, `legHz`, `phaseDeg`, `circulation` and `legDuty`, read as for `emi.radiated` above, and `phasor` says whether it was added as a phasor. A power loop whose leg switches at the switching frequency and whose current's way round the board the run resolves adds as a phasor: each axis of the field sums the loops' fields turned by their phases at the map's harmonic, and the cell takes the length of that vector. Near the board, loops that share a part can add where their far fields cancel, so read this map, not `emi.radiated`, for where to probe. `dmTiming` is `simulated` when two or more loops add this way, and then each of those loops' current pulse takes its own leg's duty (`legDuty`) instead of the request's `duty`, as in `emi.radiated`: complementary legs (one high while the other is low) cancel at every harmonic, not only at the odd ones; `harmonicA` is each loop's own line. A loop whose leg switches below half the switching frequency, or not at all, carries no current at the map's harmonic and is listed in `skipped`. - **An upper bound for the rest.** Gate loops, and power loops whose phase or direction the run does not resolve, add in amplitude on top of that sum: the worst case for them. Without a run every loop does, and `dmTiming` is `amplitude`. - **The reply.** `levelsDbuam` is the map in dB(µA/m), `dominant` each cell's strongest loop, `hotSpots` the local maxima (strongest first, each with its loop and that loop's share), `loops` each loop with its own peak, its field straight above its centre and its far field at `distanceM` (Paul's small loop), `cables` each cable connector of the board (as `emi.radiated` lists them) with the map's field over it, its strongest loop there and how far it is under the map's strongest cell, strongest first, since a cable that leaves where the field is strong carries it off the board, and `skipped` the loops it could not map and why. It is an estimate, not a scan, and it changes nothing. ## Debugging tools `circuit.problems` (the list in **Problems**) checks the circuit for mistakes: a missing ground, floating or unconnected pins, undriven gates, a half bridge without dead time, each with its fixes. `{"compile": true}` adds the reference solver's compile report (nodes, unknowns, warnings). With `{"run": true}` it also runs a short simulation to look for shoot-through, ringing, growing oscillation, a saturated controller and parts over their rating. `circuit.diagnose` and `circuit.check` still answer for older scripts, as aliases of these two forms. `fault.*` inserts an open, a short, a stuck switch or a drifting value so you can see what a failure does. `waveform.compare` lines up your simulation with a measurement, and `debug.fitToMeasurement` moves the values you list (an inductance, an ESR, a dead time) until the simulation matches it. `debug.locateFault` takes the same measurement and ranks the faults that would explain it: it injects each candidate fault into a copy of the circuit, simulates it, and reports the best match only when it beats the circuit without a fault. The guide, organised by symptom, is [`docs/workflows/debugging.md`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/workflows/debugging/). ## Faults at a time and fuse coordination **Analysis › Faults › Inject Fault** (`fault.inject`) also places a fault that appears part-way through the run: give `at` in seconds and an open, short or ground fault becomes an ideal switch driven by a step block, so one run shows the circuit working, the fault and what the protection does about it. Besides a part (`component`, with `port` for the terminal), a fault can go on nets: `{"net": "a", "kind": "ground"}` shorts net `a` to ground (net `0`), and `{"between": ["a", "b"], "kind": "short"}` shorts two nets together. `value` is the fault's resistance (1 mΩ for a short or ground fault, 1 GΩ for an open). The fault parts are named `Fault_…`, show on the schematic and go away with one undo or **Clear Faults**, which takes a part or a net. **Analysis › Faults › Fuse Coordination** (`protection.fuseCoordination`) checks two fuses in series: the one nearer the load must clear a fault before the one upstream of it melts. Name the two fuse parts (or give each fuse's melting I²t and minimum melting current). It sweeps the fault current and compares the two melting times of the fuse model (the overcurrent check), and compares the downstream fuse's operating I²t with the upstream fuse's melting I²t (the short-circuit check). The fuse model has no arc, so the operating I²t, pre-arcing plus arcing, comes from the downstream fuse's data sheet (`operatingI2t`); without it the result is **unchecked**, never a pass. Then prove it in simulation: inject a short at a time behind the downstream fuse and run; the warnings name the fuse that opened. **Analysis › Faults › Protection Coordination** (`protection.coordination`) does the same check for any pair of fuses and circuit breakers. Each side is a fuse or breaker part (a breaker needs `itrip` and trips after `tdelay`), or figures: `{i2t, imin}` for a fuse, `{itrip, tdelay}` for a definite-time breaker, or `{curve, rating}` for a miniature breaker with curve B, C or D to IEC 60898-1 (Table 7, up to 125 A). The standard gives test points, not one curve, so the check uses bounds: at each fault current the upstream device's earliest operating time must come after the downstream device's latest. Set `iMax` to the prospective short-circuit current at the fault. Above an upstream miniature breaker's instantaneous range (5 In for C) the standard promises no selectivity; only the manufacturer's selectivity tables can. With an upstream fuse, give the downstream device's let-through I²t from its data sheet (`letThroughI2t`); without it the result is **unchecked**. **Analysis › Faults › DESAT Short-Circuit Check** (`protection.desat`) says whether a gate driver's desaturation detector clears a hard short of a power switch before the switch's short-circuit withstand time runs out. Give the bus voltage `vdc`, the power-loop inductance `lLoop`, the detector threshold `vDesat`, the switch's on-state `ron` (and `vCe0` for an IGBT), the blanking time `tBlank`, `tFilter` and the turn-off delay `tOffDelay`; add `isc` (saturation current), `tScWithstand`, `tFall` and `vMax` from the switch data sheet to get the verdict. It returns the detection and short times, the peak current, an energy bound, the withstand margin and the turn-off spike against `vMax`. The loop current is a linear ramp (resistance ignored), so the peak is an upper bound; the model is the one in TI SLUA618A, and every figure is yours (none is assumed). It changes nothing in the circuit. **Analysis › Faults › Active Short Circuit Check** (`protection.activeShort`) says what a permanent-magnet motor does when a drive fault makes the inverter short its three phases, and whether that or turning every switch off is the safe state. Give the machine's `rs`, `ld`, `lq`, `psif` and `poles` and the speed `rpm`; add the current before the fault (`id0`, `iq0`), the bus voltage `vdc`, the peak current the switches and the machine allow (`iMax`) and the d-axis current that starts demagnetising the magnets (`idDemag`). It returns the steady short current (which tends to `psif/ld` at speed), the braking torque and copper loss, the transient's peak current, its most negative d-axis current and the largest braking torque, and with `vdc` the line-to-line back EMF and the speed above which pulse-off charges the bus through the diodes (`safeState`). The speed is held constant and the inductances are linear (no saturation); the model is the dq one in Jahns and Caliskan (IEEE Trans. Ind. Appl., 1999). Every figure is yours (none is assumed). It changes nothing in the circuit. **Analysis › Faults › DC Arc Fault** (`protection.arcFault`) says whether a series arc (a loose connector or a broken conductor in a PV string or a battery bus) keeps burning. Give the source voltage `vSource`, the loop resistance `rLoop`, the arc length `gap` and the Ayrton coefficients `ayrton: {a, b, c, d}` (V_arc = a + b·L + (c + d·L)/I, Ayrton 1902). The coefficients depend on the electrodes and the current range, so none is assumed: use the set from the source you trust. The reply gives the stable arc current, its voltage and power, the energy over `duration`, the lowest source voltage that sustains this gap (`minSourceVoltage`), and with `tripCurrent` whether the overcurrent protection would see it. The arc is quasi-static: it has no strike or extinction transient. **Analysis › Battery Ageing** (`battery.age`) says how much capacity a lithium-ion cell has lost and how much its resistance has grown after `days` of storage and cycling: the cell temperature `temp` (0 to 55 °C), the depth of each cycle `dod`, `cyclesPerDay`, and the cell's average rest voltage `voc` (4.2 V for a cell stored full). The model is NREL's graphite/NMC life model (Smith et al., NREL/CP-5400-67102, 2017): calendar fade with the square root of time, lithium and electrode sites lost with cycles, and resistance growth. It answers as the battery's state of health `soh` (capacity left, a share of new) and resistance growth `rAge`; with `component` and `apply: true` it sets both on that battery, one undo step, so the next run sees the aged cell. Give `soc` (the charge the cell is stored at, or the top of each cycle, 0 to 1) and the negative electrode's potential follows it, from a graphite open-circuit curve (Safari and Delacourt, J. Electrochem. Soc. 158(5), A562, 2011): a cell kept at 65 % ages much slower than a full one, as in the paper's 45 °C storage tests. Without `soc` the state of charge acts only through `voc`, so a cell cycled about mid charge comes out more aged than it is; past the 300 days of the ageing tests the reply says the result is an extrapolation. With `fromRun: true` and `component`, the stress comes from the last run instead (`simulation.run` or **Simulation › Long Battery Run**): the battery's state of charge is rainflow counted as one period of a repeating mission, so `dod` is its deepest swing and every swing counts as cycles of that depth in proportion to its own; `voc` is the time mean of its cell's rest voltage; `temp` is the mean temperature of its `thermal` net, or else its own `temp` (a `temp` in the call wins). `period` says how much calendar time one run stands for, at least the run's length: a 2 s test cycle that the product sees twice a day is `period: 43200`. Add `soc: "run"` and the negative electrode's potential follows the recorded state of charge, its effect averaged over the run's time: the same graphite curve as a hand `soc`, so a cell cycled about mid charge comes out less aged than with the full-charge reference. The reply's `fromRun` lists what was read (`deepest`, `cyclesPerDay`, `meanSoc`, `voc`, `temp` and where it came from, and `socFromRun`). **Analysis › Fit Battery Impedance Spectrum** (`battery.fitImpedance`) turns a measured impedance spectrum (EIS) into the battery's cell model. Give the points as `points` (`[[Hz, Re Z, Im Z], ...]`, Im Z negative on the capacitive arc, the frequencies in sweep order) or a file: a CSV or whitespace table whose header names the frequency and the real and imaginary parts (`freq/Hz`, `Re(Z)/Ohm`, `-Im(Z)/Ohm` as EC-Lab writes them; `Zreal`, `Zimag`; `Z'`, `Z''`; in Ω or mΩ), or a one-port Touchstone file of Z or S parameters. It fits `r0`, `rcPairs` parallel RC pairs (1 to 3, default 2) and, with `inductance: true`, the lead inductance, by complex nonlinear least squares with each point weighted by its measured size (Macdonald and Garber, J. Electrochem. Soc. 124(7), 1977; Boukamp, Solid State Ionics 20, 1986). Every value stays positive and inside bounds set by the measured band. The reply gives the battery's `r0`, `r1`, `c1`, `r2`, `c2`, each pair's time constant and corner frequency, how far each value can move (`SpreadPct`), the error at every frequency, and the measured and fitted spectra to plot. `flags` names any value the spectrum does not pin down: a time constant at the edge of the band, or a pair the data does not need. With `component` and `apply: true` the values go on that battery, one undo step; `perCell: true` scales them when you measured one cell of an `ns`-cell battery. Too few points, a frequency out of order or a value that is not a finite number is refused, naming the point. ## Parasitic elements in the conducted EMI estimate With ideal parts, the conducted estimate is optimistic from about 5 to 30 MHz: a real capacitor's ESL, an inductor's winding capacitance and a switch's Coss let noise through there. Tick **Parasitic elements** on the Conducted EMI form (`"parasitics": true`) to put them on the measured copy, never on your circuit. They come from your circuit's own `esr`, `esl` and `coss`, from **Parasitic values** (data-sheet values by part name, such as `{"Cin": {"esl": "2n"}, "L1": {"srf": "30Meg"}}`), from the capacitor catalogue's ESR (`{"Cin": {"mpn": ""}}`), from the self-resonant frequency of the catalogue part a capacitor or inductor names in its `part` (an ESL or a winding capacitance; Murata ceramic capacitors and the Coilcraft inductors publish one), or from the assigned device's Coss table. The filter's own parts take theirs the same way. Nothing is assumed: a part with no value is listed as skipped, with what to give. The notes compare the worst margin with and without the parasitics. Chapter 16 lists every key. ## Explain a circuit (beta) `circuit.explain` reads a circuit you did not draw (imported from LTspice, for example) and says, without simulating, what it is: the topology (buck, boost, flyback, bridge, inverter, LLC, motor drive and more) with a confidence, the role of each part (`S1: high-side switch`), and the main loops and the operating point. Use `{"detail": "full"}` for the long form. --- # 7. The Design panel (beta) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/07-design-panel/ > **Beta.** The Design panel was developed on a branch that had not been merged when this release was > prepared. If your build has no **Design** menu, it is not in your build yet. Everything else in this > manual works without it. The command names and the shape of the replies may change. Sizing a power stage often means jumping between tools: a spreadsheet for L and C, a script for the compensator, a simulation to check the ripple, another for the temperature. Then you copy the numbers into the circuit by hand and hope you copied them right. The Design panel puts these steps in one place. Each task does the same five things: 1. **Reads your circuit.** The fields start filled with the voltage, inductance, load and switching frequency already in the circuit. You change only what you want to change. A small note beside each field says where its value came from: the circuit, a default, your own input, or a calculation. 2. **Gives one main number**, for example the inductance, the crossover frequency or the efficiency. 3. **Draws one plot** of the result. 4. **Explains the formula in plain words**, in English and Traditional Chinese: which equation, why these defaults, and the textbook it comes from. 5. **Applies and verifies.** **Apply** writes the result into the circuit as *one undo step*. Then it checks the result by simulation or by an independent calculation. If the check fails, it tells you what to change next. ## Open it Choose **Design** from the menu bar, or press **Cmd+Shift+D**. The Design page opens in the editor area, as a tab beside the circuit's tab, with the tasks listed on its left. The side bar and Properties step aside while it is in front and come back with the schematic; the bottom panel keeps a compact strip of the latest result. Pick a task, check the fields, press **Run** to see the result and the plot, and press **Apply** to write it into the circuit. Fields in the **Advanced** fold are rarely needed. On a wide window the spec form and the result sit side by side and scroll on their own, so the form stays in view while you read the result; on a narrow one the result goes under the form and ends with **Back to spec**, which scrolls back up to it. An empty field means "use the value in the circuit, or the default". Opening the panel never shows an error. When a task needs a value the circuit does not give (no load resistor found, say), its field turns red, reads **needed**, and a line under the form says what to do: type the value, or select the part that sets it and press **Run**. A delay is counted in sample periods: `0.5` beside **× sample period** means half a sample period. **Run** is the panel's blue main button. ## The tasks | Task | Command | What it gives you | Apply writes | |---|---|---|---| | Converter | `design.converter` | Inductor and capacitor for buck, boost and inverting buck-boost, plus a switching-frequency hint | L1 and C1 values, the duty cycle (open loop), the frequency if you gave one | | LLC Tank | `design.llc` | Turns ratio, Lr, Cr and Lm of an LLC for an input range, by first-harmonic approximation. Also the gain curves at full and lightest load, fmin and fmax, and a check that the magnetising current swings each leg within the dead time | The tank, the PWM frequency, the nominal input, the load and the output capacitor of the LLC in the circuit | | Voltage loop | `design.voltageLoop` | A compensator for a voltage-mode loop: PI, or Type II or Type III; with `mode` peakCurrent, the slope compensation and Type II network of a peak-current-mode loop | For a PI, the block's `kp` and `ki`. For Type II or III, a `tf` block in place of the PI | | Current loop | `design.currentLoop` | The d and q current PIs of a drive (pole-zero cancellation), or of a grid-tie inverter (L1 + L2 of its filter, PI zero a decade below the crossover) | `kp` and `ki` of both PIs | | Speed loop | `design.speedLoop` | The speed PI (symmetrical optimum) | `kp` and `ki` of the speed PI | | Efficiency | `design.efficiency` | An efficiency curve over load, and the loss split at full load | Nothing | | Thermal | `design.thermal` | The junction temperature of each switch and diode, and the heat-sink thermal resistance you need | The cooling it picked as a thermal network (heatsinks, pads or board copper, one ambient), when the circuit has none yet | | Parts | `design.parts` | Candidate parts from the library, ranked by estimated loss, for each switch and diode; a part rated more than 2.5 times its voltage stress, or one whose gate plateau the switch's `von` does not clear, is proposed only when nothing else fits; the switches of a full bridge get one device | Nothing | | Magnetics | `magnetics.design` | An inductor or transformer from the core catalogue: the part kind, the limits (peak flux over saturation, hottest, window fill, ambient), the winding order and whether cores rank by size or loss. **Core** lists the cores that meet every limit, the best first, and why the others failed; **Build sheet for the winder** and **Check in FEMM** open those commands | The part's inductance, resistances and core loss | | Protection | `design.protection` | The current, over-voltage and under-voltage trips, the sense shunt and the soft start, from the spec (lowest and highest input, output, full load). **Current sense** says what it senses with and why, and what the shunt loses at each point; **Make a test plan** opens `design.testPlan` | Nothing | ![Magnetics on the buck example, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/design-panel/07-magnetics.png) 1. The winding order. 2. The build sheet for the winder, under the cores that fit. ## Example: size a buck converter 1. Open the `buck` example, or make one with `circuit.template`. 2. Open the Design panel and choose **Converter**. ![The Design menu, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/design-panel/01-menu.png) 1. Design. 2. Converter. 3. Check the fields. The panel read `vout` and `iout` from the circuit. Set `ripplePct` to 30 if you accept more current ripple. Leave the rest. ![The Converter task, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/design-panel/02-fields.png) 1. The task. 2. A value read from the circuit. 3. Inductor ripple set to 30. 4. Run. 4. Press **Run**. You see the inductor and capacitor, the formulas (`L = (Vin - Vout) * D / (fsw * dI)`, and so on) and the plot. 5. Press **Apply**. L1 and C1 change, and the duty cycle is set so the output equals `vout`. Press **Cmd+Z** (or **Edit > Undo**, which names the step) if you do not like it. 6. Read the verification. It simulates a short run and checks that the inductor ripple and the output ripple are within 15 % of the target, and that the mean output is within 5 % of `vout`. If it fails, the message names the new value to try. ![After Apply, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/design-panel/03-verified.png) 1. The verdict. 2. The changes written. 3. Each check with its measured value and target. With 30 % ripple the buck gets L = 60 µH and C = 15.63 µF; the measured inductor ripple is 1.50 A against a 1.73 A limit. ## Reading the Parts table The **Parts** task lists one row per switch and diode: the chosen device, the voltage the part saw (**Stress**), the device's rating (**Rated**), the **Margin** of that rating over the derated need (red when it falls short) and the estimated **Loss**. Hover the **?** at the end of a row for what to check on the data sheet before you buy that device, such as Rds(on) at the hot junction temperature, Qg and Qgd, or a diode's reverse recovery. Click a part's name to select it on the schematic. The Auto Design result window shows the same parts, with their margin and the same **?**. Below it, **Capacitors and inductors** lists the catalogue part the BOM picks for each one (the same choice as File › Export › Bill of materials), how many, and the margin of the rating that limits it: voltage or ripple current for a capacitor, saturation or RMS current for an inductor (hover the margin to see which). A ceramic capacitor's count already allows for the capacitance it loses at the DC voltage. The **?** lists what to check on that part's data sheet. ## Reading the Efficiency and Thermal results **Efficiency** sweeps the load (**Sweep**: from, to, points), or under **Weighting** runs the European or CEC load points instead and adds the weighted efficiency. Under the plot, **Where … goes** splits the full-load loss by part and by kind (switching, conduction, core, copper, ESR and other), and names the largest single loss. **Rank switches by loss** opens the Parts task; **Sweep the frequency** opens the parameter sweep. **Efficiency at each point** lists the plot's numbers, with **Copy as CSV**. ![Efficiency on the buck example, marked 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/design-panel/05-losses.png) 1. The advice on the largest loss. **Thermal** takes the ambient, the junction limit and the airflow (**Still air**, **1 m/s** or **2 m/s**: each heatsink curve is read from its data sheet at that airflow). **Junction temperatures with the picked cooling** gives each switch and diode its package, loss, the heatsink or board copper picked, its sink-to-air resistance, the junction temperature and the margin to the limit. **Show thermal overlay** tints the parts on the schematic by temperature. ![Thermal on the buck example, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/design-panel/06-cooling.png) 1. The airflow. 2. Each junction with its cooling. The losses of an inverter, a motor drive or a PFC are averaged over whole line periods, taken from the AC source or from the modulator (a sine reference, or the angle of a dq current loop), so the switches of one leg read the same loss. A device that has no thermal net is simulated again with its loss tables read at the junction temperature the first run gave, until no junction moves by 1 K, so a hotter ambient raises the losses as well as the temperatures. Each device is held to its own limit: its data sheet's maximum junction temperature less 25 K (a 175 °C part to 150 °C), unless you or the design spec give `tjMax`. Without a heatsink of your own, the headline is the hottest junction on the cooling picked. **Modules, one shared heatsink, extrusions and fans.** A power module (an EasyPACK or EconoDUAL from the device library) goes with the rest of its switches on an extruded heatsink: the lightest catalogue profile and cut length on which every junction stays within its limit, with its mass. Its footprint and the area its heat leaves through come from the module's outline drawing, and its case-to-heatsink resistance from its own data sheet. `design.thermal {cooling: {shared: true}}` puts every device a heatsink can take (or the `devices` you list) on one bar: each junction then carries the other devices' heat (`mutualK`) and the spreading of its own source into the base (`spreadingK`), so the hottest junction is higher than the same device alone on that bar. With an airflow, the fan is the lightest catalogue fan whose operating point (its data sheet's pressure against flow, meeting the pressure drop of the fins computed from the profile's drawing) reaches it, and the reply gives the flow, the pressure and the air speed. `cooling.tim` picks the interface: an insulating pad (the default), a grease (for a TO-247, the greased value its data sheet cites; it does not insulate) or a phase-change material. `thermal.placeHeatsink {part, lengthMm, airflow}` places an extrusion on the schematic, and `bom.export {cooling}` lists the extrusion cut to length, the fan and each interface. A heatsink part placed on the schematic is in the thermal simulation only, never in the electrical one, and `bom.export` lists it under its own name with its catalogue data sheet. So is a thermal pad: an `rth` part whose `part` names a catalogue interface material (a pad, a grease or a phase-change material) is listed under its own name with that material's data sheet. **Load profiles.** `design.thermal {profile: [{t, loadPct, fOut, vdc}]}` runs an overload, a mission profile or a motor stall and gives every junction over time, its peak, when it happens, and when a junction first passes its limit. Each step lasts `t` seconds at `loadPct` % of the circuit as drawn (the variable that sets the load is `loadVar`, `Iref` by default) and at the output frequency `fOut`. Instead of simulating the whole profile, it maps each device's loss over the line period from a few short runs and steps the circuit's own thermal network through the profile, from the rated thermal steady state. On `inverter3Thermal`, 150 % for 10 s and then 200 % at 1 Hz for 2 s takes seconds and agrees with the full simulation of the same profile within 3 K. The profile is a command parameter: give it from the console, the command line or the AI assistant. ## Notes for the loop tasks - The voltage-loop task builds a model of the converter (the duty-to-output transfer function), picks the compensator to reach the crossover frequency `fc` and phase margin `pm` you ask for (defaults: one tenth of the switching frequency, 60 degrees), and then checks it three ways: the model, the loop gain measured on your circuit by perturbation, and a 50 % load step. - A PI cannot cross above the LC resonance of a buck, because the phase there is near -180 degrees and a PI can only lag. With `controller` left at `auto`, the task tries a PI and, when that cannot meet the target, switches to Type III and says so. Applying a Type II or Type III result replaces the PI that drives the PWM with a `tf` block of the same name and connections, holding the compensator's transfer function; a `tf` block already there only gets new coefficients. The `tf` keeps the PI's output limits, which also stop its integrator from winding up on start-up or a large step, though not the PI's gains. On an open loop, with no PI to retype, the inserted network gets the same 0 to 0.9 duty clamp a PI would. One undo brings the PI back. - Under the Bode plot, **Corner check** reads the same compensator again, without redesigning it, at the design point, at the lowest and highest input and load you give under **Operating range**, and with L and C both 20 % low and both 20 % high (**L and C tolerance** in **Advanced**). Each row gives the damping Q, the crossover, both margins and **Pass** or the margin it misses. When a corner fails, **Open Robust Loop** opens `design.robustLoop`, which moves the design until every corner passes. ![The voltage loop of `buckClosedLoop`, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/design-panel/04-corner-check.png) 1. The corner check. 2. The marker under Run. - **Peak current mode.** `design.voltageLoop {"mode": "peakCurrent"}` (from a script or the assistant; the panel's form runs voltage mode) designs the loop of a buck, boost, buck-boost, SEPIC or flyback whose switch turns off when the sensed current plus a compensation ramp reaches the error amplifier's output. On a circuit with a `pcmModulator` it reads the clock, the ramp and the sense gain from the modulator and the network from the op-amp on its VC pin. It first sets the ramp: the sampled current loop has a double pole at half the switching frequency with Qp = 1/(π·(mc·D' − 0.5)), mc = 1 + Se/Sn (R. B. Ridley, IEEE Trans. Power Electronics 6(2), 1991; TI SLUS223H Eq. 37 to 41). The recommended ramp gives Qp = 1 at the corner with the highest duty and the lowest inductance, and every corner is listed with its Qp. A ramp that leaves a corner above 50 % duty oscillating at half the switching frequency, or with Qp above 2, gives a subharmonic warning naming the corner. Then it designs a Type II network on the current-mode plant, rounds it to E96 resistors and E12 capacitors, and reads the margin again with the op-amp's own bandwidth: the margin it predicts for `pcmBuckArch` is within a few degrees of the one `spec.verify` measures. Apply writes the network and the ramp in one undo step. Beside the slopes, the Peak current mode card lists the UCx84x parts that give this ramp and sense gain (TI SLUS223H): the sense resistor, RT and CT for the switching frequency, RRAMP and CRAMP that add the ramp from the RT/CT pin, and the RCSF and CCSF filter on CS; they are not written into the circuit. When they cannot be sized, for example at 500 kHz where RT would fall below 5 kΩ, the card says why. - A Type II or Type III result also lists the **Op-amp network values, for the board**: the input, feedback and lead resistors and the zero, pole and lead capacitors of an inverting op-amp stage. - **How it was designed** has its own **English** and **繁體中文** buttons, and **Copy as JSON** copies the whole reply. Under **Run**, *Nothing changed since the design.* means the result still fits the circuit and the fields; after you change a field it says to press **Run**. - The current-loop task takes the least phase and gain margin under **Targets**. On a grid-tie inverter it also shows the **Output filter, read from the circuit** and **Why** its crossover: each crossover the search tried, 10 % lower each step, with both margins, until both hold. - The current-loop and speed-loop tasks check the design on a small model of the plant, not on your whole drive. Test the full drive yourself. ## The Loop Studio **Design › Design Steps › Loop Studio** designs the voltage loop of the open converter with sliders. It uses the same model and compensators as the voltage-loop task and simulates nothing, so everything follows the sliders as you drag. ![The Loop Studio on `buckClosedLoop`: Type III at 5 kHz and 60°](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/design-panel/08-loop-studio.png) - **Steps:** the left column walks the design in five steps: **1. Plant** (a typed plant, the last AC sweep or imported response, or the circuit's own model), **2. Feedback sensor**, **3. Compensator** (the type, fc and the phase margin), **4. PWM modulator** (the carrier) and **5. Solution map** (click the map to pick fc and the margin; with the map's boundary it also gives the highest margin that works at fc). Click a step to go straight to it, or use **Back** and **Next**. The result, **Apply to Circuit**, **Check with a Load Step** and the parts stay under every step. - **Left:** pick **PI**, **Type I** (an integrator and one high-frequency pole, for slow outer loops: it only lags, so it works only below the LC resonance), **Type II**, **Type III** or **Peak current** (a Type II on the peak-current-mode plant, with the ramp of the circuit's current-mode modulator), then the crossover **fc** (a log slider up to fsw/5) and the **Phase margin**. **Result** gives the crossover, the phase margin (green when it meets the target, red when not), the gain margin, the **Modulus margin** (how close the loop's Nyquist locus comes to −1: it bounds the phase and gain margins at once, and is red below 0.5, a sensitivity peak of 6 dB) and fc/fsw, then the **Step overshoot**, **Rise time** (10 % to 90 %) and **Settling time** (to ±2 %) of the closed loop's response to a step of the reference, worked out from the same model with nothing simulated (red when the loop is unstable or does not settle). **Parts** lists the zeros, poles and gain, the resistors and capacitors of the op-amp network (or Kp and Ki of a PI) and, folded, the digital coefficients (Tustin, one sample per switching period). The **Feedback sensor** step takes the feedback sensor's **Sensor gain** (Vref/Vo of a divider: 0.1 asks the compensator for ten times the gain) or, for a current loop (a charger or an LED driver), its **Current-sense gain** in V/A (a shunt times its amplifier's gain, or a Hall sensor's sensitivity; the loop then regulates the load current, and the line under the fields gives the reference that holds it), and **Sensor pole** (type the error amplifier's Vref into **Reference voltage**, and **Gain = Vref/Vo** fills in the sensor gain from the plant's output voltage), and the **PWM modulator** step the PWM carrier's **Carrier peak** and **Carrier valley** (the modulator's gain is 1/(peak − valley)). Type a value with an SI prefix and press Enter; an empty field is unity feedback and a 1 V carrier. With a voltage sensor set, **Apply to Circuit** puts the sensor into the circuit with the compensator: a gain block `HSENSE` (H0) and a pole block `HSENSE_P` between the output's voltmeter and the error sum, and the reference scaled to H0·Vref so the output settles where it did (Erickson and Maksimovic, *Fundamentals of Power Electronics*, 3rd ed., section 9.1); **Check with a Load Step** steps the load on a copy with the sensor in place. A current sensor, peak and average current mode, a PFC and a dual active bridge apply for unity feedback, so with a sensor set both buttons are greyed out there, with the reason on hover; peak current mode takes no carrier. **Plant model** designs on a plant typed as a transfer function instead of the circuit's own model, for a converter Voltecx has no loop model of, or a plant from a paper or another tool: **Numerator** and **Denominator** take the coefficients in descending powers of s, separated by commas or spaces (`48` over `10n, 41.7u, 1` is 48/(10n·s² + 41.7µ·s + 1)). Both are needed; empty goes back to the circuit's model. The typed plant holds its own sensor and modulator, so the feedback fields are greyed out while it is set, and so is **Check with a Load Step**, because a transfer function gives no operating point to step; **Apply to Circuit** still proposes the controller. **Swept plant** designs on a measured response instead: after an **AC sweep** from the control input (the PWM's modulating signal) to the output, or after **File › Import › Measurement** reads a network analyser's CSV, it names the last one (its points and span) and **Use the last sweep as the plant** designs on it, for any converter that can be swept (LLC, phase-shifted full bridge, dual active bridge, forward) or a board on the bench. The sweep stays the plant, whatever is swept or opened later, until **Use the circuit's model**; the switching frequency comes from the circuit's PWM. A sweep already holds the sensor and modulator it went through, so the feedback fields and the typed plant are greyed out while it is used, and so is **Check with a Load Step**; **Apply to Circuit** still proposes the controller. - **Centre:** the Bode plot of the loop, the plant (dashed) and the compensator, with the crossover marked and the phase margin drawn as a bar above −180°. After **Analysis › Loop Gain**, its measured points show on the same plot. **Nyquist** above the plot switches it to the loop in the complex plane (the dashed mirror is the negative frequencies), with the unit circle, the critical point −1 and a circle around it whose radius is the modulus margin; the locus touches that circle where it comes closest. **Step response** switches it to that reference step against time, drawn from the model on every slider move: the final value dotted, the ±2 % settling band dashed, the 10 % to 90 % rise shaded and the settling time a vertical line (a swept or typed plant has no step, and the view says so). **Bode** switches back. **Analysis range** under the switch sets where both plots are drawn: type the **Start frequency** and the **Stop frequency** (SI prefixes, such as `100` and `1M`) and press Enter. Both are needed, lowest first; empty fields are the default, fsw/10 000 to fsw/2, which the fields show greyed. The range moves only the plots: the margins, the map and the step are worked out over their own ranges. Above fsw/2 the plot is still the averaged model, which stops holding near the switching frequency. - **Right:** **Where a design works** is a map of crossover (across, on a log scale) against phase margin (up, from 10° to 85°): the green area is where the type can make the design, with its highest and lowest working margins drawn as curves, the grey is out of its reach, and the accent dot is the design now. Near the LC resonance a type may hold a low margin and a high one but not those between, so the green can come in more than one piece. A cross-hair follows the pointer and the line under the map gives the crossover and margin under it and whether the type works there; click anywhere to try that design (the margin goes to the nearest whole degree). The **Phase margin** slider also goes from 10° to 85°, and both sliders take a typed value. **Why** says what sets the limit: the plant's phase at fc, the phase boost the margin needs and the most the type gives there. - **Apply to Circuit** makes the design a proposal on the schematic; accept it there (one undo step). Retyping a PI to Type II or III keeps the PI's output limits on the `tf`, so the loop does not wind up at start-up or on a large step; an open loop with no PI gets the same 0 to 0.9 duty clamp a PI would. **Apply as Op-Amp Network** (Type II or Type III on the circuit's own buck or boost model) builds the design as the board would have it instead, in one undo step with no proposal: the output's voltmeter, the reference, the error sum and the controller block give way to module `XCOMP`, an inverting op-amp (LM358B values, from a 5 V rail) with the output divider, the network's resistors and capacitors in E96 and E12, and the PWM comparator. **Edit › Undo** takes it out. It is greyed out, with the reason on hover, for the other types, a typed or swept plant and a sensor. **Check with a Load Step** simulates a 50 % load step on a copy of the circuit and shows the dip and the overshoot; for peak current mode it measures the loop on the copy and shows the phase margin. - On a **dual active bridge** the loop sets the phase shift, not a duty: the plant line adds the turns ratio **n** and the operating phase shift **φ**, and Peak current and Average current are greyed out. **Apply to Circuit** takes a **PI** only, and writes its Kp and Ki into the bridge's phase PI (the feed-forward phase and the limits stay); for Type I, II or III it is greyed out, with the reason on hover. **Check with a Load Step** is greyed out there, because the bridge's load step needs a spec: run `design.loopStudio` with `spec`. **Apply as Op-Amp Network** is greyed out on every isolated converter (flyback, forward, phase-shifted full bridge, dual active bridge): an op-amp beside the output cannot drive the primary's PWM across the barrier. - On an isolated **flyback** or **forward**, **Apply as Optocoupler Network** shows under it (Type II on the circuit's own model): the error crosses the barrier the way a board carries it. In one undo step with no proposal, the output's voltmeter, the reference, the error sum and the controller block give way to module `XOPTO`. On the secondary it holds a TL431C, with Rz and Cz from its cathode to REF and the output divider. The TL431 drives a TCET1100 optocoupler's LED through Rled from an RC-filtered output, so the LED path's direct gain does not set the loop. On the primary the phototransistor pulls COMP down against Rpull from a 5 V rail, with Cpole, and a comparator maps COMP from 1 V to 4 V onto the duty. The design follows C. Basso, *Designing Control Loops for Linear and Switching Power Supplies* (Artech House 2012), chapter 5. The resistors are E96 and the capacitors E12. **Edit › Undo** takes it out. The button is greyed out, with the reason on hover, for the other types, a typed or swept plant, a sensor and a phase-shifted bridge (whose loop **Apply to Circuit** writes). `design.loopStudio {apply: true, network: "opto"}` does the same from the CLI or the chat. - On a **phase-shifted full bridge** the model is the full-bridge buck-derived converter, a buck fed from Vin/n with the phase shift as the duty: the plant line adds the turns ratio **n**, and a note under it says that the duty-cycle loss of the series inductance is not in the model (sweep the circuit and design on the swept plant for it). PI, Type I, Type II and Type III design as on a buck, and **Apply to Circuit** writes the design into the block that moves the lagging leg's phase (a Type I, II or III replaces the PI with a `tf` that keeps its limits; the feed-forward duty stays). Peak current and Average current are greyed out. **Check with a Load Step** is greyed out, because the bridge's load step needs a spec: run `design.loopStudio` with `check` and `spec`. **Apply as Op-Amp Network** is greyed out too: the output is across the transformer's isolation barrier from the PWM. - On a **UC3854-class PFC controller** (`multiplierPfcController`, placed with `ic.place`, as in the `uc3854Pfc` example) the IC's own amplifiers close both loops, so the window shows them instead of the type, the sliders and the map. The line on top names the IC, the line voltage and frequency, Vout, the power, L, C and fsw. **Design targets** take the **Current-loop crossover**, **Current-loop margin**, **Voltage-loop crossover** and **Voltage-loop margin**; empty, the loops are read as built from the networks on CAOUT and VAOUT (P. C. Todd, Unitrode U-134). **Design New Values** fills them with the defaults (the current loop at fsw/10, the voltage loop at a tenth of twice the line frequency, both 45°; on a DC line the voltage crossover stays empty for you to type), and **Read As Built** clears them. **Result** gives each loop's crossover, phase margin and gain margin, the current loop's attenuation at fsw and the twice-line ripple VAOUT passes on. With targets set, it adds the **Down-slope / ramp** check (L. H. Dixon, Unitrode U-140: above 1 the current loop goes subharmonic) and the margins after rounding. **Apply Network Values** makes the rounded parts (Rcz, Ccz, Ccp on CAOUT and Rvf ∥ Cvf on VAOUT, E96 and E12) one proposal to accept on the canvas. **Parts** lists the parts as built and as designed. The centre draws both loops' Bode plots, with each crossover and its margin bar. `design.loopStudio {currentCrossoverHz, voltageCrossoverHz, apply: true}` does the same from the CLI or the chat. - On a **UCC28180-class PFC controller** (`ccmPfcController`, as in the `ucc28180Pfc` example) the window is the same, with these differences. CICOMP alone sits on ICOMP, so the current loop's crossover is set by the sense resistor and the inductor, not by CICOMP: CICOMP only places the loop's averaging pole and with it the margin (TI SLUSBQ5D equations 102 and 103). So the current-loop target is **Averaging pole** or **Current-loop margin**, one of the two: typing one clears the other. **Design New Values** puts the pole at the data sheet's 5 kHz (section 9.2.2) and the voltage loop at a tenth of twice the line frequency with 45°. **Result** adds the **Averaging pole**, the **Amplifier linear share** (the share of each switching period the current amplifier stays inside its linear range on the inductor ripple; below 100 % the loop's gain is scaled down) and the **VCOMP ripple**; there is no slope check. **Apply Network Values** proposes CICOMP and RVCOMP, CVCOMP, CVCOMP_P on VCOMP, rounded to E12 and E96. `design.loopStudio {currentAveragingPoleHz, voltageCrossoverHz, apply: true}` does the same from the CLI or the chat. The run card offers **Loop Studio** after a run of a converter with a loop, and the assistant can open it with a type, crossover and margin. From a script, the same numbers come from `design.loopStudio`. ## LED driver **Design › Design Steps › LED Driver** (`design.ledDriver`) sizes a constant-current LED driver from the input, the string (`ns` LEDs in series, `np` strings, each LED's `vth` and `rd` from its data sheet's forward curve) and the LED current `iled`. - **Buck** (the default, the `ledBuckDriver` example): hysteretic current control. It gives L for a switching frequency (or the frequency of a given L), the comparator's band and, with PWM dimming (`dimFreq`, `dimDuty`), the rise and fall of each pulse, the mean current, the shortest duty that still regulates and the percent flicker against IEEE Std 1789-2015. On the example it reads the circuit, and **apply** writes the design in one undo step. - **Boost** (`topology: "boost"`, the `ledBoostDriver` example): a fixed-frequency boost with a PI loop on the LED current. It gives the duty, the inductor current, L for an inductor ripple (`ripplePct`, or give `l`), Cout for an LED current ripple (`ledRipplePct`, or give `cout`), and the boost's averaged current-loop plant: its DC gain, right-half-plane zero and resonance. With the PI's `kp` and `ki` it finds the crossover and the phase margin (verify holds it to 45°). `analogDim` scales the current (and warns when the inductor leaves continuous conduction), and PWM dimming with the disconnect switch gives the mean current and the flicker. On the example it reads its inputs from the circuit; **Apply** writes the input, L, Cout, the reference (through `Ifull` and `Adim`), the PI gains and the PWM frequencies in one undoable step, starts the inductor, the capacitor and the PI at the operating point, and verify simulates the driver and checks the mean LED current within 5 %. ## Wireless power link **Design › Design Steps › Wireless Power Link** (`design.wpt`) sizes an inductive wireless power link at its operating frequency, by first-harmonic analysis. Give the coils (`l1`, `l2`), their coupling `k`, the frequency `f0`, the load (`rload`, or `vout` with `pout`) and either the bridge's DC input `vdc` or the power to deliver `pout`; on the `wptSeriesSeries` example the coils, `k`, `f0`, the load and `vdc` come from the circuit. Choose `topology` `ss` (a series capacitor on each coil), `sp` (the secondary's capacitor across the load) or `lcc` (double-sided LCC: on each side a series inductor `Lf`, given as `lf1` and `lf2`, a capacitor `Cf` across the network and a capacitor in series with the coil; on the `wptDoubleLcc` example they come from the circuit). It gives: - the compensating capacitors `C1` and `C2`: SS tunes each coil alone; SP tunes the primary for this `k`; LCC tunes each `Lf` with its `Cf` and the rest of the coil, `L − Lf`, with `C`, none depending on `k`, so the primary coil carries `V1/(ω·Lf1)` and the rectifier is fed `M·V1/(ω·Lf1·Lf2)` whatever the load; - the coil currents and the peak voltage across each capacitor, the bridge voltage that delivers `pout` (or the power at `vdc`), and the output voltage; - with both coils' quality factors `q1` and `q2`, the coils' resistance `ω·L/Q`, the link efficiency, the figure of merit `U = k·√(Q1·Q2)`, the highest efficiency any load reaches, and the load that reaches it; - a plot of efficiency and output power against `k`, with the capacitors and the bridge voltage held: what a misaligned pad does. An SS link delivers more power as `k` falls. For a link in the circuit, series-series (one capacitor in series with each coil, as in `wptSeriesSeries`), series-parallel (one in series with the primary and one across the secondary, as in `wptSeriesParallel`) or double-sided LCC (as in `wptDoubleLcc`), the topology read from the circuit, **Apply** (`apply: true`) writes the capacitors (for LCC also `Cf1` and `Cf2`), the bridge supply and, when you give `f0`, the PWM frequency in one undoable step. Verification then simulates the circuit with the design written in, and checks the primary and secondary currents (peak of the fundamental) and the power into the load against the design, within 10 %, the accuracy of a first-harmonic analysis. An LCC link's simulated power sits about 8 % below the design: the rectifier's square voltage drives a third harmonic through `Lf2` that a first-harmonic analysis leaves out. The SP primary capacitor is tuned for the present `k`, so run the design again after changing `k`. Without `q1` and `q2` the coils are lossless and a note says so. Take L, k and Q from the coils' measurement or data sheet. **Design › Design Steps › Pad Coupling** (`design.wptCoupling`) gives the coupling of two air-cored circular pads. Describe each pad as a flat spiral: its outer radius `r1Out`, inner radius `r1In` and turns `n1` (pad 2, `r2Out`, `r2In`, `n2`, is the same as pad 1 unless you give it), the radius of the wire or litz bundle `wire`, the distance between the pads `gap`, and the lateral misalignment `offset`. It gives the two self-inductances, the mutual inductance and `k` at that offset, `k` with the pads aligned, and the offset where the coupling falls to zero and changes sign, with a plot of `k` and `M` against the offset. The turns are taken as concentric rings; the rings' mutual inductances come from Maxwell's formula for coaxial rings and, for misaligned pads, from integrating one ring's field around the other. **Apply** writes `l1`, `l2` and `k` into the circuit's coupled inductor in one undoable step, so `design.wpt` can size the compensation at that coupling. Without more, the pads have no ferrite or shield. Give **ferrite** (a catalogue material such as N87, or a relative permeability, and the discs' thickness; their radius and their distance behind the wire are optional) to put a flat ferrite disc behind each pad: the aligned pads' inductances and `k` then come from an axisymmetric field solve, beside the air-cored values. The check solves the same pads without ferrite and compares them with the ring formulas, so you see what the mesh costs. Give the pads' peak currents (`i1`, `i2`, and `phase`, how far the secondary current leads the primary) to see each disc's flux density at those currents, checked against the material's saturation flux density at `temperature` (25 °C unless given; for a relative permeability, give `bSat` from the data sheet). Without a phase the check takes the worst phase. Give the pads' current `frequency` as well to get each disc's core loss from the catalogue material's Steinmetz fit: each part of the disc loses as a sinusoidal flux of its peak flux density. Where the pads' currents are out of phase the flux also turns, and that extra loss is not included; a frequency outside the fit's range is reported as an extrapolation, and a relative permeability gets no loss. The ferrite is linear at its initial permeability, and its loss does not change the field, so a disc past saturation means the inductances are not valid either; with an `offset`, the ferrite's share of L1, L2 and M at that offset comes from 3D field solves (about a minute), scaled so that aligned it matches the axisymmetric solve, and is added to the air-cored ring values; the discs' flux density and loss stay the aligned pads', and the misalignment sweep stays air-cored. The check shows how far that scale is from 1. ## From a script or an assistant The ten commands also run from `powercraft-cli` and the assistant, with the same replies: ```sh powercraft-cli run --in buck.voltecx \ --cmd design.converter --params '{"vout": 12, "iout": 5, "ripplePct": 30}' ``` Each reply has the same shape: `inputs` (with the source of each value), `result`, `plot`, `formula` (English and Traditional Chinese), `apply`, `applied` and `verify`. A mistyped key or an out-of-range value returns an error, and the circuit is never changed silently. The task-by-task guide (formulas, defaults and verification rules) is `docs/workflows/design.md`, which arrives with the Design panel. --- # 8. Problems and quick fixes (beta) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/08-problems-and-fixes/ When you make a mistake, Voltecx tries to say four things: **what** is wrong, **where**, **what to try**, and, when it can, it offers a **one-click fix**. ## The Problems tab The bottom panel has three tabs: **Scope**, **Problems** and **Design**. The Problems tab shows the number of problems in a badge beside its name, red when one of them is an error and amber for warnings; hover it for the counts in words. It never opens by itself: a blocked or failed run leaves the tab you were on and says on the status line how many errors there are. Click that line (or the tab) to read them. **View > Problems** opens the tab too. Each problem is one line, as in VS Code's Problems view: - an icon for the severity (the shape differs for each level, so colour is not the only cue): **error** (the run cannot work), **warning** (it probably does not do what you want) and **info**; - a message in plain language; - the rule's code, muted, at the end of the line (`param.out_of_range`); - a **Fix** button when Voltecx knows a safe change, shown on the row under the pointer or picked. Hover a row for its title and the **hint** on what to try. On a wide panel the picked problem is spelled out on the right: what happened, where, what to try and its fixes. The tab's actions are icons at the right of the panel's tab row: **Copy as JSON**, **Filter Problems** (show or hide errors, warnings, suspect results and notes; **Only the Selected Part**; **Hide All Warnings**; **Include All**) and **More Actions** (group by severity or by part). Here a run is blocked by an error (a gate that nothing drives), and the list also holds a warning (an inductance of 100 H) and a note. ![The Problems tab, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/problems/01-problems.png) 1. The tab, with the number of problems. 2. A problem, picked (its code ends the line). 3. **Fix:** and what it changes, beside the picked problem. 4. The part it names, outlined on the schematic. Click a row to select and zoom to the part or pin it names. Parts and pins with problems get a red (error) or amber (warning) outline on the schematic. The Properties panel marks a bad field with a red border and one line under it, and this applies to `tEnd` and `maxStep` too. When you press **Run** (F5), Voltecx checks the circuit first. Errors stop the run, and the status bar says how many must be fixed. Warnings only appear in the status bar. An error from the run itself stays in the list until the circuit changes; an undo does not bring it back. **Fix** is an ordinary command. It makes exactly one undo step. Press **Cmd+Z** to take it back. Pressing **Fix** on "Value out of range" sets L1 to 100 µH. The row goes, the other rows stay, and the count on the tab drops from 3 to 2. ![After Fix, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/problems/02-fixed.png) 1. L1 now reads 100 µH. 2. The tab, one problem fewer. ## Exclude a problem or ignore a rule Some findings are on purpose: a pin left open, a signal kept for later. Right-click the row and choose **Exclude This Problem**. The row leaves the list; with nothing left the line reads **No problems found. · 1 excluded**. **Ignore Problems of This Kind** hides every finding of that rule. Both are saved in the circuit file, so they stay hidden when you or a colleague open it again, and each is one undo step. An excluded finding only covers that rule at that place. The same rule on another part or pin still shows, and if the part is renamed the finding counts as new and shows again. **Include All** in the **Filter Problems** menu brings back everything that was excluded or ignored. When a reviewed circuit's warnings crowd out what is left, **Hide All Warnings** in the same menu leaves every warning out of the list, its counts and the status bar at once. Errors and notes still show, and a rule you raised to an error still shows. While it is on, a line under the list counts the warnings it hides, and its **Show warnings** link turns it off. The switch is saved in the circuit and is one undo step; turn it off again there, in the menu, or with **Include All**. The list you read is the only thing that changes. `design.auto`, the Test Bench and the assistant still see every finding at its own severity. From a script, `problem.exclude {code, where, note}` waives one finding with a note, `problem.include` brings it back, `problem.setSeverity {code, severity}` reports a rule as `error`, `warning`, `info` or `ignore` (`default` undoes it), `problem.hideWarnings {on}` is the Hide All Warnings switch, and `circuit.problems {includeExcluded: true}` lists what was waived, with the notes. ## Jump to the part An error that names a part or a net, such as a singular matrix at `X1.C9` or a floating node, carries a link: **Show {part} on the schematic**. It appears in the console and in the agent panel. Click it: Voltecx enters the subsystem that holds the part, selects the part and highlights the net, so you do not have to search for a flattened name. Scripts get the same place from the `where` field of the problem, which gains a `subsystem` path. ![A run error in the console and its link followed, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/problems/03-error-highlight.png) 1. The link under the error in the console: **Show X1 › y on the schematic**. 2. Voltecx has entered the subsystem `island` (instance `X1`) that holds the node: the bar above the canvas shows the path and **‹ Back** leads out. 3. `C8`, a part on the node, is selected and the net is highlighted. ## Notes from an import An import lists what it did not carry over exactly. **Problems** shows these notes in groups, the worst first: - **Values not defined**: a value is missing, and the run cannot start. - **Files not found**: an include or a symbol file was not there. - **Parts left out**: parts that were not imported. - **Parts simplified**: parts that were read as a simpler part. - **Settings ignored**: simulation settings Voltecx does not use. - **Nets tied to ground** - **How the run starts** - **Other notes** Each group has an icon for its severity, a title with the number of notes, and a line that says what it means. Open a group to see a chip for each part it names (a click selects the part and zooms to it) and the notes word for word. A note that no group matches stays in **Other notes**, so nothing is dropped. After an import, the status line gives one summary, for example `imported buck.asc: 1 stop the run, 2 to check, 1 notes`, and Problems opens when something needs a look. The number on the tab counts these groups, and a value that is not defined turns it red. ## A result that cannot be right After every run, Voltecx looks over the recorded waveforms once. A node voltage or a part's current that jumped a millionfold in one step, or any value that is not a number, is listed in Problems as a **Suspect result** warning on that node or part, with the time. That sample is rounding in the solver, or an ideal switch cutting an inductor's current, not your circuit: do not read numbers near that time. Run again with the reference solver (**Simulation > Settings**, `"solver": "reference"`) and compare. The warning stays until the next run. Every run also keeps an energy account: what the sources delivered, what the resistors, switches and other lossy parts dissipated, and how much more or less the inductors and capacitors hold at the end. When more than 5 % of the energy the run moved is missing from that account, Problems shows a **Suspect result** warning on the inductor or capacitor whose own energy (½·C·v², ½·L·i²) strays most from what flowed into it, with the time window where most of it happened. A part that can only dissipate (a resistor, a switch, or a controlled source that senses its own terminals and so acts as a conductance) and delivered more than 5 % of that energy gets the warning too: it made energy no source delivered, which usually means a negative value or a gain with the wrong sign. Controlled and behavioural sources, C blocks and batteries put energy in by design and are counted with the sources. A circuit with a part whose energy the run cannot read from its values alone (a machine, a saturating or core-linked inductor, a voltage-dependent capacitance, a dynamic-level MOSFET) is not checked, and gets no warning. ## Common problems | What you see | What it means | What to do | |---|---|---| | Missing ground | No pin is on net `0`, so the voltages have no reference | Place a ground (key `G`) and wire it | | Floating or unconnected pin | A part's pin is not wired | Wire it, or remove the part | | Net with one pin | A wire goes nowhere | Connect the other end, or delete the wire | | Gate not driven | A switch's gate pin is open, or its signal has no source | **Fix** (Place PWM): a PWM block at half duty and 100 kHz on the gate, as a starting point; or connect your own control block | | No dead time in a half bridge | The two switches of a leg can conduct together | Add a `deadtime` block in the gate path | | Voltage source and capacitor in a loop | Two ideal elements force the same voltage | Add a small series resistance | | Inductor and current source cut set | An ideal inductor in series with an ideal current source | Add a parallel resistance | | Singular matrix | The circuit has no unique solution. The message names the node or element | Look at that node. It is usually a floating node or a loop of ideal sources | | Switches that will not settle | Two switches fight over a node | Use a smaller step, the reference solver, or add a snubber | | Forced or skipped steps (`solver.forcedSteps`, after a run) | The fast solver accepted steps it could not check, or passed over steps without solving them. The message gives the counts, the time window and the part or node named most often | **Fix 1** halves `maxStep`; **Fix 2** switches to the reference solver to compare; or add a snubber across the part named | | Solvers may disagree (`solver.parityGap`, after a fast run) | A warning when the circuit is an example the fast and reference solvers are known to disagree on (the message names the issue that tracks it); a note on the dead-time block when a dead time is shorter than `maxStep`, so it falls inside one step | **Fix 1** switches to the reference solver; for the dead time, **Fix 2** sets `maxStep` to the dead time | | Unknown variable (`Vi`) | The name is not a circuit variable. Voltecx suggests `Vin` | Accept the suggestion | | Value far outside the usual range (`100 H`) | Probably a unit slip. Voltecx suggests `100u` | Accept the suggestion, or keep the value if you meant it | | Duty or modulation outside 0 to 1 | A PWM input that can never work | Fix the source of the duty value | | `maxStep` above one fiftieth of a period | The step is too coarse for the fastest source | Lower `maxStep` (chapter 4) | | Symbols drawn on top of each other (`CTRL` and `VinSense`) | An old file or an import left two symbols on one spot, hiding pins and wires | Press **Fix** (Move apart): the second one moves to the nearest free spot | | A control signal drawn as a long wire through the power stage (hint) | A gate signal, a sensed value or a duty crosses the power parts as a wire | **Fix 1** draws that net as labels; **Fix 2** runs Tidy Schematic (chapter 3) | | Foster stages out of order, or a Zth curve that falls or runs backwards | A data-sheet table pasted in the wrong order or misread | **Fix**: sort the stages, or sort and flatten the curve (chapter 4) | | Zth fit misses the curve by more than 5 % | Too few terms for the curve, or a misread point | **Fix**: fit with more terms, or check the points | | Run too short for steady state | `tEnd` ends before the circuit settles | Raise `tEnd`, or use `simulation.steadyState` | ## Forced or skipped steps The fast solver shortens a step to locate a diode or switch that changes state inside it. When a shorter step does not solve, it keeps the longer step that did, and the commutation stays somewhere inside that step. A variable step whose error stays over the tolerance even at the shortest step is taken again with backward Euler, without the check. Both are **forced** steps. A step to an event that is shorter than the shortest refinement and does not solve is passed over: the clock moves to the event and the circuit holds its state. That is an **unsolved** step. Neither solver ever accepts a step whose switch states or operating points did not settle: that stops the run with an error. After a run, Problems shows the warning **Forced or skipped steps** (`solver.forcedSteps`) when more than 1 % of the steps were forced or any step was unsolved. The waveforms are still drawn through those instants, but they were not solved as intended there. The run summary of `simulation.run` has the counts in `stepEvents`: `rejected`, `forced`, `unsolved`, `minStep`, `window` and `worst`. Counting the steps changes no value of the run. The reference solver steps on its grid, so it reports no forced or unsolved step. ## Unknown names If you mistype a command, a component or a pin, the message adds a "did you mean" suggestion. If no circuit is open, a **Fix** opens a new one. ## From a script or an assistant - `circuit.problems` lists the static problems. With `{"run": true}` it adds the findings of a short simulation (shoot-through, ringing, growing oscillation). - `problem.fix` applies a fix by its code or index. - A failing command over `serve` returns the usual `error` message plus a `problem` object with the same hint and fixes, so an assistant can repair its own mistake. - `circuit.apply` makes several edits (add, connect, set a parameter, remove) as one all-or-nothing step. Limits in the beta: the desktop app's own control channel still returns plain text errors without the `problem` object. Hints are in English in both languages. ## Report a problem When Voltecx gets something wrong, **Help > Report a Problem** (or the **Report** button on a command error in Problems) files it as an issue for the Voltecx team. It opens the feedback window on the kind **Problem** (see **Send Feedback** below; picking another kind there keeps what you typed). It is opt-in, and nothing leaves your computer until you send it: 1. Describe what you did and what you expected. Clear **Include the circuit file** to leave the circuit out. 2. The window shows exactly what will be sent: the title, the labels and the whole text, with your note, the error, the Voltecx version, the operating system and the circuit file. Every path and your user name are replaced by `` and ``. 3. Tick **I have read what will be sent**, then press **Send Report**. Any change to the report clears the tick, so you confirm what is actually sent. The report goes to a Voltecx relay that files the issue; the app holds no GitHub account or token. A build made without a relay address greys the item out. An assistant can open the window, read the report and write the note (`ui.dialog.list`, `ui.dialog.respond`), but it cannot send it: only your own click does. `help.reportPreview` returns the same report and never sends anything. **Help > Send Feedback** opens the same window on the kind **Idea**: send an idea or praise in your own words, through the same relay. Picking **Problem** turns it into the problem report above. Write your message, and optionally give a rating from 1 to 5 and an email address for a reply. The window says what is sent (your message, the kind, the rating, the Voltecx version and the system) and shows it exactly as it will go out, with paths and your user name taken out. The email address is kept on the Voltecx server only to reply to you; it is never put in the GitHub issue. To show us what you mean, tick **Attach a screenshot of the Voltecx window**: Voltecx takes a picture of its window (without the feedback window) and shows it before anything is sent. The picture shows everything in the window, your circuit included; the Voltecx server keeps it for 90 days for the Voltecx team only. Tick **I have read what will be sent**, then press **Send**. The same feedback sent twice, or the same crash reported from several computers, becomes one issue with a count, not many. `help.feedbackPreview` returns the same object and never sends anything. ## Look deeper For problems that no rule names (the waveform looks wrong, but the circuit runs), the workflow is in [`docs/workflows/debugging.md`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/workflows/debugging/). It starts from the symptom: what to measure, the common causes, and how to reproduce the problem in Voltecx. --- # 9. Import, export and LaTeX figures URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/09-import-export/ Voltecx reads and writes its own file, and it exchanges circuits with other simulators. | Format | Read | Write | Status | |---|---|---|---| | Voltecx `.voltecx` | yes | yes | Plain JSON text. Everything is saved | | SPICE netlist (`.cir`, `.net`, `.sp`, `.spice`) | yes | yes | Works. Things that have no SPICE equivalent are listed as warnings | | LTspice schematic (`.asc`) | yes | yes, back into the same file | (beta) | | PLECS (`.plecs`) | yes | yes, back into the same file | (beta) | | PSIM (`.psimsch`) | yes | no | (beta) Opened with **File > Open**; needs sign-in to Voltecx Cloud. C blocks become running C blocks; parts Voltecx does not map are listed in a warning | ## The native file **File > Save** (Cmd+S) writes a `.voltecx` file. It holds the parts, the wiring, the layout, the simulation settings, the scopes and the variables. It is JSON, so it works with version control (a diff shows what changed) and you can read it in a text editor. The file keeps numbers exactly, bit for bit. `powercraft-cli info buck.voltecx` prints a summary of a file without opening the app. ## SPICE netlists **Import.** Convert a netlist to a Voltecx file in the terminal, then open it: ```sh powercraft-cli convert design.cir design.voltecx powercraft design.voltecx ``` In the app, **File > Import > Circuit** opens a file dialog with filters for LTspice, PLECS, SPICE and PSIM, and imports the file by its path. **File > Open** also takes `.asc`, `.plecs`, `.cir`, `.net`, `.sp`, `.spice` and `.ckt` files, and PSIM `.psimsch` files (see [PSIM schematics](#psim-schematics)). Includes and `.asy` symbols beside the file are read. From a script or an assistant, call `file.import` with a `path`, or with the netlist as text: `{"text": "", "format": "spice"}`. The reply lists warnings. A new circuit opens with an automatic layout. After **Import**, the window shows the import as it runs: the file, a bar with the percentage and about how long is left, and its stages (reading the file, converting it, on Voltecx Cloud for a PSIM schematic, and opening the circuit). **Cancel import** stops it and opens nothing. Close the window and the import keeps going: the status bar shows it with its own **Cancel**. When it ends, the circuit opens in a new tab and the Review step follows. ![The File menu, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/import-export/01-file-menu.png) 1. Import: a circuit, a measurement or a load trace. 2. Export: SPICE netlist, LTspice or PLECS file, waveforms (CSV), schematic as PDF and measurement comparison. 3. Pack for Sharing. 4. Print. 5. Protection: save protected, remove protection, verify signature. **Export.** Write a circuit as a SPICE netlist: ```sh powercraft-cli convert buck.voltecx buck.cir ``` In the app, **File > Export > SPICE Netlist** returns the text, and **Circuit > Show Netlist** shows it on screen. **Warnings.** A power-electronics simulator has parts that SPICE does not, such as control blocks, thermal networks and machines. Those cannot become netlist lines. The converter prints each one to the standard error output (and the app returns them as `warnings`). Nothing is dropped silently. A circuit that uses only R, L, C, sources, diodes, switches and the usual SPICE parts goes through cleanly. Read the warnings before you trust the result of a round trip. `docs/formats/spice.md` lists what is supported. **Includes.** `.include`, `.inc` and `.lib` lines are followed when you import a file with `path` (`powercraft-cli convert`, or `file.import` with `{"path": "design.cir"}`). A path is relative to the folder of the file that names it, and a nested include is relative to its own file. Voltecx reads every `.param` of an included file and the `.model` and `.subckt` definitions that the netlist uses. The text of the definitions is kept inside the circuit, so an LTspice file still writes back byte for byte. Cycles, nesting deeper than 8, more than 64 files and files over 8 MB each give a warning and are skipped. A missing file gives a warning that names it. If variables stay undefined, an error says they are probably defined in that missing file. Where files cannot be read (the browser build), includes are not followed and a warning says so. **Directives.** These lines are read, not ignored: | Directive | What Voltecx does | |---|---| | `.step` (`param`, `list`, `lin`, `oct`, `dec`) | Kept as a parameter step. `.step temp` and a step of a source give a precise warning | | `.ac dec`, `oct`, `lin` | Kept as an AC sweep. `lin` converts to the log sweep of `analysis.acSweep` with a warning | | `.op` | Kept. It runs `analysis.op`, the DC operating point | | `.dc` | Kept. It runs `analysis.dcSweep` on its first source. A second swept source is ignored with a warning | | `.tf` | Kept. It runs `analysis.transfer` from the source to the output | | `.meas` (`TRAN`, `AC`, `OP`, `DC`) | Translated: `AVG`, `RMS`, `MAX`, `MIN`, `PP`, `INTEG` with `FROM` and `TO`, `FIND ... AT`, `FIND ... WHEN`, `WHEN`, `TRIG ... TARG` and `PARAM`. Functions such as `ph()` are refused with a warning | | `.options` | `reltol`, `abstol`, `vntol`, `maxstep` and `method` become simulation settings. The rest is listed as ignored | **Run what the file asked for.** `analysis.runImported` runs the imported directives and never edits the circuit: ```json {"what": "all"} ``` `what` is `all`, `tran`, `step`, `ac`, `op`, `dc` or `tf`. `source`, `output` and `solver` are optional. The stepped runs go in parallel, a single transient serves the transient `.meas` lines, `.op` and `.dc` run the DC solver, and `.ac` runs through the AC sweep. The `.meas DC` lines read the signals of the sweep, and `sweep` stands for the swept value in their expressions. Each measurement is evaluated, and an error in one does not stop the others. If the DC solver cannot solve the circuit, the reply says why. For `.op` it then gives the values at the end of the transient. **More parts are mapped.** BJTs and level-1 MOSFETs (chapter 10), LTspice control-library symbols (gain, integrator, delay, limiter and so on), op-amps, `Misc\battery` and behavioural B sources import as Voltecx parts. A B source whose expression reads node voltages only is solved with the circuit, as SPICE does; one that reads an element current `I(...)` follows its expression one step late, and the import says so. A named op-amp such as `LT1001` becomes a generic op-amp, and a warning says that the part's own model is not used. Other parts stay "not supported" until their pins are known. **LTspice symbol files.** A symbol that LTspice does not build in is described by its own `.asy` file. Like LTspice, Voltecx looks for it next to the schematic and then in the folders of a symbol search path: `powercraft-cli convert design.asc design.voltecx --sym ~/LTspicePowerSim/sym/PowerSim` (repeat `--sym` for more folders), or `file.import` with `{"path": "design.asc", "symbolPaths": ["lib/sym"]}` (at most 32 folders). `SYMBOL PowerSim\\GAIN` is looked for as `PowerSim/GAIN.asy`, then as `GAIN.asy`. A symbol file whose `Prefix` is a primitive (`R`, `C`, `L`, `D`, `V`, `I`, `MN`, `MP`) imports as that part. The blocks of the LTspicePowerSim library (`iNMOS`, `PWM`, `DEADTIME`, `TYPE2`, `zPI`, `PHASESHIFT` and about 60 more) are recognised by the pin names in their symbol files and import as Voltecx parts and control blocks. The table in `docs/formats/ltspice.md` lists what each one becomes and what is approximated. The symbol files that were read are kept inside the circuit, so the write-back opens no file. A symbol whose file is not found is named in one warning. **LTspice details.** `Rser`, `Lser` and `Rpar` on an inductor or capacitor become its winding resistance, ESR, ESL, core-loss or leakage resistance. `.ic I(L1)=` sets an inductor's starting current. A `.tran` without a maximum step gets a step that keeps the run between 50 and a million steps. LTspice's quoted `.options method="gear"` and `modtrap` are read. ### Sources given as a list of points (PWL) A voltage or current source with a `pwl` parameter follows a list of points joined by straight lines (chapter 10). SPICE and LTspice `PWL(...)` sources import as that. `r=0` sets `repeat`. A `PWL FILE=` source and other forms stay DC, with a warning. A SPICE export writes `PWL(...)` again. In an LTspice file, an edited list is reported as not written back. ### Files saved in the Windows code page or as UTF-16 LTspice saves schematics in the Windows code page unless you tell it to save UTF-8, so the micro sign and accented letters in comments are single bytes that are not UTF-8. Voltecx reads UTF-16 (little endian), UTF-8, and otherwise Windows-1252. `file.import` and `powercraft-cli convert` keep the encoding, and the write-back uses the same one, so a file you did not edit comes back byte for byte. The reply has an `encoding` field when it is not UTF-8. A character the code page cannot hold (the ohm sign, for example) makes the write-back UTF-8, with a warning. A file with NUL bytes or other control characters is refused as not a text file. ## LTspice and PLECS (beta) The beta build reads LTspice `.asc` schematics and PLECS `.plecs` files, and it can write changes back into the same file. ```sh powercraft-cli convert design.asc design.voltecx ``` or `file.import` with `{"path": "design.asc", "format": "auto"}`. The format is detected from the file. - **Import** maps what it understands and lists everything else in `warnings`. Run `circuit.explain` on the imported circuit to check that the topology is what you expected. - **Write-back** is the unusual part. The imported file is kept inside the circuit. When you edit the circuit and export it (`file.exportNative`, or `convert design.voltecx design.asc`), Voltecx changes only the lines of the original that your edits touch. A file you did not edit comes back byte for byte. Changing one value changes one line. This keeps your LTspice or PLECS project clean in version control. - **C-Script code in files.** A PLECS C-Script block may `#include "x.c"` or `#include "x.h"`, code kept beside the model. When you import the model by its path, Voltecx reads those files from the model's folder and puts their text into the block, so the block carries all its code and runs. A file may include others (8 deep at most), and a name is read relative to the file that names it. Absolute paths are refused, and so are paths that leave the model's folder (`../x.c`) unless you allow a folder that contains the model (below); the block keeps its `#include` line. A missing file, or an import that has no access to files (the browser build, or text imported without a path), gives a warning that names the file; the block then reports the include as an error, as before. A block never reads files while it simulates. Voltecx keeps the files it read inside the circuit, so an unchanged model still writes back byte for byte. - **Shared C files one folder up.** When a C-Script includes a file with `..` (`#include "../common/x.c"`), Voltecx first imports the model without it and asks, naming the C-Script block and the include. Under **Allow includes from this folder** it offers the smallest folder that holds the model and the file (**Choose** picks another, such as the project folder). **Allow and import again** imports the model again and reads the files inside that folder; nothing outside it is read. **Keep without it** (or Esc) keeps the circuit as imported, and the block reports the include as an error. The same choice from the command line: `powercraft-cli sim model.plecs --include-root DIR` or `convert model.plecs out.voltecx --include-root DIR`, and in a command `file.import` with `{"path": "work/m/model.plecs", "includeRoot": "work"}` (the folder must contain the model). - **Net labels.** Voltecx draws a net label as a flag instead of a wire (**Edit > Draw Tools > Net Label**, key `N` in the Classic keymap, `L` in Default). Import maps LTspice `FLAG` names and PLECS `Goto` and `From` blocks to labels. LTspice flags that name a supply rail (`VCC`, `VDD`, `VEE`, `VSS`, `V+`, `V-`, `+5V`, `-12V`, `3.3V` and similar) become **rail** labels. `0` and `GND` stay ground, and an `IOPIN` flag stays a **port**. - **Label write-back.** When you add, rename or remove a label and export, Voltecx writes the change into the original file. Untouched flags and blocks keep their bytes. What each program gets: | | LTspice | PLECS | |---|---|---| | Add a label | A new `FLAG` line, for every label kind | On an output pin, a `Goto` block with the net name as its tag. On an input pin, a `From` block, and a `Goto` at the net's output if no `Goto` has that tag yet | | Rename a net | Every flag on the net is renamed. A net the file did not name gets one flag at a pin | The tag of the blocks on the labelled pins | | Remove a label | Its `FLAG` is removed only when the pin stays on the net and the net keeps its name. Otherwise the change is reported | The pin stays on its net. A `Goto` is removed unless a `From` block still reads its tag. Then it stays, and a warning says so. Tag blocks left with no connection are removed | Labels on electrical pins and the **rail** and **port** kinds are reported but not written to a PLECS file, because the format notes in `docs/formats/plecs.md` do not document a block for them. - **Vector signals in PLECS files.** PLECS carries a three-phase set or a group of gate signals as one vector. When every vector in the model fits a bus (chapter 3), import keeps it as one: a `SignalMux` becomes a **Bus Mux**, a `SignalDemux` a **Bus Demux** (or a **Bus Selector** for an output wider than one element), and a `SignalSelector` a **Bus Selector** whose `index` keeps the PLECS order (`[3 1]` becomes `3, 1`). A gain, sum, PI or logic gate on a vector stays one block that acts on every element, and the bus net takes the name of its PLECS `Goto` tag when it has one (otherwise `s1`, `s2` …). A pin that reads or drives one element (a Function block's `u[2]`, one phase of a three-phase meter) reaches it through an added demux or mux named after the bus (`s4_demux`). The reply then warns, for example, "3 vector signal(s) kept as buses: the PLECS muxes, demuxes and selectors became bus blocks, and element-wise blocks act on every element". A model of three constants (1, 2, 3) muxed into a gain of 2, a selector `[3 1]` and a demux imports as `M` (`busMux`, `n` 3), `G` (`gain`), `Sel` (`busSelect`, `index` `3, 1`) and `D` (`busDemux`, `n` 2), and its outputs read 6 and 2, as in PLECS. The circuit simulates exactly as it did split into scalar nets, an unedited file still writes back byte for byte, and editing a gain on a bus changes the one line of its PLECS block. When the vectors do not fit (widths that disagree around a mux or selector, a vector with no driver or two, more than 8 elements reached one by one, a mux of more than 8 inputs, a block that does not work element by element on a vector, or a vector wider than 64), the whole model is split into one net per element, as before. Only the PLECS importer keeps vectors. - **Limits.** In an LTspice file, rewiring an existing symbol and changing its orientation are reported, but not written. In a PLECS file, an edited connection is rewritten without its drawn `Points`. Nothing was ever opened in LTspice or PLECS to test: the guarantees come from the file format rules and from tests on public sample files. The formats are described in `docs/formats/ltspice.md` and `docs/formats/plecs.md`. ### PSIM schematics Needs sign-in to Voltecx Cloud: the desktop app sends the PSIM file to Voltecx Cloud's converter and opens the circuit that comes back (sign in under **Help > Licence**). Without a sign-in, or offline, opening a `.psimsch` file (File > Open, a drop, or File > Import) shows a Voltecx Cloud notice with **Sign in** and **Retry**; Retry opens the same file again. In File > Import, a PSIM file chosen while signed out shows **Sign in to convert** in place of Import. **File > Open** (or `powercraft-cli convert x.psimsch x.voltecx`) reads a PSIM schematic saved by PSIM 8, 9, 11 or 2022 and later (seen up to 2026). The parts Voltecx has are placed where they were, with their values, and the wiring is rebuilt from the drawing: wires, junctions, parts touching each other and net labels. The ideal 3-phase inverter becomes six MOSFETs drawn as a bridge (three legs, drains up, gates to the left), with PSIM's switch resistance and an ideal body diode as the antiparallel diode. Resistor, capacitor, inductor, diode and MOSFET modules (whatever language PSIM ran in) become the matching Voltecx part with their values, and a flipped part keeps its pins where PSIM drew them. PSIM's ideal transistors become gated one-way switches (Voltecx's IGBT, with the saturation voltage as its drop), a Zener diode becomes two antiparallel diodes (the forward drop one way, the breakdown voltage the other), and a two-winding transformer becomes a transformer with PSIM's turns ratio, winding resistances, leakage and magnetizing inductances. A three-winding transformer becomes two transformers whose primaries are in parallel behind the primary's resistance and leakage, which is the same ideal transformer, with each winding's turns ratio, resistance and leakage and the magnetizing inductance across the primary. A D flip-flop with set and reset inputs becomes Voltecx's D flip-flop, whose optional `s` and `r` inputs force the output at once while they are high (reset wins). An op-amp whose inputs are circuit nodes and whose output feeds only control blocks (a comparator, for example) becomes control blocks: a voltage meter across its inputs and, for PSIM's ideal op-amp, a switch between the two supply values, or, for the level-1 op-amp, a single pole with PSIM's DC gain and unity-gain frequency whose output stays between the supply values. An optocoupler, a TL431 and a UC3842, UC3843, UC3844 or UC3845 controller module become Voltecx's behavioural ICs (the same ones **ic.place** puts in): the optocoupler with PSIM's LED values and current transfer ratio, the TL431 with the TL431C data sheet's values, and the controller with its part's data sheet values, its oscillator set by the timing resistor and capacitor on PSIM's RT/CT pin. Voltecx's controller has no VREF pin, so what that pin fed is left without its 5 V reference, and a warning says so. Everything that was not imported exactly is listed in **Problems**, in groups with the most important first (chapter 8), and the status line says how many there were (for example `Opened closed_loop.psimsch: 10 import warnings — see Problems`): - C blocks. Each becomes a Voltecx C block (PSIM dialect) with the same name, its inputs `x1…` and outputs `y1…` on the nets the drawing put them on, and it runs its code in Voltecx's C interpreter at every solver step. The interpreter supports a subset of C, so a note lists every C block and asks you to compare its outputs with PSIM. Double-click the block, or use **Circuit > C Code** or **Edit Code** on the right-click menu, to open the code editor: it checks the code as you type, and **Save** keeps your change as one undo step (**Revert** drops it). The code starts with a comment that lists the net each pin touched in the drawing (`// x1 = net Id_ref`, `// y1 = net Vduty_A2`); PSIM's standard `#include` lines are left out. A block without code (none in the file, or over the circuit's limit for kept code) is warned and does not run until you add some. When a C block could not be added, a "Signal has no source" problem on a net it drove names that block. - Module parts whose model Voltecx does not map (a level-2 MOSFET, for example), and other part types Voltecx does not map, each with the reason: a random source (the file does not say how often it draws a value), an op-amp whose output drives parts of the circuit, such as its own feedback network (place Voltecx's `opAmp` IC by hand; the warning says which pin is which), and a UC384x controller whose timing resistor is below the data sheet's 5 kΩ minimum. - Subcircuits. A PSIM 9 subcircuit block becomes a subsystem made from the file it calls, read from the same folder (Circuit > Subsystems shows the inside). Each of its pins sits where PSIM's symbol puts that port and joins the wires drawn there; a pin with nothing drawn at it is left open, and a warning names it (a schematic wired for an older version of the called file has such pins). - Variables that the file uses but does not define. A file that another PSIM schematic calls as a subcircuit takes these values from that schematic: open the calling schematic with this file in its folder, or define the variables in this circuit before simulating. - Voltage probes that watch control signals: they are not imported, but the net a probe was on alone takes its name (`Vduty_A2`), so you can put it on a scope. - Settings Voltecx does not model (a carrier's start time, for example), then text boxes and file records that were not read. The PSIM file is never changed: **File > Save** asks for a new `.voltecx` file. The format notes are in `docs/formats/psim.md`. ## Trademarks PSIM is a trademark of Altair Engineering, Inc. (a Siemens company); PLECS of Plexim GmbH; LTspice of Analog Devices, Inc. Voltecx is not affiliated with, sponsored by or endorsed by them; their names are used only to describe file compatibility. Their files are read for interoperability. Voltecx writes LTspice and PLECS files only back to the format a circuit was imported from (**File > Export > LTspice or PLECS File**), and never writes PSIM files. The same notice is in **Help > About Voltecx** and under an import's notes in **Problems**. ## Comparing two versions `file.diff` tells you what changed between two versions of a circuit. Each side can be a file (a `.voltecx` file, or an LTspice, PLECS, SPICE or PSIM file), a circuit you have open (its number in `session.list`), or `.voltecx` or netlist text: `{"a": "buck-v1.voltecx", "b": "buck-v2.voltecx"}`. Leave out `b` to compare with the active circuit. Nothing is opened or changed. The reply lists each change once: - parts added, removed and renamed. A part that has another name in the new version is one rename, not a removal and an addition. In the same file the part's id gives it away; across files, a part of the same kind with the same values or the same wiring; - parameters that differ, with their unit (`C1.c: 1 µF → 2.2 µF`); - wiring per net: the pins attached to and detached from each net, and nets that were only renamed. The pins of an added or removed part are not repeated here; - circuit variables, simulation settings and subsystem definitions. For a definition that changed, `subsystems.details` says what changed inside it (its parts, parameters and wiring, and whether its pins changed), and `lines` reads `filter: C1.c: 1 µF → 2.2 µF`. `summary` counts the changes, and `lines` gives one sentence per change, both in English and in Traditional Chinese. A side can also be a checkpoint (`checkpoint.create`): `{"a": {"checkpoint": "c3"}}` compares checkpoint `c3` of the active circuit with the circuit now. A checkpoint's label works as a version tag: `{"checkpoint": "sent to layout"}` names the newest checkpoint with that label. Add `"index"` to take the checkpoint of another open circuit. A side can also be a run of the Runs list: `{"a": {"run": "r3"}}` compares the circuit run 3 was computed from with the circuit now, and `{"a": {"run": "r2"}, "b": {"run": "r5"}}` two runs with each other (ids from `runs.list`). A run read from a bundle keeps its waveforms but not its circuit, so it cannot be compared this way. ### Side by side in the window **File > Compare With File** picks a circuit file and opens **Compare Circuits** on it and the circuit now. The two schematics are drawn side by side: parts added are green, parts removed red, and parts, nets and subsystems that changed amber, with the rest faded. Under them, the same table as a Runs card lists every change, **Before** and **After**. In Runs, **Compare with now** on a card compares that run's circuit with the circuit now, and **Compare circuits** compares the circuits of the two runs picked with **Compare**. ### In git A `.voltecx` file is pretty JSON written the same way every time: saving a file you opened writes the same bytes, maps (parameters, variables, subsystem definitions, positions) are written in key order, and changing one value changes one line. So plain `git diff` already stays small. To see what a change means for the circuit instead of the JSON lines, make `powercraft-cli diff` git's diff driver for circuit files (**Preferences and saving > Circuits in git**). To compare the design results of two versions, run `bom.export` or `spec.verify` on each and pass both replies: - `bom.diff {"a": , "b": }` lists the BOM lines added and removed and, per reference designator, a changed status, part number, manufacturer, value, quantity, footprint or unit price, with the change in total cost, pieces and board area; - `spec.diff {"a": , "b": }` matches the rows by requirement and corner, and lists the rows that now fail, now pass, measure differently, or were only checked in one run, with the overall verdict before and after. ## The bill of materials in the app **View › Bill of Materials** shows the open circuit's bill of materials as a table: one line per part with its designators, value, the rating the last run asks of it (for example `≥ 60V, ≥ 2.1A rms`), part number, manufacturer, pieces and a DNP mark. Equal parts share one line with all their designators. Parts no catalogue part fits say so, with the reason on hover, and have no part number: Voltecx never makes one up. DNP parts come last. Meters, control blocks and probes are not on a board and are left out, as in the exported list. The lines are the rows `bom.export` writes to its CSV (`bom.list` returns them to scripts), read again after every run, so the view needs a simulation result. Click a line to select its parts on the schematic and zoom to them; click **Designators**, **Value** or **Qty** to sort, and again to reverse. When the project has a board, a **Fitting** column says how each line's parts are fitted, in the order the steps run: reflow, wave or selective solder, hand solder, press fit, or inserted into a socket, marked *by hand* or *removable* where the board's fitting plan (`board.fittingPlan`) says so. A drilled part with no mount data reads *Unknown*, never a guessed step. Hover the cell, or select the line, for the fitting note; **Copy table** adds the column too. ## Bill of materials and KiCad project **File > Export > Bill of materials** (`bom.export`) picks a catalogue part for every component from the stress of the last run and writes the list as CSV, with the KiCad BOM columns first. **File > Export > KiCad project** (`file.exportKicad`) writes a KiCad 8 schematic with those parts, a project with net classes and a design-rules file. Both open a form first, and both are also in **Design > Manufacturing**, beside **Manufacturing Outputs** for the files an assembly house needs once the board is routed. [Chapter 16](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/16-automatic-design/) gives their parameters. ### Open a Voltecx board in another PCB tool The KiCad project is also the way to take a Voltecx design into a PCB tool other than KiCad: many tools have an importer that reads a KiCad 8 project. Export with a path, then point the other tool's KiCad importer at the `.kicad_pro`; the `.kicad_sch` and the `.kicad_dru` beside it go along. - The folder stands on its own. Every symbol is defined inside the `.kicad_sch`, so the importer needs no KiCad library, and no file names a path on your computer, so the folder can be zipped and sent. - Each board part carries its reference, value and footprint as a `Library:Name` id from the KiCad standard library. The other tool maps that id to its own footprint, or asks you to; a part listed in `missingFootprints` has no id yet, so give it one first. - Net classes and clearance rules are in the `.kicad_pro` and the `.kicad_dru`. Not every importer reads custom rules: check the high-voltage clearances in the other tool before routing. - To come back the other way, export IPC-2581 or ODB++ from the other tool; reading those files is on the roadmap. The test fixture `crates/io/tests/data/kicad_exchange` is such a project, for the synchronous buck. ### Open a KiCad schematic `file.importKicad {path}` (from the command line or the assistant) opens a `.kicad_sch` from KiCad 6 to 9 as a new circuit. Resistors, capacitors, inductors, diodes, sources, batteries, fuses and test points come in by their reference letters, transistors by NPN, PNP, NMOS or PMOS in the symbol's name, and anything a Voltecx export wrote by its library id. Each part keeps its place, turn and mirror. With a path, the hierarchical sheets beside or below the file come in too, each on a Voltecx sheet of its own name. A sheet file drawn twice is read once per drawing, with the references KiCad keeps for each. Buses come back as bus wires on the sheet they are drawn on, with their labels (`D[0..7]`, `USB{DP DM}`). A bus wired into a sheet pin carries its members into the sheet below, as KiCad joins them. A vector bus pairs members by position from the lowest index, so `X[2..3]` into `D[0..1]` joins X2 to D0. A group bus pairs them by member name. A bus sheet pin with no bus on it carries the members its own name gives. The net labels you drew in Voltecx come back on the same pins with the same kinds (net, goto, from, rail, port, ground): the export still puts a global label on every pin, so KiCad joins the nets, and marks the drawn ones with a hidden `voltecx_label` field that changes no net. A schematic drawn in KiCad brings no drawn labels; its labels only join nets. Symbols of no known kind (connectors, ICs) are left out and listed in the warnings. A KiCad schematic holds no device models or simulation settings, so parts start on their defaults. A circuit drawn over several sheets goes to KiCad as a hierarchy. Sheet 1 is the top `.kicad_sch`, with a sheet box for each other sheet, named after it. Each other sheet is its own file beside it, `-2.kicad_sch`, `-3.kicad_sch` and so on. The pins still carry global labels, so the nets join across the files. Opening the top file with `file.importKicad {path}` puts every part back on its sheet. KiCad's top sheet has no name of its own, so a renamed sheet 1 keeps its name in the top file's title block, as comment 4 `Voltecx sheet: `. KiCad shows it there, and `file.importKicad` reads it back as the name of sheet 1. ### Keeping a KiCad project in step After the circuit changes, File › Sync with KiCad (`pcb.sync {path}`) compares the project's `.kicad_sch` with a fresh export and lists what a sync would change: parts added and removed, field changes (Reference, Value, Footprint, MPN, Manufacturer, on board, do not populate) and the net on each pin. Parts are matched by the hidden `voltecx_id` field, never by position or reference. Apply writes the export over the project; run Update PCB from Schematic in KiCad afterwards, and every footprint keeps its place and tracks. Every symbol also carries a hidden `voltecx_base` field: the values Voltecx last wrote. Each field change says where it happened (`origin`): | Origin | Meaning | Apply | |---|---|---| | circuit | You changed the circuit; KiCad still has the last synced value | Writes the circuit's value | | kicad | Someone edited the field in KiCad; the circuit did not change | Refused, so the edit is not lost | | both | The field changed on both sides to different values (a conflict); `base` is the last synced value | Refused | To keep KiCad's value, change the circuit to match and sync again. To keep the circuit's value, apply with `overwriteKicad: true`. In the window each field row shows its origin as **Changed in the circuit**, **Edited in KiCad** or **Changed on both sides**; hover a KiCad edit for the value to set in the circuit, and a conflict for the last synced value and both new ones. While KiCad edits are listed, Apply stays greyed out until you tick **Overwrite KiCad edits**. A project exported before the base field existed has none: every difference counts as the circuit's until the next apply writes one. The other way, the window's **KiCad to circuit** switch (`pcb.sync {path, direction: "fromKicad"}`) lists what was changed in KiCad. Each row says whether it **comes back**: a reference KiCad's annotation changed (labels, probes and expressions follow the new name) and a do-not-populate flag. Every other difference (a value, footprint or part number typed in KiCad, a wire, a part added or deleted there) **stays**, and its tooltip says why and where to make the change instead. A value, footprint or part number edited in KiCad (or changed on both sides) has a box in its row: tick it to pick KiCad's side, and the row then says it comes back. From the command line or the assistant, each such change has an accept name such as `C1.Value`, and `pcb.sync {path, direction: "fromKicad", acceptFields: ["C1.Value"], apply: true}` sets the part's value parameter (KiCad's `4k7` and `1M` read as 4.7 k and 1 M), its Footprint field (a library footprint `Library:Name`) or its part number, in the same undoable step. A value an expression sets, or one the bill of materials gives, stays. **Apply to circuit** makes the edits that come back as one step that Edit › Undo restores, and writes no file. It is greyed out when nothing comes back, inside a subsystem, or when KiCad gives two parts one reference or a name another part keeps. The routed board can come back too, from the command line or the assistant: `pcb.sync {path, direction: "fromKicad", boardPath: "out/buck.kicad_pcb"}` also reads the board's layout parasitics, as **Sync Simulation with Board** (`layout.syncBoard`) reads them: each power loop's series inductor `Lpcb` and each switching node's capacitor `Cpcb__`. They are listed under `parasitics` with the circuit's value before, the board's value after and whether each is new, changed or unchanged. Nothing goes into the circuit until you accept it: `acceptParasitics: ["Lpcb1"]` (or `true` for all) with `apply: true` puts the accepted ones in as named stray parts, drawn beside their capacitor, in the same **Sync from KiCad** step that Edit › Undo restores. While the board is still open in KiCad, the parasitics can come from the routing on KiCad's screen, saved or not: add `liveKicad: true` to `layout.extract` or `layout.syncBoard` with `path` to the `.kicad_pcb` KiCad has open. The tracks, arcs, vias and zone fills come from the running editor over KiCad's API (KiCad 9 or later, with its API server turned on in its preferences); the board file still gives the stackup and the footprints, and nothing changes in KiCad. The reply's `board.copperFrom` says `kicadEditor`. A zone KiCad has not filled adds no copper and is named in the warnings: fill the zones in KiCad (B) and read again. When KiCad has another board open, or cannot be reached, the file's copper is used and a warning says why. To take only some nets from the editor, add `liveNets` with their names as the board gives them (for example `["GND", "SW"]`): those nets' copper comes from KiCad, every other net keeps the file's, and KiCad 10.0.1 or later reads just those nets. A name with no copper in KiCad is named in the warnings, as is an unfilled zone on those nets. In the window, **KiCad to circuit** has a **Routed board** field for the same `.kicad_pcb` (or a `.vxpcb`); the last one is offered next time. **Layout parasitics** then lists each stray part with its loop or node, the circuit's value and the board's, and a box. Only new or moved stray parts can be ticked, and nothing is ticked at first: tick the ones you accept and **Apply to circuit** puts them in, with the references that come back, as one step. Stray parts the circuit has but the board no longer gives are listed apart; they stay until you delete them. With a `.kicad_pcb`, **Read the routing open in KiCad** takes the copper from the board open in KiCad's PCB editor, unsaved routing included (`liveKicad: true`, as above); the list's heading says whether the routing came from KiCad's open editor or the saved file, and a note says why when KiCad could not be read. To keep a project in step without opening the window each time, tick **Sync on every save** (`pcb.watch {path}`). The setting is saved in the circuit file and Edit › Undo takes it back. From then on every save writes the circuit's changes to that project, as Apply does, and the status bar says how many changes went over. A sync that would overwrite fields edited in KiCad, or drop parts drawn there, writes nothing and says why; the circuit itself is always saved. Untick the box (`pcb.watch {off: true}`) to stop. When Apply runs, the board follows too. If Voltecx can reach a KiCad that has the project's board open in its PCB editor, the changed references, values and part numbers go straight into that board as one step that KiCad's Undo takes back, matched by `voltecx_id`; every footprint keeps its place, side, lock and tracks. The board is then changed but not saved: save it in KiCad. A changed footprint, a part added or removed and a net change still reach the board through Update PCB from Schematic. In every other case (KiCad not running, another board open, or a build that cannot reach KiCad) the reply's `kicadBoard` says why the board takes the file route, and Update PCB from Schematic brings it in step as before. If KiCad refuses a change, nothing changes in its editor and the schematic files stay written. The desktop app and the command line reach KiCad 9 or later on macOS and Linux when KiCad's API server is turned on in its preferences; on Windows and in the browser the board always takes the file route. ### Fabrication files from a Voltecx board A board drawn in Voltecx (the project's `.vxpcb`) gives its own fabrication files with `board.exportFab`, with no outside program. It fills the zones first, then writes into a `fab` folder beside the board (or the `folder` you give): | File | What it is | |---|---| | `-L1-top.gbr` … `-L-bottom.gbr` | one Gerber X2 file per copper layer: zone fills, tracks, vias and pads, each with its net | | `-mask-top.gbr`, `-mask-bottom.gbr` | solder mask openings (pads at copper size; vias are covered) | | `-paste-top.gbr`, `-paste-bottom.gbr` | paste stencil (fitted surface-mount pads only) | | `-silk-top.gbr`, `-silk-bottom.gbr` | legend | | `-profile.gbr` | the board outline; a board without one is refused | | `-PTH--.drl`, `-NPTH--.drl` | Excellon drill files, plated and non-plated apart, one per via span | | `-pos.csv`, `-cpl.csv` | pick-and-place: the position file (`Ref,Val,Package,PosX,PosY,Rot,Side`, mm, y up) and JLCPCB's CPL; parts not fitted are left out, values come from the open circuit | | `-component-top.gbr`, `-component-bottom.gbr` | Gerber X3 component layers of the same parts: reference point, rotation, value, footprint, mount type, maker and part number, footprint library, LCSC supplier part (when given), body height (when cited), courtyard and pins (number, net and port) | | `-bom.csv`, `-bom-jlcpcb.csv` | bill of materials: `Designator,Qty,Value,Footprint,MPN,Manufacturer`, and JLCPCB's `Comment,Designator,Footprint,LCSC Part #,MPN,Manufacturer` (LCSC number empty); one line per value, package and part number, of the same fitted parts | **What to upload to a fab:** the Gerber and drill files, zipped together. For assembly, send the position file and the BOM (`-cpl.csv` and `-bom-jlcpcb.csv` for JLCPCB); the notes name BOM lines without a part number. The Gerber X2 attributes say which layer each file is, so the fab's viewer sorts them itself. Text on the board is not drawn yet; the reply's `notes` say how many text items were left out. IPC-2581 from the board follows. ## Hand an IC block to the IC team `ic.exportHandoff {"dir": "handoff"}` writes the bundle an architect hands to the IC team into a folder, through the file service (so the folder must be one the automation was granted): - `handoff.json` has one block per top-level library IC instance (`ic.place`): instance, definition, template, title, data sheet `source` and preset part, every parameter with its value, unit, range, default, the data sheet row it came from, and `overridden` when `ic.place` params changed it, the pins and the nets on them, and `notModelled`, what the model leaves out. `skipped` lists definitions edited after placing, which no longer match their data sheet. - `waveforms.csv` has the `probes` of the last run (default: the circuit's probes) between `t0` and `t1`, every sample, with the run conditions (solver, end time, step, window) in `handoff.json`. - `circuit.pcraft` is the circuit itself. Without a simulation result the bundle holds the block specs and the circuit only, and `warnings` says so. The command changes nothing and records no history step. ## Waveforms The **Scope** menu has the CSV exports as well: **Export CSV (Visible Window)** writes what the plot shows, **Export CSV (Full Run)** the whole run, and **Copy CSV (Visible Window)** puts the visible part on the clipboard. They are grey until a run has finished. ![The Scope menu, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/import-export/02-scope-export.png) 1. Export CSV (Visible Window). 2. Export CSV (Full Run). 3. Copy CSV (Visible Window). - **File > Export > Waveforms (CSV)** or `scope.export` with `"format": "csv"` writes signals to CSV; `"format": "mat"` writes a MATLAB MAT-file and `"raw"` an LTspice binary `.raw` (`docs/formats/waveform-files.md`). - `waveform.compare` reads a CSV from a bench scope or another simulator and compares it with your simulation (chapter 5). - **Open a waveform file on its own.** File > Import > Waveform File opens a scope CSV or any file Import Measurement reads (`.raw`, `.mat`, `.sr`, `.vcd`, `.isf`, `.bin`, `.trc`) as a dataset of its own, in a new tab named after the file, with no circuit and no run. The scope shows its traces at once, and the cursors, the measurements and the FFT read them as they read a run. A column in volts reads as `v(CH1)` and one in amperes as `i(CH2)`, so it goes on the voltage or current axis; `V(out)` and `I(L1)` from a `.raw` file become `v(out)` and `i(L1)`. A file dropped on the window before any run opens the same way. The command is `file.openWaveforms` (`csv`, `bytes` or `path`, as Import Measurement takes them). - **Merge a waveform file into the result.** File > Import > Merge Waveforms adds every trace of a file to the result on screen (a run, or a file opened as above), named after the file: `v(CH1)_(bench)` from `bench.csv`. The traces are read at the result's own times, so the cursors, the measurements, math signals and the FFT read them beside the run's; where the file has no samples they are not drawn. Merging the same file again adds `_2`. The merged traces stay until the next run. The command is `file.mergeWaveforms` (`csv`, `bytes` or `path`, plus `tag` for another name and `timeOffset` to move the file in time). - **Waveforms from LTspice or MATLAB.** File > Import > Measurement also opens an LTspice `.raw` file (binary or ASCII, from LTspice or ngspice) or a MATLAB MAT-file, so a run you trust in another simulator can be laid over a Voltecx run. A `.raw` file's columns keep their names (`V(out)`, `I(L1)`) and units (V, A from the variable type). A MAT-file gives its time vector (`time`, `t` or `tout`; `timeVariable` names another) and every vector or matrix column of the same length (`x(:,2)`); MATLAB's default compressed `-v7` files are read, a `-v7.3` file is refused (save it with `-v7`). A stepped `.raw` run gives its first step, with a note. An AC sweep is refused: only a transient run compares with the scope. For automation, pass the file as `bytes` (base64) or as a `path` ending in `.raw` or `.mat`; `waveform.compare` takes the same. A file written by File > Export > Waveforms (CSV) reads back with zero error (`docs/formats/waveform-files.md`). - **Logic analyser and USB scope captures (sigrok).** File > Import > Measurement also opens a sigrok session (`.sr`), the file PulseView and `sigrok-cli` save from cheap logic analysers and USB scopes (fx2lafw boards, Hantek 6022, and Rigol or Siglent scopes through sigrok). Each named logic probe becomes a 0/1 column (a gate signal, a fault flag) and each analog channel a column, timed by the file's sample rate. A capture longer than 5,000,000 samples keeps one sample in a whole stride, and a note says which. Analog channels carry no unit in the file, so give one in the window or with `units`. For automation, pass a `path` ending in `.sr` or `bytes` with `"format": "sr"`. - **Digital dumps (VCD).** File > Import > Measurement also opens a Value Change Dump (`.vcd`, IEEE 1364 clause 18), the text format of GTKWave and Surfer that sigrok, PulseView and every HDL simulator write. Use it to lay an MCU's PWM, gate signals and fault flags, or an FPGA controller's simulation, over the circuit. Each variable becomes a column named by its scopes (`top.ctrl.pwm`), held between its changes on the union of all change times, in seconds from `$timescale`. A vector reads as its unsigned value, a `real` as its value, and `x` or `z` as a gap. A dump past 5,000,000 time steps is refused: cut it to a window first. Pass a `path` ending in `.vcd`, or `bytes` with `"format": "vcd"`. - **Binary scope captures.** File > Import > Measurement also opens a scope's own binary file, which keeps the full resolution, the vertical scale and the trigger position that a CSV export may round or drop: Tektronix `.isf` (TDS, DPO, MSO and MDO reference waveforms), Keysight or Agilent `.bin` (InfiniiVision and Infiniium; every waveform in the file with the same time axis, a peak-detect record as its max and min) and Teledyne LeCroy `.trc` (the first segment of a sequence). Each column carries the unit the header names (V, A) and is scaled as the header says; the time is 0 at the trigger, and a note gives the trigger's sample and the sample interval. Tektronix `.wfm` files are not read yet: save the waveform as `.isf` or CSV. Pass a `path` ending in `.isf`, `.bin` or `.trc`, or `bytes` with `"format": "isf"`, `"bin"` or `"trc"`. - **File > Import > Measurement** does the same from the menu, after a run. Pick the CSV; the window lists its columns with the simulated signal each one seems to be (by name, then by unit) and lets you change the pairs. **Compare** finds the time shift and shows, per signal, the RMS error, how well it matches and what the difference suggests. Each measured trace is then drawn dashed on its signal's plot, marked "(measured)"; its **Measured** row in the scope toolbar's **References** list hides or drops it. A file written by File > Export > Waveforms (CSV) reads back and matches its own run. The command behind it is `file.importMeasurement`. - From a script, name the file with `path`: `powercraft-cli run --in pol.pcraft --root w --cmd simulation.run --cmd file.importMeasurement --params '{"path":"scope.csv","map":{"v(out)":"CH1"}}'` reads `w/scope.csv` (a `.raw` or `.mat` is read as bytes). `waveform.compare`, `debug.fitToMeasurement` and the other commands that take a scope file read `path` the same way wherever a folder is allowed: `--root` on the command line, the automation folders of `serve` and the app. A path outside the allowed folder is refused. - The reader knows the CSV layouts of Tektronix (the legacy TDS/TBS/DPO2000 files with the data in fields 4 and 5, and the MSO 4/5/6 files with a `Vertical Units` line), Keysight InfiniiVision (`x-axis`, then a `second,Volt` units row), Rigol (`X,CH1`, including the Start/Increment files that number the samples) and any plain time/value table. Units in the headers (`Time (ms)`, `CH1 [mV]`) are converted to seconds, volts and amps. `units` (`{"CH2": "A"}`) says what a column's numbers are in when the file does not, `decimate` keeps one sample in n of a long record, and `timeOffset` adds seconds to the measured time before the alignment. - A measured loop gain from a network analyser (a Bode 100, an AP300 or a scope's frequency response analysis) is a CSV with `Frequency (Hz)` (or `kHz`), `Gain (dB)` and `Phase (deg)` (or `rad`) columns, in any order. The same command reads it as a frequency response, not a waveform, with no run needed: the reply has `kind: "bode"`, the points, and the crossover, phase margin and gain margin read the same way as `analysis.loopGain` reads its own. Pass that reply to `analysis.loopGain` as `compareTo`; its `comparison` gives the crossover and margin differences (simulated minus measured) and the largest gain and phase gaps where the two sweeps overlap. - Alignment: `"timeShift": "auto"` (the default) finds the shift by cross-correlation; `"trigger"` puts the first rising edge (`"triggerEdge": "falling"` for a falling one) of the first measured column on the simulated one's, as the scope's trigger did; a number is a fixed shift. Tick **Align on the first rising edge (trigger)** in the window for the same. - Per signal the comparison gives the RMS error, the peak error and, for a step response, the 10–90 % rise time and the 2 % settling time of both traces with their difference (shown in the window as two more columns). - **File > Export > Measurement Comparison** (`file.exportComparison`) writes what a report or thesis needs: the overlay figure (`"figure": "svg"` or `"png"`), the error table (`"table": "latex"`, `"markdown"` or `"csv"`, with `"lang": "zh-Hant"` for Chinese headings) and the aligned traces as CSV (`time,sim:…,meas:…`) to replot with your own plot style. With `"out": "results/c1"` it writes `results/c1.svg`, `results/c1-table.tex` and `results/c1-data.csv`. Voltecx makes no measured data: the numbers come only from your scope's file. - **Share this validation with Voltecx** appears in the Import Measurement window once a comparison has run. It is optional and sends nothing until you say so. The dialog lists what is sent (the version and solver, the component kinds and counts, a fingerprint of the circuit, and the summary numbers per signal, never the waveforms), lets you pick the topology and add the operating point and instrument, and shows the exact payload. Send stays grey until you tick the consent box; the circuit itself goes only if you also tick **Also send the circuit**. Offline, the upload waits and is retried every hour. We review each upload and publish only per-model accuracy over at least 3 accepted uploads. The command is `validation.share`; the Privacy Notice (section 6) has the details. ## Design report as PDF or HTML Needs sign-in to Voltecx Cloud: the design report is made with Auto Design, which runs there (chapter 16). `report.export` writes the design report of the active circuit as one file: ```sh powercraft-cli run --root out --new '{}' \ --cmd design.auto --params '{"spec":{"vin":12,"vout":3.3,"iout":5}}' \ --cmd simulation.run --params '{}' \ --cmd report.export --params '{"path":"report.pdf","lang":"en"}' ``` - **What is in it.** The latest `design.auto` run on this circuit in this session: the verdict, spec, topology, gates, values with their formulas, magnetics, verification, the loop with its Bode plot and margins, efficiency and losses, thermal, stress, worst case, gate drive, sense network, protection, firmware, conducted emission, layout checklist, bill of materials, the stages of the run, open items and what was not checked. Then the schematic of the circuit as it is now and the key waveforms of its latest simulation: one plot per scope, or, without scopes, the output voltage, the switch node and the inductor and switch currents. - **After reopening the file.** `design.auto` keeps a record of its report with the circuit, saved in the file (the same undo step that keeps its spec). Open the file in a later session, or on another computer, and `report.export` writes the same report from it: `powercraft-cli run --in pol.pcraft --root out --cmd report.export --params '{"path":"report.pdf"}'`. The record leaves out the schematic picture (the report draws the circuit as it is then) and keeps at most 200 points of each plot. - **Without a design.auto run** (and no record in the file) the report has the schematic and the waveforms only. You can also pass a saved `design.auto` reply as `report`. - **Out of date.** When the circuit changed after the run, or after the simulation, the report says so. - **Formats.** `pdf` (the default) is written by Voltecx itself, with no other program, and is read back before it is written. `html` is one page with the schematic and the plots inline. - **Fonts.** The PDF uses the standard fonts every PDF reader has, so no font is embedded. Chinese text uses the reader's own Traditional Chinese font (Adobe-CNS1): Acrobat, Preview on macOS and browsers have one. On Linux, poppler-based readers need the `poppler-data` package. ## Schematic figures for reports and theses (beta) `file.exportSchematic` writes the schematic as a picture you can put in a document: ```sh powercraft-cli run --root figs \ --cmd file.openExample --params '{"name":"buck"}' \ --cmd file.exportSchematic --params '{"format":"tex","path":"fig-buck.tex"}' ``` | `format` | What you get | |---|---| | `svg` | A vector picture. Every drawn item carries a `data-part`, `data-net` or `data-pin` attribute, so you can pick parts by name in Inkscape. Text uses IBM Plex, and falls back to a system font | | `png` | A raster picture, with every designator, value, pin name, label and note lettered in a small pixel font: paste it into a chat, an issue or a review. Use SVG or PDF where the text must be typeset | | `tex` | A `circuitikz` fragment in the style of a thesis kit. It holds only the content, so you `\input` it into a figure | Other keys: `theme` is `light`, `dark` or `print` (black on white). `scheme` is `classic` (textbook colours) or `ink` (all ink, blue control signals). The `tex` output ignores the theme, because your LaTeX package sets the colours. `file.print` writes a black-and-white `svg`, `png` or `pdf` for printing: `{"path": "buck.svg", "format": "svg"}`. The command itself does not open a print dialog. In the desktop app, **File > Print** (**Cmd+P**) writes the sheet as an A4 PDF, with a page for each subsystem, in the temporary folder and opens the system's print dialog on it: Preview's on macOS, the PDF viewer's on Linux (or the default printer through `lp` when there is no viewer), and the `print` action of the PDF program on Windows. In the browser, Print downloads the sheet instead. `parts` draws only the parts you name, with the nets between them and the labels on their pins (`{"path": "stage.svg", "parts": ["Q1", "D1", "L1"]}`), so one stage of a converter can be a figure of its own. The circuit keeps every part. **Edit > Copy Schematic as Image** and **Edit > Copy Schematic as SVG** put the drawing on the clipboard, to paste into a report, a slide or a mail. The image is the PNG above in light colours; the SVG is its text, which drawing programs and office suites paste as a vector figure. Neither depends on the zoom or the grid. With parts selected, only they are copied. **File > Print Selected** prints the selected parts alone on one A4 sheet, through the same print dialog as Print (`file.print {"parts": [...]}`). **File > Export > Schematic** asks where to save and writes the same A4 sheets as a PDF (`file.exportSchematic {"path": "buck.pdf", "format": "pdf", "page": "a4"}`). Every sheet (`page` a4, letter or fit, and `file.print`) has zone references around its frame, as KiCad and Altium draw them: rows A, B, C… from the top (no I or O, which read like 1 and 0) and columns 1, 2, 3… from the left, in 50 mm fields measured from the sheet's centre lines (ISO 5457). An A4 or Letter sheet has rows A to D and columns 1 to 6, so a review can say "Q1 in B3". **File > Export > Scope image** opens the same Export window on its Scope image page: PNG or SVG at the width and height you pick, with the scope's plots stacked as the scope shows them (voltages and currents each on their own range, `scope.export {"axes": [...]}`). The preview is drawn at the size it is shown, so its traces and labels stay readable. File > Export lists the same items, in the same order and under the same names, as the window's left column; a greyed item says why when you point at it. All three formats use the same drawing data as the canvas, so the file matches what you see. The paths are always checked against the folder you allow (`--root` on the command line). Without an allowed folder the command writes nothing. The `tex` output was checked against the thesis package's conventions and by unit tests, but it has not been typeset on a machine with LaTeX. Compile your first figure and look at it. Parts that the package has no symbol for appear as boxes, and the reply lists their names under `unsupported`. The details are in `docs/workflows/schematic-export.md`, which arrives with this feature. --- # 10. Models: motor drives, ICs, non-ideal parts and digital control URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/10-models/ Voltecx has four families of models beyond the basic parts. This chapter says what each one is, how to start with it, and what it cannot do. In every case the models are textbook models with illustrative default values. Replace the defaults with your own data before you trust a result. ## Motor drives Voltecx has a rotational mechanical domain and electric machine models, so you can simulate an inverter and the motor it drives in one circuit. ### What is in the box | Part | Details | |---|---| | Mechanical elements | `inertia`, `friction`, `torque` (constant load), `fan` (T = k w abs(w)), `constantPower`, `speed` (ideal speed source), `gear`, `speedSensor`, `positionSensor`, `torqueSensor` | | Machines | `induction` (squirrel cage), `inductionWound` (wound rotor or doubly fed), `spmsm` and `ipmsm` (permanent-magnet synchronous), `dc` (separately excited), `dcPm` (permanent-magnet dc) | | Control blocks | `clarke`, `invClarke`, `park`, `invPark`, `abc2dq`, `dq2abc`, `svpwm` and `angle`, for field-oriented control. The three-phase `pwm3` block makes the gate signals. The `smo` block estimates the rotor angle and speed without a sensor (below) | | Beta machines | `bldc`, `syncWound`, `srm` (switched reluctance), `stepper`, `inductionSat` (saturating induction), with `encoder`, `resolver` and `hall` sensors (beta) | | Beta examples | `imVf` (open-loop V/f), `imIfoc` (indirect field-oriented control), `imDtc` (direct torque control), `pmsmFoc`, `dcMotor` (beta), and `pmsmSmo` (sensorless PMSM) | An `ipmsm` can also run from a flux map instead of Ld, Lq and ψf: `mapId` and `mapIq` list the d- and q-axis currents of a grid (rising, at least two each), and `mapPsiD` and `mapPsiQ` the flux linkages at each grid point, rows by d-axis current. The machine then saturates and cross-saturates as the map says, bilinear between the points and carried on linearly past the edges. `magnetics.machineEquivalent` with `fluxMap`, `component` and `apply` writes such a map from the field solver. Machine ports are named: `a b c` for the stator, `n` for the neutral, `shaft` for the mechanical side. The mechanical side is a net of its own. Its "voltage" is the speed in rad/s, and the "current" is the torque in N m. Wire a load (`inertia`, `fan`, `torque`) to the shaft net. ### Start from a part description `component.describe` tells you a part's ports and parameters, with units and defaults: ```json {"kind": "machine", "model": "induction"} ``` The properties panel shows the same list, with the unit beside each value and the description on hover. ### Results | Signal | Meaning | |---|---| | `Te(M1)` | Electromagnetic torque of machine `M1`, N m | | `wm(M1)` | Mechanical speed, rad/s | | `theta(M1)` | Electrical angle, rad | | `i(M1.a)` | Winding current. A dc machine has `i(M1.a)` (armature) and `i(M1.f)` (field) | | `w(net)` | Speed of a mechanical net, rad/s | ### A typical drive An inverter-fed induction motor with V/f control chains: a ramp, a V/f table, `angle` (integrates the frequency), `dq2abc`, `svpwm` (in `duty` mode), `pwm3`, the six-switch bridge, the `induction` machine, and an `inertia` and a `fan` on the shaft. With field-oriented control you add the `abc2dq` transform on the measured currents, a pair of current PIs and a speed PI. The `design.currentLoop` and `design.speedLoop` tasks (chapter 7) size those PIs. For a PM synchronous machine, `design.mtpa {imax, vdc}` gives the d- and q-axis current references for the most torque per ampere, the base speed, and the torque-speed envelope with field weakening above it. It reads Rs, Ld, Lq, ψf and the poles from the `spmsm` or `ipmsm` and changes nothing. **Design › Design Steps › PMSM Efficiency Map** (`design.motorMap`) maps a three-phase PMSM's steady-state efficiency over speed and torque without a circuit. Give `rs`, `ld`, `lq` (at least `ld`), `psif`, `poles`, the peak phase current `imax`, the peak phase voltage `vmax` and the top speed `rpmMax`; `speedPoints` and `torquePoints` set the grid (10 each by default). Each cell takes the least-current point of its torque inside both the current circle and the voltage ellipse (flux weakening above the base speed) and gives id, iq, the voltage, the copper loss and the efficiency, or says it is not reachable; the result also has the torque-speed envelope and the per-unit values (Kirtley, MIT 6.685 class notes 7, 2005). By default the voltage limit leaves out the drop on the phase resistance. With `resistiveDrop: true` it includes it (Vd = Rs·Id − ω·Lq·Iq, Vq = Rs·Iq + ω·(Ld·Id + λf), class notes 9, eqs. 51–52), at the Rs you give, with no temperature rise and no inverter or cable drop: the base speed comes out lower, and 0 when Rs·imax reaches vmax. `ironLoss` adds the iron loss of M-19 or M-36 steel, or of your own fit, over up to 8 regions such as teeth and back iron; without it the efficiency counts copper loss only and is an upper bound. `braking: true` also maps the braking quadrant with the power returned to the supply. With `resistiveDrop`, braking is no longer the mirror of motoring: at a high speed a small braking torque can be out of reach while a larger one is reachable. Magnet, friction and windage loss are left out unless you give `windage` {`radius`, `length`, `gap` (below the radius), `density`, `viscosity` (dynamic) and an optional multiplier `factor`, 1 for a smooth cylinder}: each cell then also counts the windage loss Pw = k·π·Cd·ρ·R⁴·Ω³·L of a cylindrical rotor in turbulent flow at its speed, with the skin friction coefficient Cd from the Reynolds number R·t·Ω·ρ/μ (Vrancik, NASA TN D-4849, 1968, eqs. 5 and 6), and `windage.speeds` lists Re, Cd and Pw per grid speed. The gas and the factor are yours: none is built in. Bearing friction stays out unless you give `bearings` with either one total frictional `moment` of all bearings (N·m) or a table `moments` of {`rpm`, `moment`} points (speeds strictly rising, interpolated in a straight line and held at the ends), for example from the bearing maker's calculator: each cell then also counts Pb = M·Ω at its speed (SKF, Rolling bearings, 2018, p. 132), and `bearings.speeds` lists M and Pb per grid speed. No bearing model is built in. Magnet loss stays out unless you give `magnetLoss` {`volume` (m³, all magnets), `resistivity` (Ω·m), `thickness` (m, across which the eddy currents close, one segment's for segmented magnets), `ripple` (T, the peak of the alternating flux density in the magnets), `order` (its frequency as a multiple of the electrical frequency) and `permeability` (relative, at least 1)}, all six required: each cell then also counts the resistance-limited thin-sheet eddy-current loss Pm = V·π²·B̂²·d²·f²/(6·ρ) at f = order·p·rpm/60, and `magnetLoss.speeds` lists f, the skin depth δ = √(2ρ/(ω·μ0·μr)) and Pm per grid speed. Where the thickness is not below the skin depth the speed is flagged `quasiStatic: false` and a note says the loss there is above its true value; it is not corrected. The ripple and its order are yours (one ripple at every load): none is derived from slots, windings or switching. Without all of these losses the efficiency is still an upper bound. The map changes nothing in the circuit. A drive has fast current dynamics and slow mechanics, so try variable step (chapter 4) if a fixed step is too slow. ### Sensorless control with the `smo` block A position sensor costs money and can fail. The `smo` block (sliding-mode observer) estimates the rotor angle and the electrical speed of a permanent-magnet synchronous machine from its stator voltage and current. | Pin | Meaning | |---|---| | `valpha`, `vbeta` | The stator voltage the inverter is commanded to apply, in the alpha-beta frame (for example from `invPark`) | | `ialpha`, `ibeta` | The measured stator current in the alpha-beta frame (for example from `clarke`) | | `theta` | Estimated rotor electrical angle, 0 to 2 pi, in radians | | `w` | Estimated electrical speed in rad/s. It is negative when the machine turns backwards | The parameters are `rs` and `ls` (the machine's stator resistance and inductance; the observer assumes a surface machine, so Ld = Lq), `k` (the sliding gain), `phi` (the boundary layer, default 1 A), `fc` (the low-pass on the back-EMF estimate, default 300 Hz) and `fpll` (the bandwidth of the phase-locked loop, default 100 Hz). Set `k` to about 1.5 times the highest back-EMF, which is the flux linkage times the highest electrical speed. If `k` is lower, the estimate saturates and the angle is wrong. The block uses a boundary layer instead of a sign function, so it does not chatter, and its angle is compensated for the lag of its own filters. Two things to remember. First, the observer needs back-EMF, so it cannot start a machine from standstill. Start open loop and hand over once the estimated speed is high enough. Second, give it the voltage the machine really gets, not a duty cycle. The `smo` block has no direct feedthrough, so it can sit inside the loop it feeds. The example `pmsmSmo` (**File › Open Example › Motor drives › PM synchronous motor, sensorless**) is `pmsmFoc` without the position and speed sensors. It starts with an open-loop I/f ramp: a rotating current vector with id* of 5 A. When the observer's speed and the ramp both pass 250 rad/s (electrical), a latch hands the angle over to the observer, id* goes to 0 and the speed loop takes over. The speed loop works in electrical rad/s. Plot `wm(M1)`, `wh` (the estimate), `Te(M1)`, `idm`, `iqm` and `sel` (0 before the hand-over, 1 after). As with every example, the parameters are illustrative, not from a datasheet. ### Limits The machine models are textbook models (Krause, *Analysis of Electric Machinery*), and the example parameters are illustrative, not from a datasheet. The equations, parameters, numerical method and the list of what is not modelled yet are in `docs/motor-drive.md`. ## Transistors: BJT and level-1 MOSFET Besides the gate-driven switches (`mosfet`, `igbt`), Voltecx has transistors whose control pin is an electrical node, as in SPICE. | Part | Pins | Model | |---|---|---| | `npn`, `pnp` | `c b e` | Piecewise-linear Ebers-Moll. The base-emitter junction is a diode with drop `vbeOn` and resistance `ron`. The base-collector junction is a diode with drop `vbeOn` minus `vceSat`. A current of `bf` times the base-emitter current minus `br` times the base-collector current flows from collector to emitter. `rb`, `rc` and `re` add series resistance | | `nmos`, `pmos` | `d g s` | Level 1 (Shichman-Hodges, square law with `lambda`), solved by Newton iteration at each step. At `level: 3`, the SPICE level-3 short-channel model (threshold, mobility, velocity saturation, channel-length modulation, subthreshold; Meyer and overlap capacitances; the bulk-drain junction) that vendor subcircuits use. At `level: 2`, the SPICE level-2 Grove–Frohman model (bulk charge, mobility degradation `ucrit`/`uexp`, velocity saturation `vmax`/`neff`, channel-length modulation from `lambda` or `nsub`, subthreshold), with the same capacitances and junction. At `level: vdmos`, the VDMOS power MOSFET of vendor SPICE models: the channel with subthreshold, `mtriode` and `theta`, series `rd`, `rs`, `rg`, a constant `cgs`, the non-linear gate-drain capacitance (`cgdmax`, `cgdmin`, `a`) and the body diode with its junction capacitance and stored charge (`is`, `n`, `rb`, `cjo`, `vj`, `m`, `fc`, `tt`) and its reverse breakdown, which clamps the drain in avalanche (`bv`, `ibv`, `nbv`) | `i(Q1)` is the collector current. Use a BJT for base-driven switches, level shifters, current sources and small linear stages. Use `mosfet` or `igbt` for power switching. Limits to know: - The BJT is piecewise linear: cutoff, active, saturation and reverse. There is no exponential law, no charge storage and no Early effect. A BJT amplifier can report "switch states did not settle" because the junction states keep flipping. - The level-1 MOSFET has no charge storage and no body effect (the `vdmos` level has its capacitances and body diode, but no quasi-saturation, breakdown or self-heating, and it is evaluated at `tnom`). A circuit with one skips the factorisation cache, so it runs slower than a switch-only circuit. Linear AC analysis uses the operating point it held at the end of the run and warns about it. - These parts are not written to a SPICE netlist or an LTspice file: exporting a circuit that holds one gives a warning. They are read, though (chapter 9). The component guide (F1, `component.reference`) lists every parameter. `demo:npn`, `demo:pnp`, `demo:nmos` and `demo:pmos` open a small circuit for each. GaN transistors (`tech gan`: EPC2045, EPC2218, EPC2302, TP65H050G4WS, GS66508T) are drawn without a body diode, and conduct in reverse through the third-quadrant drop of their data sheet. `rdsDyn` is the factor on `ron` after the device has blocked a high voltage (the data sheet's dynamic RDS(on); 1 is off). The EPC parts carry the transfer curve and the capacitance curves that the dynamic switching level reads. The `buckGan` example (chapter 15) uses them. ## Data sheets of catalogue parts Every catalogue part cites its data sheet: the vendor's own link, the document, its revision, and the table, figure or page each value was read from. Voltecx does not ship the PDFs, which belong to their vendors. The **Data sheet** button opens the vendor's link: on a library row (hover the row), in the Component Guide, and next to the catalogue part in Properties. Under the part, Properties lists its cited values. Hover one to see where it was read (`RDS(on) 66 mΩ: Wolfspeed C3M0065090D data sheet, Rev. 08, Fig. 5`); click it to open the data sheet, at that page when the citation names one. To read a data sheet offline, right-click **Data sheet** and pick **Save offline…**. Voltecx shows the size and the source first and downloads nothing until you click **Download**. The copy stays in your cache folder on this computer, and it opens from there next time. The same commands are `part.datasheet {part, value?}` and `part.datasheetCache {part, consent?}`, so an agent can quote a citation and open the page too. A part that is not in the catalogue can be modelled from the graphs of its own data sheet. In **Library › Your Parts**, **Fit a data-sheet graph** takes the points you read off one graph, one `x, y` pair per line in SI units (`5m` and `2n` work): on-resistance against junction temperature, forward voltage, turn-on or turn-off energy against current, reverse-recovery charge against di/dt, or output capacitance against voltage. **Fit the points** fits the curve's usual form (or the model you pick) and shows the formula, its parameters, the RMS and worst relative error, and every point with its fitted value and error, the worst one marked. A fit worse than the error you allow (10 % by default) is refused. A forward-voltage fit can be kept as your own diode: name the data sheet and figure, and give its voltage and current ratings. The points you entered are kept, not the fitted values, in the open circuit (so they are saved with its file), with the source `user, from graph: …`, never in the cited catalogue. A loss or charge curve is fitted and shown but not kept as a new part, since a switch also needs its conduction table. A turn-on or turn-off energy graph, or a forward-voltage graph, can instead be added to a part of your own that you already have (`library.fitCurve` with `attachTo`, the part id, and for an energy graph the blocking voltage `v` of the figure): it becomes that part's energy curve at that voltage and temperature, or the conduction curve of a diode or of a switch's body diode. Catalogue parts are not changed. The command is `library.fitCurve`. ## Vendor SPICE models A vendor's model file (`.lib`, `.mod` or `.sub` for a MOSFET or a diode) can go straight into your circuit. Voltecx reads the file from your disk and keeps only the part it builds from it, in your circuit file. It never copies or ships the vendor's file. ```sh powercraft-cli run --cmd file.openExample --params '{"name": "buck"}' \ --cmd spice.listModels --params '{"path": "models/vendor.lib"}' \ --cmd spice.placeModel --params '{"path": "models/vendor.lib", "name": "MYFET", "instance": "Q2"}' ``` `spice.listModels` lists the file's subcircuits (`.subckt`) and its `.model` cards of type `D`, `NMOS`, `PMOS`, `VDMOS`, `NPN` and `PNP`, with their pins. `spice.placeModel` builds one of them as a subsystem and places it with its pins unconnected, named as the model names them. Wire them with `circuit.connect`. A bare `.model` card gets the pins SPICE gives its element: `a k` for a diode, `d g s` for a MOSFET (body tied to the source; a VDMOS has no body pin), `c b e` for a bipolar transistor. One undo removes the placement. Each element is read as `file.import` reads a SPICE netlist (chapter 9): diodes become piecewise-linear ones unless the card gives stored charge (`CJO` or `TT`, as vendor diode models do), which makes them the exponential diode with that junction capacitance and recovery charge, `NMOS`/`PMOS` cards are read as level 1 or, with `LEVEL=2` or `LEVEL=3`, as that level (other levels, BSIM among them, are read as level 1 with a warning), and `VDMOS` cards (most vendor power-MOSFET models) become an `nmos` or `pmos` at `level: vdmos`, with the capacitances and body diode that set the switching waveform (see the limits above). Its double-pulse waveform is checked against ngspice (`docs/accuracy.md`). Whatever is not mapped exactly is listed in `warnings`, so read them. To see it before you place the part, run `spice.importReport` with the same `path` and `name`: it lists each element and each `.model` parameter as mapped, approximated, dropped or unused (noise and information fields, which do nothing in SPICE either), with its line in the file and the reason, and ends with one line of fidelity such as `MYFET: kept as written 5 of 6 elements and 30 of 34 model parameters; dropped: J1 TV.RTHJC`. `spice.placeModel` returns the same line as `fidelity`. Encrypted models are refused: ask the vendor for an open model, or build the part from its data sheet. Controller and driver IC macro-models are not supported yet. Use the behavioural ICs below for those. ### Example: a VDMOS, a diode and a level-3 MOSFET card Save these three cards as `models/demo.lib` in the project folder. They were written for this manual and are no vendor's part; the first is the card Voltecx checks against ngspice. ``` .model VTEST VDMOS(Rg=1.5 Vto=3.5 Rd=40m Rs=5m Rb=10m Kp=25 Lambda=2m Theta=0.05 Mtriode=0.8 Ksubthres=0.12 + Cgdmax=1.2n Cgdmin=150p A=0.4 Cgs=1.8n Cjo=1.5n Vj=0.6 M=0.45 Is=5e-11 N=1.2 TT=40n) .model DFW D(Is=1e-12 N=1.5 Rs=5m Cjo=500p Vj=0.7 M=0.4 TT=30n BV=650) .model M3 NMOS(LEVEL=3 VTO=3 KP=20u UO=600 TOX=100n NSUB=1e15 NFS=1e11 VMAX=1e5 THETA=0.1 KAPPA=0.2 NSS=1e10) ``` ```sh powercraft-cli run --root . --cmd file.new --params '{}' \ --cmd spice.listModels --params '{"path": "models/demo.lib"}' \ --cmd spice.placeModel --params '{"path": "models/demo.lib", "name": "VTEST", "instance": "Q1"}' \ --cmd spice.placeModel --params '{"path": "models/demo.lib", "name": "DFW", "instance": "D1"}' \ --cmd spice.placeModel --params '{"path": "models/demo.lib", "name": "M3", "instance": "Q2"}' ``` `spice.listModels` lists `VTEST` (kind `vdmos`, pins `d g s`), `DFW` (kind `d`, pins `a k`) and `M3` (kind `nmos`, pins `d g s`). `VTEST` places with no warning. `DFW` becomes the exponential diode with its junction capacitance and transit time, and warns that the reverse breakdown (`BV=650`) is not modelled. `M3` becomes a level-3 MOSFET and warns that the threshold from process parameters (`NSS=1e10`) is not modelled. In a 400 V, 20 A double pulse, `VTEST` follows ngspice-42 within 2.2e-3 in the drain voltage, with the same 202 µJ turn-off energy and 1.10 mJ against 1.02 mJ at turn-on (`docs/accuracy.md`). ### Limits of the vendor models - VDMOS: quasi-saturation (`RQ`, `VQ`), the subthreshold shift `SUBSHIFT` and the body-diode breakdown are modelled, and a part at another temperature than the card's `TNOM` is moved there. Every temperature coefficient the card gives (`TEXP1` and `TKSUBTHRES1`/`2` among them) moves the part; self-heating is not modelled. The warnings name each one a card gives. - Diodes: breakdown, `IKF`, `ISR`/`NR`, temperature dependence and the area factor are not modelled. A diode with both `qrr`/`trr` and `cjo`/`tt` is an error. - Levels 2 and 3: sheet resistance (`RSH`) and the body effect of a body off the source are not modelled. The instance's `AD`, `PD` and `AS` size the body junction from `CJ`, `CJSW` and `JS`, as in SPICE. BSIM cards are read as level 1, with a warning. - Encrypted models are refused. ### Whole vendor libraries Vendors publish their models as libraries of hundreds of parts. Voltecx does not ship them (the vendors' terms do not allow it), so download a library yourself and point Voltecx at its folder. `library.vendorSources` (and **Where to Get Vendor Models** in the library panel's **More Actions** menu, at the right of its title) links the official pages of Infineon, Wolfspeed, TI, onsemi, Navitas, EPC, ROHM and ST. Choose **Library › Import Vendor SPICE Models** (or the import icon at the right of the library panel's title). The **Import vendor SPICE model** window reads one model file (**Choose file…**) or a whole library folder (**Choose folder…**) and lists its models before anything is added: each model, what it reads as (a VDMOS MOSFET, a diode, a subcircuit), its pins and its status (**Ready**, a number of warnings, **Needs pin map**, **Mapped**, **Skipped** or **Failed**). The warnings and the reasons a model or file is skipped (an encrypted file, a `.model` type Voltecx does not map) are listed under the table. Under them is the **Import report** of one model (the first one Voltecx can use; click another model's name to see its own), as `spice.importReport` gives it: the line of fidelity, how many elements and parameters are mapped, approximated, dropped or unused, and each one that is not mapped as written, with its line in the file, its kind, the result and the reason (hover over a cut reason to read it whole). A model with nothing lost says **Every element and parameter is mapped as written.** A model whose pins are numbered gets a **Pin map** table: pick its symbol, then the role each pin connects to; the map is saved with your library. **Add N models to library** indexes the file or folder; **Cancel** (or Esc) leaves the library as it was. From the CLI: ```sh powercraft-cli run --root ~/models \ --cmd library.importVendor --params '{"folder": "infineon"}' \ --cmd library.vendorModels --params '{"filter": "MYFET", "status": "ok"}' \ --cmd file.new --params '{"name": "dpt"}' \ --cmd library.placeVendor --params '{"name": "MYFET65", "instance": "Q1"}' ``` Every `.model` and `.subckt` of the folder's `.lib`, `.mod`, `.sub` and `.cir` files is indexed with its pins, vendor and file, and mapped the way `spice.placeModel` maps it: **ok** (warnings name what is not modelled exactly), **unsupported** (with the reason, such as a `.model` type Voltecx does not map) or **failed**. Encrypted files are listed as skipped. Pins named like `D G S`, `C G E` or `A K` (with a Kelvin source or `Tj`/`Tcase` thermal pins) are matched to the MOSFET, IGBT or diode symbol; numbered or unknown pins put the model on the **needs pin map** list: it still places, and you wire its pins by name. The models show in the panel with a **user library** badge; click one to place it. The index is yours (`library/vendor-models.json` in the settings folder), never in a circuit or shared; the vendor files stay where you put them. `library.removeVendor` forgets a folder. Details: `docs/vendor-libraries.md`. ### Behavioural B sources Vendor macro-models often build a part's channel, a clamp or a controller stage from SPICE `B` elements: a voltage or current source whose value is a formula of node voltages, element currents and time. There is no command of its own: `file.import` reads `B` lines in a netlist (and LTspice `bv`/`bi` symbols), and `spice.placeModel` reads them inside a vendor `.subckt`. Each becomes a controlled source named after the `B` element, driven by meters and an `expr` block whose signals are recorded too (`B1_v1`, `B1_ctl`). | You write | It reads | |---|---| | `Bname n+ n- V=expr` or `I=expr` | A voltage source, or a current from `n+` to `n-` through the source | | `V(a)`, `V(a,b)` | A node voltage, or the difference of two | | `I(X)` | The current in `X`, for a resistor, inductor, capacitor, DC, sine or pulse voltage source, DC current source, ideal switch, controlled source or diode | | `time`, `pi`, `.param` names | The simulation time, π and the netlist's parameters | | `+ - * / % **`, `< <= > >= == !=`, `! & \|` | Arithmetic, power (`**`), comparisons (1 or 0) and logic (true above 0.5) | | `sin` … `atan2`, `sinh`, `cosh`, `tanh`, `exp`, `ln`, `log` (natural, as in LTspice), `log10`, `sqrt`, `abs`, `min`, `max`, `pow`, `pwr`, `pwrs`, `sgn`, `u`, `uramp`, `int`, `floor`, `ceil`, `round` | The LTspice functions of the same names | | `if(c, a, b)`, `limit(x, lo, hi)`, `table(x, x1, y1, x2, y2, …)` | A choice, a clamp, and a piecewise-linear table held flat beyond its ends | **Example.** Save this netlist as `bdemo.cir`: ``` b source demo V1 in 0 SIN(0 5 1k) B1 out 0 V=limit(2*V(in), -4, 4) R1 out 0 1k B2 sq 0 V=if(V(in) > 0, 1, 0) + table(time, 0, 0, 1m, 2) R2 sq 0 1k B3 ib 0 I=I(R1)*2 R3 ib 0 1k B4 d 0 V=ddt(V(in)) R4 d 0 1k .tran 1u 1m .end ``` ```sh powercraft-cli run --root . --cmd file.import --params '{"path": "bdemo.cir"}' \ --cmd simulation.run --params '{}' \ --cmd scope.measure --params '{"signals": ["v(out)", "v(sq)", "i(B3)", "i(R1)"]}' ``` The import warns that `B4` is skipped (`ddt` is not supported) and that one source reads an element current and so follows one step late. `v(out)` is the doubled sine clamped at ±4 V, `v(sq)` steps between the two branches of the `if` on a ramp that ends at 2 V, and `i(B3)` peaks at 8 mA, twice the 4 mA in `R1`, one 1 µs step after it (67 µs against 66 µs). **How it is solved, and its accuracy.** A source that reads only node voltages and `time` is solved with the rest of the circuit in each Newton iteration, in both solvers and in the AC analysis, as SPICE does. A source that reads an element current `I(X)` is evaluated from the last solution, one step late; inside a tight feedback loop it can need a smaller maximum step. On a 400 V, 20 A double pulse of a MOSFET macro-model whose channel is a B source (written for the tests, not a vendor model), both solvers follow ngspice-42 within 0.4 % in the turn-on and turn-off energy, and the drain current at the end of the first pulse is 20.30 A in all three (`docs/accuracy.md`). **Limits.** - `ddt(x)`, `idt(x[, ic[, reset]])` and `delay(x, td)` are solved with the circuit: the derivative, the integral from `ic` (held at `ic` while `reset` is true) and `x` as it was `td` ago. - `white`, `rand`, ngspice's `pwl`, `mod` and any function not in the table skip the source with a warning, as do the options `laplace=` and `delay=`. Other options (`Rpar=1k`) are ignored with a warning. - `^` is refused (it is exclusive-or in LTspice and a power in ngspice: write `**`), and so is `? :` (write `if(c, a, b)`). - At most 8 different voltages and currents in one source; an `I(X)` of another kind of element, or of a part that is missing, skips the source. - `I(X)` sources lag one step, as above. - Digital XSPICE `A` devices import as logic blocks (gates, flip-flops, latches, bridges, `d_osc`, the `d_source` pattern source, the `d_state` state machine, whose files are read next to the netlist, and the `d_ram` memory). The unknown state is not modelled, so some controller and driver IC macro-models still do not import whole: use the behavioural ICs below. - The B source has been checked against a macro-model written for the tests, not against a vendor's file. `spice.placeModel {"text": "", "instance": "Q2"}` on the buck example (`text` takes the file's text in place of `path`): ![The VTEST card placed as Q2 in the buck example, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/vendor-spice/01-placed.png) 1. `Q2`: the VDMOS built from the card, a subsystem with the pins `d`, `g` and `s`. 2. **Problems**: its pins are still open. Wire them with `circuit.connect`. ## Thyristors: TRIAC, DIAC, GTO and IGCT Besides the `thyristor` (SCR), the library has four more thyristors, each with defaults from a named data sheet. | Part | Default from | Behaviour | Pins | |---|---|---|---| | `triac` | ST BTA16-600B (DS2114 Rev 11) | Fires either way when the gate current exceeds `igt` (50 mA) in one of its `quadrants` (`1234`, or `123` for a three-quadrant part); stays on until the current falls below `ih` (50 mA) | `mt2 mt1 gate` | | `diac` | ST DB3 (DS2125 Rev 3) | Breaks over at `vbo` (32 V) either way, then conducts at `vf` until its current falls below `ih` | `a1 a2` | | `gto` | ABB 5SGA 30J4502 | A positive gate (above 0.5) fires it, a negative gate (below −0.5) turns it off; holding current 50 A | `a k gate` | | `igct` | ABB 5SHY 35L4520 | Conducts forward while its gate unit's command is above 0.5 | `a k gate` | The TRIAC's gate is read as a current in amperes, so a logic 1 fires it too. The examples `triacDimmer` (an R-C network and a DIAC fire a TRIAC about 98 degrees into each half cycle of 230 V) and `triacHeater` (zero-cross drive, 3 of every 5 cycles) show them at work: ```sh powercraft-cli run --cmd file.openExample --params '{"name": "triacDimmer"}' --cmd simulation.run ``` What the models leave out: a TRIAC's commutating and static dV/dt limits are not checked, so a real part may fire falsely or fail to turn off where the model does not; a GTO turns off any current, so check it against its largest controllable current (3000 A for the default part) yourself; an IGCT blocks any reverse voltage, though the real asymmetric part blocks only 17 V, so put a diode across it in a bridge; and gate-unit minimum on and off times are not enforced. Layout hints, soft-switching checks and the KiCad and SPICE exports do not know these four kinds yet. ## Oscillators, the 555 and phase-locked loops **Measure an oscillation.** `scope.measure` takes `"oscillation": true` (or `{"threshold": 2.5}` to choose the level). For each signal it returns `frequency`, `period`, `duty`, `riseTime` (10 to 90 %), `fallTime` and `cycles`. A signal that does not oscillate returns null values and a `reason`. The other keys of `scope.measure` do not change. ```json {"signals": ["v(out)"], "t0": "5m", "oscillation": true} ``` **Blocks.** Four control blocks are new: | Block | Pins | What it does | |---|---|---| | `vco` | `v` in; `out`, `theta` out | Frequency f0 + kv v, in hertz, clamped to `fmin` and `fmax`. The output is a sine, square, triangle or sawtooth with an `amplitude` and an `offset`; a square is high for `duty` of each period (default 0.5), and the wave starts at `phase` degrees (default 0). It has no direct feedthrough, so a loop can close through it | | `phaseDetector` | `a`, `b` in; `out`, `up`, `down` out | A multiplier, an XOR gate or a phase-frequency detector (`pfd`) | | `pll` | `in` in; `f`, `theta`, `locked` out | Locks to a single-phase signal with a quadrature generator and a PI loop. With `kp` and `ki` unset, the natural frequency is 0.3 times `f0` and the damping is 0.707. `locked` is 1 when the error stays below `lockTol` for two periods | | `srfPll` | `a`, `b`, `c` in; `theta`, `w` out | The same loop in the synchronous frame of a three-phase set, for grid synchronisation | `kv` is in hertz per unit of input, not radians per second. The solver ends a step on each edge of a `square` or `sawtooth` output, so an edge is not up to a step late; keep the step well below the period if the edges drive switches. `demo:vco`, `demo:phaseDetector`, `demo:pll` and `demo:srfPll` open working examples. **Grid-forming control.** `droop` (pins `p`, `q` in; `theta`, `w`, `e` out) makes an inverter a voltage source that shares a load with others: its frequency is `f0·(1 − kp·(P − pset)/prated)` and its amplitude `e0·(1 − kq·(Q − qset)/qrated)`, with the measured powers filtered at `fc`. `kp` and `kq` are per-unit droops, and only `f0` has a default. Inverters with the same per-unit droop share active power by their ratings. Feed `p` and `q` from `clarke` and `pq` on the inverter's own voltage and current, and `theta` and `e` to `dq2abc` (`d` = `e`, `q` = 0). `demo:droop` and the `droopLoadSharing` example open working circuits. `vsm` (same pins) is a virtual synchronous machine: its speed follows the swing equation `2H·d(ω/ω0)/dt = (pset − P)/prated − (ω/ω0 − 1)/kp`, so right after a power step ΔP the frequency moves at `f0·ΔP/(2H·prated)` and then settles on the same droop line with the time constant `2H·kp`. `h` is the inertia constant in seconds on the base `prated`; the damping `1/kp` is the frequency droop, so a `vsm` shares a load exactly like a `droop` with the same `kp`. The amplitude follows the Q–V droop with `q` filtered at `fc`. Only `f0` has a default. `demo:vsm` and the `vsmLoadSharing` example open working circuits. **The 555.** `timer555` is a behavioural 555 (pins `VCC GND TRIG THR CTRL DIS OUT RESET`). The divider is three real 5 k resistors, so a voltage on `CTRL` (or a bypass capacitor) moves both thresholds. The defaults are typical NE555 values. `circuit.applicationCircuit` builds the astable and the monostable with their design formulas. Give it a target instead of parts: `freq` and `duty` size RA and RB, `width` sizes the monostable R, each rounded to E96. The PWM controller's `boost` takes `fsw` and sizes RT = 1.72/(fsw·CT), rounded to E96; the shunt monitor takes `iFullScale` and `vFullScale` and sizes the shunt Vfs/(G·Ifs), rounded down to E12 so the output stays within full scale. The comparator's `schmittTrigger` takes `vRise` and `vFall` and sizes the external hysteresis: R1 from the input to INP, R2 (`rFb`) from OUT to INP, INN at Vref, with R1 = R2·(ΔV − 2h)/(VOH − VOL + 2h) rounded to E96 and Vref set from the rounded R1. The IC's own hysteresis 2h and offset are taken out, and the output levels include the pull-up loaded by R2. The gate driver's `halfBridgeLeg` takes `tBlank` and sizes the DESAT blanking capacitor C_blk = ICHG·t/VDESAT, rounded to E12. `values.designed` lists each sized part with its equation and the value before rounding. **The crystal.** `crystal` (pins `p`, `n`; designator `Y`) is the Butterworth-Van Dyke circuit: a series `rm`, `lm`, `cm` branch with `c0` across it. Give either `fs` and `q` (with `cm`) or `lm`, `cm` and `rm`. A mixed or incomplete set is refused with an error that names the part. A crystal needs about Q cycles to build up its oscillation, so simulate a high-Q crystal only with a step and a time that allow that. **Examples.** `relaxationOscillator`, `timer555Astable`, `wienBridge` and `colpitts` are in the Examples menu under Basics (or open them with `file.openExample`). The Colpitts example uses an op-amp, because the piecewise-linear BJT would switch its junction every cycle. There is no Pierce example. The frequency tests of these examples allow 3 %. Replace the textbook defaults with your own parts before you trust a number. ## Behavioural ICs (beta) You have a datasheet for a gate driver, an op-amp, a comparator, a PWM controller or a current-sense amplifier, and you want the part and its typical application circuit in the simulator. A Voltecx IC is a **behavioural model**: a subsystem with named pins, built from voltmeters, controlled sources, ideal switches and control blocks, and driven by numbers from the datasheet (thresholds, delays, resistances, gain-bandwidth). It is not the manufacturer's transistor-level SPICE model. It is much faster, and it shows the behaviour that matters for a power stage: propagation delay, undervoltage lockout, desaturation protection, slew rate, hysteresis. | Template (`name`) | What it models | Pins | |---|---|---| | `gateDriverIso` | Isolated gate driver with UVLO, propagation delay, source and sink resistance, DESAT protection, soft turn-off and latched fault | `IN FLT VDD VEE OUT COM DESAT` | | `halfBridgeDriver` | Half-bridge gate driver of the UCC27211 type: built-in bootstrap diode, VDD and HB UVLO, propagation delay, source and sink resistance on both outputs; HI and LI take the controller's 0/1 gate signals | `HI LI VDD VSS HB HO HS LO` | | `lowSideDriver` | Single-channel low-side gate driver of the UCC27517 type: VDD UVLO, propagation delay, source and sink resistance on the output; IN takes the controller's 0/1 gate signal | `IN VDD GND OUT` | | `opAmp` | One-pole op-amp: DC gain, GBW, slew rate, output limited by its supply, input offset; optional second pole from a phase margin `pm`, CMRR (`cmrr`, dB) and input bias current (`ib`), all off by default; presets `TL072`, `OPA2171` and `TLV9062` (`ic.place` with `preset`) | `INP INN OUT VCC VEE` | | `comparatorHyst` | Comparator with hysteresis, rising and falling delay, open-drain or push-pull output | `INP INN OUT VCC GND` | | `pwmController` | Peak-current-mode PWM controller of the UC384x type: oscillator, error amplifier, current-sense comparator with the 1 V clamp, maximum duty, UVLO. Slope compensation and the CS filter are external parts, as on the part (TI SLUS223H Figure 7-11); design.auto's controllerIc boost and flyback place them | `VFB COMP CS OUT VCC GND` | | `syncBuckController` | Voltage-mode synchronous buck controller of the LM5145 type: feed-forward ramp, error amplifier, soft start, EN/UVLO, valley current limit with hiccup, PGOOD, two gate drivers | `VIN EN SS FB COMP PGOOD ILIM BST HO SW LO VCC GND` | | `syncBoostController` | Peak-current-mode synchronous boost controller of the LM5122 type: current-sense amplifier, slope compensation from RSLOPE, error amplifier, soft start, UVLO, cycle-by-cycle current limit with the RES hiccup timer, two gate drivers | `VIN UVLO SS FB COMP SLOPE RES CSP CSN BST HO SW LO VCC GND` | | `ccmPfcController` | CCM boost PFC controller of the UCC28180 type, average current mode without line sensing: FREQ-resistor oscillator, current amplifier with the M1 gain, leading-edge PWM with the M2 ramp, transconductance voltage amplifier with soft start and enhanced dynamic response, UVLO, OLP, ISENSE open-pin protection, two-level OVP, soft overcurrent, peak current limit, gate driver with its 15.2 V clamp | `GND ICOMP ISENSE FREQ VCOMP VSENSE VCC GATE` | | `multiplierPfcController` | Boost PFC controller of the UC3854 type, average current mode with line sensing: analog multiplier IMO = k·IAC·(VAOUT − 1 V)/VRMS² limited to 2·IAC and 3.75 V/RSET, voltage and current operational amplifiers (gain, gain-bandwidth, swing, emitter-follower output with 8 kΩ), RSET/CT oscillator with 95 % maximum duty, PKLMT peak current limit, soft start, ENA and VCC UVLO, 7.5 V reference, gate driver with its 14.5 V clamp. `circuit.applicationCircuit` topology `multiplierPfc` builds the data sheet's 250 W preregulator (Figure 9) | `GND PKLMT CAOUT ISENSE MULTOUT IAC VAOUT VRMS VREF ENA VSENSE RSET SS CT VCC GTDRV` | | `crmPfcController` | Transition-mode (critical-conduction) boost PFC controller of the UCC38050 type: self-oscillating PWM turned on by the zero-current detector on an inductor winding (armed above 1.7 V, fires 350 mV lower) or the 400 µs restart timer, and off when CS, through the internal 40 kΩ / 5 pF filter, passes the multiplier 0.65·(MULTIN + 75 mV)·(COMP − 2.5 V) (at most 1.7 V); 90 µS transconductance amplifier with ±10 µA linear output and the slew-rate enhancement (1.3 mA source below 0.88·VREF, 1 mA sink above 1.05·VREF down to 2.4 V), zero-power stop below COMP = 2.3 V, OVP, enable on VO_SNS, VCC UVLO, gate driver from VCC. Preset `UCC38051` for the 12.5 V UVLO part. `circuit.applicationCircuit` topology `transitionModePfc` builds the data sheet's universal-line 100 W preregulator (Figure 19) | `VO_SNS COMP MULTIN CS ZCD GND DRV VCC` | | `llcController` | Half-bridge LLC controller of the UCC25640x type with hybrid hysteretic control: optocoupler feedback to a control effort, VCR comparators with the frequency-compensation ramp, dead time, BLK start and stop, LL/SS soft start, OCP1 and bias winding OVP with the 1 s pause, RVCC and both gate drivers. Burst mode, the capacitive-region protection and OCP2/OCP3 are not modelled | `GND VCC RVCC BLK FB ISNS VCR BW LLSS HB HO HS LO` | | `psfbController` | Phase-shifted full-bridge controller of the UCC28950 type: oscillator from RT, error amplifier into a duty cycle and a phase shift, programmed delays between the outputs of each leg, synchronous rectifier drives, closed-loop soft start and the CS current limit. Peak current mode (CS, the RSUM slope ramp and the 0.85 V offset against COMP) or voltage mode (`pcm`); burst mode and the adaptive delays are not modelled | `GND VDD VREF EAP EAN COMP SS CS OUTA OUTB OUTC OUTD OUTE OUTF` | | `currentSenseAmp` | Gain, one-pole bandwidth, offset, output clamp | `INP INN OUT VS GND` | | `hallCurrentSensor` | Hall-effect sensor of the ACS712-05B type: 185 mV/A, 2.5 V at zero current, 80 kHz, saturation near the rails | `IPP IPN VIOUT GND` | | `shuntAmplifier` | Shunt amplifier of the INA240A1 type: gain 20, 400 kHz, 2.5 V reference, output swing limits | `IPP IPN OUT GND` | | `isolatedAmplifier` | Isolated amplifier of the AMC1301 type: gain 8.2, 210 kHz after a 1.1 µs signal delay (1.6 µs to 50 %), differential output on 1.44 V, clips at 2.49 V; a run with more than `vIowm` (1500 V) from `IPN` to `GND2` is an `isolation.workingVoltageExceeded` error naming the part | `IPP IPN OUTP OUTN GND2` | | `isolatedAmplifierAmc1302` | Isolated amplifier of the AMC1302 type: ±50 mV linear input, gain 41, 280 kHz after a 1.2 µs signal delay (1.6 µs to 50 %), a lower gain from 50 to 64 mV, clips at 2.49 V | `IPP IPN OUTP OUTN GND2` | | `shuntRegulator` | Adjustable shunt regulator of the TL431 type: 2.495 V reference, REF current, transconductance with one pole, 0 to 100 mA, lowest cathode voltage | `K A REF` | | `optocoupler` | Optocoupler of the TCET1100 type: LED, current transfer ratio against LED current and temperature, phototransistor pole, saturation | `AN CAT C E` | | `digitalIsolator` | Digital isolator of the ISO7710 type: thresholds that follow VCC1, 11 ns delay, push-pull output, UVLO, default output, CMTI 100 V/ns | `IN VCC1 GND1 OUT VCC2 GND2` | | `highSpeedOpto` | High-speed logic-output optocoupler, 10 MBd class (typical values, user must set): LED threshold current, tPHL and tPLH (pulse-width distortion), open-collector or totem-pole output, output capacitance, supply range, CMTI | `AN CAT VCC OUT GND` | | `fiberTx` | Fiber-optic transmitter, 650 nm plastic-fiber class (typical values, user must set): input thresholds, delay, launched optical power on its `OPT` signal | `IN VCC GND OPT` | | `fiberRx` | Fiber-optic receiver with its fiber (typical values, user must set): attenuation per metre and connector loss, sensitivity, delay, time of flight, seeded jitter, minimum pulse width, push-pull output | `OPT VCC OUT GND` | | `pvDriver` | Photovoltaic MOSFET driver, the driver of a solid-state relay (typical values, user must set): LED, short-circuit current proportional to the LED current, open-circuit voltage clamp, turn-off circuit | `AN CAT VOP VON` | | `ldo` | LDO of the LP5907 3.3 V type: dropout, supply rejection with a zero and a pole, current limit, enable, start-up ramp | `IN OUT GND EN` | | `voltageReference` | Series reference of the REF3025 type: 2.5 V, supply rejection, output impedance that rises with frequency, current limit | `IN OUT GND` | | `currentTransformer` | Current transformer of the Coilcraft CS4100V-01L type: a one-turn primary, 1:100, magnetising inductance with saturation, secondary resistance and burden | `IPP IPN OUT GND` | | `rogowskiCoil` | Rogowski coil with its integrator, of the PEM CWT Ultra-mini type: sensitivity, low and high cut-off, output limit | `IPP IPN OUT GND` | | `closedLoopHall` | Closed-loop Hall current transducer of the LEM LA 55-P type: secondary current = primary / 1000 from DC, bandwidth, offset, largest secondary current | `IPP IPN M GND` | | `isolatedVoltageSensor` | Resistive divider into an isolated amplifier of the AMC1311 type: gain 1, signal delay and bandwidth, clipping, differential output; preset `AMC3330` (gain 2, ±1 V, 375 kHz, 1.6 µs) | `HVP HVN OUTP OUTN GND2` | | `ganPowerStage` | 600 V GaN FET with integrated driver of the LMG3422R030 type: input hysteresis and delays, VDD UVLO, on resistance at tj, third-quadrant drop, cycle-by-cycle overcurrent (70 A) and latched short-circuit (95 A) protection, overtemperature ideal-diode mode, FAULT and OC outputs | `DRAIN SOURCE IN VDD FAULT OC` | The default parameters come from public datasheets (cited per parameter). A default marked `assumption` is the model's guess, not a datasheet number. Read it with `ic.describe`. | Command | What it does | |---|---| | `ic.list` | Lists the built-in ICs and the subsystems in the circuit | | `ic.describe` | Pins, parameters (unit, default, range, datasheet source), what the model does and does not do. A part with a shipped application example also gets `example`; run its `open` (`file.openExample`) to open it | | `ic.place` | Puts the IC into the circuit, with its pins unconnected. Wire them with `circuit.wire` | | `ic.fromSpec` | Builds a new IC from a JSON spec: `{"template": "gateDriverIso", "params": {"tPd": "75n"}, "source": "datasheet, Table 6.5"}` | | `circuit.applicationCircuit` | Opens a new circuit with the IC's typical application, already laid out | ### Fast isolation and CMTI SiC and GaN switch nodes move at 50 to 200 V/ns. Every part that crosses an isolation barrier (`optocoupler`, `highSpeedOpto`, `digitalIsolator`, `gateDriverIso`) measures the slope of the voltage across its barrier during the run, over a 1 ns window: GND2 against GND1, E or GND against the LED cathode, COM against the circuit ground. When the slope passes the part's `cmti` rating, the output glitches for `tGlitch` (it inverts, or the phototransistor turns on), and after the run `circuit.problems` lists a warning such as `CMTI exceeded: 150 V/ns > 100 V/ns rating on `U1``, with the part selected. A `cmti` of 0 means the rating is not set: the slope is measured, nothing glitches and nothing is reported. The ratings come from data sheets: the `digitalIsolator` default is the ISO7710's 100 V/ns (typical), and the `UCC21750` preset of `gateDriverIso` sets 150 V/ns (minimum, SLUSD78C Table 6.8). The TCET1100 and UCC21756-Q1 defaults have no CMTI in Voltecx yet, so their `cmti` is 0 until you enter your part's value. The glitch width is an assumption (20 ns): data sheets give CMTI as a pass/fail limit, not the shape of the failure. `highSpeedOpto` is the logic-output optocoupler used for PWM and fault signals. Its defaults are a generic 10 MBd set, labelled "typical, user must set" in every row: no data sheet of this class has been read into Voltecx yet. Set `iFth`, `tPhl`, `tPlh`, `rOnLo`, `cOut`, `vccMin`, `vccMax`, `maxRate` and `cmti` from your part. The output pulse comes out longer by `tPlh − tPhl` (the pulse-width distortion), and an open collector rises through your pull-up and `cOut`. Its `optoLink` application circuit (`circuit.applicationCircuit {ic: "highSpeedOpto", topology: "optoLink"}`) drives the LED with a square wave across a 100 V ground offset. ### Fiber-optic links Medium-voltage converters and modular multilevel converters carry their gate signals on fiber: there is no galvanic path at all, so no CMTI limit. `fiberTx` turns a logic input into light and `fiberRx` turns it back; the net between their `OPT` pins is the fiber, and it carries the optical power as a signal in watts. The receiver holds the fiber's numbers: `length`, `alpha` (dB/m at the link's wavelength) and `lossConn` (connectors and coupling, dB). An edge arrives `tTx` + `length · nGroup / c` + `tRx` after it was sent, plus up to `jitter` (uniform, seeded by `seed`, the same in both solvers). A pulse shorter than `tPwMin` is dropped, so check the shortest PWM pulse against it. Below the sensitivity `pSens` the receiver stops following. `fiber.linkBudget` checks the link: received power = `pTx − alpha·length − lossConn`, its margin over `pSens` against 3 dB (or your `margin`), and the overload `pMax`. With no params it reads every transmitter–receiver pair of the open circuit; with `pTx` and `pSens` it checks the numbers you give. `circuit.problems` warns (`fiber.linkBudget`) when a link of the circuit has less than 3 dB of margin. The schematic draws the link as an isolation barrier: on an isolated circuit (secondary ground `sgnd`), Layout puts the transmitter on the primary, the receiver on the secondary and the barrier line between them, across the fiber; elsewhere it draws a barrier half way between the two ends. Both templates' defaults are a generic set labelled "typical, user must set": no transmitter or receiver data sheet of this class has been read into Voltecx yet. Set them from your parts and fiber before you trust a delay or a budget. `circuit.applicationCircuit {ic: "fiberTx", topology: "fiberLink"}` builds a link to start from. ### Photovoltaic MOSFET drivers `pvDriver` is the photovoltaic-output optocoupler of a solid-state relay, a battery disconnect or a precharge switch: an LED lights a photodiode stack that charges the MOSFET gate on the far side of the barrier with no supply there at all. The stack gives `iscRef · IF / iFref` (micro-amperes) up to the open-circuit voltage `vocRef`, and a turn-off circuit discharges the gate through `rDis` when the LED goes dark. The turn-on time into a gate capacitance C is about `C · Vth / Isc` (hundreds of microseconds for a nanofarad) and the turn-off time about `rDis · C · ln(V0 / Vth)`, so it switches seldom: never use it for PWM. Its `solidStateRelay` application circuit switches a 24 V load with two MOSFETs back to back. The defaults are a generic set labelled "typical, user must set": no data sheet of this class has been read into Voltecx yet. ### Feedback and isolation An isolated supply regulates on its secondary and crosses the barrier with an optocoupler. `shuntRegulator` is the TL431 error amplifier, and `optocoupler` carries its current to the primary. The shunt regulator is solved with the circuit, so a type II network from the cathode to REF needs no small step. The optocoupler's current transfer ratio is a curve read off the data sheet, scaled by `ctrScale` (another bin, or end of life) and by `tAmb`. The curve and its temperature factor are parameters too (`ctr0m2` … `ctr100m`, `kTm25` … `kT75`; the defaults are the TCET1100's). `crates/engine-core/ics/presets/` holds them for the PC817 (Sharp), LTV-817 (Lite-On) and SFH617A (Vishay), each value cited to its figure or table: pass a file's `spec` to `ic.fromSpec`. The LTV-817 and SFH617A sheets give only a normalized curve, so `ctrScale` there is the CTR at the normalizing current; the file's notes give each rank. The model keeps regulating down to zero cathode current, but a real TL431 needs about 1 mA (TI SLVS543S, Section 6.4). `circuit.problems` with `run: true` reports `shunt.lowCurrent` (a warning) when a `shuntRegulator` carries less than 1 mA for more than 20 % of the second half of the run. A resistor across the optocoupler LED (Rbias in the `flybackTl431` example) fixes it. `file.openExample` with `flybackTl431` opens a 12 V flyback whose loop closes through both. The module notes in `crates/engine-core/src/ic/flyback_tl431.rs` give the design: a zero a factor of five below the crossover and the optocoupler pole above it. The output holds 12.06 V at full and half load in both solvers. The data sheet gives the optocoupler's pole with a 100 Ω load only. A pull-up of several kΩ makes the real pole much lower, so enter the pole you measured, or set it with a capacitor across the pull-up as the example does. ### Architecture blocks for power-IC design Before a power-management IC is drawn at transistor level, its architect chooses the control scheme and sizes its numbers with the real power stage. The blocks below serve that stage. They are generic: every default is a design value labelled "typical, user must set", not a part's data sheet, and each block cites the public paper or application note its equations come from (`ic.describe` gives the source). Logic pins (`EN`, `GATE`, `RUN`, `OK`, `FAULT`, `FLT`, `OVP`, and the driver's `IN`, `HO`, `LO`) are signals, 0 or 1; analog pins are voltages to `GND`. Voltecx does not do transistor-level IC design (no PDKs, BSIM sign-off, layout or DRC/LVS); see the scope boundary in `docs/roadmap.md`. | Template (`name`) | What it models | Pins | Source | |---|---|---|---| | `pcmModulator` | Fixed-frequency peak current mode: clock, slope-compensation ramp `se`, blanking `tBlank`, maximum duty, cycle-by-cycle clamp `vcMax`. `valley` = 1 gives valley current mode: the clock turns the switch off, it turns on when ISNS minus the ramp falls to VC, `tBlank` is the minimum off-time; without a ramp it oscillates below D = 0.5, and it is stable when `se > (sE − sD)/2`, half the sensed up-slope minus the down-slope | `VC ISNS EN GATE GND` | Ridley, IEEE TPEL 1991; Erickson & Maksimovic ch. 12; Unitrode U-97; valley mode: Tiwary & Rincon-Mora, Electronics 15(8) 1609, 2026, section 5.1 | | `cotModulator` | Constant on-time `tOn` started when FB falls below REF, minimum off-time; or the adaptive on-time `kOn·V(VOUT)/V(VIN) + tOnAdd` (`adaptive` 1) or `kOn/V(VIN) + tOnAdd` (`adaptive` 2) | `FB REF EN GATE GND VIN VOUT` | Redl & Sun, IEEE TPEL 2009; Li & Lee, IEEE TCAS-I 2010 | | `hystModulator` | Window `REF ± vHyst/2`, delay `tDelay` on both edges | `FB REF EN GATE GND` | Redl & Sun, IEEE TPEL 2009 | | `softStartRef` | `iSs` charges the SS capacitor, REF is the lower of SS and `vRef`, RUN = EN and not FLT, SS discharges when not running | `EN FLT SS REF RUN GND` | LM5145 SNVSAI4B §7.3 (scheme) | | `uvloComparator` | Rising and falling thresholds, hysteresis current `iHys` into the divider | `SENSE OK GND` | LM5145 SNVSAI4B §7.3 (scheme) | | `ocpHiccup` | Over-current held for `tFilter` raises FAULT for `tHiccup` | `ISNS FAULT GND` | LM5145 SNVSAI4B §7.3 (scheme) | | `ovpComparator` | FB above `kOv`·REF (or `kOv`·`vRef`) for `tFilter` raises OVP until FB is below (`kOv` − `kHys`)·REF; `latch` = 1 latches off | `FB REF OVP GND` | Feedback-pin OVP scheme of TI TPS54360, SLVSBB4G §7.3.12 (`tFilter` and `latch` are not from that sheet) | | `ldoArch` | LDO loop: error amplifier `gmEa`·`roEa` with its pole (`cEa`), gate pole `rGate`·`cGate`, pass device `gmPass`, `roPass`, dropout `rDo`, current limit `iLim`; the output capacitor and its ESR stay in the circuit, so `analysis.loopGain {signal:"U1.x_err"}` shows the ESR window | `IN OUT FB GND` | TI SLVA115A (Section 1, Equation 1): loop and ESR-window rule | | `hbDriverArch` | Half-bridge driver from one PWM command: propagation delay `tPd`, fixed dead time `tDead` or adaptive dead time (`adaptive` 1: the low side waits for SW to fall, the high side for the low-side gate, `tAdapt` after the edge), gate charge through `rSource`/`rSink` into `cGate` | `IN SW HO LO GND` | TI SLUA618 (Balogh); TI SLVAF84 | Wire them as a controller: UVLO `OK` → soft start `EN`, OCP `FAULT` → soft start `FLT`, soft start `RUN` → modulator `EN`, soft start `REF` → the error amplifier or the modulator's `REF`, and the modulator's `GATE` → the switches (through a `deadtime` block for a synchronous stage). The OVP's `OVP` goes through a `not` block and a `min` with `RUN` into the modulator's `EN`, so the switch stops while the output is over-voltage; compare it with a steady reference (`vRef`), because the output leads a soft-started REF at start-up. Three examples close a synchronous buck through them (**File › Open Example › Control**, or `file.openExample`), and `circuit.applicationCircuit` opens the same circuits with your input, load and block parameters (`pcmBuck`, `cotBuck`, `hystBuck`): - `pcmBuckArch`: 12 V to 5 V at 2 A, 500 kHz peak current mode with half the sensed down-slope as ramp, a type II error amplifier (`opAmp`), soft start, UVLO and hiccup OCP. The load halves at 1 ms. `circuit.applicationCircuit {ic:"ovpComparator", topology:"pcmBuck", params:{loadRelease:1}}` adds the OVP and drops the load to 1 % at 1 ms: FB overshoots about 1.5 %, so `kOv` 1.01 stops the switch within one period and lets it resume below the falling threshold, and `kOv` 1.03 never trips. - `cotBuckArch`: 12 V to 3.3 V at 2 A, 550 ns on-time, FB ripple from a 10 mΩ ESR. With `cotBuck`, `kOn` above 0 gives the adaptive on-time (the buck then switches at `1/kOn` from 8 V to 24 V), and `rippleInjection` 1 adds an RC network across the inductor into FB, which keeps the loop steady on ceramic capacitors (`esr` 0.0005). The switches are driven by `hbDriverArch` with a fixed 20 ns dead time, so the switch node is high for `tOn − tDead`; give it `adaptive` 1 (in `icParams` of `circuit.applicationCircuit` with `ic` `hbDriverArch`) and the body diodes conduct for about `2·tAdapt` per period instead of `2·tDead`. - `hystBuckArch`: 12 V to 3.3 V at 2 A, a 10 mV window at FB and a 50 mΩ ESR. The tests check each loop against its equation (`crates/engine-core/src/ic/arch/tests.rs`): | Check | Equation | Result | |---|---|---| | PCM control voltage at full and half load | `Vc = Ri·IL + Se·D·Ts + Sn·D·Ts/2` (averaged modulator) | within 2 % | | PCM current loop at D = 0.65 | unstable below `mc·D' = 0.5`, `mc = 1 + Se/Sn` (Ridley) | valleys alternate by more than 20 % of the ripple at 0 and 0.5 times the critical ramp, less than 2 % at twice it | | Valley-mode current loop at D = 0.3 | sub-harmonic gain `A_SH = (se − sE)/(se + sD)`, stable when `se > (sE − sD)/2` (Tiwary & Rincon-Mora 2026, Eqs. 21–22) | the currents at the clock alternate by more than 20 % of the ripple at 0 and 0.5 times the boundary, less than 2 % at twice it | | COT frequency at 12 V and 20 V in | `fsw = Vout/(Vin·(tOn − tDead))` | within 2 %; FB valley within 2 mV of REF | | COT stability | `ESR·C > tOn/2` (Li & Lee) | steady at 10 mΩ (1 µs), irregular at 0.5 mΩ (50 ns) | | Hysteretic frequency | `ESR·Vout·(Vin − Vout)/(Vin·L·window)` | within 10 %; a 100 ns delay lowers it | | Soft start | `tSs = Css·vRef/iSs` | REF at 0.5 V after 235 µs, within 3 % | | UVLO thresholds | `vRise·(R1+R2)/R2`, `vFall·(R1+R2)/R2 − iHys·R1` | within 0.5 % | | OCP hiccup into a short | peak held by `vcMax`, off for `tHiccup` | peak below 5.2 A, no switching for 200 µs, then a new soft start | Not yet in this library (each is an issue under #1397): sweeping and Monte Carlo of the block parameters, an averaged model of the IC-driven stage, loop gain broken inside a block, and a handoff export (block spec plus target waveforms). ### Current sensors The three sensor ICs show what a real current sensor does to a measurement. Each is a series resistance, a current meter and a controlled source, with the datasheet section and page named in each parameter's `source`. The primary pins `IPP` and `IPN` go in series with the branch you measure. A current that flows in at `IPP` and out of `IPN` reads positive. For `shuntAmplifier` and `isolatedAmplifier`, `rSense` is the shunt resistor you choose. It is a parameter of the IC, not a datasheet value. Each IC has a `currentStep` application circuit, which is also its demo: open it with `circuit.applicationCircuit` or with `file.openExample` and `demo:hallCurrentSensor` (or `demo:shuntAmplifier`, `demo:isolatedAmplifier`). Place one in your own circuit with `ic.place`. The library panel lists the IC templates. `isolatedAmplifier` also has `currentLoopBuck`: a hysteretic current-mode buck (48 V in, 6 A) whose comparator reads the inductor current only through the AMC1301 on its shunt. The controller is the module `XCTL` on the control ground, and the power stage sits on `sgnd` behind the isolation tie. The amplifier's delay is in the loop: the switch turns off `expect.loopDelay` (tDelay plus the 210 kHz pole's time constant, about 1.83 µs; a step reaches 50 % after the data sheet's 1.6 µs) after the current passes the band, so the current overshoots to `expect.iPeak`. Four more sensors measure what a shunt cannot. `currentTransformer` is a real magnetic circuit, so it passes AC only, droops on a long pulse and saturates past its volt-time product (298 V·µs). `rogowskiCoil` reads AC from its low cut-off up; its coil's own inductance is not modelled separately. `closedLoopHall` reads from DC and puts out a current, so it needs a measuring resistor from `M` to a supply return. `isolatedVoltageSensor` reads a high voltage through its divider across the barrier. Each cites its data sheet per parameter (Coilcraft Document 132; PEM CWT Ultra-mini Rev. 10/25; LEM LA 55-P version 19; TI SBAS786C), and its demo opens with `demo:`: ```sh powercraft-cli run --cmd file.openExample --params '{"name": "demo:closedLoopHall"}' --cmd simulation.run ``` `ntcSensor` (in the library under meters) is a 10 kΩ NTC of the Vishay NTCLE100E3103 type that reads the temperature of a thermal net as a resistance. `law` is `steinhartHart` (the data sheet's coefficients `a1` to `d1`, the default) or `beta` (`b` = 3977 K). Set `thermal` to the net of the part it watches; without it, it reads only its own body at `ta`. It heats itself by `delta` = 7 mW/K, so keep the divider current small. Some defaults are assumptions, and the parameter says so: the Hall sensor's saturation levels (0.1 V and 4.9 V) are not in the datasheet. `noise` is 0 by default. Set it to a few millivolts rms to see noise. The noise is the same on every run for one `seed`, and another `seed` gives another noise. The same effects are available on a plain `ammeter` or `voltmeter`. All of them are optional, and a meter that sets none of them behaves exactly as before: | Parameter | Meaning | |---|---| | `sensitivity`, `vref` | Output = `vref` + `sensitivity` * `gain` * x + `offset`. For a current sensor, `sensitivity` is in V/A and `vref` is the zero-current level (1.65 V or 2.5 V for a bidirectional part) | | `outMin`, `outMax` | The lowest and highest output the sensor can drive (saturation). One of them alone is an open-ended limit | | `noise`, `seed` | RMS output noise in volts (white to about 1 MHz) and a whole-number seed. The same seed repeats the same noise | The chain runs in this order: gain and offset, low-pass (`bandwidth`), `delay`, noise, limit. Both solvers build it from the same blocks, so they agree. `circuit.problems` reports `sensor.saturated` (a warning) when a meter or a sensor IC sits at its `outMin` or `outMax` for more than 0.5 % of the run. A sensor with a lower sensitivity, such as the 20 A or 30 A variants of the Hall sensor, fixes it. `ic.fromSpec` is the path from a datasheet to a model. You, or an assistant that reads the PDF, fill in the spec, and the `source` field records where each number came from. See `docs/workflows/ic-models.md` for the full guide. ## Multi-winding transformer `multiTransformer` puts one primary (`p1`, `n1`) and up to three secondaries (`p2`–`n2`, `p3`–`n3`, `p4`–`n4`) on one core, for a multi-output flyback or forward supply. Each secondary has its own turns ratio (`n2`, `n3`, `n4`, primary turns over that winding's turns), leakage (`llk2`…`llk4`) and wire resistance (`rw2`…`rw4`); the primary has `llk1` and `rw1`, and `lm` (with `im0`) magnetizes the core, seen from the primary. Winding 2 is always on; windings 3 and 4 are on only when `n3` or `n4` is set, and their pins must stay open otherwise. Before the run it becomes one ideal transformer per secondary, all across one core voltage, so both solvers run it as they run `transformer`; with only winding 2 on it gives the same waveforms as `transformer`. `rcore` across the core models core loss, and `isat` with `lmsat` saturates the magnetizing inductance, as on `transformer`. With three windings on you may instead give the leakages as you measure them on the bench: `lk12` at the primary with winding 2 shorted, `lk13` at the primary with winding 3 shorted, and `lk23` at winding 2 with winding 3 shorted, the third winding open each time. The part then solves `llk1`, `llk2` and `llk3` (taking `lm` into account) so that the same three short-circuit tests on it give your values back; a set that one leakage per winding cannot hold (one value above the sum of the other two, seen from the primary) is refused with the winding named, and the keys cannot be mixed with `llk1`–`llk4`. With winding 4 on as well, add `lk14`, measured at the primary with winding 4 shorted and the others open: it sets `llk4`, and the four tests give your four values back. The star has one leakage per winding, so the other two pairs follow from those four. When your bench values for them differ, add `lk24` and/or `lk34`, measured at winding 2 or 3 with winding 4 shorted and the others open: each sets the coupling between that winding and winding 4 (a coupled inductor in series with both, built from their leakages), and all six tests give your values back while the first four stay as they were. A set that no passive part can have (the windings would couple with k ≥ 1) is refused with the keys named. An Ideal run leaves out the leakages (also `lk12`, `lk13`, `lk23`, `lk14`, `lk24`, `lk34`), the wire resistances, `rcore`, `isat` and `lmsat`, and keeps the ratios, `lm` and `im0`. `demo:multiTransformer` opens a two-output example. ## EMI parts: common-mode choke, ferrite bead and LISN Three parts for conducted-EMI work. Their defaults come from named data sheets and from CISPR 16-1-2. | Part | What it is | Main parameters (defaults) | Pins | |---|---|---|---| | `cmChoke` | Two equal coupled windings that block common-mode noise and pass the load current (TDK B82724A2202N001) | `l` 6.8 mH per winding, `lstray` 80 µH, `rdc` 0.17 Ω, `irated` 2 A | `p1 n1 p2 n2` | | `ferriteBead` | A resistor at noise frequencies and a small inductor at low frequencies (Murata BLM18PG221SZ1) | `z` 220 Ω at `ftest` 100 MHz, `zpeak` 280 Ω at `fpeak` 300 MHz, `rdc` 0.1 Ω, `irated` 1.4 A, optional `isat` and `ksat` for DC bias | `p n` | | `lisn` | One line of the 50 µH network between the supply and the equipment | `l` 50 µH, `csup` 1 µF, `cm` 0.1 µF, `rd` 1 kΩ, `rm` 50 Ω | `line eut meas gnd` | Put the choke's dots on the same side, or the load current no longer cancels. Read the LISN's receiver port as `v(meas)` against `gnd`; tie `gnd` to the circuit's ground or chassis. The example `emiInputFilter` has two LISNs reading the line noise of a switching load behind a common-mode choke: ```sh powercraft-cli run --cmd file.openExample --params '{"name": "emiInputFilter"}' --cmd simulation.run ``` `emi.conducted` (chapter 16) puts its own LISN on a copy of the circuit; these parts are for building the bench yourself. A bead's capacitance is far below a picofarad, so a transient run needs a step near a nanosecond to see its peak; use the AC analysis for its impedance. ## Measurement blocks inside the circuit Nine control blocks measure while the circuit runs, so a controller can act on the value. Use the scope's measurements (chapter 5) when you only need the number after the run. | Block | Outputs | Main parameters | |---|---|---| | `rms` | RMS of `in` over a sliding window | `f` (50 Hz), `cycles` (1) | | `mean` | Mean (DC value) of `in` over a sliding window | `f` (no default: the ripple's frequency), `cycles` | | `thd` | `thd` as a ratio, and `amp`, the fundamental's peak | `f`, `cycles` | | `harmonic` | `amp` and `phase` of one harmonic | `f`, `order` (1), `cycles` | | `powerFactor` | `pf`, `dpf`, `p` and `s` from a voltage and a current | `f`, `cycles` | | `powerMeter` | `pin`, `pout` and `eff` of a converter from four signals | `f` (no default: the switching or line frequency), `cycles` | | `power1` | `p`, fundamental `q` (positive while the current lags), `s` and `pf` of a single-phase port from `v` and `i` (IEEE Std 1459-2010) | `f`, `cycles` | | `power3` | `p`, fundamental `q` (positive while the currents lag), arithmetic `s` and `pf` of a three-phase port from `va`, `vb`, `vc`, `ia`, `ib`, `ic` (IEEE Std 1459-2010) | `f`, `cycles` | | `fft` | `amp` and `phase` of one bin, once a period | `f`, `samples` (64), `order` | Every block except `fft` takes an optional `freq` input, such as a PLL's output, which replaces `f` while the frequency drifts. The window must be a whole number of periods, or the result ripples; the output lags a change by up to one window, so a loop that regulates an RMS value must be slower than that. `thd` counts every harmonic, where the scope's measurement stops at order 50, so they can differ by a few tenths of a percent. Each block has a demo: ```sh powercraft-cli run --cmd file.openExample --params '{"name": "demo:powerFactor"}' --cmd simulation.run ``` ## Non-ideal parts (beta) Every part is ideal until you give it a parasitic parameter. With no parameter set, the circuit is identical to before, bit for bit. | Part | Parameters | |---|---| | Capacitor | `esr`, `esl`, `rleak` | | Inductor | `dcr`, `rcore`, `isat` with `lsat` (two-segment saturation) | | Voltage sources | `rs` (source resistance) | | Switches and diodes | `ls`, `coss`, `cj`, `tdon`, `tdoff`, `qrr` with `trr` (reverse recovery) | | Meters | `bandwidth`, `delay`, `gain`, `offset`, and for sensors `sensitivity`, `vref`, `outMin`, `outMax`, `noise`, `seed` (see "Current sensors" above) | | `adc` block (new) | `bits`, `range`, `min`, `fs` | Two things in the window matter here. The **Models: Ideal | Real** switch in the toolbar decides whether the parasitics count in a run: **Real** runs every part with the parasitics as entered, **Ideal** runs with all of them back at their defaults and leaves your values in the circuit. Ideal is not lossless: a parameter's default still counts, so a switch or diode keeps its default on-resistance (1 mΩ for an ideal switch and a diode, 10 mΩ for a MOSFET or an IGBT). A part's parasitics are in the **Advanced** fold of its Properties. ![The toolbar switch and a part's Properties, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/models/01-parasitics.png) 1. Ideal. 2. Real. 3. The inductance of L1. 4. Advanced, where the parasitics are. ### Seeing what Real changes Clicking **Real** in the toolbar also turns on the switches' **device models**: a MOSFET whose device or parameters carry the gate data (`ciss`, `crss` and two of `vth`, `gfs`, `vplateau`) runs at its `dynamic` level, so its switching losses come from simulated edges, and a diode with `is` and `n` runs at its `exponential` level. A part that names its own `level` keeps it. A file that never chose keeps its levels as entered (`simulation.settings {"deviceModels": true}` turns them on from a script). **Ideal** always runs every switch ideal. Neither edits the circuit. When Real is on and some parts still run ideal, an amber chip sits next to the switch: **1 part without losses**. Its tooltip also counts the switches that stay on their ideal model. Click it and the **Losses picker** opens under it: *These parts simulate the same in Ideal and Real*. Only parts that carry power-stage current are listed: a compensator or soft-start capacitor, or a sense filter, sits in the control and sense network (found by its nets, never by name) and is left out, so an auto-designed PCM buck no longer asks for a compensator capacitor's ESR. The output capacitor and the snubbers still are listed. Each row names the part, its kind and what it is missing (for a MOSFET: Ron, Eon, Eoff, Coss), with two buttons: - **Pick part** opens the catalogue picker of that part in Properties, to choose a real part with a data sheet. - **Typical** sets the values of the part's class (`circuit.fillTypical`): a switch or diode takes the values of one named part of the lowest voltage class that blocks the circuit's highest DC voltage, an inductor the typical DCR and a capacitor the ESR of the catalogue part of its value. Each value is shown with its source (data sheet, revision and table), in the picker and under the value in Properties. A quantity no data sheet gives (a Schottky diode's Qrr, a switching energy the data sheet leaves out, an inductor of a value the catalogue does not hold) reads *no cited value, left off* and is not filled: nothing is made up. **Typical for all** does every row in one undo step; **Done** closes the picker. In Problems, a capacitor or inductor whose `part` is a catalogue part number also gets **Fill from catalogue**, which sets the ESR or DCR from that part's data sheet in one undo step (a parallel set of capacitors divides the ESR, a series set of inductors adds the DCR). The buck example comes with real losses: S1 is a MOSFET with the RDS(on) of the Infineon BSC070N10NS5 data sheet, D1 a Schottky diode with the forward drop of the Nexperia PMEG100V080ELPD, and C1 the ESR of a Panasonic EEHZC1V101P. Only L1 has no loss, since no catalogue inductor of 100 µH cites one. ![Before: Real is on, and the hint counts the parts with no losses set, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/models/04-fidelity-before.png) 1. Real. 2. The hint: click it to list the parts in Problems. Run once in Ideal and once in Real. The second run lays the first over the plots by itself, and the run card adds a table of the two runs side by side with the difference: the output voltage's average and ripple, the efficiency, the total loss and the three largest part losses. ![After: an Ideal run and a Real run of the catalogue buck, compared in the run card, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/models/05-fidelity-after.png) 1. Total loss, Ideal against Real. 2. Compare with Run 1, on by itself: the Ideal run is the dashed trace. The same numbers come from `runs.compareFigures`, and the list from `circuit.fidelityCheck`. ### Compare Ideal vs Real **Compare Ideal vs Real** on the run card (`simulation.compareFidelity`) runs the circuit twice from the same start, Ideal and Real, without changing the circuit or its runs, and opens a window with: - four cards: **Efficiency**, **Vout ripple**, **Peak Vds** of the main switch and **Total loss**, each with the Real value, its difference from Ideal (red or amber when Real is worse) and the Ideal value under it; - one switching edge of the switch node from both runs, Ideal dashed grey and Real in colour, with Real's overshoot marked when there is one; - **Where the loss goes (Real)**: a bar per part and mechanism (conduction, switching, ESR, DCR); - the line under it, such as *Ideal: 123 mW total, from the default Ron only (S1 10 mΩ, D1 1 mΩ)*: what Ideal's own loss comes from. **Keep Real** switches the circuit to Real. **Add to report** puts the comparison into Scope › Export › Results Report (`scope.resultsReport {"comparison": …}`). Two commands save typing: - `circuit.makeRealistic` fills in typical values for the parts you name (`{"components": ["L1", "C1"], "level": ...}`), or for the whole circuit. Qrr comes from the datasheet's switching energy, Coss from the current rating, and the rest are documented generic values. The result is one undo step. - `circuit.makeIdeal` removes them again. `component.describe` returns a typical range for each parameter. ### Values over temperature Some of these values change a lot with temperature. A temperature table scales the part's own value, which is its value at the datasheet's reference temperature. Write it as temperature (°C) and factor pairs, read from the datasheet's normalised curve, for example `-40 8 25 1 105 0.6`. Between the points the factor follows straight lines; past the ends it stays at the end value. | Part | Table | Read at | |---|---|---| | Capacitor | `esrTemp` (on `esr`), `cTemp` (on `c`, for class-II ceramics) | `temp`, 25 °C when unset | | Inductor | `isatTemp` (on `isat`) | `coreTemp`, 25 °C when unset | | Switches and diodes | `qrrTemp` (on `qrr`) | the junction temperature, every step: the thermal node of `thermal`, or `tj` | A part without a table is the same as before. A `temp` without a table changes nothing and gives a warning. An inductor on a catalogue core ignores `isatTemp`, because the core's material already gives the saturation at `coreTemp`. A device's switching energies and on-state voltage come from its tables at the junction temperature, as before. Not done yet: a capacitor or inductor that follows a thermal node during the run, the threshold voltage over temperature for the dynamic level, and the tables for the catalogue devices. Non-ideal parts ring. A small series inductance with a small capacitance is a fast resonance, so use a small step or the **variable step** (chapter 4). The details, with where each value comes from in a datasheet, are in `docs/workflows/non-ideal.md`. Not done yet: a value label for parasitics on the canvas, and AC-analysis support for the `adc`, gain, low-pass and delay meter blocks. ## Digital control (beta) The control library has long had continuous blocks (`pi`, `integrator`, `limiter`, `comparator`, `deadtime`, `pwm`) and sampled ones (`sampleHold`, `delay`). The beta adds four families. | Family | Blocks | |---|---| | Analog (s domain) | `tf` (numerator and denominator in descending powers of s, optional `lo`/`hi` output limits with anti-windup), `pid` (with a derivative filter and anti-windup), `lowpass2`, `bandpass`, `notch` | | Digital (z domain) | `zoh`, `zDelay`, `ztf`, `dpi`, `dpid`, `dIntegrator` (`method`: forward, backward or tustin), `fir`, `iir` (biquad sections) | | Logic | `and`, `or`, `xor`, `nand`, `nor`, `srff`, `dff`, `counter`, `monostable` | | MCU timing | `mcu`: when the interrupt runs (valley or peak of the carrier), the computation delay, when the duty register updates, and the duty resolution | | Linear, other forms | `zpk` (zeros, poles in rad/s, `a+bj` for a conjugate pair, gain `k`), `stateSpace` (single-input single-output `a`, `b`, `c`, `d`; rows of `a` separated by `;`), `derivative` (`k·ωc·s/(s + ωc)`, corner `fc`); each becomes a transfer function when the circuit is built and runs like `tf` | | Nonlinear and tables | `lookup2d` (bilinear over `xs × ys`, `zs` one row per `xs` value), `rateLimiter` (`rise`, `fall` per second), `transportDelay` (`td`), `memory` (one solver step of delay: the input at the previous accepted step, `x0` before the first; a PLECS `Memory`), `hysteresis` (relay: `on`, `off`, `yon`, `yoff`), `expr` (Fcn: a formula of `in1` … `in8`, `time` and the circuit variables) | | Bus timing | `commLink`: a message between two controllers (PMBus, CAN, UART) with a `rate` (0 sends on change), a `latency`, a seeded `jitter` and `loss`, and 1 to 4 values; outputs the held values, a `fresh` pulse and a `lost` count | | Random source | `random`: a seeded uniform (`offset ± amp`) or Gaussian (standard deviation `amp`) value, a new one every `1/fs`, held in between; the same `seed` gives the same sequence in every run and both solvers, and each new value is a step the solver lands on | Every digital block has a sample time `ts` and an optional `offset`. It updates only at `offset + k * ts`, and the solver lands exactly on those instants, in fixed and variable step. Why this matters for a loop: a digital controller adds delay. Sampling plus the computation delay costs about 1.5 sample periods of phase lag, which you must include in your phase margin. The `mcu` block lets you model it: chain `zoh`, `abc2dq`, `dpi`, `dq2abc`, `svpwm` (duty mode), `mcu`, `pwm3`. The `design.currentLoop` task has a `delayTs` field for this (use 1.5 for a digital loop). The block's `delay` counts from its own interrupt instant: with the ADC sample at that instant, `delay` 1 and `update` period give the usual one-period latency; if the ADC is triggered after the interrupt instant (a `zoh` offset past the valley), the block already reads the previous sample's duty, so use `delay` 0, or the latency becomes two periods. A digital PWM places each edge on its timer, so the duty has a finite resolution. Give `pwm` or `pwm3` the timer counts of one period as `counts` (TBPRD on a TI C2000, ARR on an STM32) and the duty rounds to a multiple of 1/counts. A high-resolution PWM moves the edge in much finer steps: set `hrpwm` to the step in seconds, or to `f28379d` (150 ps, the typical MEP step of TI SPRS880P section 6.11.4.1.2) or `stm32g474` (184 ps, ST RM0440 Rev 9 Table 231), and the duty rounds to a multiple of step × freq. Without either, the duty is not rounded. When the DPWM is coarser than the ADC, the loop limit-cycles: the output hunts by about one DPWM step. `design.digitalize` checks this (`dpwmBits`, `dpwmCounts` or `hrpwm`, with `adcBits` and `vFullScale`; chapter 16). A `pwm` block compares its input with a carrier that runs from 0 to 1 by default, so the input is the duty. When the controller's output is a voltage, give the carrier its span in those units instead: `offset` is the carrier's lowest value and `vpp` its peak-to-peak value, and the duty is (in − offset)/vpp. A 0.5 V to 3 V carrier fed by an error amplifier is `offset` 0.5 and `vpp` 2.5; a modulation index from −1 to 1 is `offset` −1 and `vpp` 2. An input at or below `offset` keeps the switch off, and one at or above `offset + vpp` keeps it on. The rounding of `counts` and `hrpwm` applies to the duty after this mapping. Generated code maps the duty the same way before it writes the compare register (chapter 13). The averaged view (`design.voltageLoop` and the other loop designs) reads the PWM's input as the duty and refuses a block that sets `offset` or `vpp`: put the scaling in a gain and a sum ahead of a default `pwm` there. A supervisor that talks to a converter over a bus adds its own delay. Put a `commLink` between them: a set point sent at `t` reaches the loop between `t + latency` and `t + latency + jitter`, in order, and a lost message never arrives. The same `seed` gives the same jitter and losses in every run and in both solvers. It models only the timing, not a protocol stack. Code generation leaves it out as a simulation-only block, because on the target the bus driver carries the message. The component guide lists typical numbers for PMBus, CAN and a UART, worked out from the bit rates; they are not from a standard. A slow interrupt changes this. Give the block the ISR's execution time in place of `delay`: `tIsr` in seconds, or `cycles` and the CPU clock `fclk` (the line `cargo xtask armgcc` prints for the generated STM32G474 code ends with these two values). With `update` set to `end` (the same as `immediate`), the new duty takes effect when the ISR ends. With `period`, it takes effect at the next update event, as before. The block has two more outputs: `load` above it and `overrun` (`ovr`) below it, so the pins already wired do not move. `load` is tIsr times fs, and `overrun` is 1 when the ISR takes the whole period or more. An ISR that comes while the previous one still runs waits for it. One that cannot start before the next interrupt is lost, and its duty is never written. Without `tIsr` or `cycles` the block works as before, and both outputs read 0. `design.digitalize` takes the same `tIsr`, `cycles`, `fclk` and `update` and reads the phase margin with that delay (chapter 16). The guide, with the equivalent transfer functions of each discretisation, is `docs/workflows/digital-control.md`. When the loop works in simulation, **Tools > Code Generation** turns its sampled blocks into portable C99 for a microcontroller (chapter 13). ### Linear forms, tables, rate limits, delays and relays The blocks of the last two rows of the table above (`zpk`, `stateSpace`, `derivative`, `lookup2d`, `rateLimiter`, `transportDelay`, `hysteresis`, `expr`) are in **Insert > Control**, and each has a reference page and a demo (`file.openExample` with `demo:rateLimiter` and so on). **Example: a reference step through a rate limiter.** The example `buckClosedLoop` regulates 12 V. This chain feeds its error amplifier from an `expr` block that steps the reference to 15 V at 5 ms, first directly, then through a `rateLimiter` of 2 V/ms: ```sh powercraft-cli run --cmd file.openExample --params '{"name":"buckClosedLoop"}' \ --cmd circuit.addComponent --params '{"name":"Step","kind":"control","block":"expr","params":{"f":"if(time > 5m, 15, 12)"}}' \ --cmd circuit.connect --params '{"component":"Step","port":"out","net":"vstep"}' \ --cmd circuit.addComponent --params '{"name":"Soft","kind":"control","block":"rateLimiter","params":{"rise":"2k"}}' \ --cmd circuit.connect --params '{"component":"Soft","port":"in","net":"vstep"}' \ --cmd circuit.connect --params '{"component":"Soft","port":"out","net":"vsoft"}' \ --cmd circuit.connect --params '{"component":"Err","port":"in1","net":"vsoft"}' \ --cmd simulation.run --params '{}' \ --cmd scope.measure --params '{"signals":["v(out)","i(L1)"],"t0":"5m","step":true}' ``` With the step fed directly (connect `Err.in1` to `vstep` and leave out `Soft`), the inductor current peaks at 7.24 A after the step and `v(out)` rises in 1.19 ms. Through the rate limiter the reference ramps for 1.5 ms, the inductor current peaks at 6.76 A (the 15 V load alone takes 6.25 A) and `v(out)` rises in 1.90 ms; both settle at 15.0 V with an overshoot below 0.3 %. **Limits.** - Code generation writes `lookup2d`, and `rateLimiter` at the code's sample time when it feeds a PWM's duty cycle (chapter 13); it leaves out `transportDelay` and `expr`, each with a reason. `zpk`, `stateSpace` and `derivative` are treated like `tf`: written as their discrete equivalent when they feed a PWM, otherwise left out as s-domain blocks. `hysteresis` is generated with its held level in the state struct. - `stateSpace` has one input and one output, an order of at most 16 and a zero initial state; states the input cannot reach or the output cannot see are dropped. `zpk` must have no more zeros than poles, also up to order 16. - `lookup2d` holds each input at the edge of its grid, without a warning, and takes at most 65536 values. - `transportDelay` keeps at most about one million points of history; a longer delay against a small step stops the run. - `rateLimiter`, `transportDelay`, `expr` and `hysteresis` act once per accepted solver step, so the step size sets how exactly they follow their input. A source driven by `expr` follows one step late. ### State machines A start-up, precharge, takeover or fault sequence is one `stateMachine` block instead of a tangle of gates, latches, counters and one-shots. Its definition lists the inputs, the outputs, the states with the value of each output, the initial state and the transitions `{from, to, guard, priority}`. Guards are expressions over the inputs (by name or as `in1`, `in2` …), `t_in_state` (the time spent in the active state) and the circuit variables. Set it with `circuit.setStateMachine {component, definition, fs}`; it checks the definition (unknown or unreachable states, no initial state, a guard that does not parse or reads an unknown name) and moves the pins to `in1` …, `out1` … and `state`, keeping the nets of wired pins. The Properties panel lists the states and transitions and any problem. View › Overlays › State Graph (or a double click on the block, or State Graph in Properties) draws the states as boxes and the transitions as arrows labelled `priority: guard`, with the initial state's entry arrow; after a run it highlights the state active at the end, and during the animation the one active at the playback time (wire the `state` pin for this). ![The state graph of a state machine block after a run, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/models/02-state-graph.png) 1. **State Graph** in Properties opens the graph (also **View › Overlays › State Graph**). 2. The state active at the end of the run, highlighted in the graph. At every sample (every `1/fs` from t = 0, or every solver step when `fs` is 0) the transitions out of the active state are tried, the smallest priority first and, at equal priorities, in list order. The first true guard (above 0.5) fires and restarts `t_in_state`; at most one transition fires per sample. The outputs then take the new state's values and hold until the next sample, and `state` gives the index of the active state, counted from 0. A precharge sequence looks like this: ```json {"inputs": ["en", "vbat", "vpack"], "outputs": ["k1", "pre", "qb", "k2"], "initial": "Idle", "states": [{"name": "Idle"}, {"name": "CloseK1", "outputs": {"k1": 1}}, {"name": "Precharge", "outputs": {"k1": 1, "pre": 1}}, {"name": "Bypass", "outputs": {"k1": 1, "pre": 1, "qb": 1}}, {"name": "Run", "outputs": {"k1": 1, "k2": 1}}], "transitions": [{"from": "Idle", "to": "CloseK1", "guard": "en > 0.5"}, {"from": "CloseK1", "to": "Precharge", "guard": "t_in_state > 19.5m"}, {"from": "Precharge", "to": "Bypass", "guard": "vpack > 0.95*vbat"}, {"from": "Bypass", "to": "Run", "guard": "t_in_state > 9.5m"}, {"from": "Run", "to": "Idle", "guard": "en < 0.5", "priority": 0}]} ``` With `fs` set, the sample instants are solver events, and code generation writes the machine as a C `switch` on its state (floating point only). Write a timed guard half a sample early (`t_in_state > 9.5m` at 1 kHz for 10 ms), so rounding never moves it a whole sample. ## Power-supply control blocks and the three-phase source These blocks and options cover the control of switch-mode supplies and grid converters. Every option is off by default, so a circuit made before them runs as it did. | Block | What it adds | |---|---| | `deadtime` | A second output `outn`: the complement of `in`, its rising edge delayed by `td` too. One block drives both gates of a half bridge. | | `comparator` | `hys`: out turns 1 above `in2 + hys`, 0 below `in2 - hys`, and holds in between. | | `srff` | `priority` = `set` makes the latch set-dominant (reset is ignored while set is high), as peak-current-mode control needs. | | `clarke`, `abc2dq` | A third output `zero` = (a + b + c)/3. | | `invClarke`, `dq2abc` | An optional `zero` input, added back to every phase. | | `sampleHold`, `zoh`, `dpi`, `dpid` | An optional `clk` input: while it is wired, the block samples on its rising edges instead of every period. | | `monostable` | An optional `ton` input: its value at each trigger is the pulse width. | | `pwm`, `carrier` | Optional `phase` (degrees) and `freq` (Hz) inputs replace the parameters while wired: a phase-shifted full bridge or a dual active bridge shifts one leg against the other. | | `mux` | Up to eight inputs; `sel` (counted from 0, rounded, limited) picks one. | | `ramp` | `gate` mode: `se*(t - t_rise)` while `in` is high (slope compensation). `saw` mode: from 0 at each rising edge of `clk`, reaching `vh` after 1/`f`. | | `compensator` | Type II or Type III: `H(s) = g*(wz1/s)*(1 + s/wz1)/(1 + s/wp1)`, Type III times `(1 + s/wz2)/(1 + s/wp2)`, on `ref - fb`, with a finite DC gain `avol`, limits `vl`, `vh` and anti-windup. An AC sweep uses its transfer function. | | `atan2` | The angle of the alpha-beta vector, wrapped to 0 ... 2*pi. | | `pq` | Instantaneous power: `p = k*(ea*ia + eb*ib)`, `q = k*(eb*ia - ea*ib)`, `k` = 1.5. | `sine3VoltageSource` is a balanced three-phase source with pins `a`, `b`, `c` and the star point `n`. `vac` is an RMS value: the phase voltage with `mode` = `phase`, the line-to-line voltage with `mode` = `line` (a 400 V grid is `vac` = 400, `mode` = `line`). Code generation (chapter 13) writes `mux`, `atan2`, `pq`, the zero-sequence pins and a comparator with hysteresis. It leaves out `ramp` (a function of simulation time), `compensator` (s domain; discretise it with `ztf`) and any block clocked by its `clk` input (call the generated step from the clock's interrupt instead). The example **GaN synchronous buck converter** (`buckGan`) drives both gates of its half bridge from one dead-time block: ![The GaN buck's dead-time block, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/control-blocks/01-deadtime.png) 1. `DT`: one `deadtime` block. `out` is the PWM signal with its rising edge delayed by `td` (20 ns), `outn` its complement, delayed too. 2. `Q1`: the high side, driven by `out` (`g1`). 3. `Q2`: the low side, driven by `outn` (`g2`). ## Sources from a list of points (PWL) A DC voltage source or a DC current source follows a list of points when you fill in `pwl`. Write time and value pairs, `"t1 v1 t2 v2 ..."`, with SI prefixes or variables, separated by spaces or commas. The source joins the points with straight lines and replaces its fixed value. There are at most 100 000 points. The times must not decrease, and two points at the same time make a step. Set `repeat` to 1 to run the pattern again and again; the period is the last time. An odd count of numbers, times that go down and a bad number are refused with a message. The fast solver lands on every corner. SPICE and LTspice `PWL(...)` sources import as this part (chapter 9). ## Loads: constant power, load profiles and the rectifier load The electrical constant-power load (`powerLoad`, pins `p n` and an optional `pref` input) draws `i = P/v` above `vmin` and is the resistor `vmin²/P` below it, so it stays defined at 0 V. It stands for the input of a regulated converter, so its incremental resistance is negative: an LC filter in front of it rings up unless the filter is damped. Set `von` and `voff` to the UVLO thresholds of the converter it stands for: the load starts off, turns on once its voltage reaches `von` and drops out below `voff`. Without a lockout, a load on a supply that ramps from 0 V latches near 0 V, as a real one would. The power it draws is the `pref` signal when that pin is connected, else its `profile`, else `p`. A profile is the power as a function of time: | Profile | Meaning | |---|---| | `pwl(t1 p1 t2 p2 ...)` or the bare list | straight lines between the points, as a PWL source | | `steps(p0 t1 p1 t2 p2 ...)` | `p0` from the start, then each level from its time on | | `pulse(p1 p2 delay rise fall width period)` | a pulsed load, as the pulse source; `period` 0 runs it once | | `workload(pidle ppeak period duty edge [pexc texc])` | an AI-training cycle, repeated every `period`: the compute phase at `ppeak` for `duty·period`, then the communication phase at `pidle`, each edge taking `edge`; with `pexc texc`, each compute phase opens with `texc` at `pexc` (above TDP) | | `vrstep(p0 p1 delay slew [width period])` | a load step from `p0` to `p1` at `delay`, at `slew` per µs; with `width period` it steps back after `width` and repeats | Numbers take SI prefixes and variables. Set `repeat` to 1 to run a `pwl` or `steps` pattern again and again; a `workload` always repeats. None of the numbers has a default: take them from your own measurement or a cited source. The `aiRackWorkload` example takes its workload from Choukse et al., "Power Stabilization for AI Training Datacenters", arXiv:2508.14318v2 (2025): a 1 s cycle between 65 % of TDP and TDP with 50 ms at 1.1 × TDP, on an OCP Open Rack V3 48 V shelf whose BBU rides through a mains failure. Both solvers follow the profile, and the fast solver lands a step on each of its corners. Example: `cplInputFilter`. The DC current source takes the same `profile` (in amperes), ahead of its `pwl` and `i`: `vrstep(i0 i1 delay slew)` is a voltage-regulator load step with the slew in A/µs, as VR transient specs give it. `spec.verify` uses it for `loadStep.slew`, and `loadStep.loadLine` (Ω) checks that the output settles on the load line. `circuit.importLoadTrace` (File › Import › Load Trace) replays a measured trace: it reads a logger, PMBus or scope CSV (time and power in W, or current in A), moves it to start at 0 s and writes it as the `profile` of a power load or a current source in one undoable step. A trace longer than `maxPoints` (2000, at most 20000) is averaged over that many equal bins, which keeps its energy; the reply gives the energy of the trace and of the profile. The nonlinear rectifier load (`rectifierLoad`, pins `l n`) is a single-phase diode bridge with its smoothing capacitor `c` and load resistor `r`, behind an optional line resistance `rs` and inductance `ls`. It draws its current in short peaks near each crest of the line, the classic source of odd harmonics. `c` and `r` have no default; they are the load you stand for. For a load named NL1, the DC voltage is `v(NL1:p) − v(NL1:m)` and, with `rs` set, the line current is `i(NL1.rs)`. Example: `rectifierHarmonics`. ## Batteries, solar modules, supercapacitors and the three-phase grid These parts have their own component guides (F1), with every parameter. - **Battery** (`battery`): an open-circuit voltage that follows the state of charge, a series resistance `r0` and up to two RC branches. `ah` is the capacity, `soc0` the starting charge, `ns` the cells in series, and `socs` with `ocvs` is the voltage table of one cell. The default table is only an example curve, so take your own from the cell data. The state of charge is the signal `:soc` and the pin `soc`. It is held between 0 and 1, with a warning. Its `thermal` param names a thermal net: the heat of `r0` and the RC branches' resistors goes into it, so a thermal network (the cells' `cth`, an `rth` to an `ambient`) gives the cells' temperature `T()` from the run's losses. With `ea` set, the resistances follow the net: after each step they take the Arrhenius factor at `T()` in place of `temp`, which then only sets their value at the start (warm cells lose less, cold cells more). With `ea` 0 they are fixed. The rest-voltage shift `dOcvDt` still follows `temp`. - **Solar module** (`pv`): the single-diode model, fitted so that the curve passes through `isc`, `voc`, `imp` and `vmp`. `temp`, `alphaIsc` and `betaVoc` set the temperature, `irr` or the pin `g` sets the sunlight, and `nser` with `npar` make an array. Values that cannot be fitted (for example `imp` above `isc`) are refused before the run. - **Supercapacitor** (`supercap`): the capacitance `c` with `esr`, `rleak` and an optional slow branch `r2` with `c2`. - **Water electrolyzer** (`electrolyzer`): a load, the stack of a hydrogen electrolyzer. Each of the `ns` cells needs the reversible voltage `erev` plus an ohmic overvoltage `(r1 + r2·T)·j` and an activation overvoltage `s·log10((t1 + t2/T + t3/T²)·j + 1)`, where `j` is the current density (the current over the cell area `area`) and `T` the stack temperature `temp` in °C: the empirical law of Ulleberg (Int. J. Hydrogen Energy 28(1), 2003). The defaults of `r1` to `t3` are Table I of Cantisani, Dovits and Jørgensen (arXiv:2311.09882v2, 2024); `area` and `temp` have none, so set them for your stack. `i()` is the current into `p`. Tests check the stack voltage against the law on both solvers. - **Three-phase grid** (`grid3`): a three-phase source with a neutral. `vll` is the line-to-line rms voltage. `ka`, `kb` and `kc` unbalance the phases, `harmonics` adds harmonic pairs such as `5 4 7 3` (order, percent), `sagDepth` with `sagStart` and `sagEnd` makes a sag, `fDev` with `fStart`, `fEnd` and `fRate` moves the frequency (a step, or a ramp at `fRate` Hz/s, held to `fEnd` and ramped back), and `rs` with `ls` is the grid impedance. Connect the neutral `n`. - **Three-phase parts built from simpler ones**: `rlc3` (a series R-L-C in each phase), `transformer3` (vector groups such as Dy11, Yy0 and Yd1, with leakage and magnetizing inductance), `breaker` (opens at a set time or on overcurrent after a delay, and may close again), `fault` (a short circuit between chosen lines, or to ground, in a time window), `sixSwitch` (three legs of switches with a diode across each) and `diodeBridge3`. - **MMC arm** (`mmcArm`): one arm of a modular multilevel converter, `n` half- or full-bridge submodules inserted by the signal `m`. `level` `switched` (up to 8 submodules) builds every submodule and picks them with an `mmcBalance` block, at the nearest level or with phase-shifted PWM at `fc`, sorting by capacitor voltage (`sorting` 0 switches the sorting off: the submodules go in by index and the capacitors drift apart). `level` `averaged` is the arm-averaged model for any `n`. Plot `:v1` … for the capacitor voltages and `:vsum` for their sum. The `mmcInverter` example adds a circulating-current controller. Tests check that the switched and averaged arms give the same fundamental (after the nearest-level staircase gain) and that the sorting keeps the capacitors together. - **Pi-section line** (`piLine`, and `piLine3` for three phases): a transmission line from its per-metre `r`, `l`, `c` (and optional `g`) and its `length`, cut into `sections` pi sections, each a series R-L with half its shunt C at each end. The three-phase line is one uncoupled line per phase with the positive-sequence values, so it does not model the zero sequence. Plot `:1` … for the inner nodes. Tests check that the input impedance of an open or shorted line matches the distributed line, Z0·coth(γℓ) and Z0·tanh(γℓ), and that the open end of a 300 km line rises by 1/cosh(γℓ). - **Transmission line** (`tline`): a distributed lossless line from its characteristic impedance `z0` and one-way delay `td`, with an optional total series resistance `r` lumped half at each end. It has two ends, `p1`–`n1` and `p2`–`n2`, like SPICE's `T` element, and imports from and exports to it. A transient solves it by the method of characteristics (Bergeron's method, after H. W. Dommel, IEEE Trans. PAS-88, 1969): a wave leaving one end arrives at the other exactly `td` later and reflects as the impedance it meets demands, which is what makes the overvoltage at the terminals of a motor fed through a long cable. Max step must not exceed `td`, or the run stops with an error naming the line. An AC sweep and the DC operating point use its exact chain matrix (quarter-wave resonances in a sweep, the resistance `r` at DC). The currents into both ends are `i(.1)` and `i(.2)`. Tests check a step into a line mismatched at both ends against the bounce diagram, the input impedance of an open and a shorted line (−j·Z0·cot(ωτ) and j·Z0·tan(ωτ)), a 200-section pi chain of the same line, the fast solver at a fixed and a variable step, and ngspice's `T` on the same netlist (within 4e-8 relative RMS). The loss does not spread along the line or grow with frequency (no skin effect). These parts were checked with tests on both solvers (a battery step, a solar module near its maximum power point, the 120 degree spacing and the depth of a sag, and the time constant of a supercapacitor). No part was compared with a measurement. ## Your own blocks For a control block that is not in the library, you can write a WebAssembly block and load it. It runs in a sandbox. See `docs/plugins.md`. ## Searching for parts **Library › Search Parts** (`parts.search`) looks through every part source at once: the shipped catalogue of capacitors, inductors and semiconductors, and the other sources as they are added. Type a part number or a piece of one, pick a category, and narrow it with that category's specs: voltage and current for any part, **Rds(on) ≤** for a MOSFET, capacitance and **ESR ≤** for a capacitor, inductance and **Isat ≥** for an inductor. A value takes SI prefixes (`600`, `10u`, `20m`). **Leave out end-of-life parts** drops the parts recorded NRND, EOL or obsolete. Each part is one line: part number, key specs, package, price, stock and where the data came from; the pointer over the source says when each source was fetched (the shipped catalogue has no fetch date, its values come from the data sheets). **Place** (`parts.place`) puts the part on the schematic as the matching component with its values filled: a capacitor's C and ESR, an inductor's L, DCR and Isat, a MOSFET's, IGBT's or diode's device model. It is one undo step. The search works offline. ## Your parts library When no catalogue part fits a line of the bill of materials, **Library › Your Parts** adds a part of your own, read off its data sheet: kind, part number, manufacturer, the data sheet you read it from (required, so anyone can check the numbers), package, ratings and an optional **Category** such as `approved`. The check beside each field flags missing values and unit slips. `bom.export` (and so the Parts page and `design.auto`) uses your part for a line no catalogue part fits. The list under the editor manages the library: - **Search** filters by part number, manufacturer, package, category or source, and the category menu shows one category (`parts.list {"query":"GRM","category":"approved"}`). - **Edit** fills the editor with a part; **Save changes** changes it in place (`parts.update {"mpn","set":{...}}`), through the same check. The next bill of materials picks with the new values. - **Export CSV** copies the parts shown to the clipboard as CSV, one column per field (`parts.export {"format":"csv"|"json"}`); paste it into a spreadsheet to keep a team's approved-parts list. - **Import** reads pasted CSV or JSON (`parts.import {"text"}`): every row goes through the check, the good rows are added, and each row left out is named with its row number and the reason. **Add from a data sheet** reads a part's values off its data sheet into a review card instead of typing them. Pick the kind, fill in the part number, manufacturer, package and **Data sheet source**, then **Read the file** (a PDF Voltecx can read, or the sheet's text with a page break per page, in a folder you granted) or **Read the pasted text** (`parts.fromDatasheet`). Each row shows the value with where it was read, such as `p. 2, Table 2` (hover for the line), and the sheet's other readings of the same field (another temperature, a figure) as links that take their place. A field the sheet does not give stays empty and says **Not in the data sheet**: nothing is filled in. Edit any value, then **Save to your library** (`parts.saveDraft`), which runs the same check and keeps every citation and the date the sheet was read with the part; **Discard** drops the draft. The assistant can read an attached data-sheet PDF the same way: its values land in the same card, each with its page, and you save. The library stays on your computer (`user-parts.json` in the settings folder); nothing is uploaded. ## Import a part you only have files for `part.import {mpn, kind, source, footprint, symbol, model, fields}` adds a part to your catalogue from what you supply: a KiCad footprint (`footprint`, its text or `{"path":...}`), a KiCad symbol library (`symbol`, with `name` to pick one symbol), a STEP or VRML 3D model (`model {"path":...}`), and the values you read off the data sheet in `fields`. Every field carries its `source` (a data sheet title, revision and address, with `page` and `quote` when you have them); a value with no source of its own and no part-level `source` is an error, because Voltecx never invents a value. `kind` (`mosfet`, `sic`, `gan`, `igbt`, `diode`, `capacitor`, `inductor`, `resistor`, `ic`, `connector` or `other`) decides which fields are expected, and the ones nobody gave are listed in `missing`, never filled in. The reply checks the part and lists each finding in English and Traditional Chinese under `checks`: pins without pads and pads without pins, the exposed pad and the pin it joins, power pins that are hidden or typed wrongly, Kelvin pins, a missing footprint, symbol or model, and a footprint that does not match the symbol. Give `pinMap {pad: pin}` for pads whose number is not the symbol's pin number (null for a mounting pad) and `roles {pin: role}` when a pin's name does not say it is power, ground or Kelvin. `"ok": false` means a check is an error. With `"add": true` (and no error) the footprint, symbol and 3D model are kept in your model cache under the part number, so `file.exportKicad` uses them. The command changes no circuit and uploads nothing. ## Your own symbols **Library › Editors › Symbol Editor** draws a part symbol of your own: an IEC resistor box, a vendor's IC outline, a block for a subsystem. 1. Type a name and click **New**, or select one part on the schematic and click **New from selected part**. The second way starts from that part's box, with a pin for each of its ports, already bound to it. 2. Pick a tool and click the grid. **Polyline** adds a point per click; click **Finish line** when it is done. **Polygon** works the same way and closes itself (**Finish polygon**). **Box** takes two corners, **Arc** and **Circle** a centre and a point on the circle, and **Text** and **Pin** one click each. Type the text or the pin name first. With **Box**, **Circle** or **Polygon**, tick **Fill** to draw the shape solid (a filled polygon must be convex). Shapes snap to half a grid unit. Pins end on whole grid points, where wires meet them. Each shape and pin is one step that **Cmd+Z** takes back. 3. To change what is drawn, pick **Select** and click a shape (near its first point, corner or centre) or a pin (at its tip): it is ringed. Click anywhere else on the grid to move it there. A picked shape can be filled or unfilled, or erased; a picked pin shows its name, number and side to edit, then **Apply**. Parts drawn with the symbol redraw at once and stay bound. A pin's name is the model port it stands for, so renaming is refused while the symbol is bound or a part is drawn with it. 4. **Bind** ties the symbol to a model: a subsystem's name (an IC placed from the library is a subsystem too) or a part kind such as `resistor`. The pins must be exactly the model's ports, or Bind says which are missing and which are extra. 5. **Place** adds a part drawn with the symbol. On a part that already exists, the `symbol.apply` command switches its drawing. **Save to library** keeps the symbol for your other projects, in `library/symbols.json` in the settings folder. **Export** copies it as a symbol file to share. ![The Symbol Editor with a hand-drawn IEC resistor, and R1 drawn with it, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/models/03-symbol-editor.png) 1. **New** starts a symbol (step 1). 2. The drawing tools, Polyline first (step 2). 3. **Bind** ties the symbol to a model (step 4). 4. **Place** adds a part drawn with it (step 5). 5. `R1`, drawn with the IEC symbol. A symbol only changes the drawing. The part simulates exactly as with its standard symbol, and a part whose symbol no longer fits its ports goes back to the standard one. The lesson *Draw your own symbol* walks through it. ## Your own footprints **Library › Editors › Footprint Editor** draws a board footprint of your own, saved as `footprints/.vxfp` beside the project. 1. Type a name and click **New**, or pick a footprint of the project's library from the list (or type a `.vxfp` path). To start from a data sheet instead, open **Generate IPC-7351 Footprint** under the name: pick the package (a two-terminal chip, a dual-row part such as a SOIC, or a quad no-lead part such as a QFN), name the data sheet, page and revision the dimensions come from, and type each dimension's min and max in mm as the data sheet's table gives them, with the pitch and the number of lands. Pick the density (**Most**, **Nominal** or **Least**, the IPC-7351 presets for chips and dual-row parts) or **Own goals** (toe, heel and side, with the courtyard excess; a quad part always takes its own), then type the board fabrication tolerance F and the placement tolerance P. **Generate** stays grey and says what is missing until everything is typed, since Voltecx never guesses a dimension. It writes the land pattern (lands numbered from pin 1 and the courtyard) to the library and opens it here; an existing footprint of that name is kept unless **Replace an existing file** is ticked. This is the `footprint.ipc7351` command. Some parts also have the maker's own recommended land pattern, copied from its drawing and cited in the footprint's source as maker recommended, never as IPC-7351B: Vishay's 0402 and 0201 chip resistors, TI's 3 × 3 mm 16-pin VQFN (RGT0016C) and 10-pin VSSOP (DGS0010A), and the D2PAK (TO-263) as three makers draw it. The D2PAK makers disagree (their tab pads are 9.017, 8.00 and 7.01 mm tall), so each has its own preset named after it: Vishay AN826 (3-lead, minimum pads), Vishay document 96683 (2-lead) and Diodes TO263AB. Pick the one from your part's maker; pads 1 and 2 are the lead pads and pad 3 the tab. Pick **Maker Recommended** as the package, then the part's drawing (its maker document and page show under the buttons), and type the courtyard excess, since the makers give none (zero is allowed); the data sheet, dimensions, density and tolerances do not apply. The command takes them as `"package": "maker"` with the `preset` id and the courtyard excess. TO-247, BGA and the 7-lead D2PAK have no preset: their drawings leave the holes or ball positions open, or give no land pattern, so draw those by hand from the maker's drawing. 2. **SMD Pad** and **Through Pad** place a pad at each click on the grid, numbered on from the highest number. Pick the shape (rectangle, round rect, oval or circle) and type its size in mm, and for a through pad its drill; the tool waits until you do, since Voltecx never guesses a pad size. Clicks snap to **Grid (mm)**. **Segment** and **Box** draw on the silkscreen, the fabrication drawing or the courtyard, two clicks each, at the line width you type; **Circle** takes the centre, then a point on the circle. **Arc** takes three clicks: its start, a point on it and its end. The **Drawings** list below the drawing area names each drawing by layer and shape; its **×** deletes that one drawing, as one undo step. With the shape **Custom Polygon**, a pad tool draws the pad's copper outline instead: click its corners on the grid and click the first corner again to close it. The pad is anchored at the middle of the outline's bounding box, where a through pad's drill goes. An outline with all its corners in line and an arc whose three points are in line are refused and say why; the clicks so far stay. **Add Pads** takes the other shapes only. With a pad tool on, **Add Pads** places a whole row of those pads at once: type where the first one goes (**Row start x** and **y**), the **Pad count** and the pitch in x or y. The pads are numbered on from **First pad number** (empty: from the highest number); tick **Same number (thermal vias)** to give them all one number, as for the vias in an exposed pad. The row is one undo step. 3. **Select** picks a pad: edit its number, place and size and click **Apply**, or **Delete pad**. **Mask margin** and **Paste margin** set the pad's solder mask and paste openings with the same **Apply**: a margin in mm grows the copper (negative shrinks it), **No opening** leaves that layer closed (as for the paste on an exposed pad with vias), and an empty margin opens the copper itself. Drag a pad to move it: it lands on the nearest grid point, as one undo step. Drag anywhere off the pads to pan and scroll to zoom; **Zoom to Fit** frames the pads and body. The layer switches show or hide the copper, paste, mask, fabrication, courtyard and silkscreen. 4. **Set Courtyard** draws the courtyard around the pads and the body, grown by the excess you type (IPC-7351 calls it the courtyard excess). **Check Footprint** places the footprint alone on a board with the project board's stack-up and rules and runs the DRC; it lists each violation, and a missing courtyard or pads outside it, and rings each violation on the drawing where the DRC found it. 5. **3D Model and Properties** places the 3D model (a STEP or VRML file, with its offset in mm and its rotation in degrees; an empty offset or rotation is 0) with **Place Model**, or takes it off with **Remove Model**. **Set Properties** saves the description and the source of the dimensions. **Set Height** saves the body's height above the board, the data sheet's maximum seated height, with the document it comes from; it stays grey until that source is named, and an empty height removes it. **Set Fitting** saves how the part is fitted, off its data sheet: its **Mount** (surface mount, through-hole by hand, wave or selective solder, press-fit), whether it is **Plugged in** (stays soldered, socketed, plugged by the user), whether it is **Removed in service**, and whether it is **Keyed**. Anything the data sheet does not say stays Unknown, and the button stays grey until the **Fitting source** is named. **Remove Fitting** takes it off. Every part placed with this footprint then carries the fitting into the fitting plan, the assembly and layout reviews, the coating keep-outs and the BOM's Fitting column. The fields follow the footprint, so **Undo** shows what it had before. Every change is one step of the footprint's own history: **Undo** and **Redo** in the window take it back and do it again. The same edits are the `footprint.*` commands, from `footprint.new` and `footprint.addPads` to `footprint.check`, and `board.placePart {"footprint": ".vxfp"}` puts the footprint on the board. --- # 11. Chat and the command line URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/11-chat-and-mcp/ Voltecx's assistant is its built-in chat. Every Voltecx action is a command, so the assistant uses the program the way you do: it builds the circuit, runs the simulation, reads the waveforms and tells you what it found. You talk to it in two places. | Where | Use it when | |---|---| | The agent panel in the desktop app | You want to work on the circuit in the window, with proposals you accept or reject (chapter 12) | | `powercraft-cli chat` | You want to talk to Voltecx in a terminal, or answer one message from a script | Outside AI tools cannot drive Voltecx: it has no MCP server and no connection for other assistants. The one way in is Claude Code started from **Terminal › Claude Code Here**, which works on the open window through `powercraft-cli app` with Voltecx's own skills (see "Claude Code in the terminal" below). To script the program without an assistant, use the command line (chapter 19) or `powercraft-cli app` (below). The assistant does not see more than you allow (see "What the assistant can reach" below). ## Chat in the terminal You need an Anthropic API key. It costs money on your own account. Voltecx reads the key only from the environment and never writes it to a file. ```sh export ANTHROPIC_API_KEY=sk-ant-... mkdir -p work powercraft-cli chat --automation-read-root work --automation-write-root work ``` Then type a request: ```text you> build a 48 V to 12 V, 5 A, 100 kHz buck and tell me the output ripple -> circuit.template {"fsw":"100k","iout":5,"topology":"buck","vin":48,"vout":12} ok -> sim_run ok -> scope_measure {"signals":["v(out)"],"t0":0.000153} ok The output averages about 12 V ... you> /save buck48.voltecx ``` (The numbers above are a sketch. The real values depend on your run.) **In the open window.** While Voltecx runs, a chat started in a Voltecx terminal (View › Terminal), or in any shell while the app runs with its control channel, works on the open window instead of a circuit of its own. The banner says "Linked to the open Voltecx window". What the chat builds appears in the window as it happens, each command is one step you can undo, and the version history records it as the CLI's. A spec the chat sets shows in the Spec tab with Set by CLI (chapter 16). `/save` saves the window's circuit, and `/reset` forgets only the conversation: the window's circuit stays. `--headless` keeps a session of the chat's own, as before. With no window running, nothing changes. **It checks its own changes.** When the assistant has changed the circuit in a message, it checks the change before it answers, as in the agent panel (chapter 12). If it tries to answer without having run anything since the change, Voltecx sends it back to run `spec_verify` with the spec or targets you gave, or to simulate and measure, and to answer with pass or fail for each target, the measured value and its limit. It is sent back at most twice per message, so a message always ends. The answer it wrote before the check prints first, as a draft, and the check prints as a line of its own with its verdict: ```text → self_check {"after":"spec_verify"} error: 1/2 ✗ · ripple 0.15 > 0.12 V ``` `ok · 5/5 ✓` means every row of the spec passed; a plain `ok` follows a simulation run again after the change. When a target still fails, the final answer says which one, by how much and what would meet it. | Chat command | What it does | |---|---| | `/save NAME.voltecx` | Saves the current circuit (needs `--automation-write-root`) | | `/reset` | Forgets the conversation and starts with an empty circuit | | `/help` | Shows help | | `/exit` or Ctrl-D | Leaves | | Ctrl-C | Cancels the current message. The conversation stays | Options: `--model ID` (default `claude-opus-5-5`), `--max-tokens N` (default 64000, thinking included), `--max-tool-calls N` (default 200), `--effort LEVEL` (`low`, `medium`, `high`, `xhigh` or `max`; default `high`). Claude 4.6 and later models think before they answer (adaptive thinking); `--effort` sets how much. **Web search.** With `--allow-web`, the assistant may search the web and read pages when the circuit, the results, the catalogue and your files do not answer a question: a data sheet value, an application note, a standard's limit. Without the option it never reaches the web. Anthropic runs the search, so the computer still talks only to `api.anthropic.com`; the search queries and the addresses of the pages it reads go there, never your circuit file. It searches at most 8 times and reads at most 8 pages per message. Each search shows as a `→ web_search {"query":…}` line, and the answer is followed by the pages it cites: ```text The total gate charge Qg is … nC at VGS = 10 V (data sheet, page 3). Sources from the web: 1. data sheet, page 3: https:///… ``` The line after the answer counts the searches and pages (`[2 tool calls, 1 web search, 1 page read, …]`), and `-p --json` adds `webSearches`, `webFetches` and `sources` (each with `url`, `title`, `page` and the `cited` passage). The assistant does not write a value from the web into the circuit without naming its source; check the source before you keep the value. `--allow-web` needs Anthropic's API: with a self-hosted model server (below) it is refused. **Privacy.** Your messages and every tool result go to Anthropic's API. That includes circuit data, waveform values and the content of any file you allow it to read. Do not put data you must not send into the read folder, and do not paste it into the chat. The engine itself works fully offline. Only `chat` connects to the network, and only to `api.anthropic.com`. You can build a CLI with no network code at all: `cargo build -p powercraft-cli --no-default-features`. A conversation is not saved when you close the program. Save the circuit with `/save`. ### A self-hosted model (closed networks) On a network with no internet access, point `chat` at a model server on your own network instead. Nothing then goes to Anthropic, and no `ANTHROPIC_API_KEY` is needed. The server can speak the OpenAI chat-completions API (vLLM, llama.cpp's server, Ollama, LM Studio, a LiteLLM gateway) or the Anthropic Messages API. ```sh export POWERCRAFT_AI_ENDPOINT=http://gpu-box:8000/v1 # the server's base URL export POWERCRAFT_AI_ENDPOINT_MODEL=qwen3:32b # the model id the server knows export POWERCRAFT_AI_ENDPOINT_API=openai # or anthropic (default: openai) export POWERCRAFT_AI_ENDPOINT_KEY=... # only if the server wants a key export POWERCRAFT_AI_ENDPOINT_MAX_TOKENS=8192 # output limit per reply (default 8192) powercraft-cli chat --automation-read-root work --automation-write-root work ``` `http://` is accepted only for this machine and the local network (`localhost`, private addresses such as `10.x`, `192.168.x`, a name without dots, or one under `.local`, `.lan`, `.internal`); anything else needs `https://`. Voltecx never follows a redirect, so the key goes only to the server you named. `--model` and `--max-tokens` do not apply to the server; the variables above set them. **Models that cannot call tools.** The assistant builds and simulates through tools. If the server says the model cannot call tools, `chat` sends the message again without them and answers in **Ask mode**: advice only, the circuit is not changed. It says so once, with `[this model cannot call Voltecx's tools …]`. Set `POWERCRAFT_AI_ENDPOINT_TOOLS=off` to start in Ask mode. Pick a model trained for tool calling (and, for vLLM, start it with `--enable-auto-tool-choice`) to get the full assistant. ## The licence on the command line `powercraft-cli chat` (and `run`, `script`, `sim`, `convert`, `serve`) uses the licence the desktop app keeps (Help › Licence), so the terminal gets the same Pro features as the window. `powercraft-cli licence status` shows it (tier, dates, what is unlocked, never who it is issued to), `powercraft-cli licence load FILE` checks a licence file and stores it in the same place, and `powercraft-cli licence remove` deletes it. The assistant cannot install a licence: there is no command or tool for it. ## The terms on the command line `powercraft-cli chat` starts only after the Voltecx Terms are accepted (chapter 1): by the desktop app or an earlier command-line run, by `--accept-terms`, or by `VOLTECX_ACCEPT_TERMS=` in the environment. In a terminal the first use asks; `serve`, which scripts start, never asks and exits with a message that says how. The assistant cannot accept the terms through any tool. ## Check the install `powercraft-cli doctor` checks this install: the program, its version, the file folders and the API key. ```sh powercraft-cli doctor --root ~/Voltecx ``` It prints one line for each check, `pass`, `warn` or `fail`. The lines look like this (the paths and numbers on your machine differ): ```text pass binary /usr/local/bin/powercraft-cli pass version powercraft-cli 0.0.1 (macos aarch64) pass read root /Users/ann/Voltecx can be read pass write root /Users/ann/Voltecx can be written warn api key ANTHROPIC_API_KEY is not set or not usable; `chat` needs it No check failed; 1 warning. ``` | Check | What it looks at | |---|---| | binary | The program file exists | | version | The version, the system and the processor | | read root, write root | The folders from `--root`, `--automation-read-root` and `--automation-write-root` (or the two `POWERCRAFT_AUTOMATION_*_ROOT` variables). The write check saves a small test file and removes it again. A folder that is not set passes, and the line says the assistant cannot read or write files | | api key | Whether `ANTHROPIC_API_KEY` is set. Only `chat` needs it, so a missing key is a warning. The key itself is never printed | The exit code is 0 when no check failed and 1 when one did. A warning is not a failure. ## One message from a script `chat -p` answers one message and exits. It does not open the chat. You need `ANTHROPIC_API_KEY`, as for the chat, and the same privacy rules apply. ```sh powercraft-cli chat -p "Build a 48 V to 12 V, 5 A, 100 kHz buck. What is the output ripple?" \ --automation-write-root work ``` The answer goes to standard output. The lines that show the tool calls go to standard error, so `> answer.txt` keeps only the answer. With `--json` the result is one JSON object with `answer`, `model`, `toolCalls`, `inputTokens`, `outputTokens` and `truncated`. If the model cannot answer, the exit code is 1 and the reason is on standard error. With `--json` it is also in an `error` field on standard output. ## Drive the running app from the command line `powercraft-cli app` talks to the same control channel without an assistant, so a shell script can drive the window. It connects to `127.0.0.1` only. The port and the token file come from `--port` and `--control-token-file`, or from `POWERCRAFT_CONTROL_PORT` and `POWERCRAFT_CONTROL_TOKEN_FILE`. The token itself is never accepted on the command line, where other users of the machine could read it. ```sh export POWERCRAFT_CONTROL_PORT=7878 POWERCRAFT_CONTROL_TOKEN_FILE=~/.powercraft/control.token powercraft-cli app open buck.voltecx # relative to the app's --automation-read-root powercraft-cli app set theme=darkPlus panels.chat=false powercraft-cli app run # simulates as a job and waits for the result powercraft-cli app wait idle powercraft-cli app inspect state.theme powercraft-cli app menu view.animate powercraft-cli app screenshot shot.png powercraft-cli app engine.execute '{"command":"scope.measure","params":{"signals":["v(out)"]}}' ``` Any control method works as `app METHOD [JSON]` (`app methods` lists them). The conveniences are `screenshot OUT.png [--max-side N]`, `menu ID`, `set KEY=JSON...` (a dotted key nests, and a value that is not JSON is taken as text), `inspect [PATH]`, `run [--timeout S]`, `open FILE` and `wait idle|job|agent|dialog:ID|frames:N`. The reply is printed as JSON. The exit code is 1 when the app refuses the call and 2 for a usage error. `docs/automation-coverage.md` lists, for every command, menu item, view setting and window, which entry points can reach it. ## The terminal (View › Terminal) The desktop app has a terminal in its bottom panel, as VS Code does, so you can run `powercraft-cli` or any other program without leaving the window. Open it with **View › Terminal** or **Ctrl+`** (the same key closes it again). **Ctrl+Shift+`** or the **New Terminal** icon (a plus) starts another one; the list on the left of the terminal's toolbar switches between them, **Kill Terminal** ends the one shown and **Clear Terminal** clears it and its scrollback. The Terminal menu has the same items. The toolbar of the terminal has the session list, the **New Terminal**, **Kill Terminal** and **Clear Terminal** icons, then what the terminal shown is (its shell, its folder, the active circuit, marked "(unsaved)" before it has a file, and whether `powercraft-cli` is on its PATH). With no terminal running, the panel offers **New Terminal** with its key. ![The Terminal tab, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/chat-and-mcp/02-terminal.png) 1. New Terminal (the plus). 2. Kill Terminal (the trash icon); Clear Terminal sits beside it. Each terminal is your own login shell (`$SHELL -l`; `%ComSpec%` or PowerShell on Windows) started in the folder of the active circuit file, or, when the circuit has not been saved, in Voltecx's workspace folder `Documents/Voltecx` in your home folder (made the first time it is needed). It is a full terminal: 256 colours and true colour, bold, italic and underline, the cursor shapes programs ask for, the alternate screen of full-screen programs (vim, htop, less), 10 000 lines of scrollback (the wheel, or Shift+Page Up / Page Down), and the mouse for programs that read it (hold Shift to select instead). | Key | In the terminal | |---|---| | Ctrl+C | Interrupts the program; with text selected (drag, double-click a word, triple-click a line) it copies instead. On a Mac, ⌘C copies | | ⌘V / Ctrl+V | Pastes. When the shell asks for bracketed paste, a pasted command does not run until you press Enter. An image on the clipboard pastes the path of a saved PNG | | ⌘-click / Ctrl-click | Opens the web link under the pointer in your browser | | Ctrl+`, Ctrl+Shift+`, ⌘⇧P (Ctrl+Shift+P), and ⌘K on a Mac | Stay Voltecx's. Every other key, the function keys included, goes to the program | Chinese and other input methods type into the terminal as into any text field. **Files and images.** Drag files from Finder (or any file manager) onto the terminal and their full paths are typed at the prompt, quoted for the shell (spaces, quotes and Chinese names included) and separated by spaces, as in Terminal.app. Images and PDFs too: a program that reads paths, such as Claude Code, then reads the file. While you drag over the terminal only the terminal is highlighted; let go anywhere else and the file opens, imports or goes to the assistant as before. With a screenshot or another image on the clipboard and no text, ⌘V / Ctrl+V in the terminal saves it as a PNG in a temporary folder of that terminal's own and types the PNG's path. Only the path is typed, never Enter, so nothing runs until you press Enter; a file name with a line break in it is refused. The temporary folder and its images are deleted when the terminal ends or Voltecx quits. (Dropping onto the terminal follows the pointer on macOS; on Windows and Linux the window does not learn where a drag is, so a drop is routed by where the pointer was last seen.) **Voltecx in the terminal.** When the first terminal starts, Voltecx starts its control channel if it was not started with `--control` (on `127.0.0.1`, a random port, a new token in a file only you can read, in a private folder that is removed when the app quits). Every terminal then has: - `POWERCRAFT_CONTROL_PORT` and `POWERCRAFT_CONTROL_TOKEN_FILE`: the port and the path of this terminal's own token file, never the token itself; - `VOLTECX_CIRCUIT` (the active circuit's file, empty while it is unsaved), `VOLTECX_TAB` (its tab's name) and `VOLTECX_FOLDER` (the folder the terminal started in), as they were when the terminal started; `powercraft-cli app status` gives them as they are now; - the folder of `powercraft-cli` first on `PATH`, when it is found next to the app. If it is not, a warning above the terminal says so (the shell still works) (build it with `cargo build -p powercraft-cli`). So no flags are needed inside the terminal: ```sh powercraft-cli app status # the window's tabs: name, file, active, modified powercraft-cli run --cmd circuit.inspect # on the open window (see the command-line chapter) powercraft-cli show results/buck.voltecx # open it in the window and show its tab powercraft-cli app run && powercraft-cli app inspect signals ``` **An agent in the terminal (Claude Code and others) works on your open window.** `powercraft-cli run --cmd ... --params ...` runs its commands on the circuit you see, and each change can be undone with Edit › Undo. `powercraft-cli show FILE` opens a circuit the agent wrote (a `.voltecx`, `.pcraft`, LTspice `.asc`, PLECS `.plecs` or SPICE netlist) and makes its tab the active one, with a notice "Opened from Terminal". A terminal may open circuits only under its own folder (`VOLTECX_FOLDER`), and only while it runs: no automation folder needs granting for that, and a file outside the folder is refused. Opening the Terminal tab starts a shell; Preferences › **Start a shell when the Terminal tab opens** turns that off. **Claude Code in the terminal.** **Terminal › Claude Code Here** (also a link on the terminal's toolbar) opens a new terminal and starts Claude Code (`claude`, which you install yourself; if it is missing, the notice links its install guide). It starts with two things from Voltecx: - **Voltecx's agent skills.** The app ships them (`--plugin-dir`, in `plugins/powercraft` of the installed program): how to design, simulate, verify and debug with Voltecx's commands, and the closed-loop skill below. Only the skills ship: there is no MCP server. - **A note on the open window** (`--append-system-prompt`): the active circuit's name and file (or that it is not saved yet), and the closed-loop rule. The closed-loop rule: Claude works only through `powercraft-cli app` on the open window, so every change appears on your schematic as one undo step with Claude named in the version history; it builds with engine commands and blocks (`circuit.apply`, `ic.place`, `circuit.createSubsystem`, `schematic.labelNet`, `schematic.autoLayout`, `design.*`); it checks its work with `circuit.problems` and a simulation in the window and reports numbers from that run; and it never writes or edits circuit files (no scripts that generate a `.voltecx`, no `sed` on one). If you see it doing that, tell it to stop: the skill and the note both say not to. The command it types is shown in the terminal, for example: ```sh claude --plugin-dir '/Applications/Voltecx.app/Contents/Resources/plugins/powercraft' --append-system-prompt "$(cat '…/claude-note.md')" ``` The note is a file in the control channel's private folder, never in your project. Automation cannot start Claude Code: only your own click or menu choice does. **Security.** The terminal is your own shell with your own rights, exactly as Terminal.app or VS Code's terminal: anything you run there can do what you can. The control channel stays on loopback behind its token. Each terminal gets a token of its own, which ends when the terminal does; it can do what the window's token does, and open circuits under that terminal's folder. No token is ever shown in the terminal, written to a log or put in the environment, and `ui.inspect` reports only which terminals run (`terminal`), never what is on their screens. Automation (the control channel, `powercraft-cli app`) can open and close the Terminal tab and list, clear and end terminals, but it cannot start a shell or type into one (`ui.key` and `ui.type` never reach a shell). Closing a terminal, or quitting Voltecx, hangs up the shell and everything it started, as closing a Terminal.app window does; a program started with `nohup` or in a session of its own keeps running, by design. The terminal is a desktop feature: the browser version has none. ## The agent panel Inside the desktop app the assistant is the agent panel, with proposals you accept or reject. It is described in chapter 12. ## Good prompts - "Build a 400 V to 48 V, 10 A, 100 kHz buck. Restate the spec first, then build it." The restating step catches misunderstandings, because the template reply lists the spec it used. - "Open this LTspice file and tell me what the circuit is." (beta: needs the import, then `circuit.explain`) - "Sweep the duty cycle from 0.2 to 0.4 and tell me where the output reaches 12 V." - "Why does the output ring? Diagnose it." - "Pick a MOSFET from the library for S1 with the lowest loss at this operating point." ## What the assistant can reach - **Files.** With no folder granted, the assistant cannot read or write any file. In the app, grant a read folder and a write folder in Preferences › Privacy and updates › Automation folders (kept for the next start, shown in the status bar, with Revoke all); Elsewhere use `--automation-read-root` and `--automation-write-root`. With them, paths are relative to those folders. Absolute paths and `..` are refused. You can set the same folders with `POWERCRAFT_AUTOMATION_READ_ROOT` and `POWERCRAFT_AUTOMATION_WRITE_ROOT`. - **Network.** Only `chat` reaches the network, and only Anthropic's API. - **Undo.** Everything the assistant does goes in the same undo history as your own edits (one step per command). ## Limits - A template is an ideal, continuous-conduction starting point. It has no conduction loss and no ESR. Check a design with `analysis.losses` and `analysis.worstCase` before you rely on it. - `sim_run` cannot be cancelled in headless mode. Template runs are about one million steps or fewer. - The assistant can misunderstand you. Ask it to restate the request first. - Written depth: [`docs/workflows/ai-chat.md`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/workflows/ai-chat/) (in Traditional Chinese) and `docs/control-protocol.md`. --- # 12. The agent panel URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/12-agent-panel/ The agent is an assistant inside the desktop app. You describe what you want in a sentence. It looks at your circuit, runs simulations, and proposes changes. A proposal waits as a ghost on the schematic until you accept or reject it. The assistant never edits your circuit on its own. The assistant lives in the **secondary side bar**, the bar on the right of the schematic, as in VS Code and Cursor. The bar has two tabs at its top: **PROPERTIES** (chapter 2) and **ASSISTANT**, the same name as the activity bar item and View › Secondary Side Bar › Assistant. Selecting a part opens the hidden bar on Properties; click **ASSISTANT** to talk to the assistant. While the chat shows, a selection stays there and becomes the next message's context. The chat is for the desktop app. In the browser version it shows "The agent needs the desktop app." For an assistant that works from outside the app, see chapter 11. ## The secondary side bar - The bar is open when Voltecx starts. A window narrower than 1280 points starts with the bar hidden and the library folded to its activity bar icons, so the schematic keeps its room; the activity bar's **Assistant** icon (the speech bubble) brings the bar back. In such a window the bar opens as a drawer over the right edge of the schematic instead of taking its width; its **×** or Cmd+Alt+B closes it. - **Cmd+Alt+B** (Ctrl+Alt+B on Windows and Linux), **View > Secondary Side Bar > Show or Hide**, the **×** at the top right of the bar and the **Assistant** icon hide and show it. - **Cmd+L**, **View > Secondary Side Bar > Assistant** and the activity bar's **Assistant** icon show the bar on its ASSISTANT tab with the keyboard in the input, whatever hid it: the bar closed or on PROPERTIES, a maximized bottom panel (it is restored), or the Start page. Cmd+L works from any field, a part's parameter or the console's input included. Only when the chat shows and nothing else has the keyboard does it hide the bar again; from another field it moves the keyboard to the chat. - Selecting a part while the bar is hidden opens it on its PROPERTIES tab, and the schematic stays where it was. **View > Secondary Side Bar > Properties** does the same, and a double-click on a part also puts the keyboard in its first parameter. While the assistant is working, its own selections leave the chat in view. - The activity bar marks only the side bar's view with its accent bar; the **Assistant** icon just turns brighter while the chat shows. - Drag the bar's left edge to make it wider or narrower (280 to 360 points, and never more than half the window). It comes back at the width you left it. The library side bar on the left stops at 360 points too. The bar stops above the scope and the other bottom tabs: the bottom panel runs the full width of the window, under both side bars, so the scope keeps its width. ## The assistant in the bottom panel The assistant can move into the bottom panel, as VS Code lets a view move between the side bar and the panel. Right-click the bar's **ASSISTANT** tab and choose **Move to Panel**: the chat, with what you were typing, becomes an **ASSISTANT** tab beside Scope, Problems, Design, Console and Terminal, and the secondary side bar keeps Properties alone. With the panel at the Right (**View > Panel Position > Right**) the console and the assistant then sit together in one column. Right-click the panel's **ASSISTANT** tab and choose **Move to Side Bar** to bring it back. Voltecx remembers the place for the next start; the side bar is the default. In the panel, Cmd+L, View > Secondary Side Bar > Assistant and the **Assistant** icon open the tab, show the panel if it was hidden or folded, and put the keyboard in the input; Cmd+L from the chat's own input closes the tab. Selecting a part still opens Properties in the side bar and leaves the chat open. The **+** at the right of the panel's title bar starts a new chat. With **View > Panel Position > Right** the panel stands between the canvas and the secondary side bar, and the bar keeps the window's right edge. In a narrow window the drawer then opens over the canvas beside the panel, and is never narrower than 280 points. ## Set up 1. Get an Anthropic API key. It is billed to your own account. 2. Open **Edit > Preferences** and find **Assistant**. Paste the key into the field and press **Save**. It works at once, with no restart. Voltecx keeps the key in your system's credential store: the macOS Keychain, the Windows Credential Manager, or the Secret Service on Linux. It is never written to a circuit file, the settings file or a log. After saving, the window shows only the start and the last four characters, for example `sk-ant-…ab12`. **Test** makes one request that costs no tokens and says whether the key works, whether it was refused, or whether the network failed. **Remove** deletes the saved key. 3. Type in the chat's input at the top of the secondary side bar, or press **Cmd+L** to put the keyboard there. ![Preferences before a key is saved, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/agent-panel/02-prefs.png) 1. The key field. 2. Save. 3. The model. Without a key, the ASSISTANT tab says what the assistant can do and offers two ways to set it up: a Voltecx account (**Sign in**), or your own Anthropic API key. **Add a key** opens Preferences › Assistant; **Get a key** opens Anthropic's console. Hover **Set up the assistant** to read why it needs one. ![The secondary side bar without a key, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/agent-panel/01-key.png) 1. ASSISTANT. 2. Add a key. 3. PROPERTIES. You can still set the key in the environment instead, for example `export ANTHROPIC_API_KEY=sk-ant-...` before you start Voltecx. When the variable is set it wins over a saved key, and Preferences says so. If your system has no credential store (some Linux setups), a pasted key is used until Voltecx quits, and Preferences says that too. **Model.** Preferences › Assistant has a list: `claude-opus-5-5` (the default, the strongest current model for design and debugging), `claude-sonnet-5-5` (faster and about half the price), `claude-haiku-5-5` and `claude-fable-5-1`. **Custom…** takes any other model id. The model picker at the bottom left of the chat's input shows and sets the same choice, by name (Claude Opus 5.5); the id is in its tooltip. The choice applies from the next message. The environment variable `POWERCRAFT_AGENT_MODEL`, when set, wins over the list, and the picker then only shows the model it names. The browser version has no agent, so it does not ask for a key and keeps none. **Privacy.** Your messages, the images you paste into them, the selection, the values the assistant reads and the circuit data it asks for go to Anthropic's API. Nothing is sent until you press Send. The Tab suggestions and the checkpoints below work entirely on your machine. ### Developer note: Claude Code as the backend For developing and testing Voltecx only, a debug build can run the chat on the `claude` command (Claude Code) installed and logged in on your computer, with your own Claude subscription and no API key. Turn on **Claude Code (subscription, local)** under **Edit > Preferences > Assistant > Developer backend**, or start Voltecx with `POWERCRAFT_AGENT_BACKEND=claude-code`. Release builds do not offer it: a Claude subscription is for your own use, so customers use their own API key or a Voltecx account. - Each message starts `claude -p` in headless streaming mode with the app's system prompt and no built-in tools (with **Allow web search** on, only Claude Code's own WebSearch and WebFetch). The panel's own tools reach it through a small MCP server on `127.0.0.1` that lives for that one message, so tool rows, proposals, plan steps, Stop and checkpoints work as with an API key. The next message continues the same Claude Code session (`--resume`); **New chat** starts a new one. - The model is `claude-haiku-5-5` (cheap, for testing) unless you picked another one in the list or set `POWERCRAFT_AGENT_MODEL`. With **Allow web search** on, the assistant searches and reads pages with Claude Code's own WebSearch and WebFetch, on your subscription; each search and page read shows as a step, and the pages the answer names are listed under it, as with an API key. - No API key is read or stored: `claude` gets your environment without `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN` and `ANTHROPIC_BASE_URL`, so it uses its own login. `POWERCRAFT_CLAUDE` names the executable when it is not on `PATH`. - If `claude` is not found, or answers that it is not logged in (run `claude` and `/login`), Preferences says so and the chat uses the normal backend. Turn the option off and on again after you log in. - Tools a group load (`tools_load`) adds become callable from the next message. ## AI assistant: signing in and usage limits With a Pro or trial licence you can use the assistant through your Voltecx Cloud account instead of your own key. While you are signed in to Voltecx Cloud, the chat goes through Voltecx's server and needs no Anthropic API key. Your access token stays on your computer, and the Anthropic key stays on the server, never in the app. When you sign out, the chat goes back to the key from Preferences (or `ANTHROPIC_API_KEY`), as described above. Through your account, the tokens of each request are counted against your plan. Below the chat, a small line shows your use this month, for example "Used 1500 of 100000 AI tokens this month", or the amount in US dollars when your plan limits spending. Months and days are counted in UTC. - **Limit reached.** When the day's or month's allowance is used up, the request stops with a message that says which limit was reached, when it resets and where to upgrade. A request that started within the limit still finishes. - **Too many requests.** Each plan also allows a set number of requests per minute. Above it, wait a minute and send again. - **Not in your plan.** If your plan does not include the assistant, the line says "Your Voltecx plan does not include the AI assistant." You can still use your own API key. - **Fair use.** The cloud services also limit how many requests each licence may make per minute, per day and per month. Bulk, scripted collection of outputs is not allowed. Voltecx records when each request was made and a one-way hash of it (never the request itself), and staff review unusual patterns; nothing is blocked automatically because of a pattern. Each reply carries an identifier (`PowerCraft-Trace`) linked to your licence, so copied outputs can be recognised. It holds no personal data. Allowances and prices depend on your plan and are set by Voltecx; see the Pricing page. The Voltecx Cloud account is not open yet. Until it is, use your own key. ## Ask a question Type in the input ("Ask · @ context · / commands": **@** adds context, **/** picks a command) and press **Enter** or **Send** to send. **Shift+Enter** adds a new line. A message can hold up to 8,000 characters. While the assistant works, a status line under the chat says what it is doing now, how long the turn has run and the tokens it has used so far, for example "Simulating · 2m 36s · 2.6k tokens", with one turning mark beside it (hover the numbers for tokens in and out). **Send** turns into **Stop**. Press it to cancel the turn. A turn may run up to 200 tool calls, enough for a design from a spec with its checks; when it reaches them it stops and says so, and "continue" carries on. **+** (New chat) in the ASSISTANT header clears the conversation of the circuit you are looking at. The header also names that circuit. An empty chat offers a few suggestions, such as "Why does V(out) ripple exceed spec?" or "Design a 48 V to 12 V, 10 A buck". A click puts the text in the input; edit it, then send it. Above the input, **chips** show what goes with the message. Your current selection is one ("Selection: R1, L1"), added by itself. Its **×** leaves the selection out of your messages until you select something else. ### Paste a screenshot Copy an image (a screenshot, an oscilloscope capture, a photo of a schematic) and press **⌘V** (**Ctrl+V** on Windows and Linux) in the input. It shows as a thumbnail chip above the input, with the line "Images go to the AI model with your next message." It goes with your next message, before the text; you can also send it with no text. Its **×** takes it out. A message takes up to 5 attachments, pasted images and attached files together. Like an attached file, the image is sent with that one message only: the chat keeps a note that it was there, and the assistant works from what it said about it. An image is shrunk before it is sent: its longest side to 1568 pixels (hover the thumbnail to see the size, and the size it was pasted at), and further if its PNG would still be over the API's 5 MB. An image over 100 million pixels is refused, and the status line says why. When the clipboard holds text too, ⌘V pastes the text. The browser version has no assistant, so it takes no images. ![The chat of an open circuit with L1 selected, marked 1 to 6](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/agent-chat/01-panel.png) 1. A suggestion. 2. The selection chip. 3. The model picker (the effort picker is next to it). 4. Tune. 5. Send. 6. PROPERTIES below. Your message shows as a tinted block, with **Restore** under it (see below). The answer follows as plain text: paragraphs, list items and `code` in monospace. Nothing in an answer is a link, so no web address or file path opens from the chat. Each tool the assistant calls is one row, such as "Opened example Buck", "Ran simulation · 0.8 s", "Measured V(out)" or "Proposed: add C2". An icon at the left says what kind of work it is: a magnifier to inspect, play to simulate, a trace on axes to analyse, a set square to design, a pencil to propose, a speech bubble to ask (hover it for the name). While a call runs, its row says what it does now ("Simulating"), with a spinner and its time so far; when it ends, a tick and what it found ("12.02 V, 38 mV p-p") or how long it took. A row in red ended with an error, and the error's message shows under it. A simulation, analysis or design run that takes longer than a second gets a thin progress bar under its row, and a running simulation a small live trace of the first signal the scope shows. Click a row to open its details: the parameters as indented JSON, the result, and **Copy**, which puts the call, its parameters and its result on the clipboard; click again to fold it. The assistant's own remarks between calls show in grey, and a short summary of its reasoning in grey italics. **Effort.** Next to the model picker, the effort picker sets how hard the assistant thinks before it answers. **Auto effort** (the default) thinks hard (high) when you ask it to design, change, debug or verify something, and less (medium) for a question. Low, Medium, High, Extra-high and Max fix the level for every message. More effort takes longer and uses more tokens; it pays off on multi-step design and debugging. **Plan.** For a task of several steps (a design from a spec, a debug, a check against a spec), the assistant first shows its plan as a checklist above its steps, "Plan · 1 of 4 done", and ticks the steps off as it goes: a tick for done, a filled dot for the step it is on, a ring for the rest. **Skills.** The assistant has Voltecx's design playbooks (design, the fixes for each failing check, topology comparison, debugging, verification and hand calculations). It reads the one a task needs when it starts the task; the row says "Read the design skill". ## Commands Type **/** at the start of the input to list the commands, as in Claude Code or Copilot Chat. The list filters as you type (`/de` shows `/design` first); **Up** and **Down** choose, **Enter** or **Tab** picks, **Esc** closes it, and a click picks a row. The command you pick shows as a chip in front of the input, with what to type after it; type that and press **Send**. **Backspace** in an empty input, or a click on the chip, drops it. You can also type the whole line, such as `/design 48 V to 12 V, 10 A`, and send it. The chat shows the line as you typed it; the assistant gets the command's full prompt, which names the tools it should use. ![The command list above the input](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/agent-chat/03-commands.png) | Command | What it does | |---|---| | `/design ` | Designs a converter from the spec: reads the design playbook, asks for what the spec leaves open, sizes it and puts it on the canvas as one proposal, then simulates it | | `/simulate [what]` | Simulates the open circuit and reads the result: ripple, peak and RMS currents, the traces that matter | | `/tune ` | Measures, then tunes the loop or values to the target (for example "60° phase margin at 20 kHz") and shows the values as a proposal | | `/explain [@part]` | Explains the circuit, or the part or net you name, and highlights what it talks about. Changes nothing | | `/fix [which]` | Sends the open problems of the PROBLEMS panel and asks for their fixes as one proposal. With no open problems it says so and sends nothing | | `/verify [spec]` | Checks the design against its spec over the corners and gives a table of margins | | `/report [where]` | Writes the design report (PDF, or HTML or a folder if you ask) | | `/paper [what]` | Reproduces the attached paper. With nothing attached it opens the file picker first | | `/compare ` | Compares two topologies, control methods, runs or checkpoints in one table | | `/datasheet [@part]` | Finds the manufacturer's data sheet of the part (or of each part of the open circuit), reads the values its model is missing and proposes them on one card, each with its URL, revision and page or table. A value the sheet does not give stays empty. Needs **Allow web search** (below) | | `/clear` | Starts a new chat, as **+** in the header does | | `/compact` | Summarises the older turns so a long chat fits the model's context (see [Long chats](#long-chats-compaction)) | | `/model [name]` | Sets the model, for example `/model sonnet`; without a name the status line lists the choices | | `/effort [level]` | Sets the effort: `auto`, `low`, `medium`, `high`, `xhigh` or `max` | | `/help` | Lists every command | ![A picked command as a chip in front of the input](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/agent-chat/04-command-chip.png) **Skill commands.** Each playbook the assistant can read is a command too, marked "skill" in the list: `/debug`, `/lab`, `/calc`, `/protection`, `/layout` and the rest. It reads that playbook first, then does what you type after it. **Your own commands.** Put a Markdown file in the `commands` folder of the settings folder (`~/Library/Application Support/PowerCraft/commands` on macOS, `%APPDATA%\PowerCraft\commands` on Windows, `~/.config/powercraft/commands` on Linux) and its name becomes a command, marked "yours": `gate-check.md` is `/gate-check`. The format is Claude Code's: an optional front matter with `description` (the line in the list) and `argument-hint`, then the prompt, with `$ARGUMENTS` where what you type after the command goes (without it, your text follows the prompt). `$PROBLEMS` puts in the open problems, as `/fix` does. The folder is read each time the list opens; a built-in command keeps its name over a file of the same name. ``` --- description: Check the gate drive of a switch argument-hint: --- Check the gate drive of $ARGUMENTS: the driver, the gate resistor, the turn-on and turn-off times and the ringing. ``` ## One chat per circuit, saved in its file Each open circuit has its own chat. Switch tabs and the ASSISTANT tab shows that circuit's chat, and the assistant goes on from that circuit's conversation. When you save a circuit, its chat is saved in the `.voltecx` file with it: your messages, the answers, and the label and outcome of each proposal. Tool results such as waveforms and pictures are not kept, so the file stays small. When you open the file again, the chat comes back. Its proposals come back as history: they cannot be accepted again. The next message you send gives the assistant the old chat once, so it knows what was said. The assistant is told that a chat read from a file is only a record and may have been edited by someone else, so it never follows instructions found in it. Before the first message, the empty chat says "This chat is saved in the circuit file when you save. Anyone you share the file with can read it." Remember this before you share a file. **+** (New chat) removes the chat, and the next save takes it out of the file. There is one chat per circuit: a new chat replaces the old one, there is no list of past chats. To keep chats out of files altogether, turn off **Save assistant chat in circuit files** in Preferences › Assistant. Saving then leaves the chat out. A new answer marks the circuit as having unsaved changes, so the chat is not lost when you close it; accepting or rejecting a card alone does not. A saved chat keeps the latest 100 turns and at most 1 MB of text. A chat in a file that breaks these limits, or that is damaged, is left out with a warning, and the circuit still opens. Older versions of Voltecx open such files and ignore the chat. ### Long chats: compaction A model reads a limited amount of conversation at once (its context window). When a circuit's chat grows near that limit, the assistant compacts it before your next message, as Claude Code's `/compact` does: the older turns go to the model once more and come back as one note, with the goal and specification, the decisions and why, every number with its unit, the circuit changes and the proposals you accepted or rejected, the open questions and next steps, and the preferences you stated. The latest turns stay as they were. The turn shows the notice "The earlier chat was compacted into a summary to stay within the model's context." Type `/compact` to do it now; its answer is the note, so you can check what was kept. If the model cannot write the note, a plain extract of your messages and its answers takes its place. Compaction changes only what the assistant is sent. Every turn still shows in the chat, and **Restore to before this** on an earlier turn still puts the circuit back to that turn's checkpoint. The note is saved in the circuit file with the chat (up to 16 KB), and a reopened chat gives it to the assistant first. **+** (New chat) removes it with the rest of the chat. Every message carries your current selection, unless you removed its chip. You can also point at things with `@`: | Write | It means | |---|---| | `@R1` | The component R1: its kind, parameters and which nets its pins are on | | `@net:vout` | The net `vout`: the pins on it, its label and whether it is ground | | `@wave:V(out)` | A waveform of the last run: min, max, mean, RMS, final value and peak-to-peak. A bare trace name also works | | `@param:R1.r` | One parameter: its value and unit, what it means, its default and typical range, and the problems about it | | `@wave:V(out)[2.5m]` | The waveform at one moment: its value there, with the stats of the whole run | | `@wave:V(out)[1m..2m]` | The waveform between two times: min and max with their times, peak and its time, mean, RMS, AC RMS and ripple | | `@selection` | The parts you have selected | When you type `@`, a list opens with the component names, the nets (`net:`) and the traces of the last result (`wave:`). It narrows as you type, with prefix matches first. **Up** and **Down** choose, **Enter** or **Tab** picks, **Esc** closes it, and a click picks too. A picked mention leaves the text and becomes a chip above the input (`@R1 ×`); it goes in front of your message when you send it, and its **×** takes it out. A mention you type out in full works as well. A message uses at most 16 mentions. Example: "why is @R1 hot? add a 10 ohm load". ### Ask Assistant about what you click You don't have to type the mention. Right-click the thing and choose **Ask Assistant**: it becomes a chip, the chat opens, and you type the question. | Right-click | The chip | |---|---| | A part, or several selected | `@R1` (with the problems that name it, and the data sheet its device comes from) | | A wire or a net label | `@net:vout` | | A parameter's name in Properties | `@param:R1.r` | | A trace in the scope's signal list | `@wave:V(out)`, or `@wave:V(out)[t1..t2]` while the cursors are on | | The scope plot | **Ask Assistant about this time** (where you clicked), **about the cursor window** or **about the visible window**, one chip per trace of that plot | ![Ask AI on L1 in the canvas menu, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/agent-chat/02-ask-ai.png) 1. The @L1 chip it adds. 2. Send. To ask about a spike, zoom on it (drag a box) or put the two cursors around it, right-click the plot and pick the window. The numbers come from the `waveform.statsAt` command, which the CLI and MCP can run too. The assistant answers with a proposal for any change ("reduce this spike" may come back as a snubber or a larger gate resistor), shown as ghosts on the schematic until you accept it. ## What the assistant can do The assistant has a small set of tools. It can inspect the circuit, run commands that only read, run a simulation (it runs in the background and shows in the scope as usual), read waveform statistics and samples, resolve your `@` mentions, and make proposals. Commands that change the circuit, such as `design.*` with `apply`, are refused. Everything it wants to change comes back as a proposal; how far it takes those proposals on its own is the chat's mode. It also works across circuits and files, always on a card you can decline: - **Open or start a circuit.** It can open an example or a file, or start an empty circuit, in a new tab; the circuit you had stays open in its own tab, and the chat follows to the new one. In Ask mode it asks first (**Open it** or **Skip it**); in Agent mode it opens at once. - **Fix problems.** It reads the Problems list and turns a problem's fix into a proposal card. A fix that would only move the drawing is not offered as a card; it says so instead. - **Save and export, on request.** It can save the circuit and export the schematic (PDF, PNG or SVG), the bill of materials (CSV), a KiCad project or the SPICE netlist. It writes files only into the folders you granted under **Edit › Preferences › Privacy and updates › Automation folders**, and only after you click **Save it** or **Export it**, in every mode. ## Web search: values with their sources The assistant can look up what the circuit, the results, the catalogue and your attached files do not say: a part's data sheet value, an application note, a standard's limit. It is off until you turn it on. 1. Open **Edit > Preferences > Assistant** and tick **Allow web search** under **Web search**. 2. The first time, a notice says what leaves the computer: the search queries and the addresses of the pages the assistant reads go to Anthropic, which runs the search. Only the query text is sent, never your circuit file. Click **Allow web search** to agree, or **Cancel**. Untick the box to turn it off again; the notice does not come back. Scripts cannot turn it on: `ui.set` refuses `agentWebSearch` and `agentWebNoticeSeen`, and a click a script sends does not press the box. Web search works with your own Anthropic API key, and through a Voltecx account once Voltecx Cloud offers it (the cloud says so with your account's usage, and the panel follows from the next message). Until then, signed in, the assistant cannot search, but it opens the links you give it (a data sheet's URL, an application note, a standard's page) and cites them the same way. When it needs a page nobody linked, it says so and asks you for the link, or for the page's text or PDF. When your message has a web address and web search is off, a **Turn on web reading** chip shows above the input. Clicking it is the same as ticking **Allow web search**: the first time, the notice above opens under the chip, and web search is on once you click **Allow web search** there. Without it, the assistant tells you web reading is off rather than guessing what the page says. Each search and each page read shows as a step in the turn, like a tool call, and the turn ends with how many searches and pages it took. Under the answer, **Sources from the web** lists the pages and documents the answer cites: click a title to open the page, hover it for the passage quoted. A proposal card made after a search lists the same sources above Accept, so you see where a value came from before it goes into the circuit. Nothing from the web changes the circuit by itself: in Agent mode, the cards of a turn that used the web wait for your Accept like in Ask mode. What a page says is read as data, never as instructions: text on a page that tells the assistant to do something is not followed. ## Modes: Ask, Agent and Plan The mode picker sits left of the model picker under the input box (on a narrow panel, left of Send). The mode applies from the next message; it cannot change while a turn runs. - **Ask** (the default) works as described in this chapter: the assistant answers, measures and proposes, and you accept or reject every card. - **Agent** lets the assistant accept its own proposals and design cards as it makes them, so one message can go from a change to a simulated, measured result. "Auto-accept on" shows next to the picker while it is on. Each accepted card is still one undo step, and the turn's checkpoint is taken before the first of them, so the turn's **Restore** undoes the whole turn at once. Two things still ask you first, on a card in the chat: a proposal that removes parts (**Accept it** or **Leave the card**), and a long job such as Auto Design, Tune to spec, a worst case, a Monte Carlo or a sweep (**Run**, **Run all this turn** or **Skip it**). - **Plan** lets the assistant read and measure, then write its plan as the checklist above its messages. Before it changes anything or starts a long job it waits on **Approve this plan?**: **Approve** lets it carry the plan out as in Agent mode; **Revise**, or your own words in the field, sends it back to change the plan. Scripts pick the mode with the control method `agent.send {message, mode}` (`ask`, `agent` or `plan`); `agent.status` reports it. ## It checks its own changes When the assistant has changed the circuit in a turn (in Agent mode, or after you accepted a card while it was still working) it checks the change before it says the task is done. If it tries to finish without having run anything since the change, Voltecx sends it back once to run `spec_verify` with your spec or targets, or to simulate and measure, and to answer with pass or fail for each target, the measured value and its limit. If a target fails it fixes the circuit and checks again, or tells you plainly which target is still unmet, by how much and what would meet it. It is sent back at most twice per message, so a turn always ends. Each check shows as its own row, **Verified the result**: `5/5 ✓` when every row of the spec passed, or the failing rows with their numbers (`1/2 ✗ · ripple 0.15 > 0.12 V`). An answer it wrote before the check stays above the row, as a draft. In Ask mode nothing changes until you accept a card, so nothing is held up. ## Project rules: VOLTECX.md A file named `VOLTECX.md` beside the circuit's file, or in a folder up to eight levels above it, holds the project's rules for the assistant: house rules, preferred parts, derating and naming, in plain words. The nearest one wins. Every message reads it again and carries it, up to 6,000 characters, so an edit counts from the next message. The assistant follows the rules in its designs, proposals and names, and says when a request goes against one. The rules never change the mode, accept a proposal or let it skip asking. The chat's header shows **Project rules: VOLTECX.md** with **Edit**, which opens the file in your system's editor. For a saved circuit without one, **Add project rules** creates `VOLTECX.md` beside the circuit from a short template (headings only) and opens it. An unsaved circuit has no folder, so it has no rules. ## Your memory The assistant can remember your own lasting preferences and facts across chats and circuits: the devices you prefer, how you derate, how you name parts, company rules that are not in a project's `VOLTECX.md`. They are kept only on this computer, in `assistant-memory.json` in the settings folder, and sent only as part of each message you send to the assistant (up to 4,000 characters). Every message reads the file again, so an edit counts from the next message. Where your memory and the project rules differ, the project rules win. The assistant never saves anything itself. When you state such a preference, or correct it the same way twice, it may offer an entry on a card under its reply: **Remember this for later chats?** with **Remember** and **Not now**. Only **Remember** saves it; **Forget** on the same card takes it back. **Edit › Preferences › Assistant › Memory** lists the entries. **Edit** changes one, **Delete** removes one, the field below adds your own, and **Clear all** empties the list. **Undo** takes back the last change, a Remember included (up to 30 changes). **Use memory in the assistant's messages** off sends none of it and stops the offers; the entries stay. Scripts cannot turn it on or off (`ui.set` refuses `agentMemory`). ## Questions as buttons, and next steps When the assistant needs a choice from you (a topology, which of two fixes, yes or no), it asks on a card with one button per choice: click one and it goes on. A card that takes several choices has check boxes and Send, and some have an Other field for your own words. While a card waits, the status line says "Waiting for your answer"; Esc or Stop ends the turn instead. Asked to design a converter with values missing ("a buck from 48 V"), it shows the Requirements Interview as a card in the chat, with what you said already filled in and each default as the hint. Fill in what you know, then click Use defaults or Confirm: the spec goes back to the assistant, which runs Auto Design with it. An answer may end with up to three short next steps, such as Run worst case or Show Bode, drawn as chips under it. A click sends that text as your next message. ## Proposals: ghosts you accept or reject A proposal appears in the chat as a card, between the tool rows and the answer. The card says what it would do: what it adds, removes, connects and changes. It has two buttons. - **Accept** applies the whole proposal as one undo step, labelled with the proposal. Press Cmd+Z to take it back. - **Reject** throws it away. On the schematic, the parts a proposal would add are drawn as ghosts, at 40 % opacity, where they would go. A parameter it would change gets an outline on its part, with `key: from → to`. Ghosts show only on the circuit they belong to. If you open another circuit, the card says "Open its circuit to accept or reject it." If you edit the circuit after a proposal was made, the card says "The circuit changed since this was proposed. Accept checks it again." Accept still works. The engine checks the proposal against the circuit as it is now, and it refuses with a clear message if it no longer fits, and the card stays. A card the engine no longer lists reads "No longer available". At most 32 proposals wait per circuit. While it works, the assistant shows on the schematic what it is doing. The parts a step reads (a lookup of `C1`, a measurement of `i(L1)`) get a soft wash for a moment. When a new proposal changes a part outside the view, the view glides to it, at most as close as your zoom; any zoom or pan of your own stops the glide. An accepted change's outline settles onto its parts and fades. These effects last 150 to 250 ms, never take a click, and are off under **Preferences › Reduce motion** (or the system's setting): the wash then shows without fading and the view stays where you left it. ## Checkpoints and undo Before each turn, Voltecx takes a **checkpoint**: a copy of the circuit as it is. The turn has a **Restore** button. It puts the circuit back as it was before that turn, as one undo step. At most 50 checkpoints are kept per circuit, and the oldest go first. A finished turn that changed the circuit shows a row under it, **N changes in this turn**. Click it to see the list: parts added and removed, parameters changed (old → new), pin connections and net labels. Click an entry to select that part on the canvas. **Put back** on a changed parameter sets it to its old value, as one undo step. A turn that changed nothing shows no row. If you accept a proposal and the next simulation fails, the chat says "The simulation failed after an accepted proposal." and offers **Revert to checkpoint**. It restores the checkpoint of the turn that made the proposal you accepted. A clean simulation clears the offer. ## Tab suggestions Tab suggestions need no API key and send nothing anywhere. They are rules inside Voltecx that look at the circuit and say what usually comes next. 1. Click the schematic so it has the keyboard focus, optionally select one part, and press **Tab**. 2. The first suggestion appears as a ghost, with a small box that says why. For example, a switch node with a freewheel diode and no inductor gets an inductor and an output capacitor. Other rules cover a missing ground or a floating pin, an undriven gate, an inductor with no output capacitor, an output capacitor with no load, and a power stage with no meter. 3. Press **Tab** again to accept it, as one undo step. Press **Esc** to dismiss it. Press **Down** or **Up** to see the next or the previous suggestion (up to five, wrapping around); **Alt+Right** / **Alt+Left** and **]** / **[** (also typed with AltGr) do the same. An edit or a switch to another circuit dismisses the ghost for you, and no half-finished suggestion is left behind. If there is nothing to suggest, the status line says "No suggestions here." Tab does nothing while a text box, Quick Open or a dialog has the keyboard, and over a schematic you have not clicked it moves the keyboard focus as usual. **Edit > Suggest Next**, **Accept Suggestion**, **Next Suggestion** and **Previous Suggestion** do the same from the menu bar and Quick Open. ## Tune to spec The **Tune** button opens a small form that runs `analysis.tuneToSpec` (chapter 6) for you. - **Target:** a signal such as `v(out)`, a statistic, a comparison (`<=`, `>=` or `=`) and a value. - **Vary:** a part, one of its parameters, and the range it may take (from and to). - **Limits (optional):** the number of iterations (20 by default) and of simulations (60 by default). Values accept SI suffixes (`4.7u`, `10k`). Press Run. A progress bar shows under the chat's input, and Stop cancels it. The result never changes the circuit directly. It comes back as a proposal card, "Tune to spec: met" or "Tune to spec: best found, not met", with each target as before → after and the number of iterations. A stopped run still offers the best values it found. You accept or reject it like any other proposal. The assistant can use the same search through its own `tune_to_spec` tool. ## Designs, analyses and pictures The assistant can also ask for a whole converter. `design_propose` runs `circuit.template` on a scratch copy and comes back as a new-circuit card, also in an empty window. When you accept it, the circuit opens laid out in a new tab. `design_auto` does the same with `design.auto` (chapter 16), and `spec_verify` checks the circuit against a spec and changes nothing. The assistant learns to write a spec from your words. The `design.*` commands it runs go as background jobs, and their edits come back as an ordinary proposal that you accept or reject. `analysis_run` runs a loop gain, an AC sweep, a parameter sweep or an FFT as a job, and the curves are thinned before they reach the model. `picture` sends the scope plot or the schematic as an image. The assistant also has typed command tools (`analysis_loop_gain`, `topology_suggest`, `design_converter`, `analysis_losses` and so on), each with the parameters of its command. In the panel they keep its rules: one that would change the circuit comes back as a proposal card, and one that only reads or analyses never changes it. ## Background jobs A long analysis (a parameter sweep, Monte Carlo, a worst case, sensitivity, EMI, a test bench or a spec check) can run in the background while you keep chatting. The assistant starts it with `job_start`: the job runs on a copy of the circuit as it was then, so it never changes your circuit, and the turn goes on or ends at once. Each job shows in the **Background jobs** strip above the input, as "Job 1 · R1 sweep" with its progress and **Stop**. Up to three run at a time, beside the window's own simulation. When a job ends, a notice says "Background job 1 finished: R1 sweep" (or failed, or stopped), and the result of a job that finished or failed goes into the chat as a message of its own, which the assistant answers with what it means. If a turn is running then, the result waits until that turn ends; if you are looking at another circuit's chat, it waits until you come back. The assistant can also read a job itself with `job_status` (then no extra message follows) and stop it with `job_cancel`. A job stopped with **Stop** or by the assistant posts no message. **Remove** takes an ended job off the strip. **+** (New chat) stops the jobs of that chat. The result the assistant reads is cut at about 12 kB, so a large one costs a few thousand tokens at most. In Plan mode the assistant starts no job until you approve its plan; in Agent mode it asks on a card before a long one, as for any long job. ## Sub-agents When a request has parts that do not depend on each other (the losses of each switch and the margins of the output capacitor, say), the assistant can hand each part to a sub-agent with `subagents_run`: two or three of them work side by side, each in a fresh conversation that holds only its question and the open circuit. A sub-agent only reads: it inspects the circuit, runs commands that only read, reads the last simulation's waveforms and the skills. It never simulates, runs an analysis, changes anything or asks you, so there is nothing to undo. Each one answers in a few lines, and the assistant merges the answers for you, saying which number came from where. While they work, the **Sub-agents** strip above the input shows each one, as "Sub-agent 1 · Switch losses" with its tool calls and **Stop**; **Stop** on the turn stops them all. Each sub-agent has at most 12 tool calls and 250 000 tokens (past that it is stopped), and the assistant reads at most about 4 kB of each answer. The assistant offers sub-agents only when the app's assistant can run them (not in the browser build). ## Reproduce a paper The assistant can read a paper and rebuild its circuit. Press **+** under the chat's input and pick a PDF, or a figure as a PNG, JPEG, GIF or WebP image; or drop the file on the window. It waits as a chip above the input, with its size (a PDF up to 15 MB, an image up to 3.75 MB, 5 files and pasted images at most, 20 MB together). The line under the chips says what will leave your computer: the file goes with your next message only, to the AI model (Anthropic; through Voltecx Cloud when you are signed in). Nothing is sent before you press Send. The file is not saved in the circuit file and is not sent again: the chat keeps only its name. Press the chip's **×** to leave it out. Send with an empty input asks the assistant to read the paper and build its circuit. The assistant then works in three steps, each one shown in the chat: 1. **Extract.** It writes down what the paper gives: the topology, every part with its value and the table it comes from, the operating point (Vin, Vout, the power or the load, the switching frequency, the duty), the modulation and the control, and the results the paper reports, each with its figure or table. `paper.extract` checks it: values it cannot read, a duty that does not fit the topology's conversion ratio, a load that does not add up. It also says whether a template draws the topology and whether automatic design (chapter 16) supports it. The assistant never invents a value the paper leaves out; it asks you. 2. **Build.** `paper.build` comes back as one new-circuit card. A catalogued topology is its template with the paper's values; any other topology (a Ćuk, a quadratic or coupled-inductor stage, a new converter) is built from parts, and the assistant tells you that automatic design does not support it. The schematic is laid out like a hand-drawn one: the power stage in signal-flow order, gate and measurement nets as labels, a ground at each grounded part, control blocks in their own subsystem, and a note that names the paper. Accept opens it in a new tab. 3. **Validate.** After you accept, the assistant simulates the circuit and runs `paper.validate`. It shows a table, paper | simulated | error | tolerance | result, with a likely cause for every row that misses: ideal parts that leave out the prototype's losses, a capacitor without its ESR, a run that has not settled, a figure read with an error. Digitised curves from the paper's figures are drawn on the scope under the simulated signal of the same name. Ask for "the report" to get the whole comparison (source, run, verdict, table, causes, method) in English or Traditional Chinese. Default tolerances are ±5 % for mean values, ±20 % for ripple, ±2 points for efficiency and ±10 % for a digitised curve; the assistant widens a row whose value it read off a figure, and says so. ## Figures and marks: answers you can see An answer can show what it says. Below the tool rows, the reply carries small figures drawn in the chat, in the window's theme: | Figure | What it shows | A click opens | |---|---|---| | Plot | The signals and the time window the assistant measured, one lane each, with min, max, mean and peak-to-peak. Point at it to read the values and the time under the pointer. | The scope, on those signals and that window | | Bode | The gain and phase of the loop gain (or AC sweep) it ran, the 0 dB and −180° lines, the crossover, and the crossover and margins in figures | The full result window | | Losses | One bar per switch and diode, its switching share in the second colour, the total, and the efficiency when it knows the output power | The Losses result | | Parts | A crop of the schematic around the parts it talks about, the rest drawn faint, and their names | The schematic, zoomed to those parts | | Modes | One switching period's operating modes (T1, T2 and so on) with each one's share and what conducts | The animation (View > Animate) on the schematic; a click on a band holds that mode | On the schematic, the parts and nets the assistant points at are outlined in the accent colour until you send your next message. A part or net named in an answer is underlined: point at it (`L1`, `V(out)`, `i(S1)`) and it is marked on the schematic. When the assistant explains how a converter works, it can start the animation with its operating modes: current flows along each interval's path and what carries none is dimmed. An accepted proposal fades from its ghost into the real parts, with a short outline on what changed. Motion follows Preferences > Reduce motion: with it on, nothing moves, the marks are drawn still and the animation shows the mode it was asked for without playing. The tools behind them are thin layers over commands you can run yourself: `show_plot` (`waveform.get` and `scope.measure`), `show_bode` (the last `analysis.loopGain` or `analysis.acSweep`), `show_losses` (`analysis.losses`), `highlight` (the `file.exportSchematic` renderer) and `animate_modes` (`simulation.modes` and `ui.set {"animate"}`). None of them changes the circuit. ## Limits - The assistant is a language model. It can misread what you meant. Check each proposal before you accept it, and read the numbers it quotes against the scope. - One turn runs at a time. While a simulation or a tuning of the turn runs, a new message waits ("The agent is still working. Wait for it or press Stop."). Background jobs do not hold the chat: up to three run beside it. - A chat is kept only by saving its circuit. The chat of a window with no circuit open is not saved. - An attached paper is read in the turn it is sent with. Later messages work from what the assistant wrote down; attach the file again if it needs to look again. --- # 13. The Tools menu: Parameter Sweep, scripts and C code URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/13-tools-menu/ The **Tools** menu has six items: the five below, and **Board**, the project's board canvas (last section). **Parameter Sweep** runs one simulation for each value of a variable and tabulates a measurement. **Scripting** replays a list of commands from a text file. **Code Generation** writes C code for the digital part of your controller. **Generated Code in the Loop** (`codegen.closedLoop`) and **Processor-in-the-Loop** (`codegen.pil`) run the generated controller in a closed loop with the circuit, the second compiled on this computer (below). ![The Tools menu, marked 1 to 6](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/tools-menu/01-menu.png) 1. Parameter Sweep. 2. Scripting. 3. Code Generation. 4. Generated Code in the Loop. 5. Processor-in-the-Loop. ## Parameter Sweep Use it when you want to see how one result changes as one circuit variable goes from A to B, without writing JSON. It is a form for `analysis.paramSweep` (chapter 6). Choose **Tools > Parameter Sweep**. The window has the setup on the left, under **Vary** and **Measure each run**, and the results on the right. Fill in: ![The Parameter Sweep window, filled in for a sweep of D from 0.2 to 0.8, marked 1 to 6](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/tools-menu/02-batch.png) 1. Variable. 2. Start. 3. End. 4. Points. 5. Signal. 6. Run sweep. | Field | Meaning | |---|---| | Variable | A circuit variable, for example `D`, or a part's parameter written `Part.param`, such as `L1.l`. The window lists the variables of the open circuit | | Start, End | The first and last value. Start must be below End. SI suffixes work (`3.3`, `4.7u`, `25µ`, `10k`); Sweep fills them in that form. A part's parameter shows its name and unit beside the fields | | Points | How many values, from 2 to 1000 | | Spacing | **Linear** steps evenly from Start to End. **Log** keeps an equal ratio between neighbours (10 to 100 µ in 7 points is 10, 14.7, 21.5, 31.6, 46.4, 68.1 and 100 µ), so Start must be above zero. The line under it lists the values | | Signal | The signal to measure, for example `v(out)` | | Measure | One of `mean`, `rms`, `max`, `min`, `pp` or `last` | | Add a measurement | Another signal and statistic, measured in the same runs, up to 16 in all. The table gets a column for each. A row left without a signal is skipped | | Window start, end (s) | Optional. Measure only between these two times. Use it to skip the start-up transient | | Overlay each run's waveform on the scope | Keeps the signal of every run (`keepWaveforms`), so the scope draws them as a family, one trace per value | Press **Run sweep**. The sweep runs as a background job, so the status bar shows progress and a **Cancel** button. The results appear on the right. A header names the swept variable and counts the runs that measured everything ("7 of 7 runs · log spacing"). Under it is a plot of each measurement against the variable, on a log axis for a log-spaced sweep, with the point nearest the circuit's value marked and the ripple limit drawn as a dashed line. Then comes a table, with one row for each value of the variable and a column for each measurement. Every number reads with its unit (`39.69 µH`, `105.7 mV`), right-aligned so the digits line up; a part's parameter is named as in Properties (`L1 inductance`, the key `L1.l` on hover), and a measurement by its signal and statistic (`v(out) p-p`). In the result window, a log-spaced sweep is plotted on a log axis. When the circuit has a design spec with a ripple limit (`ripple.maxPp`, set by the Test Bench or Auto Design) and one measurement is `pp` of the output voltage, the table gets a **Ripple** column that reads PASS or OVER for each run, and a line under it names each range of swept values that keeps under the limit ("L1 inductance from 39.7 µH to 159 µH keeps ripple under 100 mV"), or says that none does. The row nearest the variable's value in the circuit now is shown in bold with a dot. **Copy CSV** puts it on the clipboard, ready for a spreadsheet. The form refuses an empty or reversed range, a bad number of points and a reversed window before it starts anything, and tells you why. **Sweep a part's value from Properties.** Right-click a number in Properties (the name of the row, for example L1's **Inductance**) and choose **Sweep**. The form opens filled in for that parameter: `L1.l` from a tenth to ten times its value (a value that is not positive goes ±50 %), 5 points, the scope's first signal as the measure (before any run, the output voltage), and the overlay ticked. Press **Run sweep**: the table fills in, and the scope shows each run's waveform labelled with its value. A value that is an expression or a variable has no Sweep; sweep the variable instead. The points run in parallel on all your cores. For several variables, tolerances or random draws, use `analysis.monteCarlo` or the commands in chapter 6 directly. ## Scripting A script is a plain text file with one engine command on each line. Use one when you repeat the same steps: open a circuit, change a value, run, measure, and do it again for other values. A script can do exactly what you can do by hand, nothing more. It has no access of its own to files or the network. ### Run a script | Where | How | |---|---| | Desktop app | **Tools > Scripting** opens a window. Type or paste the script and press **Run**. A list shows the line, the command and the result of each step | | Command line | `powercraft-cli script FILE [--root DIR]` prints one line of JSON for each step. It exits with code 1 at the first error and names the line. `--root` is the folder the script may read and write, as for the other commands | | Command | `script.run {"text": "..."}`, for assistants and the control channel | ![The Scripting window after a run, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/scripting/01-script.png) 1. The script: the example below. 2. **Run**. 3. How many steps ran. 4. One row per step: the line, the command and its result. ### The format ```text # A comment. Empty lines are skipped. file.openExample {"name": "buck"} simulation.settings {"tEnd": "5m"} for d in 0.2, 0.25, 0.3 circuit.variables {"set": {"D": ${d}}} simulation.run scope.measure {"signals": ["v(out)"], "t0": "3m"} end ``` The part names and parameters in this example are an illustration. Look up the real ones with `command.list` and `circuit.inspect`. | Line | Meaning | |---|---| | `command.id {JSON}` | Run one command. The parameters are a JSON object. Leave them out when there are none | | `# text` | A comment | | `let name = /pointer` | Keep a value from the result of the previous command. The pointer is a JSON pointer (RFC 6901), for example `/name` or `/a/0/b`. An empty pointer keeps the whole result | | `${name}` | Use the kept value in a later line | | `for name in a, b, c` ... `end` | Repeat the lines in between once for each value. Loops can be nested two deep, and loops and `if` blocks together eight deep | | `let name = var/pointer` | Read a value from a kept variable instead (`let r =` keeps a whole result; `let eta = r/efficiencyPercent` reads it later) | | `set name = expression` | Compute a number: `+ - * / % ^`, comparisons, `&&`, `\|\|`, `!`, functions such as `min`, `abs` and `if(c, a, b)`, and suffixes such as `100u`. Variables are used by name, without `${}` | | `if expression` ... `else if expression` ... `else` ... `end` | Run the first branch whose expression is true | | `break` | Leave the innermost `for` at once | A value in a `for` line is read as JSON when it is valid JSON (`3`, `"text"`, `[1, 2]`). Otherwise it is a string, so `for r in 1k, 2.2k` gives `"1k"` and `"2.2k"`. In an expression such a string counts as its number. This script sweeps the switching frequency of the `buck` example and stops at the first point whose output ripple is under 0.5 % of the output. The window and the command line list the variables the script ended with: ```text # Sweep fsw on the buck example; stop at the first point whose output ripple is under 0.5 % of the mean. file.openExample {"name": "buck"} simulation.settings {"tEnd": "6m", "maxStep": "100n"} set limit = 0.5 for f in 20k, 50k, 100k, 200k circuit.variables {"set": {"fsw": ${f}}} simulation.run scope.measure {"signals": ["v(out)"], "t0": "5m"} let m = /stats/v(out) let pp = m/peakToPeak let mean = m/mean set ripple = 100 * pp / mean if ripple < limit set best = f break else if ripple < 2 * limit set close = f end end set bestKHz = best / 1k ``` Saved as `ripple.pcs`, `powercraft-cli script ripple.pcs` runs two simulations: at 20 kHz the output ripple is 0.283 V (2.4 %), at 50 kHz 0.045 V (0.38 %), so the loop stops there and 100 kHz and 200 kHz never run. The last line lists the variables: `best` 50000, `bestKHz` 50, `ripple` 0.377. The window measures from 5 ms because the example's output filter rings for the first few milliseconds after start-up; measured from 1 ms the ringing, not the switching, sets the ripple. `script.run` answers with `steps` (one row per command: `line`, `command`, `ok` and `result` or `error`), `ok`, `vars` (the variables the script ended with that hold a number, a boolean or a short string; whole results kept with `let` are not listed) and `used` (the steps counted). For example: ```sh powercraft-cli run --cmd script.run --params '{"text": "set x = 2.2k * 2\nif x > 4k && x < 5k\n set y = sqrt(x)\nelse\n set y = 0\nend"}' ``` gives `"ok": true`, `"steps": []` (no command ran), `"used": 3` and `"vars": {"x": 4400.0, "y": 66.33…}`. ### Safety - The whole script is checked before anything runs. A syntax error stops everything and names the line (`line 5: ...`). The circuit is not touched. - Every name an expression or `${}` uses must be set on an earlier line, and `break` must be inside a `for`; both are checked before the run. A variable set only inside an `if` branch passes that check, but when the branch did not run, a later line that reads it stops the script there. - The first command that fails stops the script. It is the last step in the report, and the steps before it stay in the circuit. - A script can run at most 10,000 steps (each command, `let`, `set`, `if` test and loop pass counts as one), and at most 10 minutes, checked between steps. `script.run` takes `maxSteps` and `maxSeconds` to set lower or higher limits (up to 10,000 steps and 24 hours; the browser has no time limit). The text is limited to 1 MiB. A script cannot call `script.run`. A script stopped by a limit, a failed command or an unknown variable answers with `ok` false and an `error` naming the line, not with an error of the command itself. There is no `while`: every script ends. - Commands run one after another. A simulation finishes before the next line starts, and in the desktop app the window does not update meanwhile. ### Undo A script is one undo step, so one Undo takes back everything it changed. The step is called Script, or the `label` you give `script.run`. When a command fails, the step is called `Script (stopped at line N)`, and one Undo still returns the circuit to how it was before the script. Inside a script, `edit.undo` and `edit.redo` work as usual. A script that changes nothing adds no step. A circuit that the script opens gets one step after the one it was opened with. The longer guide is [`docs/workflows/scripting.md`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/workflows/scripting/) (in Traditional Chinese). ## The console The console is a command line inside the window. Open it with View > Console or ⌘⇧Y (Ctrl+Shift+Y on Windows and Linux; Ctrl+`` ` `` opens the terminal, chapter 11). It sits under the schematic. Type one command on the line and press Enter. The result is printed above the line. A line is one engine command, written as a script line or in a short form: ```text circuit.setParam {"component": "R1", "key": "r", "value": "2k"} circuit.setParam component=R1 key=r value=2k ``` In the short form each parameter is `name=value`. A number, `true`, `false` and `null` are read as JSON. A value with an SI prefix, such as `2k` or `100u`, stays text, and the engine reads the prefix. Put text with spaces in quotes: `label="input filter"`. Lists and objects are written as JSON: `components=["R1","C1"]`. `let name = /pointer` keeps a value from the last result, `let name = var/pointer` reads one from a kept variable, `set name = expression` computes a number, and `${name}` uses a value in a later line, as in a script. `for`, `if`, `else`, `end` and `break` need several lines, so the console refuses them and points to Tools > Scripting. | Key or word | What it does | |---|---| | Enter | Runs the line | | Up, Down | Brings back earlier lines. The last 500 lines are kept when you quit | | Tab | Completes a command, then a parameter name, then a part or net name after `component=` or `net=`. When several match, they are listed | | Esc | Stops a simulation or sweep that the console started | | `help` | Lists the commands by area | | `help command.id` | Shows the menu item, the shortcut and the parameters of one command | | `history` | Lists the lines you typed | | `clear` | Empties the console | A command runs the same way as its menu item. Each change to the circuit is one undo step. A simulation or a sweep runs in the background with progress in the status bar, and the console prints its result when it ends. A line that fails says why and changes nothing. When you use a menu, a toolbar button or a shortcut, the console prints the command line that does the same thing. This is a quick way to learn the commands. To turn it off, clear Echo menu actions in the console in Edit > Preferences. ## Code Generation When your controller is digital, you eventually need the control code in C. **Tools > Code Generation** turns the sampled control blocks of the active circuit into portable C99 code. Choose the menu item. A window shows two files, `pc_control.h` and `pc_control.c`, one under the other, with the prefix `pc_control`. Above them, **Precision** picks the number format (`float`, the default, `double`, `q15` or `q31`) and writes the code again in it, and **Save Files…** writes each file into a folder you choose, under its own name (in the browser, each file downloads). **Copy** copies the text. Once you have built the code for a Cortex-M4, **ISR Execution Time** reads the listing of your build (`arm-none-eabi-objdump -d --no-show-raw-insn`, saved to a file) and shows under the buttons how many cycles the interrupt takes, in µs at 170 MHz, and its share of the PWM period, in red when it takes the whole period (`codegen.isrCycles`; the browser does not offer it). For the F28379D, call `codegen.isrCycles` with `{"core": "c28x"}` and the `.asm` file the TI C28x compiler keeps with `--keep_asm`: it counts each instruction at TI's published cycle counts at 200 MHz, names the run-time support functions it cannot see (such as a software divide), and gives no stack depth. Check the result with `isrGpio` and an oscilloscope. To change the prefix, give a `qM.N` format, or write the files from a script, use the commands: | Command | What it does | |---|---| | `tools.codeGeneration` | Returns the text of the two files. `{"precision": "double", "prefix": "drive_ctl"}` | | `file.exportCode` | Writes `.h` and `.c` (and the target's files) into the folder `dir`, within the folders you allow, then `_map.json`: which state, signal, input and calibration fields belong to each block, the circuit signal behind each input and output field, the options, the circuit's hash, the Voltecx version and the hash of every other file written. `{"dir": "ctl", "precision": "double", "prefix": "drive_ctl"}` | | `codegen.evidence` | Writes what `file.exportCode` writes, checks that the code is the same when generated again, with another prefix and (with a microcontroller target) on the portable target, runs `codegen.verify` and `codegen.closedLoop`, and writes `_evidence.json`: the version, the circuit's hash, the options, every file's hash, the map and both replies with their coverage. `status` is `passed`, `failed`, or `incomplete` when a check could not run on this computer (no C compiler). The bundle has no time stamp, so the same circuit gives the same file. `{"dir": "review", "target": "stm32g474", "fullScale": 20}` | | `codegen.ranges` | Before any run, says which values of the code may saturate in fixed point and which divisions may divide by zero. Give each measured input its range in `inputs`, or `fullScale` for every input read by the ADC (0 to the full scale). The reply lists, per block, the operations that may leave the format (with the values they may reach), the inputs the format cannot hold, the divisions whose divisor may be 0, and the range of every output and state. A value not listed cannot leave its range; a listed one may, so check it with `codegen.verify`. `{"precision": "q15", "fullScale": 20}` | `precision` is `float` (the default), `double`, `q15`, `q31` or a fixed-point format such as `q7.24`. `q15` and `q31` choose the integer bits that hold every constant of the code, and the reply's `format` names the result (chapter 16, `design.digitalize`). The prefix must be a C identifier: letters, digits and `_`, starting with a letter. The generated code has no `malloc` and no global variables. You use `_init(&state)` once at start-up, `_reset(&state)` to restart without losing gains tuned at run time (see below), and `_step(&state, &inputs, &outputs)` at every sample. The header declares the state, input and output structures. ### Microcontroller targets `target` adds the set-up and the interrupt of one microcontroller to the two files. The default `portable` adds nothing. | `target` | Extra files | What they do | |---|---|---| | `stm32g474` | `_stm32g474.h`, `_init.c`, `_isr.c` | TIM1 makes the PWM (CH1, its complement CH1N with the dead time) and triggers ADC1. The ADC interrupt scales the codes into the inputs, runs `_step` and writes the duty into TIM1_CCR1. | | `f28379d` | `_f28379d.h`, `_init.c`, `_isr.c`, `_main.c`, `_f28379d.projectspec` | ePWM1 makes the PWM (EPWM1A, its complement EPWM1B through the dead band). SOCA at CTR = ZERO starts ADC-A, and its interrupt 1 runs `_step` and writes the duty into the shadowed CMPA. The CLA is not used. Import the `.projectspec` into Code Composer Studio (File > Import > CCS Projects) after setting `C2000WARE_ROOT` in it. | | `f280049c` | `_f280049c.h`, `_init.c`, `_isr.c`, `_main.c`, `_f280049c.projectspec` | The TI F280049C (LaunchPad LAUNCHXL-F280049C). One to three `pwm` blocks on ePWM1 to ePWM3 (EPWMxA, and EPWMxB through the dead band with a `deadtime` block). ADC-A runs on its internal 3.3 V reference, so `fullScale` defaults to 3.3; up to 10 inputs on A0 to A6 and A8 to A10, then ADC-B (B0, B2 to B4) and ADC-C (C0 to C5, C14), 21 inputs in all. Name `PGA1` to `PGA7` in `adcChannels` to read an input through that on-chip amplifier (the signal on its PGAn_IN pin) at the gain `pgaGain` sets (3, 6, 12 or 24, default 3); that input's full scale is `fullScale` divided by the gain. SOCA at CTR = ZERO starts every ADC in use, and ADC-A's interrupt 1 waits for ADC-B and ADC-C, then runs `_step` and writes the duties into the shadowed CMPA. The ePWM runs on SYSCLK (100 MHz), so `timerClock` is not taken, nor are the f28379d-only options. With a `supervisor` the files also run the start-up sequence, the soft start and the fault states: the outputs stay low (a one-shot trip) until `_f280049c_enable(1)`, the measured input voltage, output voltage and temperature go on the ADC-A pins the code's inputs leave free, and the current limit is CMPSS1's high comparator on the A2 pin, which ends a PWM period early on every ePWM without software (a blanking time needs a sawtooth carrier). Set `C2000WARE_ROOT` in the `.projectspec`, then import it into Code Composer Studio. | The timer counts follow the circuit's `pwm` block: its frequency, a sawtooth carrier (counting up) or a triangle (counting up and down), and the dead time of a `deadtime` block, rounded up to whole timer counts so it is never shorter. A `deadtime` block whose `tdn` gives the complement `outn` its own dead time (one block driving both switches of a half bridge) sets the F28379D's DBFED from `tdn` and DBRED from `td`, and `mcu.deadTime` gives both (`counts` and `fedCounts`); the STM32G474's TIM1 has one dead time for both edges and refuses it. `timerClock` is the timer's clock (TIM1 at 170 MHz, or EPWMCLK at 100 MHz, the most the F28379D allows). `fullScale` is the value of an input when the ADC reads 4095 (3.3 on the STM32G474, 3.0 on the F28379D). On the F28379D, `isrGpio` names a GPIO (0 to 168) that the ADC-A interrupt sets high on entry and clears on exit: a scope on that pin shows how long the control step takes and how often it runs. It cannot be an EPWM pin the code drives (EPWMmA is GPIO 2m − 2, EPWMmB GPIO 2m − 1). `adcTrigger` sets where ePWM1 starts ADC-A: `valley` (the default) at the counter's zero, which is the middle of the on pulse on a triangle carrier and its start on a sawtooth; `peak` at the counter's period, the middle of the off pulse on a triangle carrier, so the new duty cycle starts half a period after the sample. `peak` needs a triangle carrier. `midPulse` samples in the middle of ePWM1's on pulse on a sawtooth carrier: the interrupt also writes half of the new CMPA (at least 1) into CMPB, and ADC-A starts when the counter reaches CMPB counting up. It needs a sawtooth carrier; on a triangle `valley` is already the middle of the on pulse. When the code runs faster than the PWM, a whole number of times per period (2 to 8, for example an interleaved converter whose `zoh` or `dpi` per phase samples at its own carrier, k/n of a period after the first), ePWM1 starts nothing: the next ePWM module after the ones the circuit drives counts up on the same clock at that multiple of the PWM frequency, and its zero starts the ADCs, so the step runs at ePWM1's zero and every 1/n of a period after it. The period's counts must divide by n (pick the PWM frequency so they do); `adcTrigger` stays `valley`, and CPU2, `syncInGpio`, the supervisor, `pwmStart` `firstDuty`, `startStop` and `codegen.pil` refuse it. `mcu.stepsPerPeriod` and `mcu.stepTrigger` (`module`, `tbprd`, `trigsel`) give it. On the STM32G474 the code may run twice per period (one sample per carrier: TIM1 and TIM8): TIM1's channel 4 starts nothing, TIM20 counts up on TIM1's counter clock at twice the PWM frequency, and its update event (tim_trgo) starts ADC1 and ADC2, one counter clock after each phase's start, since TIM20 is preset to its ARR so its first update comes right after TIM1 starts. The period's counts must divide by 2; the supervisor and `codegen.pil` refuse it, and `mcu.stepTrigger` gives `timer` and `arr`. `adcChannels` lists the board's ADC pin of each conversion: the code's inputs in the order the reply's `mcu.adcInputs` gives, then the supervisor's input voltage, output voltage and temperature. A number is an ADC-A CHSEL, 0 to 5 for ADCINA0 to ADCINA5 or 14 and 15 for ADCIN14 and ADCIN15; a name such as `"ADCINB2"` picks a pin of any of the four ADCs: ADCINA0 to ADCINA5, ADCIN14, ADCIN15, ADCINB0 to ADCINB5, ADCINC2 to ADCINC5 and ADCIND0 to ADCIND5 (the 337-ball package). No pin may be named twice, and the supervisor's measurements stay on ADC-A. A conversion past the end of the list takes the first of those pins, in that order, the list leaves free, so leaving it out keeps the order ADCINA0 to ADCINA5, ADCIN14, ADCIN15 and puts a ninth input and more on ADC-B, then ADC-C and ADC-D, up to 24. The same ePWM1 SOCA starts every ADC used, each from its own SOC0, and the ADC-A interrupt waits for the others to finish before it reads them; when no input is on ADC-A, its SOC0 converts a free pin only so that its end runs the step. The pins become the defaults of the channel macros, and `mcu.adcChannels` and `mcu.adcPins` give the CHSEL and the name of every conversion's pin. `pwmPolarity` sets which pin level turns a switch on: `activeHigh` (the default) or `activeLow`, for a gate driver with inverting inputs. Active low makes the dead band active low complementary (DBCTL[POLSEL] = 1; with no `deadtime` block it inverts EPWMxA with no delay), and every trip, the supervisor's included, forces the pins high, their off level. The duty cycle and the timing do not change, and `mcu.pwmPolarity` echoes the choice. For a single switch with no `deadtime` block, `pwmPins` (f28379d only) drives one pin of each module: `aOnly` sets up only EPWMxA (GPIO 2m − 2), and `bOnly` only EPWMxB (GPIO 2m − 1), which AQCTLB sets and clears on the same CMPA events. The pin left out stays a GPIO for your board, and `isrGpio` may use it. The default `both` sets up both pins, and `aOnly` or `bOnly` is refused when the circuit has a `deadtime` block, whose complement needs EPWMxB. `independent` drives two switches from each module, a two-phase PWM: the `pwm` blocks are taken two to a module in block order, the first on EPWMxA at CMPA and the second on EPWMxB at CMPB, both on the module's carrier, so the two blocks of a pair need the same frequency and phase. With a wired `freq` input each pair's CMPB is scaled to the period the code writes, as its CMPA is, and a wired `phase` input moves a pair's module when both blocks of the pair read the same phase signal. It is refused with a `deadtime` block, an odd number of legs, a pair whose phases differ (drawn phases, or `phase` inputs on different signals or on one block only), the `midPulse` ADC trigger, a phased step and the PIL backend. With the supervisor, its trip holds both pins of each module off and the interrupt clears CMPB with CMPA while the PWM is off, and CMPSS1's current limit trips both legs of a module. `mcu.pwmPairs` lists each module's two blocks. `mcu.pwmPins` echoes the choice. `pwmPinBank` (f28379d only) picks the GPIOs the ePWM pins go out on: `gpio0` (the default) puts EPWMmA on GPIO 2m − 2 and EPWMmB on GPIO 2m − 1, and `gpio145` puts them on GPIO145 to GPIO160 (EPWM1A on GPIO145, EPWM8B on GPIO160). Those pins exist only on the 337-ball ZWT package, and choosing them frees GPIO0 to GPIO15 for `isrGpio`, `digitalOut` or EXTSYNCOUT on GPIO6 with four or more modules. `mcu.pwmPinBank` echoes the choice and `mcu.pwmGpios` lists each driven pin with its GPIO. `pll` (f28379d only) sets the system clock instead of `InitSysCtrl`'s 200 MHz: `{"source": "xtal", "oscHz": 20e6, "imult": 10, "div": 2}` gives SYSCLK = 20 MHz × 10 / 2 = 100 MHz, and CPU1's `main` calls C2000Ware's `InitSysPll` after `InitSysCtrl`. The source is `xtal` (a 10 to 20 MHz crystal), `x1` (a 2 to 25 MHz clock on X1) or `intosc2` (the 10 MHz internal oscillator, no `oscHz`), and `fmult` adds 0.25, 0.5 or 0.75 to `imult`. Settings the PLL or the data sheet do not allow are refused by name: the oscillator times the multiplier must be 120 to 400 MHz, and SYSCLK 20 to 200 MHz (194 MHz from `intosc2`). The ePWM clock is then SYSCLK / 2, so leave `timerClock` out; the step timer, the ADC sample windows, the SCI baud rate, the APWM and eCAP counts and the `digitalIn` qualification are all worked out at the new SYSCLK. `mcu.sysclkHz` and `mcu.pll` echo it. For an encoder read by eQEP1 or eQEP2, `eqep1Gpio` (f28379d only: 20, the default, 50 or 10) and `eqep2Gpio` (24, the default, 54 or 78) pick the GPIO of the module's A input, and with it the B, strobe and index pins next to it: eQEP1 on GPIO20 to 23, GPIO50 to 53 or GPIO10 to 13, eQEP2 on GPIO24 to 27, GPIO54 to 57 or GPIO78 to 81 (TI data sheet SPRS880P, table 5-3). GPIO10 to 13 are refused while the code drives ePWM6 or ePWM7 on GPIO0 to 15. `mcu.eqepGpios` lists each counting module with its four pins. `pwmStart` (f28379d only) sets when the gate pins start switching. With `immediate` (the default) they follow the PWM as soon as the time bases start, at the duty of 0 that the init writes until the first step's duty loads; with a `deadtime` block the complement EPWMxB is then on. `firstDuty` holds both pins of every module at their off level (low, or high with `pwmPolarity` `activeLow`) by a software one-shot trip from the init until the second interrupt, the first one after the first step's duty has loaded, which releases them, so the pins first switch at the code's own duty. It is refused with the supervisor, which already holds the outputs off until its soft start, and with a wired `freq`, whose step does not follow the PWM period. `mcu.pwmStart` echoes the choice. `startStop` (f28379d only) adds two calls for your own firmware code: `_f28379d_pwm_stop()` holds every module's pins at their off level at once by the same one-shot trip and stops running the control step, so the controller keeps its state; `_f28379d_pwm_start()` has the next interrupt reset the controller and run the step again, and the one after it, once that duty has loaded, release the pins. A start while the pins run does nothing, and a stop drops a start the interrupt has not taken yet. It is refused with the supervisor, whose `_f28379d_enable()` already starts and stops the outputs, and with a wired `freq`. `initialDuty` (f28379d only, 0 to 1, default 0) is the duty cycle whose compare value the init writes into every module before the first step writes the code's own, rounded to whole counts. `mcu.startStop`, `mcu.initialCmpa` and `mcu.initialDuty` echo them. To run one board's PWM in step with another's (f28379d only), `syncInGpio` names a GPIO whose rising edge restarts ePWM1's period: the code routes it through INPUT5 of the Input X-BAR to EXTSYNCIN1, ePWM1 loads a phase of 0 on it, and the other modules follow ePWM1 as before. Send one pulse per PWM period; without one, ePWM1 runs on its own clock. `syncOut: true` sends ePWM1's sync at the start of each period out on EXTSYNCOUT, GPIO6, for the other board's `syncInGpio`. GPIO6 is also EPWM4A, so `syncOut` is refused when the code drives a fourth module. Neither works on CPU2 or with a pin the code already uses, and `syncInGpio` is refused with a wired `freq`. `mcu.syncIn` and `mcu.syncOut` echo them. With more than three modules, `syncChain` picks the sync that ePWM4 (heading ePWM4 to ePWM6) and ePWM7 (heading ePWM7 and ePWM8) follow: `epwm1`, ePWM1's sync, as before; `epwm4` (ePWM7 only), so ePWM7's chain follows whatever ePWM4's does; `extsyncin1`, the `syncInGpio` edge that ePWM1 follows too; or `extsyncin2`, a second pin named by `sync2InGpio` (INPUT6 of the Input X-BAR). A chain on the second pin counts its phases from that pin's rising edge instead of ePWM1's carrier, so it cannot take a wired phase. `mcu.syncChain` and `mcu.syncIn2` echo the choice. A `pwm` block whose carrier spans its input's units (`offset` and `vpp`, chapter 10) is mapped in the interrupt on the STM32G474 and the F28379D: it writes the compare of (duty − offset)/vpp, and `mcu.legs` gives each leg's `offset` and `vpp`. With the default carrier the interrupt is the same as before. On any target, `comment` puts your own text (the project, the board revision, who generated the code) in a block comment under the banner of every generated `.c` and `.h` file, so the firmware says where it came from; it may have up to 20 lines and 2000 characters, `*/` and `/*` are split so it cannot change the code, and characters outside printable ASCII become `_`. On the F28379D, up to eight `pwm` blocks at one frequency and carrier (interleaved phases, a DAB's two bridges, several converters on one controller) run on ePWM1 to ePWM8 in the order of the blocks, each module's counter loaded with its block's carrier phase on ePWM1's sync; ePWM4 and ePWM7 start the second and third sync chains and take ePWM1's sync through SYNCSELECT. EPWMmA and EPWMmB are GPIO 2m − 2 and 2m − 1 (GPIO0 to GPIO15), and a ninth block is refused. A later block's `phase` input may be wired on the F28379D (a phase-shifted full bridge or a DAB whose controller moves the shift): the control computes the phase in degrees, and each step turns it into the fraction of a period the module runs ahead of the first block's carrier and writes it into the module's phase count (TBPHS, and on a triangle carrier the direction PHSDIR, counting down past the peak), which ePWM1's next sync loads. Until the first step the module runs in step with ePWM1, and a phase that is not a number is 0. With a wired `freq` too, the phase count follows the new period. `mcu.wiredPhases` names each block, its module and the output field. The first block keeps a fixed phase, since the others count from its sync; the STM32G474 and `codegen.pil` refuse a wired phase. A `pwm` block whose `freq` input is wired (an LLC or a CRM PFC whose controller sets the switching frequency) runs on the F28379D only: the control computes the frequency, and each step turns it into ePWM1's period, clamped to what ePWM1 counts (`mcu.variableFrequency` gives `minHz` and `maxHz`, at least a quarter of the block's own frequency up to where a period has 64 counts), and scales every duty cycle to that period; a frequency that is not a positive number keeps the block's own. The period and the duty load together at the next counter zero. The step no longer follows the PWM: CPU Timer 0 starts the ADCs at the code's sample time (the block's own period when nothing in the control has one), so `adcTrigger` stays `valley`. Several `pwm` blocks must read the same frequency signal. A block whose carrier is shifted against the first keeps that fraction of a period: each step scales its phase count (TBPHS) to the new period, and the module loads its period on ePWM1's sync together with the phase. the supervisor and `codegen.pil` refuse a wired frequency, and so does the STM32G474. The reply's `mcu` object gives the register values. The `supervisor` is generated for `stm32g474` and `f28379d`. On the F28379D, CMPSS1's high comparator compares the current sense on the ADCINA2 pin with its DAC (`ocpThreshold`, below the 3.3 V VDDA reference) and trips every ePWM module cycle by cycle through the ePWM X-BAR and the digital compare; the outputs are forced low and come back at the next period start once the current is below the threshold. A `blanking` time is counted from the period start and needs a sawtooth carrier. ADC-A converts the input voltage, the output voltage and the temperature after the control's inputs, and a software one-shot trip keeps the outputs low until `_f28379d_enable(1)` and the soft start. A PSIM or PLECS C block's own persistent state (a `static` it declares) is moved into the state struct too, so `_reset` clears it along with every other state, unless the code declares one codegen cannot place there (an array, several names on one declaration, an initialiser that is not a plain number, or one at file scope in a PLECS block's `declarations` section) — such a block is left out with the reason, rather than shipping a value a restart can never reach. #### Running from RAM or from flash (F28379D) The `.projectspec` has four build configurations. Pick one in Code Composer Studio with Project > Build Configurations > Set Active (or the arrow beside the hammer): | Configuration | Linker file (C2000Ware `device_support/f2837xd/common/cmd/`) | Compiler options | Use it to | |---|---|---|---| | `RAM-Debug` | `2837xD_RAM_lnk_cpu1.cmd` | `--opt_level=off` | step through the code; it is loaded by the debugger and lost at power-off | | `RAM-Release` | `2837xD_RAM_lnk_cpu1.cmd` | `--opt_level=2` | measure the interrupt's time with the optimiser on | | `Flash-Debug` | `2837xD_FLASH_lnk_cpu1.cmd` | `--opt_level=off --define=_FLASH` | debug the flash image | | `Flash-Release` | `2837xD_FLASH_lnk_cpu1.cmd` | `--opt_level=2 --define=_FLASH` | ship: the firmware runs on its own after a reset | All four keep `-v28 -ml -mt --float_support=fpu32 --tmu_support=tmu0 --define=CPU1`. `--opt_level=2` is the compiler's `-O2` (TI SPRU514AA, section 3.1). In the flash configurations `main` copies the `.TI.ramfunc` section from flash to RAM (`memcpy` of `RamfuncsLoadStart`, `RamfuncsLoadSize`, `RamfuncsRunStart`, the symbols of the FLASH linker file) before it enables the interrupts, and C2000Ware's `InitSysCtrl` sets the flash wait states. To run a flash build without the debugger, set the boot-mode pins of the board to boot from flash (see your board's guide) and reset it. #### Running the controller on CPU2 (F28379D) The F28379D has two C28x cores. With `cpu` set to `cpu2` (Code target form: Controller CPU core; the default is `cpu1`) the controller runs on CPU2 and leaves CPU1 free for your own code. The set-up and interrupt files are the same as on CPU1; `_f28379d_main.c` gives way to two programs, and the `.projectspec` holds one CCS project per core, `_f28379d_cpu1` and `_f28379d_cpu2`, the way C2000Ware's dual-core examples are laid out: - `_f28379d_cpu1_main.c` sets the clocks and muxes the ePWM pins, which only CPU1 can do, then gives the ePWM modules and the ADCs the code uses to CPU2 (`DevCfgRegs.CPUSEL0` and `CPUSEL11`). In the flash configurations it also boots CPU2 from its flash (`IPCBootCPU2`, under `_STANDALONE`). Last it sets IPC flag 17. Add your own CPU1 code after that. - `_f28379d_cpu2_main.c` waits for IPC flag 17, clears it, and then sets up and runs the controller as on CPU1. From RAM, load each project onto its own core in the debugger and run both, in either order. From flash, program CPU2's flash first, then CPU1's; after a reset CPU1 starts CPU2. Some things only CPU1 can reach, so `cpu2` refuses them by name: the supervisor (its trip goes through the ePWM X-BAR), `isrGpio` (the GPIO mux), a `pwm` with a wired frequency (CPU1's Timer 0 starts the ADCs), and more than three ePWM modules (ePWM4 and later sync through `SYNCSELECT`). `mcu.cpu` in the reply echoes the choice. On the f28379d target, `dac` shows up to three of the code's values on the buffered DAC pins, so a scope can watch an error, a duty or a sampled current while the board runs. Each entry names a field of the outputs struct (or of the inputs struct) and the two values that map to the pin's ends: `{"field": "duty", "low": 0, "high": 0.5}` puts a duty of 0 at 0 V and 0.5 at VREFHI. The first entry goes to DAC-A (the ADCINA0 pin), the second to DAC-B (ADCINA1) and the third to DAC-C (ADCINB1). Each step writes them after the duty, clamped to the 12-bit range. The DAC drives that pin, so a measurement the code takes there is refused; move it with `adcChannels`. The pin is linear from 0.3 V to VDDA − 0.3 V. On the f28379d target, `adcDifferential` puts ADC-B, ADC-C or ADC-D in 16-bit differential mode, for a sensor with a differential output such as a shunt amplifier: `{"adcChannels": ["ADCINB2"], "adcDifferential": ["ADC-B"]}` measures the first input as ADCINB2 minus ADCINB3. On such an ADC each measurement is a pin pair named by its even pin (the positive input); the odd pin next to it is the negative input, so it cannot be another measurement or a DAC output. The code reads 0 at -VREFHI between the pins and 65535 at +VREFHI, so the input's `FULL_SCALE` macro is its value at +VREFHI and its `OFFSET` defaults to minus that: 0 V between the pins reads 0. Each conversion samples for at least 320 ns, and an ADC whose conversions do not end within one step is refused. ADC-A stays 12-bit single-ended. On the board, VREFLO must be tied to VSSA and each pair's common mode must sit within 50 mV of VREFHI/2, so do not ground the negative input. `mcu.adcPairs` in the reply lists each pair (TI SPRUHM8K 11.2.4, table 11-6; SPRS880P p.109). Each of the f28379d's four ADCs has its own reference pin, VREFHIA to VREFHID, which the board drives (the part has no internal reference). When they differ, `adcVrefhi` gives them in volts: `{"adcChannels": ["ADCINB2"], "adcVrefhi": {"ADC-B": 2.5}}` measures the first input on ADC-B with a 2.5 V reference while ADC-A stays at 3.0 V. Each value must be from 2.4 V to VDDA (at most 3.47 V); an ADC left out keeps 3.0 V. `fullScale` is the input value at ADC-A's full-scale code and defaults to ADC-A's VREFHI, and an input on another ADC reads its full scale at `fullScale` times its ADC's VREFHI divided by ADC-A's, written as that input's `FULL_SCALE` macro. The supervisor's measurements keep their own scales. `mcu.adcFullScales` in the reply lists each input's full scale (TI SPRS880P 6.10 and 6.10.1.2.3; SPRUHM8K table 11-2). Also on the f28379d target, `apwm` puts up to six of the code's values out as the duty cycle of a fixed-frequency PWM, for a fan, a relay driver, a level through an RC filter or another stage's set point. Each entry names a field, the values at a duty of 0 and of 1, the frequency and the pin: `{"field": "duty", "low": 0, "high": 0.5, "freq": "25k", "gpio": 24}`. The first entry runs on eCAP1 in APWM mode, the next on eCAP2 and so on, and each goes out through the Output X-BAR, so the pin must be one that carries an Output X-BAR output (GPIO24 to GPIO31, 34, 37, 48, 49, 58 to 61, or an ePWM pin the code does not drive). Two entries cannot share an OUTPUTXBAR output. The frequency is rounded to whole 200 MHz clock cycles, from 12 Hz to 100 MHz, and each step loads the new duty at the end of the APWM's period. `mcu.apwm` shows each module's pin, period and frequency. The f280049c target takes `apwm` too, up to seven entries on eCAP1 to eCAP7: the frequency is rounded to whole 100 MHz clock cycles, from 6 Hz to 50 MHz, and the pin must be one of the 100-pin package's Output X-BAR pins (GPIO2 to GPIO7, 9, 11, 14 to 17, 24 to 31, 33, 34, 58 or 59) that the code does not already use. The eCAP modules can also measure. `capture` reads up to six of the code's measured inputs from a pulse train on a GPIO, such as a tachometer, a Hall sensor or another stage's PWM, instead of from the ADC. Each entry names the input, the pin, what to measure and a gain: `{"field": "tach", "gpio": 40, "measure": "frequency", "gain": 60}` reads a one-pulse-per-turn tachometer on GPIO40 as revolutions per minute. `measure` is `frequency` (Hz, the default), `period` (s) or `duty` (the high time over the period, 0 to 1). The inputs take the eCAP modules after those `apwm` uses, six in all, and any free GPIO up to GPIO168 reaches them through the Input X-BAR. Each module times the high and the low part of every pulse with the 200 MHz clock. When the train slows down or stops, the frequency falls with the time since the last edge, and it reads 0 before the first whole pulse and after 21 s without an edge. Two entries can measure one pin, for its frequency and its duty. The code must be float or double. `mcu.capture` shows each module, its pin and its Input X-BAR input. An entry with `"count": true` also counts the pulses, for a flow meter, an energy meter's pulse output or a tachometer's revolutions. The module raises its interrupt (ECAP1_INT to ECAP6_INT) on each falling edge, and `_f28379d_ecap_pulse_count()` returns the edges since the start, wrapping at 2^32, so the pulses between two reads are the difference. Two edges that come while the control interrupt is running count once, so the count is exact for pulses longer than the step's run time. `mcu.capture` adds the interrupt and its PIE line. Plain on/off signals go out with `digitalOut`. Each entry names a field, a GPIO and an optional threshold: `{"field": "fault", "gpio": 40}` drives GPIO40 high while `fault` is above 0.5 and low otherwise, so a logic block's 0 and 1 become low and high. Up to eight pins, for a relay, a fan enable, a status LED or a fault line to another board. The init clears each pin's latch before making it an output, so it starts low; the interrupt writes it after each step. A pin the code already uses is refused by name; `mcu.digitalOut` echoes the pins. On/off signals come in with `digitalIn`. Each entry names one of the code's measured inputs and a GPIO: `{"field": "enable", "gpio": 40, "pullup": true}` reads `enable` as 1 while GPIO40 is high and 0 while it is low, instead of from the ADC. Add `"activeLow": true` for a line that is active when low, such as a gate driver's fault output, and `"pullup": true` for a switch or an open-drain line to ground; without the pull-up the board must drive the pin. Up to eight pins. The interrupt reads each pin before the step. A pin the code already uses, a digital output's included, is refused by name; `mcu.digitalIn` echoes the pins. A noisy line, such as a mechanical switch or a long cable, can be filtered in the pin itself with `"qualify": {"samples": 6, "samplePeriod": 1e-7}`: a change only passes once 3 or 6 samples in a row agree, here 100 ns apart, so glitches shorter than the window are ignored. The period is 5 ns (one 200 MHz SYSCLK cycle) or an even number of cycles up to 2.55 µs; another value is refused with the two nearest. Pins GPIO0–7, 8–15 and so on share one period, so qualified pins in one group of eight must ask for the same one. `mcu.digitalIn` gives each window and how long the pin must hold for a change to pass for sure (SPRUHM8K 8.4.3). An input can count a pin's edges instead of reading its level: `{"field": "trips", "gpio": 40, "edges": "falling"}` reads `trips` as the number of falling edges on GPIO40 since the previous step, so a fault pulse shorter than one step is never missed (compare it with 0.5 for a latch), and a pulse train is counted. `edges` is `rising`, `falling` or `both`; it does not go with `activeLow`, so name the pin's own edge. Each counting pin takes one of the CPU's five external interrupts, XINT1 to XINT5, through its fixed Input X-BAR input, whose small handler counts the edge (held at 65535); the step's interrupt reads the count and clears it. `syncInGpio` and `sync2InGpio` hold the inputs of XINT2 and XINT3, which are then skipped, so at most five pins count edges. `qualify` filters a counting pin too. `mcu.digitalIn` names each pin's XINT (SPRUHM8K 3.17.6, table 9-1). An isolated measurement from a sigma-delta modulator comes in with `sdfm`. Each entry names one of the code's measured inputs, the modulator's data pin, its clock and its clipping voltage: `{"field": "ia", "gpio": 16, "clock": 20e6, "vclip": 0.32, "gain": 500}` reads `ia` from SDFM1 filter 1 (data on GPIO16, clock on GPIO17) instead of the ADC, for a modulator that clips at 0.32 V across a 2 mΩ shunt (500 A per volt). The data pin is an even pin of GPIO16–30, GPIO48–62 or GPIO122–136, which also picks the filter, and the clock comes in on the next pin. `filter` (`sinc1`, `sinc2`, `sinc3` or `sincfast`; Sinc3 by default) and `osr` (1 to 256; 128 by default) set the data filter, and `mode` (0, 1 or 3) says whether the clock runs at, at half of or at twice the data rate. Take the clock and the clipping voltage from the modulator's data sheet and your board: Voltecx has no default for them. The interrupt reads the filter's 32-bit output before each step and scales it by the clipping voltage over the filter's peak (SPRUHM8K 14.7, table 14-3). A clock outside the data sheet's range, mode 2 (Manchester) and a filter slower than the step are refused; the reply names the largest OSR that keeps up. Up to eight inputs, float or double precision only. `mcu.sdfm` echoes each filter with its output rate, its settling time and its scale. A fault line from the board, such as a gate driver's fault output or a desaturation detector, can turn the switches off in hardware with `tripIn`: `{"gpio": 40}` routes GPIO40 through Input X-BAR INPUT1 to TZ1, a one-shot trip of every ePWM module the code drives, so a low level on the pin forces EPWMxA and EPWMxB to their off level at once, without waiting for the step. `activeHigh: true` takes a line that is high on a fault (the pin's input is inverted, since TZ1 is active low), and `pullup: true` turns on the pin's pull-up for an open-drain line with none on the board. The pin is read asynchronously, so the trip needs no clock. The outputs stay off until the firmware calls `_f28379d_trip_clear()` once the line is back to idle; `_f28379d_tripped()` says whether the pin holds a trip, and `_f28379d_trips()` counts them (ePWM1's trip interrupt, PIE INT2.1). The code's own stops (the supervisor, `startStop`, `pwmStart: firstDuty`) never release a trip from the pin. A pin the code already uses, cpu2 and other targets are refused; `mcu.tripIn` echoes it (SPRUHM8K 9.1, 15.2, 15.9.2). The `f280049c` target takes `tripIn` too, with the same fields. The functions are `_f280049c_trip_clear()`, `_f280049c_tripped()` and `_f280049c_trips()`, the outputs are forced low, and the supervisor's soft start waits for the clear. The pin must be one of the 100-pin PZ package's GPIOs: GPIO0 to GPIO17, GPIO22 to GPIO34, GPIO39, GPIO40 or GPIO56 to GPIO59, and not an ePWM output the code drives. GPIO18 and GPIO19 (the crystal) and GPIO35 and GPIO37 (TDI and TDO, the debugger's JTAG) are refused (SPRUI33H 9.1, 18.9; SPRS945H tables 5-1 and 5-3). The `f280049c` target also takes `isrGpio`, the ISR timing pin: the pin is high while the ADC-A interrupt runs, so an oscilloscope on it shows how long the step takes and how often it runs. It can be any of the same PZ GPIOs, as long as it is not an ePWM output the code drives or the `tripIn` pin. `_f280049c_init()` makes it a push-pull output, low, and `mcu.isrGpio` echoes it (SPRUI33H 8.2, 8.9.3). The `f280049c` target reads `digitalIn` too, for pin levels: `{"field": "enable", "gpio": 40, "pullup": true, "activeLow": false}` reads `enable` from GPIO40 before each step instead of from the ADC, as on the `f28379d`. The pin can be any of the same PZ GPIOs that no driven ePWM output, `isrGpio`, `tripIn` or `digitalOut` entry uses. Each pin is synchronised to SYSCLKOUT unless it has a sampling window: `qualify` works as on the `f28379d`, with the samples counted at this device's SYSCLK of 100 MHz, so `samplePeriod` is 10 ns (QUALPRD 0) or 20 ns to 5.1 µs in steps of 20 ns, and pins in one group of 8 share one period. Edge counts (`edges`) are `f28379d` only and refused here. `mcu.digitalIn` echoes the pins and each window (SPRUI33H 8.2, 8.4, 8.5.2, 8.5.3, 8.9.2, 8.9.3). The `f280049c` target also takes `pwmStart`, `startStop` and `initialDuty`, as the `f28379d` does. `"pwmStart": "firstDuty"` holds every driven ePWM's pins low by a one-shot trip from init until the first step's duty has loaded; `"startStop": true` adds `_f280049c_pwm_stop()` and `_f280049c_pwm_start()`, which hold the pins low and stop the step, then reset the controller and release the pins once its first duty has loaded; `initialDuty` is the duty whose CMPA init writes before the first step. With a `supervisor` the first two are refused, since it owns that trip; with `tripIn` the release waits until the fault pin's trip is cleared. The reply's `mcu` echoes `pwmStart`, `startStop`, `initialCmpa` and `initialDuty`. The `f280049c` target also takes `syncInGpio` and `syncOut`, as the `f28379d` does. `syncInGpio` is a GPIO of the 100-pin package whose rising edge restarts ePWM1's period: Input X-BAR INPUT5 takes it as EXTSYNCIN1, which becomes ePWM1's sync input through SYNCSELECT, and the other modules follow ePWM1. `"syncOut": true` sends ePWM1's sync at the start of each period out on EXTSYNCOUT, GPIO6, for another board's sync input; GPIO6 is also EPWM4A, so it is refused with a fourth ePWM module. The second sync pin (`sync2InGpio`, Input X-BAR INPUT6 as EXTSYNCIN2) and `syncChain` (the sync input of ePWM4 and ePWM7, the heads of the second and third chains) work as on the `f28379d`, with the same choices: `epwm1`, `epwm4` (ePWM7 only), `extsyncin1` and `extsyncin2`. A chain on `extsyncin2` counts its phases from the second pin's rising edge. The reply's `mcu` echoes `syncIn`, `syncOut`, `syncIn2` and `syncChain`. Values can go out on an SPI bus with `spi`, for an external SPI DAC that puts a controller's internal signals on a scope, a digital isolator to another board or a logic analyser: `{"module": "SPI-B", "baud": 10e6, "words": [{"field": "vout", "low": 0, "high": 3}, {"field": "duty", "low": 0, "high": 1, "codeBits": 12, "command": 3}]}` makes SPI-B the master (SPISIMO, SPICLK and SPISTE on GPIO24, GPIO26 and GPIO27) and sends, after each step, a frame of two 16-bit words: `vout` from 0 to 3 V as a code from 0 to 65535, then `duty` as a 12-bit code under the command 3 in the top four bits. The words go into the transmit FIFO back to back, so SPISTE stays active across the frame and goes inactive after it, and the receiving part sees one chip-select frame a step. Each word is `command` above a `codeBits`-bit code (by default the whole word less `shift`) above `shift` zero bits, the code being `low` at 0 and `high` at its largest value, rounded and clamped; set them from the receiving part's data sheet. `wordBits` (1 to 16) sets the word length, `clockPolarity` and `clockPhase` (0 or 1) are TI's CLKPOLARITY and CLK_PHASE bits (pick them from the timing diagram, since other makers number the four schemes differently), `simoGpio` picks another pin group, and `baud` is the fastest clock the receiving part takes: the code runs at the fastest LSPCLK / (SPIBRR + 1) not above it. A frame that would start while the last one is still in the FIFO is skipped and counted by `_f28379d_spi_skipped()`, and `_f28379d_spi_frame` keeps the last frame sent. A frame longer than the step, a pin the code already uses, a word that does not fit, more than 16 words, cpu2 and other targets are refused; `mcu.spi` echoes the pins, SPIBRR, the clock and the frame's length (SPRUHM8K 18.3, 18.4.2; SPRS880P table 5-3). Measured inputs can come in on an SPI bus with `spiIn`, from an external or isolated SPI ADC instead of the on-chip ADC: `{"module": "SPI-A", "baud": 10e6, "words": [{"field": "vout", "low": 0, "high": 40.95, "codeBits": 12, "command": 6144}, {"field": "il", "low": -20.48, "high": 20.47, "codeBits": 12, "shift": 2, "command": 7168}]}` makes SPI-A the master (SPISIMO, SPISOMI, SPICLK and SPISTE on GPIO16 to GPIO19) and, before each step, sends a frame of two 16-bit words, 1800h then 1C00h, back to back under one SPISTE. Each reply is read from the receive FIFO: `vout` is the reply's bottom 12 bits, 0 V at code 0 and 40.95 V at 4095, and `il` the 12 bits two bits up. `command` is the word the code sends while it reads that reply, right-aligned in `wordBits`; for a part that answers a command in the next word, list its commands one word ahead and add a word for the last reply. The other fields are those of `spi`, with SPISOMI on the GPIO after SPISIMO, and `spiIn` must use another module than `spi`. The code waits for the replies at most twice the frame's length; a frame not back in time, or one that finds the transmit FIFO busy, keeps the last values and is counted by `_f28379d_spi_in_missed()`, and `_f28379d_spi_in_frame` keeps the last replies. A field that is not a measured input, a frame longer than the step, a pin the code already uses, cpu2 and other targets are refused; `mcu.spiIn` echoes the pins, SPIBRR, the clock, the frame's length and the wait (SPRUHM8K 18.3.2, 18.3.4, table 18-18; SPRS880P table 5-3). An encoder's count can be homed on its index pulse with `encoderIndex`: `["eQEP1"]` makes eQEP1 reset its count on the encoder's first index pulse only (QEPCTL[PCRM] = 2h), to 0 turning forward and to −1 turning back, so from then on the count is the shaft's angle from the index and not from wherever the shaft stood at power-up. The count still runs the full 32 bits after that. A simulated encoder's `count` is 0 at its index, so once the board has seen the index its count differs from the simulated one by whole revolutions only, and an electrical angle taken from it matches the simulation. Each index pulse also latches the count into QPOSILAT and raises eQEP1's interrupt (PIE INT5.1; eQEP2's is INT5.2): `_f28379d_eqep1_index_count()` counts the pulses (0 until the count is homed, held at 65535) and `_f28379d_eqep1_index_position()` gives the count at the last one. A module that counts no encoder in the code, cpu2 and other targets are refused; `mcu.encoderIndex` echoes it (SPRUHM8K 17.5.1.3, 17.5.2.1, 17.9). ### What is generated The code covers the blocks that run at one sample time: `constant`, `gain`, `sum`, `product`, `max`, `min`, `abs`, `not`, `limiter`, `comparator`, `affine`, the transforms (`clarke`, `invClarke`, `park`, `invPark`, `abc2dq`, `dq2abc`), `svpwm`, `adc`, `zoh`, `zDelay`, `ztf`, `fir`, `iir`, `dIntegrator`, `dpi`, `dpid` (all three methods, with back-calculation anti-windup), `sampleHold` and `delay`, and the tables `lookup` and `lookup2d` (up to 64 points per axis and 256 values). Blocks that advance over the solver step, `rateLimiter`, `integrator`, `angle`, `smo`, `pll` and `srfPll`, are written at the code's sample time when they feed the duty cycle a PWM reads: each runs its own update once per call, with the sample time as its step, and the reply lists it in `discretized` with the method `blockUpdate`. The rate is the one the sampled blocks use, or the PWM period of a continuous controller. `angle`, `smo`, `pll` and `srfPll` need sine, cosine and a square root, so they are generated in `float` and `double` only. In `float`, an observer or a position loop with a large gain can drift a sample from the model; check it with `codegen.verify {"precision": "double"}` first. Sampled blocks may run at more than one sample time when every slower one is a whole multiple N of the fastest (2 to 65535): the code runs at the fastest, and a slower block runs once every N calls, behind a call counter in the state structure, with its outputs held there between its runs. This works in `float`, `double` and fixed point. In fixed point the counter counts in the format's own steps, so it never widens the format `q15` or `q31` picks; N − 1 must fit the stored integer (up to 32767 in a 16-bit format), and a slower block whose count does not fit is left out with the reason. A C block at a slower rate is left out in every number type. The blocks are evaluated in the same order as in the simulation. A signal that is read before its writer runs becomes a state field, so a loop that is closed through a delay behaves as it does in the simulator. An algebraic loop is an error that names the blocks. ### What is not generated These are listed in the reply with the reason, and nothing is guessed: - the PWM and carrier blocks (the timer of the microcontroller does that), - continuous blocks (`pi`, `tf`, `pid`, filters) beside a sampled block, and the step-advancing blocks above anywhere but in a PWM's input, - time sources (`sine`, `step`), logic blocks, `mcu`, plug-ins, `vco` and `phaseDetector`, and tables larger than the limits above, - FIR and IIR filters of more than 32 taps, - blocks whose sample time is not a whole multiple of the code's, and blocks with an offset. A signal that crosses between a generated block and one of these becomes a field of the input or output structure. You feed it in, or read it out, yourself. If the circuit has no control blocks, the menu item says so. ### How it was checked The tests run the generated assignments in double precision against the simulator's own block evaluation, for a PI loop with each method and for a circuit with every supported block. They agree to 1e-9. The C text itself was not compiled in the tests. Compile it with your own toolchain and check it against your simulation before you rely on it. Chapter 10 explains why a digital loop needs the delay of the `mcu` block in the model first. ### Logging the controller over a UART To see what the real controller computes, add `"log"` with the fields to send: `{"log": ["u", "PI_i", "y"]}`. A field can be an output (a duty cycle), an input (an ADC reading) or a state field (an integrator). Two more files come out, `_log.h` and `_log.c`, and the reply's `log.channels` gives each field its id. - Build with `-D_LOG` (for example `-DPC_CONTROL_LOG`). Without it every log function does nothing (`_log_read` and `_log_dropped` return 0), so the same source builds without the log. - Call `_log_init()` once and `_log_sample(&st, &in, &out)` right after each `_step()`. It puts one 13-byte frame per field into a ring buffer (1024 bytes; set `_LOG_BUFFER_BYTES` to change it) and never waits for the UART. The `stm32g474` interrupt file does not call it yet: add the call after `_step()` in `_stm32g474_isr.c`. - `_init(&st)` sets the tunable parameters to their defaults and clears the states; `_reset(&st)` clears the states and keeps `st->params`. The supervisor's restart (hiccup or a new start) calls `_reset`, so gains tuned at run time survive it. In the `stm32g474` interrupt the wait for ADC2 is bounded by `_SUP_ADC2_WAIT_LOOPS` (default 4096, from RM0440: 653 ADC clocks at an ADC clock of core/6; define it first if your ADC clock is slower). On a timeout the supervisor goes to FAULT with `_SUP_FAULT_ADC` (bit 8), the PWM stays off, and the trip is counted. - Send the bytes that `_log_read(buf, n)` returns over your UART, from the main loop or a transmit interrupt. When the buffer is full, a frame is dropped and `_log_dropped()` counts it. - On the `f28379d` target the generated code does both. The ADC-A interrupt calls `_log_sample` after it writes the duty cycles, `main` calls `_f28379d_log_start()` before it enables the interrupts, and its loop calls `_f28379d_log_send()`, which fills SCI-A's 16-word transmit FIFO and returns without waiting. SCI-A sends 8 data bits, no parity and one stop bit at `logBaud` (default 115200) on `logTxGpio` (default GPIO84; SCITXDA can also go out on GPIO8, 29, 36, 42, 48, 65 or 135). The rate comes from LSPCLK, 50 MHz, so it is not always exact: `mcu.logSci` gives the BRR and the rate actually sent (115741 bit/s for 115200). The project file adds `_log.c`; build with `-D_LOG` to turn it on. - A frame is `0xA5 0x5A`, the id, the step counter (uint32, little endian), the value (float32, little endian) and a CRC-16/CCITT-FALSE over the id, counter and value. Read the capture back with `debug.serialLog`. A host with a read root (`powercraft-cli serve`) reads a capture file (`path`) or a serial port (`port`, `baud`, `seconds`), and the command takes the bytes as base64 (`bytes`) as well. Give `sampleTime` (the code's sample time) and pass `log.channels` as `channels`; `map` pairs simulated signals with channels: `{"port": "/dev/ttyUSB0", "baud": 921600, "seconds": 2, "sampleTime": "100u", "channels": [...], "map": {"u": "u", "PI_i": "PI_i"}}` Damaged frames fail their CRC and are dropped and counted, and the reader finds the next frame after noise or a lost byte. A value held between steps is compared as a staircase, like the simulated sampled block. Besides the `waveform.compare` figures, `divergence` lists where the hardware leaves the model: an error above `tolerance` (5 % of the signal's span) for a run of samples, and a variable outside the range the simulated one ever took, which is how an integrator winding up on the board shows. To tune the controller on the board without building again, add `"tune": true`. Two more files come out, `_tune.h` and `_tune.c`, and the reply's `tune.params` gives each tunable coefficient (the rows of `_params.csv`) its index. It needs at least one tunable coefficient (a gain, PI, PID or transfer-function block). - Build with `-D_TUNE`. Without it every tuning function does nothing. - Call `_tune_init()` once. In the main loop, pass every byte the UART receives to `_tune_rx(&st, byte)` and send the bytes `_tune_read()` returns. Never call them from the control interrupt. If a store of the number type takes more than one instruction on your MCU (a `double` on a C28x), define `_TUNE_LOCK()` and `_TUNE_UNLOCK()`, for example as `DINT` and `EINT`. - A request is 10 bytes: `0x5A 0xA5`, `R` (read) or `W` (write), the index, the value (float32, little endian) and a CRC-16/CCITT-FALSE over the four bytes before it and the value. Each request gets a 10-byte reply in the same layout, with a status in place of the operation (0 done, 1 no such index, 2 written but saturated, 3 refused because the value is NaN or infinite, 4 unknown operation) and the value the code now holds, so you see how a `float` or fixed-point code rounded it. A request whose CRC fails is counted (`_tune_errors()`) and never carried out. - The generated `f28379d` and `stm32g474` interrupt and main files don't receive on the UART yet: connect your receive code to `_tune_rx`. ## Real-time model To test firmware against the power stage on a real-time rig, export the stage itself as C. `tools.realtimeModel` turns the active circuit into a fixed-step model: `.h` and `.c` (prefix `pc_plant` by default), C99 with no `malloc`. Call `_init(&state)` once, then `_step(&state, gates)` every step with the gate levels the firmware drives (a gate is on above 0.5), and read the node voltages and currents with `_outputs(&state, out)`. The header lists the inputs and outputs by name. `file.exportRealtimeModel {dir}` takes the same params and writes the two files into the folder `dir` (`path` is its older name), within the folders you allow; nothing is written when the circuit has no real-time model. | Param | What it does | |---|---| | `step` | The fixed step. The default is the circuit's maximum step. | | `prefix` | A C identifier for the file names and functions. | | `check` | Also run the reference solver at the same step, replay its gates through the model and report the largest error of every output (`tEnd` shortens the run). | | `fpga` | `{clockHz, multipliers, latencyCycles}`: budget the slowest step against an FPGA clock (below). | **How it works.** Every ideal switch, diode, MOSFET (with its body diode), IGBT and thyristor-family device (SCR, TRIAC, DIAC, GTO, IGCT) is a resistance that is either low (`ron`) or high (`roff`), with its forward drop as a source beside it. So for a fixed step there are only `2^n` different circuit matrices for `n` switches. The export inverts each one in advance, for the trapezoidal rule and for backward Euler. A step on the target then builds the right-hand side, multiplies by the matrix of the present switch states, and repeats that while a diode changes state. It never factors a matrix. The step follows the reference solver: backward Euler on the step after any switching, and the same switch rules. **Reading the reply.** - `worstCase` gives the multiply-adds of the slowest possible step: the solves (the switching-iteration limit) times the size of the matrix squared. Check that your target does that within one step. - `dutyResolution` is the step times the fastest PWM frequency of the circuit. The model reads the gates once per step, so an edge takes effect up to one step late. Keep at least 100 steps per switching period for 1 %. The reply warns below that. - `tableBytes` is the size of the stored matrices. - With `check`, `check.outputs` gives the largest error of every output, `check.maxSolves` the most solves a step took, and `check.hostStepNs` the time per step measured on this computer. When PWM edges fall between steps (sine-triangle PWM), a switched voltage or switch current is up to one step late at each edge, so its largest error is close to its full swing; judge the model by the smooth signals (inductor currents, capacitor voltages) instead. - With `check`, `timing.histogram` gives how many steps took each number of solves (1, 2, ...), ascending; the counts sum to `check.steps`. Most steps take one solve; only a step that changes switches takes more, up to `worstCase.solves`. - With the `fpga` param, `timing.fpga` gives an estimate — not a measurement; no FPGA or HDL export (#4265) was built or run — of whether the slowest step fits that clock, from the multiply-add budget below ("Notes for FPGA and commercial real-time targets"): `cyclesPerStep` is `worstSolves · ⌈unknowns² ∕ multipliers⌉ + latencyCycles`, checked against the `stepCycles` a step of `step` has at `clockHz`. `fits` says whether it does, and `note` says what the count leaves out (the right-hand side, and for a machine its sine, cosine and divisions). **Sources.** DC, sine, pulse, piecewise-linear (PWL, also repeating) and grid sources (with their harmonics and a sag or swell) are evaluated in the C at the end of every step with the same rules as the simulator, so a corner that falls on a step takes effect at that step. **Coupled inductors.** A coupled inductor carries both winding currents from step to step, like a single inductor carries its current. Its companion conductances depend only on the step and the integration method, so they are part of the stored matrices; the outputs `i(K.1)` and `i(K.2)` are its winding currents. **Saturating inductors.** An inductor with `isat` and `lsat` has two segments: `l` up to `isat` and `lsat` beyond. The simulator picks the segment of a step from the inductor's current at the last step, without iterating, so the model does the same: each saturating inductor is one more bit of the stored combinations, like a switch, and the reply lists them in `saturating`. A buck whose inductor crosses a 4 A knee dozens of times in 1 ms agrees with the reference solver within 4e-8 of each peak. An inductor on a linked catalogue core follows a continuous curve that no small set of stored matrices holds, so it has no real-time model. **Single precision (`numbers: "f32"`).** For a target with a single-precision FPU (most microcontrollers) or float IP on an FPGA, `numbers: "f32"` writes the C in `float` throughout: each stored matrix entry and companion conductance is rounded once from the double-precision model, time is the integer step count, and a sine source's angle is a 32-bit phase that wraps at a full turn, so neither loses resolution in a long run. The sine is a fixed polynomial in the C rather than the platform's `sinf`, and no multiply-add is fused, so the C gives the same bits as the host's own `f32` emulator wherever `float` is binary32 (`FLT_EVAL_METHOD` 0). The tables take half the bytes. With `check`, `check.againstF64` gives each output's largest difference between the `f32` form and the double-precision model on the same gates: on the buck about 3e-4 of the inductor current's peak, on the three-phase inverter about 3e-6 of the phase currents' peak. A sine source's frequency is rounded to a whole number of phase units per step (at 1 µs, 1.2e-4 Hz at most), so its phase drifts slowly from the double-precision model's. A pulse or piecewise-linear source is a table of straight pieces, each starting at the first step its corner reaches: a one-shot pattern counts steps, a repeating one a 64-bit phase that wraps once a period, so it keeps its period over any run (on the step grid its corners and levels are the double-precision values, rounded once). A grid source's fundamental and each harmonic have a 32-bit phase of their own, and its sag is in force on the steps from the first that reaches its start up to the first that reaches its end. The `f32` form takes switches, capacitors and inductors (saturating too), coupled inductors, DC, sine, pulse, PWL and grid sources, and PM machines with the shaft and its sensors: a machine's and a position sensor's angle is a 32-bit phase too, advanced each step by its speed and rounded to a whole unit (2⁻³² of a turn). A speed that a step changes by a small fraction of its size keeps few bits of that change in `float`: on a PM generator at 300 rad/s the speed drifts about 7.5e-4 of its value in 10 ms and the phase currents about 3e-3 of their peak. A diode bridge whose bleeder resistors leave every stored matrix entry near the same value (all about 200 Ω, differing by 1e-3) loses that difference in `float` and its diodes chatter: export such a circuit in double precision. **Block floating point (`numbers: "bfp24"`, `"bfp18"`).** For the multipliers of an FPGA's fabric, `bfp24` and `bfp18` are the `f32` form with the solve's stored matrices as block floating point: every entry is a 24- or 18-bit integer, and each row of each matrix shares one power of two. Each solve turns the right-hand side into 35-bit integers sharing one power of two, multiplies and sums in integers, in two slices of the right-hand side (its low 17 bits and the rest) so that each product fits a 25 × 18 DSP multiplier and its 48-bit accumulator (AMD UG479, DSP48E1), and rounds each row's exact sum once to `float`. The states and the rest of the step stay `float`, as do an interior machine's correction tables. The C gives the same bits as the host's emulator of the form. The tables take 4 bytes an entry and 2 a row. With `check`, `check.againstF64` gives the errors: on the buck `bfp24` keeps about 1.5e-4 of `v(out)`'s peak and 5.4e-4 of the inductor current's, the per-row 24-bit figures of the table below, and `bfp18` about 4e-3 and 1.5e-2. Holding the right-hand side at 18 bits instead of two slices makes the errors 30 to 160 times larger. `bfp18` can make a lightly damped circuit diverge (the half-bridge example does), which `check.againstF64` shows as an error larger than the peak: use `bfp24` or `f32` there. **The solve in Verilog (`tools.realtimeHdl`).** `tools.realtimeHdl {rhsExponent, numbers, multipliers}` writes the model's solve, `x = A·b` with the table of one switch combination, as plain Verilog-2005 (`_solve.v`, no vendor primitives) with the same `bfp24` or `bfp18` table words as the C. Each of the `multipliers` (`P`) reads its own block RAM, one word a cycle; a solve takes `N · ⌈N / P⌉` words plus 4 cycles of latency, which the reply gives as `cyclesPerSolve`. The right-hand side is `rhsBits` (default 18, the DSP48E1's narrow port, AMD UG479) integers, a word `β` standing for `β · 2^rhsExponent`: choose `rhsExponent` so the largest source and state of your circuit fit. Each output is `outputBits` (default 32) and saturates; `outputExponents` gives each unknown's scale. The core is checked bit for bit against its emulator in Verilator and Icarus. With the default `core: "solve"` the C model's step drives `table_sel` and `rhs`. `core: "step"` writes a whole step instead (`_step.v` with its solve core `_step_solve.v`): the gate and switch rules, the companions, the right-hand side, up to `S` solves and the state update, in fixed point. It needs `volts` and `amps`, the full scales (about twice the circuit's peaks: a value beyond them saturates and counts on the `saturated` port), and takes `bits` (default 24, 8 to 26) for every register. A step with `s` solves takes `fixed + s · perSolve` clock cycles, which `cyclesPerStep` gives for each method; `outputs` names each output's register and binary point, read through `rd_addr` and `rd_data`. The step core takes inductors, saturating inductors (`isat`, `lsat`: each is one more bit of the table selection after the switches', its segment picked at the start of each step from its current of the last step, as the model does; `saturating` lists them), coupled inductors (constant `l1`, `l2` and `k`; both winding currents are carried states, read as `i(K.1)` and `i(K.2)`), capacitors, sources of any waveform and the ideal switch, diode, MOSFET, IGBT, thyristor (SCR), IGCT, DIAC, TRIAC and GTO; any other part is an error that names it. A coupled inductor at a very short step (the flyback example's 20 ns) leaves the solve's entries small: raise `outputBits` if the reply asks for more. The `gates` port has one bit a model input (high above the gate threshold), then the gate terms that a TRIAC's and a GTO's rules read, which `gateTerms` lists with their bit, input, test and level: a GTO's turn-off bit is its input below minus the gate threshold, and a TRIAC's two firing bits are its input's magnitude above `igt` with a positive and with a negative sign (with the sign of its voltage they give the quadrant). Set each from its input's level, as you set the inputs' bits. A gate that is the circuit's own meter (the lamp dimmer's TRIAC and its gate ammeter) is no bit of the port: the core compares that meter's output register itself, which holds its value of the last step, as the simulator reads the meter, against the same gate threshold, `igt` or turn-off level, and `meterGates` lists each such bit with its output, register, test (`above` or `below`) and mantissa. There is nothing to set for it. In the lamp dimmer the TRIAC fires from its own meter in every half cycle; each firing comes within a few steps of the model's (11 steps in 10 000 at 1 µs and 400 V full scale), because the slow RC that times the DIAC sums the rounding of the 24-bit table words over thousands of steps. `numbers: "bfp28"` (core step and core solve) keeps the same rule with 28-bit table words, which no C model has: with `bits: 26` and `outputBits: 52` the dimmer's firings come within 2 steps of the model's. `numbers: "bfp32"` widens them to 32 bits: with `bits: 26` it needs `outputBits: 56`, and the firings come within 1 step. The step core takes solution words of up to 62 bits; a word wider than 52 bits is shifted down to its register with its own rounding (half up), and a core of at most 52 keeps the Verilog it had. The step core's registers (`bits`) go to 31, past the 26 of the machine core (a core with a PM machine keeps 26): with `numbers: "bfp32"`, `bits: 30` and `outputBits: 60` every firing of the dimmer lands on the model's step, and only the TRIAC's turn-off at its current's zero comes a step early, on 3 of 40 000 steps. With `fineCurrent: true` (core step) a switch with one terminal on ground, as the dimmer's TRIAC, reads its conducting current from its other terminal's solution word at a finer binary point instead of from its voltage register (one more operation a solve for each such switch, listed in `fineCurrentSwitches`), and those 3 turn-offs land on the model's step too. It is off by default: with `bits: 26` it moves the dimmer's second firing 2 steps late. Each product then takes more than one DSP slice. A DC source is a constant inside the core. A time-varying source (sine, pulse, PWL, grid) is a word of the `sources` input, source `k` at bits `k · bits`: before each `start`, set it to the source's value at the end of that step, at the binary point `sources` gives (the reply lists each one's register and point). `file.exportRealtimeHdl {dir}` writes the files into a folder. **PM machines and the shaft.** A surface or interior PM synchronous machine (`spmsm`, `ipmsm`) is a fixed-step machine model with its own states (stator current and flux, electrical angle, speed and torque), stepped together with the circuit with the simulator's own machine equations. Its constant winding conductances are part of the stored matrices, and its back-EMF and the torque of the last step are currents on the right-hand side. An interior machine's saliency turns with the rotor, so it cannot be stored; the model solves it exactly every step as a small correction of the stored solution (about `2·n + 20` more multiply-adds per solve), at most one interior machine per model. The shaft's inertias, frictions, springs, gears and speed sources are part of the circuit; fan, constant-power, gear-loss and vehicle loads take their torque from the speed of the last step; speed and position sensors are outputs, so the firmware reads `w` and `th` as it would read a meter. Hall, encoder and resolver sensors integrate the shaft speed into their angle as the simulator does, and their signals are outputs too: the three Hall levels, the encoder's A, B, index and count, and the resolver's sine and cosine. A switch gated by a Hall level reads it from the last step, inside the model. The outputs add `i(M1.a)`, `i(M1.b)`, `i(M1.c)`, `Te(M1)`, `wm(M1)`, `theta(M1)` and the dq current `id(M1)`, `iq(M1)`; `check` compares the angles modulo 2π. The PM drive example (`pmsmFoc`) exports with its six gates as the inputs. Its PWM and dead-time edges fall between steps, so its `check` differs by the gate sampling: at 1 µs the phase currents stay within about 1.6 A of the 8 A limit and shrink about ten times at 0.25 µs. **Gates driven by the circuit.** A gate that is the signal of the circuit's own meter (a TRIAC's gate ammeter, as in the lamp dimmer) is not an input: the model reads that meter from its last step, as the simulator does, and `switches[].meterGate` is true for it. **Two rates (`slowStep`).** The shaft changes over milliseconds while the power stage needs a step of a microsecond or less. `slowStep`, a whole multiple of `step`, splits the model at each machine's shaft: the electrical part (switches, windings and the network around them) steps at `step`, and the shaft part (inertias, frictions, springs, gears, loads and sensors) at `slowStep`. Before each slow step the shaft takes the mean electromagnetic torque of the fast steps since the last one; the fast steps see the shaft speed interpolated between the last two slow steps. The files are then `_fast.h/.c` and `_slow.h/.c`, each part's model, and `.h/.c`, the exchange that steps both with the same `_init`, `_step` and `_outputs` calls; on a target whose fast part runs elsewhere, run the exchange beside the slow part. `split` in the reply gives each part's unknowns, table size and outputs. With `check`, `check.againstSingleRate` gives each output's largest difference between the split and the single-rate model on the same gates. The torque reaches the shaft one slow step late, so the difference grows with `slowStep`: on the PM drive at 1 µs, a 10 µs slow step moves the speed by under 0.08 % of its peak and the phase current by about 0.1 %, and a 100 µs one about ten times that. An element that joins the shaft to the windings' network, or a gate driven by a shaft sensor, would put both parts in one algebraic loop and is an error that names it. A split model is double precision and takes no faults yet. **Limits.** At most 12 switches and saturating inductors together. Inductors on a linked catalogue core, nonlinear parts, machines other than PM synchronous ones (induction, dc, brushless dc, wound-field, reluctance, stepper) and reverse recovery have no real-time model; the error names the part. Losses and temperatures are not computed. The control blocks of the circuit are not part of the model: the firmware under test replaces them, and `tools.codeGeneration` writes them as C. **On the target.** No target was run in the tests; these notes say what each kind of target needs. - **A CPU real-time loop** (a real-time core, an RTOS task, Linux with PREEMPT_RT): call `_step` from a periodic task or timer interrupt at the step, read the gates just before it and write the outputs just after. Measure the slowest step on the target itself: `check.hostStepNs` is measured on this computer only, and `worstCase.macs` counts the multiply-adds of the slowest possible step, which is the figure to compare with the target's speed. - **An FPGA or a commercial real-time simulator:** the export is C in double precision; `tools.realtimeHdl` (above) writes the solve, or with `core: "step"` a whole step of a circuit of linear storage, sources and ideal switches, in Verilog. See "Notes for FPGA and commercial real-time targets" below for the table resolution, the multiply-add budget, the memory and the interface such a target needs; the `fpga` param budgets the slowest step against a clock from that same multiply-add formula (above, "Reading the reply"). **How it was checked.** The tests replay the reference solver's gates through the model. For the buck and the half-bridge, where every PWM edge falls on the step, every output agrees within 1e-6 of its peak; the measured difference is about 4e-8, the rounding of the stored waveforms. For the three-phase inverter, whose sine-triangle edges fall between steps, the phase currents agree within 1.1 % of their peak. The generated C, compiled with `cc -std=c99 -Wall -Wextra -Werror`, steps like the host model within 1e-9. ### As an FMU for co-simulation `file.exportFmu {path: "plant.fmu"}` packs the same model as an FMU (FMI 2.0, co-simulation) for system tools that co-simulate FMUs. It takes `step`, `prefix` and `maxSolves` as above, and `outputs`, a list of output names to expose (all of them by default). The gates are the FMU's inputs (on above 0.5, held through each communication step) and the chosen outputs its outputs; the outputs do not depend directly on the inputs at the same communication point, so connecting the FMU to a controller makes no algebraic loop. The FMU carries C sources, not a compiled library: the importing tool compiles `sources/` (`documentation/index.html` says how). A communication step that is not a whole number of model steps advances to the last whole step before it. Until the first communication step the outputs read the circuit's solution at the start time, fixed at export (`startValues` in the reply); from the first step on they follow the circuit. Each output whose quantity the model fixes carries its unit (`V`, `A`, `rad/s`, `rad` or `N.m`; `units` in the reply). `parameters`, a list of DC source names, makes each named source a tunable parameter of the FMU (unit `V` or `A`, start the source's value in the circuit) that the importing tool can set before the run and at any communication point; the source holds the new value from the next step on. The export is checked in FMPy, an open FMI importer: it validates the FMU, builds the sources and steps the buck example with its simulated gates, and every output follows Voltecx's own simulation within 1e-6 of its scale (`cargo xtask fmu`). With `fmiVersion: "3.0"` the same model comes out as an FMI 3.0 co-simulation FMU instead (FMI 2.0 stays the default): the archive adds `sources/buildDescription.xml`, the variables are `Float64`, value reference 0 is the independent variable `time`, the gates follow from 1 and the outputs after them, and `fixedInternalStepSize` is the model step; the FMU has no event mode and never returns early. Parameters and units work in both versions. FMU import is not in yet (#4402). ## Processor-in-the-loop **Tools › Processor-in-the-Loop** (`codegen.pil`) runs the firmware that `tools.codeGeneration` writes for the `stm32g474` target against the circuit's real-time model, both compiled with this computer's C compiler into one program, and compares the result with the circuit's own closed-loop simulation. A host stand-in for ST's LL headers plays TIM1 and ADC1: every PWM period ADC1 samples the plant's measured outputs at TIM1's trigger and turns them into 12-bit codes, the ADC interrupt runs the control step and writes `TIM1_CCR1`, and the preloaded compare drives the plant's gate from the next period, one plant step at a time. Then the circuit itself is simulated for as long. With `target` `f28379d` the same run uses the firmware written for the TI F28379D, against a host stand-in for C2000Ware's headers that plays ePWM1 and ADC-A: ePWM1 counts up, its SOCA at the counter's zero starts ADC-A, the ADC-A interrupt (reached through the PIE vector table the firmware's init fills) runs the control step and writes the shadowed CMPA, which drives EPWM1A from the next period. With a `deadtime` block, EPWM1A and EPWM1B carry the dead band, rounded up to TBCLK counts. On `buckClosedLoop` at a 10 ns step the output means are 11.9950 V with the F28379D firmware and 11.9932 V natively. | Param | What it does | |---|---| | `target` | `stm32g474` (default) or `f28379d`. | | `timerClock` | TIM1's clock (default 170 MHz) or, on the `f28379d`, EPWMCLK (default and at most 100 MHz). | | `periods` | PWM periods to run (default: the circuit's end time times the PWM frequency; at most 20000). | | `step` | The plant's fixed step (default: the circuit's maximum step; at least 10 steps per period). | | `fullScale` | Every ADC input's value at the code 4095. The default is 1.5 times the native run's peak of that input. | | `offset` | Every ADC input's value at the code 0, below `fullScale`. The default is minus the full scale for an input the native run takes below 0, such as a phase current, so it reads from mid-scale, and 0 for any other. The firmware reads it from `PC_CONTROL_OFFSET_k`, which defaults to 0 for your board. | | `precision` | The firmware's numbers: `float`, `double` or a Q format. | | `steadyPeriods` | The last periods the steady state is averaged over (default: a fifth). | | `waveforms` | Also return the per-period means of both runs. | | `supervisor` | The `supervisor` object of `tools.codeGeneration` (soft start, UVLO, OVP, OTP, restart). The firmware runs it: the run calls `pc_control_stm32g474_enable(1)` (or `pc_control_f28379d_enable(1)`) after the init. On the `stm32g474` ADC2's injected ranks convert its measurements after the control's, and outside SOFTSTART and RUN its `LL_TIM_DisableAllOutputs` (MOE clear, RM0440 29.6.20) holds every gate low. On the `f28379d` ADC-A's SOCs after the control's convert them, and a one-shot trip (TZFRC[OST], cleared by TZCLR[OST], SPRUHM8K 15.11) holds every ePWM output low. The native run has no supervisor, so compare the steady state after the soft start. On the `stm32g474` the cycle-by-cycle current limit runs too: give `iTrip`, `ocpThreshold` and `supervisorSignals.current`, the plant output (in A) the sense reads, such as `i(L1)`. COMP1 compares that current times `ocpThreshold / iTrip` with DAC3's threshold (the firmware's code for a 3.3 V reference, 10 mV of hysteresis), TIM1's channel 5 blanks it, and its output is TIM1's break input: the break clears MOE at once and sets BIF, and AOE sets MOE again at the next update event once the current is below the threshold (RM0440 29.3.18, 29.6.20). On the `f28379d` the same three parameters run it through CMPSS1: its high comparator compares the sense with its DAC, `(1 + DACHVALS) · 3.3 V / 4096` (SPRUHM8K equation 16), with the hysteresis the firmware sets, COMPHYSCTL[COMPHYS] = 1: the output rises above the DAC's level and falls 12 DAC LSB (about 9.7 mV) below it (TI SPRS880P 6.10.2.1.1 and figure 6-44), CTRIPH goes through the ePWM X-BAR's TRIP4 to every module's DCAEVT2 (held off during the digital compare's blanking window from CTR = ZERO when `blanking` is given), and DCAEVT2 sets the module's cycle-by-cycle trip: EPWMxA and EPWMxB stay low until a CTR = ZERO without the event, and TZFLG[CBC] tells the firmware the period was limited (SPRUHM8K 15.11). The reply's `supervisor.ocp` gives the comparator (`COMP1` or `CMPSS1`), the threshold, the trip current the DAC code gives, the comparator's hysteresis `hysteresisV`, and `limitedPeriods`, the periods in which the limit acted. | | `supervisorSignals` | The plant output each measurement reads, for each one the supervisor has a threshold on: `{"vin": "v(VIN)", "vout": "v(VOUT)"}`, or `temp`. The scale is the supervisor's `vinFullScale`, `voutFullScale` or `tempFullScale` (with `tempOffset`), else 1.5 times the native run's peak from 0. | **Reading the reply.** `steadyState` gives each measured signal's mean over the last periods in both runs and their difference, the mean of the PIL's ADC samples (`sampled`), and the commanded, effective and native duty. `transient` gives the largest and RMS difference of the per-period means over the whole run. Expect a small steady-state difference: the firmware regulates the sample at the start of each period rather than the average, the ADC rounds it to one LSB, and the plant reads the gate once per step. On `buckClosedLoop` at a 10 ns step the output means are 12.0031 V with the firmware and 11.9999 V natively, 3.1 mV apart. **Limits.** One `pwm` block that drives every gate input of the plant, directly or through `deadtime` blocks (CH1 and CH1N, or EPWM1A and EPWM1B, with the timer's one dead time). Its carrier may be a sawtooth or a triangle, and a `pwm3` block drives three legs: TIM1's channels 1 to 3 on the `stm32g474` (CH1 to CH3N), or ePWM1 to ePWM3 in step with ePWM1 on the `f28379d` (EPWM1A to EPWM3B). On a triangle the counter counts up and down; TIM1 loads its compares at both ends (TIMx_RCR = 0), so a duty the interrupt writes drives the gates from the middle of the period, while the F28379D loads CMPA at the counter's zero only, so the new duty starts with the next period. The reply's duty is channel 1's. On the `f28379d` a second to eighth `pwm` block at the same frequency and carrier run on ePWM2 to ePWM8 (EPWM2A to EPWM8A), each counter starting at its carrier phase (TBPHS) when ePWM1 passes zero (ePWM4 and ePWM7 take ePWM1's sync through SYNCSELECT) and loading its own CMPA at its own zero. On the `stm32g474` a second `pwm` block at the same frequency and carrier runs on TIM8's channel 1 (TIM8_CH1 and TIM8_CH1N), its counter preset to its carrier phase and started by TIM1's (slave trigger mode), loading its own CCR1 at its own update events; a third is refused. On the `f28379d` the code must run every PWM period; no supervisor yet. On both targets the ADC scales a code from `offset` at 0 to `fullScale` at 4095, so a signal that goes negative, such as a phase current, reads from mid-scale. The `f28379d` header gives each SOC a `PC_CONTROL_OFFSET_k` beside its `PC_CONTROL_FULL_SCALE_k`, as the `stm32g474` header gives each rank, both 0 at the code 0 by default for your board. The STM32G474's ADC1 injected group converts four inputs; a fifth to eighth are ADC2's injected ranks 1 to 4, started by the same TIM1 trigger and read by the same interrupt (`PC_CONTROL_ADC_CHANNEL_5` to `_8` name their ADC2 channels), so at most eight. A supervisor whose UVLO, OVP or OTP measures on ADC2 then fits only with four control inputs or fewer, and is refused by name otherwise. The F28379D's ADC-A converts eight inputs; a ninth and later go on ADC-B's pins (ADCINB0 to B5), then ADC-C's and ADC-D's, each started by ePWM1's SOCA with ADC-A, and the ADC-A interrupt waits for their ADCINT1 flags before it reads them. The stand-in converts on all four ADCs, so at most 24. An input that is an `encoder` part's `count` takes no ADC rank: the firmware reads it from TIM2's 32-bit counter in quadrature encoder mode (four counts per line, read as a signed count; a second encoder uses TIM5), and the run writes the plant's count into that counter at the ADC's trigger. The reply's `counters` lists them (`field`, `signal`, `timer`). So a drive that reads three phase currents and turns the encoder count into its angle fits. An input that the controller's own `step` block writes, such as a speed reference, is a time source the code generator leaves to the target; the run drives its ADC pin as a signal generator on the bench would, with the step's `before` value until the first plant step that reaches `t0` and its `after` value from then on, and the reply's `adc` entry names the block in `reference`. Another source of simulation time (a `sine`, for example) is refused by name. So `pmsmFoc` itself runs on both targets, its six inputs (the speed reference, the speed, three phase currents and the rotor angle) on ADC-A of the `f28379d`, or on ADC1's four injected ranks and ADC2's first two on the `stm32g474`. Over 200 ms at a 200 ns step its speed settles at 189.79 rad/s on the `stm32g474` and 189.80 rad/s on the `f28379d`, against 189.76 rad/s natively. Its `pass` stays false because the phase currents average near 0 A over the window, where the relative error measures nothing; compare `w` instead. On the `f28379d` the count comes from eQEP1's 32-bit position counter (QPOSCNT) in quadrature-count mode, four counts per line and read as a signed count, and a second encoder uses eQEP2; the project's `main` muxes their pins with C2000Ware's `InitEQep1Gpio` and `InitEQep2Gpio` (GPIO20 to 23 and GPIO24 to 27), so the ISR timing pin can't be one of those, and `timer` names eQEP1 or eQEP2. An encoder count needs `float` or `double` firmware. The compiler, the FPU and the interrupt's timing are this computer's, not the MCU's, and the conversion is taken as instant. Without a C compiler (or in the browser) the command answers an error that says so. ## The board canvas **Board > Open Board** opens the project's board (the `.vxpcb` a project gets from **Add Board**) in its own window. The layer panel on the left lists the copper layers top to bottom, each in its own colour: the check box shows or hides a layer, and a click on its name makes it the active layer, where new tracks go. Under the layers, **Non-active layers** sets how the copper layers other than the active one are drawn: **Normal** (each in its own colour), **Dim** (faint, so the active layer reads on top) or **Hidden** (only the active layer; items on the others cannot be picked by a click or a box). **Ctrl+H** over the board steps through the three; it is the Control key on macOS too. Further down, **Nets** lists every net on the board in its ratsnest colour: clear a net's box to leave its tracks, vias, zones, pads, fills and airwires undrawn and unpickable (a footprint stays, as it holds pads of other nets too), and **Show all nets** turns every net back on. The properties panel below it shows the selected item. - **Select**: click an item to select it (Shift adds or removes one) and drag it to move it onto the grid. **R** turns the selection 90°, **F** flips it to the other face (its copper goes to the mirrored layer), **Delete** deletes it. A locked part is never moved. - **Track**: click the points of a track on the active layer, then press Enter or double-click. **Via**: click to place a through via. - **Width**, **Diameter** and **Drill** left at 0 take the sizes of the net's class in the board's rules; when the rules have none, the window says so and asks for one. The **Board** menu, and the bar along the top of the board window, take the board from parts to fabrication files in order: **Add Footprints** (`board.addFootprints`), **Add Connectors** (`board.interfaceConnectors`, applied), **Add Test Points** (`design.debugAids` with only its test points, applied, then `board.addFootprints`: a test point on each switch node, gate, rail, current-sense end, ground, ADC input, feedback divider tap and PWM pin (every key net Place Test Points reviews), with a probe ground beside the ones that want a short one, put on the schematic first, then the footprints of them and of the connectors; a net that has a test point already gets none, so a second click adds nothing), **Auto Place** (`board.autoPlace`), **Place Test Points** (`board.testPoints`, applied), **Auto Route** (`board.autoRoute`), **Power Pours** (`board.groundPlan`, applied: the ground plan's copper pours for the power nets, each switching node's held to the pads of its switches, diodes and inductor, with the plan's ground checks measured on the routed board), **Fill Zones** (`board.fillZones`), **Place Labels** (`board.placeReferences`, then `board.addTitle`: each reference designator beside its part, and the board's name and revision), **Service Check** (`board.serviceCheck`, applied: each test point's net name, each pluggable connector pin's and each outer pour's on the silkscreen (a pour too small to hold its name gets it beside the pour, outside it and touching its edge), the ground net reading GND, each label's letters clear of every part's courtyard and never nearer another part than its own; the status bar counts the labels placed and the service findings, which **Check Board** lists), **Check Board** (the design rule check `board.drcRun` and the layout review `board.layoutReview`; each is also on the menu by itself), **3D View** (`board.view3d`, drawn live in a window) and **Export Fabrication Files** (`board.exportFab`, Gerber X2 and drill files in `fab/`). The steps take one row of their own, which a window 1440 px wide holds whole and a narrower one wraps between buttons; **Open as Tab** and the **Fab** picker are on the row under them. Each runs the engine command of the same name, opens the board window if it is closed and says on the status bar what it did. A greyed button needs an open circuit, or waits for a job in progress. After **Check Board** the side panel lists the design rule violations (with their markers on the board) and, below them, the layout review's findings; a click on a row selects the items it names and zooms to it. **3D View** opens a window with the board in 3D: drag to orbit, right-drag to pan and scroll to zoom; **Copper**, **Solder Mask**, **Silkscreen** and **Part Bodies** show or hide each layer (with the mask hidden, the copper and the laminate under it show bare), **Show Bottom** and **Show Top** look from the other side, **Reset View** frames the board again, and the lines under it name each part drawn without a body and why. **Board > Export STEP** (`board.exportStep`) writes the assembled board as a STEP file for mechanical CAD (chapter 22, section 8). **Board > Open Board as Tab** (or **Open as Tab** on the bar) puts the board in the editor area in place of the schematic, with a **Board · name** tab beside the circuits' tabs; a circuit's tab brings the schematic back, the board's tab brings the board back, its × closes the board and **Open in Window** floats it again. When the board is a tab narrower than the thirteen buttons need (a 1280 or 1024 px window), the bar groups them into three menus by stage, beside **Open in Window** and the **Fab** picker: **Placement** (Add Footprints to Place Test Points), **Routing** (Auto Route, Power Pours, Fill Zones) and **Finishing** (Place Labels to Export Fabrication Files). Each item works as its button does, greyed with the same reason. In the same narrow tab **Board temperature**, **Current density** and **Near field** go into one **Overlays** menu, and the hint under the toolbar keeps to one line (hover it for the whole text), so the canvas keeps about three quarters of the tab. The side panel on the left scrolls with a bar that stays drawn whenever its rows run past the window. The switch at the top right of the board canvas shows the board in **2D**, in **3D** or **2D + 3D** side by side (keys **2** and **3** while the board window has the focus). Both views are the same board: a part selected on either is selected on the other and on the schematic (a click on a part in 3D picks it, Shift adds or removes it, a click on nothing clears the selection), the parts selected on the schematic show dashed in both, and panning either view moves the other so both look at the same point; **Fit board** fits both. The 3D view needs the desktop app's GPU renderer: in the browser its choices are greyed and say why. If the board cannot be drawn in 3D (a stack-up layer with no thickness), the 3D view says why in its place. With **View > Studio Layout (Preview)** on and the board as the document in front, the board window's rows of buttons give way to the menus and an icon tool strip, as in KiCad's and Altium's board editors. **Route** (after **Design**) holds **Route Tracks** and **Place Vias** (the canvas tools), then **Auto Route**, **Power Pours**, **Fill Zones** and **Stitching and Thieving**. **Design** starts with the board's steps (**Add Footprints**, **Auto Place**, **Place Test Points**, the outline, **Stack-up…**, **Rules…**, **Check Board**, **3D View** and the fabrication exports), then the circuit's design steps after a line. The strip over the top of the 2D canvas picks **Select**, **Route**, **Via** or **Measure**; each icon names its tool and key in its tooltip. While **Route** or **Via** is in use, the tool's settings sit at the top of the side panel instead of a row over the board, as in KiCad's and Altium's interactive router: the title names the track's net (**Routing · net VOUT**), then **Net**, **Mode** (**Walk around**, **Shove** or **Highlight**, which goes straight through and outlines what the track collides with), **Width (mm)**, the via's **Diameter (mm)** and **Drill (mm)**, the **Layer pair** that V moves between (the active layer and the next copper layer), and **Corners**. Each size shows what the tool uses: the net class's, marked **from the net class**, until you type one of your own (0 goes back to the class's); a size neither sets reads **—** with **Not set in the rules**, since the router needs one. Undo and Redo are on **Edit**, and Rotate, Flip, Delete, Fit and Find on their keys. The view options (grid, board temperature, current density, board look and the DRC markers) stay on one row above the board. With the studio off, or another document in front, the menus and the board window are as before. In the studio, **Stack-up…** and **Rules…** (from **Design** or the side panel) open one **Board Setup** window instead of two dialogs beside the board, as KiCad's and Altium's board setup does. The list down its left picks the page: **Stack-up**, **Board finish**, then **Board limits**, **Net classes**, **Class patterns**, **Rule areas** and **Solder mask / paste**, **Pre-defined sizes**, **Violation severity**, and last **Fab preset**. Each rule page is the editor described below and makes the same edits; one page shows at a time, the one opened last. **Fab preset** picks the fab the board is made at, the same choice as the board's **Fab** box: **Board rules only**, or one of the built-in profiles (JLCPCB, PCBWay, OSH Park). Under the pick it lists that fab's published limits (track, clearance, drill, annular ring, aspect ratio, hole to hole, edge clearance, mask web, via plating, silk text height and stroke, and whether vias in pads are filled and capped), each **Not stated by the fab** where the fab's page gives none, and the page and date they were read from. The design rule check and **Auto Route** hold to the stricter of these limits and the board's own rules. **Board finish** keeps what the fab is asked for besides the images: the **Copper finish** (HASL SnPb, HASL lead-free, immersion tin, nickel or silver, ENIG, ENEPIG, hard gold, OSP, HT_OSP, or none, bare copper), and whether the board has a **Plated board edge**, an **Edge connector** and a **Bevelled edge connector**. Each starts **Not set** and is one undo step (`board.setFinish`), kept in the board file; **Export Fabrication Files** writes each value set into the Gerber job file (`Finish`, `EdgePlating`, `EdgeConnector`, `EdgeConnectorBevelled`, as the Gerber Job Format 2020.08 names them) and leaves out what is not set. No check reads them. **Pre-defined sizes** keeps the board's list of track widths and vias (diameter and drill, in mm) to pick from while routing: type a size and press **Add**, or **Remove** a row. Each change is one undo step (`board.setPredefinedSizes`) and is kept in the board file; none is filled in, so take them from the fab's capability sheet. The design rule check and the net classes keep their own values. **Violation severity** lists every rule of the design rule check with how its violations count: **Error** (the default) fails the check, **Warning** lists them among the check's warnings while the board still passes, and **Ignore** leaves them out and only counts them. A pick is one undo step (`board.setRuleSeverity`) and is kept in the board file; Auto Route and the checks an edit runs still see every violation. With the studio off the two dialogs open beside the board window as before. **Board > Stack-up…** (or **Stack-up…** beside the layer panel's heading) opens the board's stack-up beside the board window: every layer top to bottom, as `board.stackup` reads it, with its name, type (signal, plane or mixed for copper; core or prepreg for a dielectric), thickness in µm, copper weight in oz, Dk, loss tangent and material. Enter applies a field as one `board.setLayer` (one undo step); an empty field clears the value, since Voltecx never assumes one. **Add Copper Layer** (`board.addLayer`) adds a signal layer with a prepreg under it above the bottom layer, and **Remove** on a copper row (`board.removeLayer`) takes it out with its dielectric, refused while an item is on it. The line under the table gives the copper count and the total thickness, or names the layers that have none; an odd copper count is a warning with a button that adds a layer, never an error. **Board > Update from Schematic** (`board.updateFromSchematic`) brings the board up to date after you change the schematic, as KiCad's Update PCB from Schematic does. It lists every change first: a footprint whose part you deleted is removed (its tracks stay, for the design rule check to report), a renamed part's reference follows it, the do-not-populate mark follows the part, a pad whose pin moved to another net takes that net, and a net you renamed is renamed on its tracks, vias, zones and net class. Nothing is placed or moved and no copper is drawn. A part that has no footprint yet is listed too, for **Add Footprints**. The changes are one undo step; a board already in step is left as it is. The menu item (and **F8** while the board is the document in front in the studio) opens the change list as a dialog: one row per change with a tick, the kind of change, the part or net, and what changes. Untick a row to leave it out; **Apply Changes** writes the ticked rows as one undo step and lists what is left, and **Check Again** reads the schematic afresh after you edit it. A part with no footprint has an arrow instead of a tick: **Add Footprints** places it. Every edit is a command (`board.move`, `board.rotate`, `board.flip`, `board.addTrack`, `board.addVia`, `board.delete`), so the command line and the assistant can do the same. **Undo** and **Redo** in the window, or Edit > Undo while it has focus, step through the board's own history. **Board look** (on by default, in the window's bar) draws the board as its picture (`board.picture`): a black background, top copper red, bottom copper blue, silkscreen yellow, the board edge and keep-outs magenta, vias as rings with their hole, pours tinted and hatched so the tracks over them stay visible, and each pad labelled inside with its number and net (`1 GND`, or `1` over `GND` on a small pad). **Theme** beside it switches to `kicadLike` colours or to `print` (dark ink on white paper, as the assembly drawing is printed); the colours and sizes live in a theme file (`crates/board/themes/board-picture.json`), never in the program. The window draws the board in its own plain colours while a layer is hidden, a part is dragged or the temperatures are shown. `board.picture {image: "board.png"}` (or `svg`) writes the same picture to a file. What the picture shows comes from the board itself, so a readable board has: part names (`board.serviceCheck {place: true, apply: true}`), part outlines (`board.addOutlines`), `+ IN -` polarity marks and pin-1 dots (`board.markPolarity`), a title (`board.addTitle`), its width and height on the fab layer (`board.addDimensions`) and each pad's number and net on the fab layer (`board.labelPads`). The silk sizes come from the command or from the silk the board already has; Voltecx never makes one up. ## Simulate from the command line `powercraft-cli sim` opens a circuit file, runs it, prints measurements and checks them, all in one command. It is meant for scripts and for continuous integration, where the exit code says whether the design still meets its numbers. ```sh powercraft-cli sim buck.voltecx --set Vin.v=24 --tend 5m \ --measure 'mean(v(out))' --expect 'mean(v(out)) in 5.7..6.3' --png buck.png ``` FILE is a `.voltecx`, `.asc` (LTspice), `.plecs`, `.psimsch` (read only) or SPICE netlist (`.cir`, `.net`, `.sp`). It is imported by path, so `.include` and `.lib` lines are followed. The files it may read are those below the folder of FILE, or below the folder you give with `--root DIR`. Options, each of which may be repeated where it makes sense: - `--set PART.PARAM=VALUE` sets a parameter before the run, for example `R1.r=2k`. SI prefixes work. An unknown part or parameter is an error. - `--tend TIME` sets the end time of the run, for example `5m`. - `--measure 'FUNCTION(SIGNAL)'` prints a measurement, for example `mean(v(out))`. The functions are `mean`, `rms`, `min`, `max`, `pp` (peak to peak), `last` (the final value), `thd` (total harmonic distortion in percent) and `freq` (frequency in hertz). Add a time window with `mean(v(out), 2m, 5m)`. The signal names are the ones the scope shows. - `--expect 'MEASUREMENT LIMIT'` checks a measurement. The limit is `in A..B`, `< X` or `> X` (`<=` and `>=` also work), for example `mean(v(out)) in 11.9..12.1` or `max(i(L1)) < 8`. Numbers take SI prefixes. - `--csv OUT.csv` writes every signal to a CSV file, and `--png OUT.png` writes a picture of the waveforms. With `--measure` or `--expect` the picture shows only the signals you measured. - `--json` prints one JSON object instead of text. It holds the measurements, the expectations (each with `pass`), the warnings and an `error` with a `code` and a `message`. - `--strict` makes warnings a failure. The warnings come from the import (for example an ignored directive) and from the simulation. Without `--measure` and `--expect` the command prints the signals the run recorded, which is a quick way to find their names. A line of the default output looks like `v(out) mean = 12.01 V`, and an expectation prints `PASS` or `FAIL` before it. Warnings go to the error output. Exit codes: | Code | Meaning | |---|---| | 0 | The run finished and every expectation held | | 1 | FILE could not be read or imported, or an output file could not be written | | 2 | Bad arguments, including a signal that does not exist or cannot be measured, or a time window that ends after the run (the message names the run's end time) | | 3 | An expectation did not hold | | 4 | The simulation failed: it did not converge, the circuit has a problem, or the run needs too many steps | | 5 | There were warnings and `--strict` was given | If several things go wrong, the code of the first one in this order is returned: a failed run (1, 2 or 4), then a failed expectation (3), then warnings (5). --- # 14. Preferences and saving your work URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/14-preferences-and-saving/ ## Preferences Choose **Edit > Preferences** (**Cmd+,**). One window holds the settings you pick once and expect to stay: | Setting | Choices | |---|---| | Language | Follow system (the default on a new install: the system's preferred language at each start), English or 繁體中文 | | Theme | macOS (follow system, on a Mac only), Follow System, Light Modern, Light+, Dark Modern, Dark+, Dark High Contrast or Light High Contrast | | Schematic colours | Classic (textbook colours) or Ink (all ink, blue control signals) | | Grid spacing | 1, 2, 5 or 10 units. Parts and wire corners snap to it (also **View › Grid Spacing**) | | Wires follow moved parts | On (the default): a part you drag keeps its wires. Off: a dragged part lets go of the wires to parts that stay behind, and **Alt+Shift** (Option+Shift) held during the drag keeps them that once (chapter 3) | | Minimap | Shows or hides the minimap on the schematic (chapter 3) | | Minimap on large circuits | Shows the minimap by itself on a level with more than 60 parts (on by default) | | Interface scale | Makes all text and controls larger or smaller, for a projector or a sharp screen | | Show launch screen | On (the default) or off: the launch screen while the app starts (chapter 2) | | Show the Start page when no circuit is open | On (the default) or off: the Start page, or an empty canvas that names **File > New Circuit** (chapter 2) | | Reduce motion | Off (the default) or on: nothing in the app animates. The launch screen, the Start page, spinners, check boxes and collapsing sections hold still or change at once. The system's own Reduce motion setting does the same | | Use window translucency | On a Mac only. On (the default) or off: the macOS theme lets the desktop show through the side bars, the toolbar and the panels | | Autosave | On or off, and the interval in seconds | | After each run | Keep in the dock, Whole scope in one window (the default: a run opens the scope's own window, as PSIM opens SIMVIEW) or Each plot in its own window (a run opens each plot in a window, tiled on the screen) (chapter 5) | | Echo menu actions in the console | On or off: a click in a menu also shows the command it runs in the console (chapter 13) | | Check for updates once a day | On or off (chapter 1). Voltecx never installs an update by itself; **Download page** opens the website's download page. The update window has the same switch, and **Help > About Voltecx** says when a newer version is out, with **See what's new** | There is no Apply button. A change takes effect in the next frame, and Voltecx remembers it for the next start. Most of these settings are also in the **View** menu. Press **Esc** to close the window. ![The Preferences window, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/preferences/01-prefs.png) 1. Language. 2. Theme. 3. Autosave. 4. After each run. A line names the settings folder, where Voltecx keeps the session and the recovery copies. The **Assistant** section sets up the agent panel (chapter 12): the API key (pasted once, kept in the system's credential store, shown only as `sk-ant-…` and its last four characters, with Save, Remove and Test), where the key in use comes from (the credential store or `ANTHROPIC_API_KEY`, which wins when set), the model, **Ask Assistant sends questions to** (the built-in panel, or Claude Code in the Terminal; chapter 12), and **Save assistant chat in circuit files** (on by default). The key is never part of the settings file. The model and the chat setting are saved with the other settings. The **Privacy** section holds one switch, **Send anonymous usage statistics and crash reports**. It is off unless you agree. While it is off nothing is recorded, saved or sent. **Show what is sent** lists every event that is waiting to be sent, and **Delete queued events** throws them away. A version of Voltecx that collects no statistics says so here instead. The first-run screen asks the same question (chapter 1). ![The end of Preferences, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/preferences/02-privacy.png) 1. The update check: **Check for updates once a day**, or, in a version that never checks (as here), a line that says so. 2. The Privacy switch. 3. The list of what is waiting to be sent, empty here. **Input and shortcuts** lists every key binding, grouped as in **Help › Keyboard Shortcuts**. Point at a row and click **Change**, then press the new keys (Esc cancels); **Reset** puts a changed key back, and **Show changed (N)** keeps only the keys you changed. Keys another command already has are refused under the row, which names that command and its menu. Your key bindings (chapter 3) are saved with the same settings. On a Mac, a key that macOS keeps for itself (Cmd+H hides the app, Cmd+M minimises the window, Cmd+Tab switches apps) cannot be bound, and **Input and shortcuts** warns about any of your bindings that use one, with **Show keys** to change them. **Editor** ends with a link to the scroll wheel setting, which lives under **Input and shortcuts**. The **Account and licence** section has **Compare plans**, which opens the website's plans, while the free trial runs or no licence is installed. The **Assistant** panel, before a key or a sign-in is set up, says what the assistant can do (explain a waveform, fix what Problems reports, tune a value to a target, design a converter from a sentence) above its setup card. The colour themes are VS Code's default themes. **Follow System** draws Light Modern or Dark Modern as your operating system is set, and switches when the system does. On a Mac, **Follow macOS** is the theme a new install starts with (an existing settings file keeps the theme it holds). It draws the Mac's own light or dark greys as the system is set and switches with it, colours buttons, selections and focus rings with your accent colour (System Settings › Appearance; Voltecx makes it darker or lighter where text on it would be hard to read), and draws interface text in the system font, San Francisco, read from the system and not shipped with Voltecx (Chinese text keeps the bundled font). The window's content runs under the title bar: the window buttons sit at the left of the toolbar, a drag on an empty part of the toolbar moves the window, and a double click there zooms it. While **Use window translucency** is on, a window material (Liquid Glass on macOS 26 and later, the sidebar and title-bar materials before) shows through the toolbar, the activity bar, the side bars and the panels; the schematic, the plots and the text fields stay opaque. The translucency is light on purpose: every text colour keeps at least 4.5:1 contrast whatever the wallpaper behind the window. **Reduce transparency** (System Settings › Accessibility › Display) turns it off, and **Increase contrast** draws the theme as Dark or Light High Contrast. A change to the accent colour or to these settings shows within a second of the next thing you do in the window. You can also pick a theme the way VS Code does: open Quick Open (**Cmd+K**), run **View › Appearance › Color Theme**, and move through the list with the arrow keys. Each theme is shown as you reach it. **Enter** (or a click) keeps it, and **Esc** puts back the theme you had. The high-contrast themes also draw the schematic in stronger colours. ## Autosave and recovery Voltecx copies a circuit with unsaved changes to a recovery folder a few seconds after each edit. The default interval is 5 seconds, and you can change it in Preferences, from 1 second to 1 hour. Switch autosave off with the checkbox. The autosave does not replace your file. It is a separate copy. - Saving the circuit, or undoing back to the saved state, removes its recovery copy. - Closing a circuit with unsaved changes (**File > Close**, Cmd+W), quitting (**File > Quit**, Cmd+Q) or closing the window asks **Save changes to "name" before closing?** for each such circuit. **Save** saves it (Save As for a circuit that has no file yet). **Don't Save** closes it and deletes its recovery copy. **Cancel** keeps everything open and stops the quit. - If the app ends without asking (a crash, or an agent's `app.quit`), the copies stay in place on purpose. - At the next start, Voltecx says it found circuits with changes that were not saved, and asks **Restore unsaved work?** **Restore** opens the copies. **Discard** deletes them. - Without any recovery copy, Voltecx reopens the tabs of your last session from their files. It remembers the open tabs, the active one, each tab's zoom and position, the panel layout, the theme, the language, your key bindings and the recent files. The settings, the session and the recovery copies are in one folder: `~/Library/Application Support/PowerCraft` on a Mac, `%APPDATA%\PowerCraft` on Windows, and `~/.config/powercraft` (or `$XDG_CONFIG_HOME/powercraft`) on Linux. The Mac and Windows folders keep the product's old name so that existing settings, sessions and saved keys are found after the rename to Voltecx (the keychain entry also keeps it). Start the app with `--config-dir DIR` (or set `POWERCRAFT_CONFIG_DIR`) to use another folder, and with `--no-session` to start without restoring the last session. The window title and the menu bar show the active circuit's name and its file, with a dot (•) in front while it has unsaved changes. ## Several windows Each Voltecx window is a separate copy of the program, so you can put two circuits side by side or on two monitors. - **File > New Window** (Cmd+Shift+N) opens an empty window. - **File > Open in New Window** asks for a circuit file and opens it in a new window. - **File > Move to New Window** closes the active circuit here and opens its file in a new window. Save the circuit first: the new window gets only what is in the file. - **View > Detach Scope** shows the scope in a window of its own, as SIMVIEW sits beside the schematic in PSIM. The schematic window keeps the canvas. Close the scope window, click **Dock Back**, or choose the item again, to put the scope back below the canvas. While the scope window has focus, the scope's keys and F5 act in it; the other shortcuts act in the schematic window. The scope window opens where you left it (chapter 5). - **View > Enter Full Screen** (Control+Cmd+F on a Mac, F11 elsewhere) fills the screen with the window, and the same key leaves full screen. The key also works in a detached scope window, for that window. On a Mac it is macOS’s own full screen, the same as the green window button and Fn+F. Voltecx does not remember full screen for the next start. The windows share the settings folder, but each keeps its own session and recovery copies, so they never overwrite each other. The first window reopens the tabs of your last session. A window opened next starts with the first window's preferences and recent files, and with no circuits. If a window closed with unsaved changes, or crashed, the next window you open offers its recovery copies. A circuit file can be open in only one window at a time. Opening it, or saving over it with Save As, in a second window says **is already open in another Voltecx window**. Use the window that has it open, or close it there first. A window started with `--no-session` does not take part in this check. ## The last result comes back After a restart, you do not have to run the simulation again to see the scope. The desktop app keeps the last result of the active circuit in a `results` folder beside the session file, and brings it back when you open the same circuit again. The result is stored under a fingerprint of the circuit text. It comes back only for a circuit that is exactly the same. If you changed even one value, Voltecx starts clean and never shows a stale result. The folder is limited to 20 MB, and the oldest results go first. A result with values that are not numbers is not kept. ## Preview features A feature that has not passed its release checks yet ships as Preview. Today that is the field solver (its commands are `magnetics.fieldSolve`, `magnetics.fieldCoreLoss`, `geometry.*` and `field.*`; they arrive in later versions). **Edit > Preferences > Preview features (field solver)** allows them. It is off in release builds and on in development builds. While it is off, those commands are refused with a message saying where to turn it on, and their items in **Design › Field Solver** stay in the menu, greyed out, with the same hint when you hover them. A Preview result says so: its reply carries `preview: true` and a note in English and Traditional Chinese for reports and exports to show. The CLI and scripts use `preview.set {"enabled":true}`. ## Keep the simulation in step with the board **Edit > Preferences > Simulation > Keep the simulation in step with the board** is off by default. With it on, Voltecx waits until a board edit has settled (one second with no further edit, so a drag or a run of quick edits counts once) and then runs `layout.syncBoard` on the open project's board. Undo and redo on the board count as edits. The command reads each power loop's inductance and each switching node's capacitance from the board again and compares them with the stray parts in the circuit (`Lpcb1`, `Cpcb_sw_gnd`, ...). Only the parts that moved, and new ones, are written, as one undo step, and the simulation runs again. When nothing moved, nothing is written or run, and the status line says the simulation is in step with the board. When something moved, the **Board Sync** window lists each stray part with its value before and after and how much it changed. A stray part that the board no longer gives is kept and named there, so you can delete it if the loop is really gone. The sync waits while a simulation or another job runs, and starts after it. ## Memory A run can be large: one result of a 0.3 second FOC drive took about 120 MiB when it was measured. The desktop app keeps the waveforms of the newest earlier runs in memory and parks older ones in a folder of its own. **Edit > Preferences > Earlier runs kept in memory** sets how many stay (0 to 9, 3 by default, within 64 MB). Comparing or overlaying a parked run reads it back. A run you tagged stays in memory. Sweeps, Monte Carlo, optimise, sensitivity, worst case and tune to spec record only the signals they measure. Before a simulation starts, Voltecx estimates the memory its recording needs. When that is more than 60 percent of the free memory, the run is refused and the message lists what to change (the print step, **Save from**, fewer probes). **Run Anyway** starts it regardless. Between 30 and 60 percent the run starts with a warning. While a run goes, a watchdog stops it, as Cancel does and keeping the samples so far, when the memory held reaches 80 percent of the RAM or less than 2 percent is free. The solvers compute in 64-bit numbers, but a recorded waveform stores its values as 32-bit numbers (4 bytes a sample) on a 64-bit time axis. ## In the browser The browser version has no files of its own (see "Files in the browser" below), so it saves unsaved circuits into the browser's own storage (`localStorage`) instead. The idea is the same: after the autosave interval, every circuit with changes is copied. Each browser tab keeps its own recovery entry, so two tabs never overwrite each other, and the app also saves when the page is hidden or closed. When you open the page again, it offers the same **Restore** and **Discard** choice for the tabs that are gone (closed, or not seen for 10 minutes), never for a tab that is still open. Browsers can refuse storage when the quota is full or the site data is blocked. Voltecx then says so once on the status line and tries again at the next interval. A circuit larger than 4 MB is not saved, and the status line says so. The browser version does not remember your tabs or the last result. Use **File > Save** for anything you want to keep. ## Saving as a bundle Besides the plain `.voltecx` text file, a circuit can be saved as a bundle: one file that also holds the last simulation result and a small picture of the schematic. When you open the bundle, the scope shows the saved result without a new run, but only if the circuit has not changed since. The command `file.save` (or `file.saveAs`) with `"bundle": true` writes a bundle, and a file keeps the form it was opened in. Plain text stays the default, and autosave always writes plain text. The command-line tool reads both forms (`powercraft-cli info` says whether a file is a bundle). ## Versions and history Every time you save a circuit to a file, Voltecx keeps a version of it. You do not need to know git: open **File > Versions** (or the branch icon on the activity bar) to see every version as one line, newest first, like Runs (chapter 5). ![File › History, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/history/01-history.png) 1. Keep the circuit as a variant. 2. A version an agent changed: its line says `AI` after the version number, and its tooltip gives the agent's note. 3. Restore an earlier version. A line shows its buttons while the pointer is on it. - **What a line shows.** A title (the version's name, its note, or the first change), then the version number and how long ago. Its tooltip adds a small picture of the schematic, who saved it and who changed the circuit since the version before. Click the line to see every change: part, parameter, before and after. - **A note and a name.** `file.save {"note": "..."}` gives a version a note. **Add name** marks a version you want to keep, such as "sent to client": a named version is never dropped. Voltecx keeps the latest 200 unnamed versions and 100 named ones. - **Compare.** Click **Compare** on one line to compare that version with the circuit now, or on two lines to compare them. The comparison is the same as `file.diff`: parts added, removed and renamed, parameters with units, wiring per net, variables and simulation settings. Changed parts are outlined in orange on the schematic, added parts in green, and rewired nets are drawn in blue. ![Comparing a version with the circuit now, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/history/02-compare.png) 1. **Compare** on the version. 2. The legend under the schematic: what the marks mean. 3. The changed part outlined on the schematic. - **Restore.** **Restore** puts the circuit back as that version was. It is one step: **Edit > Undo** brings back the circuit you had before. - **Variants.** Type a name and click **Save as Variant** (or choose **File > Save as Variant**) to keep the circuit as it is now beside the others, for example an A design and a B design in one file. **Compare** works on variants the same way, and **Switch to** makes the circuit that variant (one undo step). - **Where they live.** The versions and variants are kept next to the file, in `.voltecx-history`. Copy or send the two files together to keep the history. A password-protected file keeps its versions only while it is open; they are never written next to it unencrypted. In the web app the versions stay in the browser tab while it is open; a save downloads only the circuit. Agents and scripts use `history.list`, `history.name {id, name}`, `history.restore {id}` or `{variant}`, `history.saveVariant {name, note}`, `history.removeVariant {name}`, `history.thumbnail {id}`, and `file.diff` with `{"version": "v2"}` or `{"variant": "B"}` sides. ### Who changed what Each version and each run records who made the change: a person at the desktop app, a CLI script, or the AI assistant. A change the assistant made carries an **AI** badge and the assistant's note: one short line on what it changed and why. Compare that version with the one before, or restore the one before, to review or undo what the AI did. The line **Not saved yet** at the top lists who changed the circuit since the last save. The words you typed to the agent are never kept: they belong to your AI session and may hold private text. Only the note the agent sends is kept, and by default only its first line, cut to 140 characters. **Edit > Preferences > Assistant > Keep AI requests in history** keeps the whole note, as the agent sent it. Only you can change this setting; automation cannot. ### Circuits in git Teams that keep circuits in git can let git show and merge `.voltecx` files the way Voltecx does. Put this line in the repository's `.gitattributes`: ```text *.voltecx diff=voltecx merge=voltecx ``` Then tell git which commands to use (once per clone, or with `--global`): ```text git config diff.voltecx.command "powercraft-cli diff" git config merge.voltecx.name "Voltecx circuit merge" git config merge.voltecx.driver "powercraft-cli merge %O %A %B" git config difftool.voltecx.cmd 'powercraft-cli diff "$LOCAL" "$REMOTE"' git config mergetool.voltecx.cmd 'powercraft-cli merge "$BASE" "$LOCAL" "$REMOTE" -o "$MERGED"' git config mergetool.voltecx.trustExitCode true ``` - `git diff` and `git log -p` now print what changed in the circuit instead of JSON lines, for example `R1.r: 1 kΩ → 2.2 kΩ`. `powercraft-cli diff OLD NEW` does the same for any two files, and `--lang zh-Hant` prints it in Traditional Chinese. - `git merge` merges two branches that changed the same circuit, part by part and value by value. When both branches changed the same value, git stops with a conflict; the file keeps your branch's value and stays a valid circuit, and the conflicts are listed in the terminal. Open it in Voltecx, check those values, and commit. `powercraft-cli merge BASE OURS THEIRS -o OUT` does the same by hand. - Add `*.voltecx-history` to `.gitignore`: git already keeps the history. - `diff` and `merge` need the Voltecx Terms accepted, as the other commands do (see chapter 1). A merge writes the plain form, without a bundle's result and runs. ## Review comments A reviewer leaves notes on the circuit itself, as in Figma, and the notes are saved in the file. Pick the **Comment** tool (the speech bubble in the tool dock, **Edit > Draw Tools > Comment Tool**, or **Shift+C** with the pointer over the schematic; **C** still places a capacitor), then click the schematic to drop a pin, or drag to pin an area. A box opens next to the pin: type the comment and press **Enter** (**Shift+Enter** starts a new line). ![A comment thread open on its pin, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/comments/01-popover.png) 1. The pin. Its number is the thread's row in the **Comments** view. 2. **Resolve** (the check mark). On a resolved thread it reads **Reopen**. 3. **Delete Thread** (the bin). Like every comment change, **Edit > Undo** brings it back. Click a pin to open its thread there: each message with its author and how long ago (point at the time for the full date), and a reply box. **Esc** or a click elsewhere on the schematic closes it. Point at a pin without clicking to read the first message and the number of replies. ![Pointing at a pin, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/comments/02-card.png) 1. The pin under the pointer. 2. The number of replies. The **Comments** view of the side bar lists the same threads, numbered as their pins. A pinned area is named by the part or the net under it, or **Canvas**. Choosing a thread there opens the same box on the schematic and moves the view to its pin. With a part or a net selected, **Add Comment** in the view pins the comment to it; on the scope, it pins one to cursor 1. Each message shows its author and the date and time it was written, in UTC (`2026-10-21 09:15 UTC`); point at it for how long ago. While the view shows, the status bar counts the threads: **Comments · 2 open, 1 resolved**. Scripts and agents use `comment.add`, `comment.reply`, `comment.resolve`, `comment.reopen`, `comment.delete`, `comment.list` and `comment.merge`, the same commands the pins run. ## Packing a circuit to share Zipping a project folder by hand loses things: a plug-in block's module, a device you added to your own library. **File > Pack for Sharing** writes one file that carries the circuit and everything it needs to open and simulate on another computer. ![The Pack for Sharing window, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/pack/01-pack.png) 1. **Files packed with the circuit** lists each outside file the circuit uses, with its size: the wasm plug-in modules of its plug-in blocks and the devices from your own library that its switches name. These files leave your computer, so the list comes first and nothing is written yet. 2. **Already inside the circuit** lists what a `.voltecx` file always carries: C code with the include files it was imported with, embedded devices, subsystems, symbols and protected blocks. They are not packed twice. 3. **What goes in**: only the listed files go in (its tooltip says so too). Voltecx never reads the rest of the circuit's folder, so licence files, keys and other files never leave with it. A file that looks like a key is refused even when a part refers to it. 4. **Pack** asks where to write the copy (`NAME-packed.voltecx`). Your circuit's own file does not change. A reference that cannot be found is listed under **Missing** in red, with the parts that use it: a plug-in that is not loaded, a device that is in no library, or a C `#include` of a file that the circuit does not hold. Load it first (**Load Plug-in**; for a device, **Add to My Library…** reads a device file, Voltecx device JSON or a device table CSV, as that device and keeps it inside the circuit, or **Pick Another Device** selects the part so Properties can name another), or tick **Pack without the missing files**; the receiver then cannot simulate those parts. The packed files may come to at most 128 MB; a larger pack is refused with the sizes. When someone opens the packed file, Voltecx copies its files into a folder beside it (`NAME-packed.voltecx-files`) and loads the plug-ins and devices, so the circuit simulates to the same result even on a computer that has none of them. Each file is checked against the SHA-256 in the file's manifest first; a damaged one is left out with a warning. A version of Voltecx from before packing refuses a packed file and asks you to update, instead of opening a circuit that cannot simulate. **Share as** picks how the pack leaves: **A file** writes it as above; **A link** (Voltecx Cloud, signed in) saves it as a new project in your team workspace, named after the circuit with "(packed)", and copies the project's link. Only the workspace's members can open it; they open it from the Cloud Projects view, and its plug-ins and devices load from the pack without anything being written to their computer. A viewer cannot save to a workspace, so the window says so and keeps **Pack** greyed until a workspace you may save to is picked. Agents and scripts use `file.packCheck {}` for the list and `file.pack {path, allowMissing?, maxBytes?}` to write the file. ## Protecting a file with a password **File > Protection > Save Protected** saves the circuit encrypted with a password. Type the password twice; a short hint says whether it looks weak, fair or strong (a rough guide only). The circuit must already have a file: save it once with **File > Save As**, then protect it. A protected file is still a `.voltecx` file, and plain text stays the default for everything else. - Opening a protected file asks for its password. A wrong password says only **The password is not correct.** and you can try again. A file that was damaged or changed says so instead. - While the circuit is open, **File > Save** keeps it protected without asking again. Voltecx keeps a key made from the password in memory until you close the circuit, never the password itself. - A lock (🔒) before the name, on the tab and in the window title, shows that the file is protected. - **File > Protection > Remove Protection** saves it as an ordinary file again. - Agents and scripts use `file.saveProtected {password}`, `file.open {path, password}`, `file.removeProtection` and `file.isProtected {path}`. What protection does not do: - **A forgotten password cannot be recovered.** It is not stored anywhere, and there is no back door. - A protected circuit is plain in memory while it is open. No recovery copy and no saved result are written for it, so if the app crashes, its unsaved changes are lost. Save often. - The browser version opens protected files but cannot save them. The key is made from the password with Argon2id (64 MiB, 3 passes) and the file is encrypted with XChaCha20-Poly1305. The details are in `docs/formats/pcraft.md`. ## Protected sub-circuit blocks A protected block is a subsystem you can give to someone else to simulate without showing them what is inside: a gate-drive stage, a controller, a power stage. 1. Build the block as an ordinary subsystem (**Circuit > Subsystem > Create Subsystem**) and check that it simulates. 2. **Circuit > Protected Blocks > Protect Subsystem** asks for the definition's `name`, an optional `password` and `allowParams`: circuit variables the inside uses that each user may change (for example an output inductance `Lf`). Their current values become the defaults. 3. The instances keep simulating exactly as before, but the inside can no longer be opened, edited, probed or exported. **Edit > Undo** gives you the open subsystem back; keep an unprotected copy of your file. 4. **Circuit > Protected Blocks > Export Protected Block** writes a `.pcblock` file. The receiver adds it with **Circuit > Protected Blocks > Import Protected Block** (give `instance` to place one), wires its pins and sets its public parameters with **Circuit > Parameters** on the instance. Copying an instance to another circuit brings the block along. Without a password any copy of Voltecx simulates the block. With one, the receiver runs **Circuit > Protected Blocks > Unlock Protected Block** with the password before simulating; a wrong password says only **The password is not correct.** What the receiver sees: the block's pins, its public parameters and their values, its own signals at the pins, and its losses as one total under the instance's name. What they never see: the parts inside, their values or names, signals inside, and the inside in an error. An error inside reads ``protected block `P1`: a part inside reported a problem; its details are hidden``. A netlist, KiCad or code-generation export of a circuit that places a block is refused. **The honest limit.** Voltecx has to decrypt the block in memory to simulate it, so the key reaches the receiver's machine. This deters casual viewing and copying, not a determined attacker with a debugger. Expressions that the simulation evaluates while it runs (behavioural sources over time) see the receiver's circuit variables, not the block's own. Agents and scripts use `subsystem.protect {name, password?, allowParams?}`, `subsystem.unlockProtected {name, password}`, `subsystem.exportProtected {name, path}`, `subsystem.importProtected {path, name?, instance?}` and `subsystem.listProtected`. ## Signed files Every save is signed with a key that belongs to this installation of Voltecx. It is made the first time the app starts and kept in the settings folder, readable only by you. When a licence is installed, the signature also names the licence (by a short id, not your name or email address). The status bar shows the signature of the active circuit's file: - **✔ Signed**: the file is unchanged since it was signed. - **⚠ Modified after signing**: the file was changed after it was signed (by hand, by another program, or on the way). - **Unsigned**: an older file, or one saved with signing off. Click it (or use **File > Protection > Verify Signature**) to see which key signed the file, the licence and the time. If a colleague sends you a file, you can **Trust This Signer** under a name, and their files then read as signed by that name. The same window turns signing off (**Sign files when saving**). Protected files are signed before they are encrypted, so their signature is checked after you type the password. What a signature means, honestly: it shows that a file is unchanged since the holder of that key saved it. Anyone can change a file and sign it again with a key of their own, so **Signed** does not mean "made by Voltecx", and it names a person only if you trust their key. The key file is protected by your account's file permissions only, and the time comes from the signer's own clock. ## Files in the browser The browser has no folders that the app can read, so the File menu works through the browser instead. - **File > Open** and **File > Import** show the browser's file chooser. You can also drop a file on the page. A `.voltecx` file, a PSIM `.psimsch` file, an LTspice `.asc` file, a PLECS `.plecs` file and a SPICE netlist (`.cir`, `.net`, `.sp`, `.spi`, `.spice`, `.ckt`) are recognised by their extension. A file with another extension is recognised by its content. Files over 64 MB are refused. Included files of a netlist cannot be read, and a warning says so. - **File > Save** and **File > Save As** download the circuit as `NAME.voltecx`. A circuit that you opened keeps the name of its file, so Save downloads it under the same name. The browser decides the folder, and some browsers ask each time. - **File > Export > Waveforms (CSV)** downloads `NAME-waveforms.csv`. **File > Export > SPICE Netlist** downloads `NAME.cir`. **File > Export > LTspice or PLECS File** downloads the circuit written back into the file it was imported from, as `NAME.asc` or `NAME.plecs`. - **Scope > Export** opens its parameter window with the format set to `png`, so the scope picture downloads as a PNG. Change `format` to `csv` for the data. - **File > Print** downloads the schematic as `NAME.svg`, black on white. Open it and print it from the browser, or save it as a PDF there. - Shortcuts with Ctrl or Cmd, and F1 to F12, go to Voltecx, not to the browser: F5 runs the simulation and Ctrl+R rotates instead of reloading the page. Cut, copy and paste work as usual. A browser keeps Ctrl+W, Ctrl+N and Ctrl+T for itself, so in the browser use the File menu to close a circuit or start a new one. --- # 15. Examples URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/15-examples/ Voltecx comes with ready-made circuits. Each one is a working circuit with a known answer, so you can open it, run it and change it. They are built in code, so they work in the browser version too, where there are no files. ## Open an example There are three ways. - File > Open Example has one submenu for each category. Point at an example to read what it shows. - Help > Examples opens the examples browser. - Cmd+K opens Quick Open. Type part of an example's name (`buck`, `pfc`, `馬達`): the examples come first, with the selected one's schematic and waveform on the right. Enter opens it; Cmd+Enter opens it and runs it. See [Quick Open](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/03-wiring-and-shortcuts/#quick-open). The browser lists the examples by category on the left. Each row shows a small picture of the schematic, the level (Beginner, Intermediate or Advanced) and about how long the example takes. Over the categories, Shelves splits the examples in two. Application circuits are each built around one commercial part, with the values of its data sheet's design example; the preview names that part under the title ("Built around TPS54360B"), and pointing at the line shows the document, revision and section the values come from. Teaching circuits show an analysis, a topology or a simulator feature. Click a shelf to show only its examples, together with any category you pick; click it again to show both shelves. A part's application example also opens from its Component Guide page (Help › Component Guide, or F1 on the part). The page of a library IC lists, under Application examples, one button for each of its real parts that has an example ("Open TPS54360B example"); with a placed part selected, it offers only that part's. Pointing at a button shows the example's title and the document it is built from. ![The examples browser, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/examples/01-window.png) 1. Type in the search box to narrow the list. The search looks at the names in English and Chinese, the descriptions and the key specs, so `buck closed`, `返馳` or `400 V` all work. Press ↑ and ↓ to move through the list and Enter to open the selected example. 2. Click a category to show only that category. Click it again, or All categories, to show every example. 3. Click a row to see the example on the right: its schematic, its main signals from a real run, its key specs (such as input and output voltage, switching frequency and control) and what you will learn from it. Double-click a row to open it. 4. Open and run opens it in a new tab and starts the simulation (⌘Enter does the same). Open only, beside it, opens it without running. 5. Use as Auto Design starting point opens Design > Automate > Requirements Interview with the example's input voltage, output voltage, load current and isolation filled in. Answer the other questions and confirm to run Auto Design. It is offered for the DC-DC examples with a DC load. The pictures and waveforms come from the examples themselves: the schematic is drawn the way `file.exportSchematic` draws it, and the waveform is the example's own simulation, thinned for the preview. Each trace is scaled to the height of the preview, so read the values in the scope after you run the example. An example opens in a new tab. The schematic fits the window, and the scope is set to show the main signals of that example. Press F5 to run it. The same thing from a command: `file.openExample` with the example's name, for example `{"name": "buckSync"}`. ## What is there Basics - `rc`, `rl` and `rlc` show the step response of a first-order and a second-order circuit. - `relaxationOscillator`, `timer555Astable`, `wienBridge` and `colpitts` are oscillators built from comparators, a 555 timer and op-amps. DC-DC - `buck` and `boost` run open loop at a fixed duty cycle. - `buckClosedLoop` holds 12 V from 48 V with a PI controller. - `buckSync` is a synchronous buck: a MOSFET with dead time takes the place of the diode, and a PI controller holds 12 V from 48 V. - `buckGan` is a synchronous buck with two GaN transistors (EPC2218 data) at 500 kHz. A GaN transistor has no body diode: in the dead time it conducts in reverse at its threshold voltage minus its turn-off voltage, here about 3.1 V, so the switch node dips to −3.1 V where a silicon MOSFET would sit near −0.8 V. - `boostClosedLoop` holds 24 V from 12 V with a slow PI controller. - `zvtBoost` is a zero-voltage-transition boost after Hua, Leu, Jiang and Lee (IEEE Transactions on Power Electronics 9(2), 1994, pp. 213–219): 200 V to 400 V at 500 W and 200 kHz, open loop at a duty of 0.5. An auxiliary switch `Qa` with a 2 µH resonant inductor `Lr` turns on 70 ns before the main switch `Q1`, at zero current. `Lr` takes the inductor current from the boost diode, then rings with the 470 pF node capacitance `Cr` (the switch's output capacitance, drawn as a part) and brings the switch node `sw` from 400 V to zero, so `Q1` turns on at zero volts. Set the variable `zvt` to 0 and the same circuit runs hard-switched: `Q1` turns on at 400 V and burns `Cr`'s ½·C·V² every cycle. The switches and diodes are ideal with a small on-resistance; the part values are the example's own design values, not a data sheet's. Plot `v(sw)`, `i(Lr)`, `g` and `ga`. - `bjtRegulator` is a discrete linear regulator built from two vendor bipolar transistors at the Gummel–Poon level, each with its maker's whole SPICE card (Diodes Incorporated MJD31CQ as the pass element, DI_MMBT3904 as the error amplifier). The error amplifier compares the divided output with a 2.5 V reference and holds about 5.01 V from 12 V, `(Vref + Vbe2)·(1 + R1/R2)`. While the input ramps up, below about 10 V the bias resistor cannot feed the pass element enough base current and the output follows the input (dropout). At 3 ms the load steps from 0.5 A to 1 A and the output settles about 67 mV lower. Plot `vin` with `vout`, and `iout`. - `buckThermal` adds a thermal model that heats the MOSFET junction. - `halfBridgeParallelSic` is a synchronous half-bridge whose switches each stand for three paralleled SiC MOSFETs from the device library (`nParallel` 3): the losses are three devices' worth, the junction temperature is one device's (chapter 4, Paralleled devices). - `tps54360bBuck` is the TPS54360B data sheet's design example (SNVSB93 section 8.2): 12 V to 5 V at 3.5 A and 600 kHz. The IC is the library's `buckRegulator` with the part's electrical characteristics, and every external part (L1 8.2 µH, two 47 µF, the 53.6 kΩ / 10.2 kΩ divider, the 13 kΩ / 6.8 nF / 39 pF compensation, the UVLO pair) comes from the data sheet's own design procedure, as `ic.designExternals` runs it. Its supply and load are the connectors J1 (input) and J2 (output), not a source and a resistor on the schematic: the test bench drives them in a run, 12 V on J1 and a 1.43 Ω load on J2 (Properties › Simulation › Test bench ports). It opens with four measurements: `Vout` (5.004 V by Equation 42), `Vout ripple` (under Table 1's 25 mV), `IL ripple` (about 0.63 A) and `Efficiency` (about 0.90, between the section 8.2.2.13 loss estimates). A note under the drawing says to check every value against the data sheet before using it. - `tps54560bBuck` is the TPS54560B data sheet's design example (SLVSF00 section 8.2, Figure 32): 12 V to 5 V at 5 A and 400 kHz. It is built the same way as `tps54360bBuck`: the library's `buckRegulator` with the part's electrical characteristics, and every external part (L1 7.2 µH, three 47 µF, four 2.2 µF at the input, the 53.6 kΩ / 10.2 kΩ divider, the 16.9 kΩ / 4.7 nF / 47 pF compensation, the 442 kΩ / 90.9 kΩ UVLO pair) from the data sheet's own design procedure. Its supply and load are the connectors J1 (input) and J2 (output), which the test bench drives in a run: 12 V on J1 and a 1 Ω load on J2 (Properties › Simulation › Test bench ports). It opens with four measurements: `Vout` (5.004 V by Equation 42), `Vout ripple` (under Table 1's 25 mV), `IL ripple` (about 1.06 A) and `Efficiency` (about 0.89, between the section 8.2.2.13 loss estimates). A note under the drawing says to check every value against the data sheet before using it. - `tps54331Buck` is the TPS54331 data sheet's design example (SLVS839H section 8.2, Figure 8-1): 3.3 V at 3 A and the part's fixed 570 kHz, run at 12 V (Table 8-1 gives the input only as 7 V to 28 V). It is built the same way as `tps54360bBuck`: the library's `buckRegulator` with the part's electrical characteristics, and every external part (L1 6.8 µH, two 47 µF, two 4.7 µF at the input, the 10.2 kΩ / 3.24 kΩ divider, the 29.4 kΩ / 1000 pF / 47 pF compensation, the 0.01 µF slow-start capacitor) from the data sheet's own design procedure; Figure 8-1's 332 kΩ / 68.1 kΩ EN divider and the B340A's 0.5 V are placed as printed. Its supply and load are the connectors J1 (input) and J2 (output), which the test bench drives in a run: 12 V on J1 and a 1.1 Ω load on J2. It opens with four measurements: `Vout` (3.32 V by Equation 5), `Vout ripple` (under Table 8-1's 30 mV), `IL ripple` (about 0.68 A) and `Efficiency` (about 0.88, between the section 8.2.2.11 loss estimates). A note under the drawing says to check every value against the data sheet before using it. - `lm5146Buck` is Design 1 of the LM5146 data sheet (SNVSBV0A section 9.2.1, Figure 9-5): 48 V to 5 V at 12 A and 300 kHz. The IC is the library's `syncBuckController` with the LM5146's electrical characteristics, and every external part is the one Figure 9-5 prints: LF 3.3 µH, five 47 µF, Q1 22 mΩ and Q2 6 mΩ, the 23.2 kΩ / 4.42 kΩ divider, the type III network (7.5 kΩ, 6.8 nF, 150 pF, 150 Ω, 820 pF), the 47 nF soft start, the 100 kΩ / 17.8 kΩ UVLO pair and RILIM 499 Ω. SYNCIN is not modelled, so the oscillator runs at the 300 kHz clock directly. Its supply and load are the connectors J1 (input) and J2 (output), which the test bench drives in a run: 48 V on J1 and a 0.417 Ω load (5 V at 12 A) on J2 (Properties › Simulation › Test bench ports). It opens with three measurements: `Vout` (4.999 V), `Vout ripple` (about 8 mV) and `IL ripple` (about 4.6 A, by Equation 7). A note under the drawing says to check every value against the data sheet before using it. - `lm5146Buck12v` is Design 2 of the LM5146 data sheet (SNVSBV0A section 9.2.2, Figure 9-16, Tables 9-7 and 9-8): the 48 V telecom input to 12 V at 8 A, with RRT 24.9 kΩ setting about 400 kHz. It is built like `lm5146Buck`, with every external part Figure 9-16 prints: LF 6.8 µH, five 22 µF ceramics, Q1 22 mΩ and Q2 10 mΩ, the 21 kΩ / 1.5 kΩ divider (12.0 V), the type III network (8.06 kΩ, 4.7 nF, 100 pF, 100 Ω, 1 nF), the 47 nF soft start, the 100 kΩ / 9.31 kΩ UVLO pair (on at 14.1 V, off at 13.1 V) and RILIM 619 Ω (a 12 A limit). Its supply and load are the connectors J1 (input) and J2 (output), which the test bench drives in a run: 48 V on J1 and a 1.5 Ω load (12 V at 8 A) on J2 (Properties › Simulation › Test bench ports). Figure 9-16 draws no PGOOD pull-up, so none is drawn. The MOSFETs' gate stand-ins are drawn as one block, `GD1`. It opens with three measurements: `Vout` (12.0 V), `Vout ripple` (about 9.5 mV) and `IL ripple` (about 3.3 A). RBST, CIN, the VIN filter, CVCC, the optional D1, CILIM, SYNCIN, the inductor's DCR and the capacitors' ESR are left out, and the example's description says why. - `lm5145BuckDsp` is Design 4 of the LM5145 data sheet (SNVSAI4B section 9.2.4, Figure 9-46, Tables 9-11 and 9-12): a DSP core rail from 24 V to 1.1 V at 10 A, with RRT 33.2 kΩ setting about 300 kHz and a 4.6 % duty cycle (a 153 ns on-time). It is built like `lm5145Buck`, with every external part Figure 9-46 prints: LF 1 µH, four 100 µF ceramics, Q1 8.5 mΩ and Q2 4 mΩ, the 6.81 kΩ / 18.2 kΩ divider (1.099 V), the type III network (2.32 kΩ, 10 nF, 470 pF, 100 Ω, 2.7 nF), the 47 nF soft start and RILIM 249 Ω (a 12.5 A limit). VCC comes from the 8 V auxiliary rail `Vaux`. Its supply and load are the connectors J1 (input) and J2 (output), which the test bench drives in a run: 24 V on J1 and Figure 9-48's 0.11 Ω load on J2 (Properties › Simulation › Test bench ports). Figure 9-46 leaves EN/UVLO unconnected and draws no PGOOD pull-up, so EN/UVLO is tied to VIN (section 8.3.4) and PGOOD is left open. The MOSFETs' gate stand-ins are drawn as one block, `GD1`. It opens with three measurements: `Vout` (1.099 V), `Vout ripple` (about 3.8 mV) and `IL ripple` (about 3.6 A). The LM10011 VID programmer and the DSP have no model, so the output stays at the divider's 1.1 V. D1, CIN, CVIN, CVCC, CILIM, SYNCIN, the inductor's DCR and the capacitors' ESR are left out, and the example's description says why. - `lm5145Buck` is Design 1 of the LM5145 data sheet (SNVSAI4B section 9.2.1, Figure 9-5): 48 V to 5 V at 20 A and 230 kHz. It is built the same way as `lm5146Buck`: the library's `syncBuckController` with the LM5145's electrical characteristics, and every external part the one Figure 9-5 prints: LF 3.3 µH, seven 47 µF with the 220 µF bulk capacitor, Q1 12 mΩ and Q2 4 mΩ, the 23.2 kΩ / 4.42 kΩ divider, the type III network (11 kΩ, 4.7 nF, 150 pF, 1 kΩ, 1.8 nF), the 47 nF soft start, the 49.9 kΩ / 11.3 kΩ UVLO pair and RILIM 422 Ω. SYNCIN is not modelled, so the oscillator runs at the 230 kHz clock directly. Its supply and load are the connectors J1 (input) and J2 (output), which the test bench drives in a run: 48 V on J1 and a 0.25 Ω load on J2 (Properties › Simulation › Test bench ports). It opens with three measurements: `Vout` (4.999 V), `Vout ripple` (about 5.9 mV) and `IL ripple` (about 5.9 A). A note under the drawing says to check every value against the data sheet before using it. - `lm5145Buck12v` is Design 2 of the LM5145 data sheet (SNVSAI4B section 9.2.2, Figure 9-20, Tables 9-7 and 9-8): 48 V to 12 V at 10 A, with RRT 24.9 kΩ setting about 400 kHz. It is built like `lm5145Buck`, with every external part Figure 9-20 prints for the 12 V rail: LF 4.7 µH, five 47 µF ceramics, Q1 and Q2 6 mΩ, the 33.2 kΩ / 2.37 kΩ divider (12.01 V), the type III network (15 kΩ, 3.3 nF, 56 pF, 100 Ω, 680 pF), the 33 nF soft start, the 80.6 kΩ / 7.5 kΩ UVLO pair (on at 14.1 V, off at 13.3 V) and RILIM 402 Ω (a 13.4 A limit). Its supply and load are the connectors J1 (input) and J2 (output), which the test bench drives in a run: 48 V on J1 and Figure 9-23's 1.2 Ω load on J2 (Properties › Simulation › Test bench ports). Figure 9-20 takes PGOOD to the LP38798's EN pin and draws no pull-up, so PGOOD is left open. The MOSFETs' gate stand-ins are drawn as one block, `GD1`. It opens with three measurements: `Vout` (12.01 V), `Vout ripple` (about 6.5 mV) and `IL ripple` (about 4.8 A). The LP38798 LDO that makes the auxiliary 10 V rail has no model, so that rail is left out. D1 (VCC from the output), RBST, CIN, CVIN, CVCC, CILIM, SYNCIN, the inductor's DCR and the capacitors' ESR are left out too, and the example's description says why. - `lm5145Buck24v` is Design 3 of the LM5145 data sheet (SNVSAI4B section 9.2.3, Figure 9-33, Tables 9-9 and 9-10): 48 V to 24 V at 5 A, with RRT 22.6 kΩ setting about 440 kHz, and an output that tracks a master supply. It is built like `lm5145Buck`, with every external part Figure 9-33 prints: LF 15 µH, seven 10 µF, Q1 and Q2 13 mΩ, the 72.3 kΩ / 2.49 kΩ divider (24.03 V), the type III network (41.2 kΩ, 1 nF, 18 pF, 1 kΩ, 390 pF), the 200 kΩ / 8.87 kΩ UVLO pair (on at 28.3 V) and RILIM 499 Ω. Its supply and load are the connectors J1 (input) and J2 (output), which the test bench drives in a run: 48 V on J1 and a 4.8 Ω load (24 V at 5 A) on J2 (Properties › Simulation › Test bench ports). There is no soft-start capacitor: the 13.3 kΩ / 2.49 kΩ divider from VTRACK to SS/TRK makes the output ramp to 24 V as VTRACK ramps from 0 V to 5 V (section 9.2.3.2). The data sheet gives no ramp time, so the bench ramps VTRACK in 1 ms. The MOSFETs' gate stand-ins are drawn as one block, `GD1`. It opens with three measurements: `Vout` (24.03 V), `Vout ripple` (about 7.5 mV) and `IL ripple` (about 1.83 A). CIN, CVCC, CILIM, SYNCIN, the inductor's DCR and the capacitors' ESR are left out, and the example's description says why. - `lm5122Boost` is the LM5122 data sheet's typical application (SNVS954H section 8.2, Figure 40): 12 V to 24 V at 4.5 A, with RT 36.5 kΩ setting 246.6 kHz for the 250 kHz design. The IC is the library's `syncBoostController` with the LM5122's electrical characteristics, and every external part is the one Figure 40 prints: LIN 10 µH, the 4 mΩ current-sense resistor, four 10 µF, three 330 µF and one 1 µF at the output, the 49.9 kΩ + 825 Ω / 2.67 kΩ divider, RCOMP 68.1 kΩ with CCOMP 22 nF and CHF 330 pF, RSLOPE 100 kΩ, CSS 0.1 µF, CRES 0.47 µF and the 49.9 kΩ / 8.06 kΩ UVLO divider. The data sheet prints no on-resistance for its MOSFETs, so they keep the library circuit's generic 10 mΩ and the example has no efficiency row. Its supply and load are the connectors J1 (input) and J2 (output), which the test bench drives in a run: 12 V on J1 and a 5.33 Ω load (24 V at 4.5 A) on J2 (Properties › Simulation › Test bench ports). It opens with `Vout` (24.0 V), `Vout ripple` and `IL ripple` (2.43 A), each read over the last millisecond of the 20 ms run, after the 12 ms soft start and the loop has settled. - `lp5907Ldo` is the LP5907 data sheet's typical application (SNVS798Q section 7.2, Figure 7-1, Table 7-1): the 1.8 V option, LP5907MFX-1.8, at 200 mA with the 1 µF input and 1 µF output capacitors Figure 7-1 prints. The IC is the library's `ldo` with section 5.5's values and the 1.8 V option's output and load regulation. Table 7-1 gives the input only as a range, 2.2 V to 5.5 V, so the example runs at 2.8 V, the VIN = VOUT(NOM) + 1 V of section 5.5's test conditions; the supply is the connector J1, which the test bench drives. EN is tied to the input, so the part starts with the supply (80 µs turn-on); at 300 µs the load ramps from section 5.5's 1 mA test load to Table 7-1's 200 mA in 10 µs, section 5.5's load-transient condition. It opens with `Vout 1 mA` (1.8 V within ±2 %), `Vout 200 mA` (1.796 V: the 0.001 %/mA load regulation), `Load-step dip` (below section 5.5's 40 mV) and `PD`, equation 2's (VIN − VOUT) × IOUT, about 0.2 W. Input ripple, the capacitors' ESR, noise and the thermal limits are left out, and the example's description says why. - `sepic` is an open-loop SEPIC that turns 12 V into 12 V at a duty cycle of 0.5. A SEPIC steps up or down without inverting; its switch node swings to the input plus the output voltage, 24 V. - `cuk` is an open-loop Ćuk converter that turns 12 V into −12 V at a duty cycle of 0.5. Its input and output currents are both smooth, because each flows through an inductor. - `zeta` is an open-loop Zeta converter that turns 12 V into 12 V at 1 A, duty cycle 0.5, 100 kHz. Like the SEPIC it steps up or down without inverting, `Vout = Vin·D/(1 − D)`, but its switch sits on the input side and the output current is smooth, because it flows through the second inductor. Each 150 µH inductor ripples by `Vin·D/(L·fsw)` = 0.4 A, and the node between the coupling capacitor and the diode swings between 0 and `Vin + Vout`, 24 V. It opens with `Vout` and `IL1 ripple`. - `invertingBuckBoost` is an open-loop inverting buck-boost that turns 12 V into −12 V at 1 A, duty cycle 0.5, 100 kHz: `Vout = −Vin·D/(1 − D)`. One 150 µH inductor carries the input and the output current together, 2 A on average with 0.4 A of ripple, and the output capacitor alone feeds the load while the switch is on. It opens with `Vout` and `IL1 ripple`. - `ledBoostDriver` boosts 12 V onto a string of ten LEDs near 33 V and holds its current with a PI loop. Analog dimming scales the reference (`Ifull`·`Adim`, 0.3 A): the current itself falls and the light does not flicker. PWM dimming (`Ddim`, 200 Hz) cuts the string off with a series switch between pulses and holds the loop's integrator, so the output capacitor keeps the string's voltage and each pulse starts near the regulated current after about 0.3 ms of ringing; the mean current is `Ddim` times the held current. Compare `ledBuckDriver`, a hysteretic buck with PWM dimming. - `poePd` powers up a Type 2 Power over Ethernet powered device (PD) through 12.5 Ω of cable from a 50 V PSE, with the PD interface (module `PD`) drawn as behaviour from the TPS2378 data sheet. The PSE probes at 4 V and 8 V and sees the 24.9 kΩ signature; at 18 V the PD sinks the class 4 current, 39.9 mA, and between the two class events it shows the 10 kΩ mark, so `t2p` latches a type 2 PSE. At 50 V the hotswap switch charges the 47 µF bulk at 140 mA, and the converter (its input power, 25.5 W) starts 80 ms later; the PD's input then sits at 42.5 V, where the cable delivers 25.5 W. Plot `ipse` with `vpd` and `en`. - `poePdFlyback` puts an isolated flyback behind the `poePd` front end in place of its converter's input power: the same detection, classification, 140 mA inrush and 80 ms start-up, then a 3:1 flyback at 100 kHz regulating 12 V at 20 W on its isolated side. Its controller (module `CTRL`) ramps the reference over 5 ms once `en` goes high, so the PI loop holds still and the switch stays off during the start-up, and the output rises without overshoot; the PD then draws about 22 W, inside the 25.5 W a Type 2 PD may. Plot `vo`, `duty`, `vpd` and `ipse`. - `usbPd` is a 27 W USB Power Delivery source and its sink, with the limits of the USB Power Delivery Specification Release 3.2: a synchronous buck from 20 V (module `CTRL`: a voltage loop, a current limit and a current loop) set by the source's policy engine (module `PE`), and a sink (module `SNK`) whose Requests are drawn as signals. VBUS starts at vSafe5V; the sink asks for the fixed 9 V supply, the source accepts 1 ms later, waits tSrcTransition (30 ms), ramps at 25 mV/µs (the limit is 30) and sends PS_RDY once VBUS is within ±5 %, and the sink then draws 27 W. Next the sink asks for the 9 V Prog PPS APDO at 7.8 V with 2 A and closes the switch to its battery (7.4 V behind 0.1 Ω): the source enters Current Limit mode, holds 2 A, and the battery sets VBUS below 7.8 V. A last Request in the same APDO raises the limit to 3 A at the Accept, with no tSrcTransition. Plot `vbus`, `ibus`, `vset`, `psrdy` and `ibat`. - `fourSwitchBuckBoost` is a four-switch buck-boost: a buck leg and a boost leg on either side of one inductor, 9–16 V in, 5, 9, 15 or 20 V out (the USB Power Delivery fixed levels, variable `Vout`) at 3 A and 400 kHz. Well above the output only the buck leg switches, well below it only the boost leg, and near Vin = Vout both; the duties `Ctrl.d1` and `Ctrl.d2` show which. The ratio Vout/Vin comes forward from the measured input and a slow PI trims it, so the input step from 9 V to 16 V at 3 ms crosses from the boost to the buck region with the output within 5 %. Set `Vin` and `VinStep` to the same value for a steady input. "Use as Auto Design starting point" asks `design.auto` for its four-switch template. - `flyingCapBuck` is a three-level flying-capacitor buck, 48 V to 12 V at 20 A, with four switches (BSC070N10NS5 data) at 200 kHz and a voltage-mode PI. The flying capacitor `Cf` sits at half the input, so every switch blocks only 24 V. The two switch pairs run half a period apart, so the switch node `SW` steps between 0 V and 24 V twice per period: the inductor sees 400 kHz and half the voltage step of a two-level buck. The two flying-capacitor states last equally long, which keeps `vfc` at 24 V with no balancing loop. Set the variable `phB` to 0 to drive both pairs in phase: the middle level is gone and `SW` jumps to 48 V again. - `switchedCap` is a 4:1 Dickson switched-capacitor converter, 48 V to 12 V at about 200 W with no inductor. Ten switches (BSC070N10NS5 data) on two non-overlapping 200 kHz clock phases stack three 22 µF flying capacitors at 12 V, 24 V and 36 V, so every switch blocks only 12 V. The output sags with load like a source behind a resistor: Seeman and Sanders' slow- and fast-switching limits give about 43 mΩ, and the loaded run reads 11.29 V into 0.65 Ω, about 5 % under that estimate. Each flying capacitor swings about 1 V per phase as it passes its charge on. - `threeLevelBoost` is a three-level boost from a 300 V PV string to a split 800 V DC link, 4 kW and 5 kW after a load step, after Zhang, Jiang, Lee and Jovanović (IEEE APEC 1995): two switches (C3M0060065D data) in series across the inductor's ends with their midpoint on the link midpoint, and two SiC diodes (IDW20G65C5 data), so every switch and diode blocks only 400 V (`vds1`, `vds2`). Their carriers at 50 kHz run half a period apart, so the inductor current `i(L1)` ripples at 100 kHz and about 1.3 A peak to peak. A voltage loop sets the inductor current, a current loop sets the duty, and a balancing loop moves the two duties apart (`Ctrl.ub`) to keep `vc1` and `vc2` equal. At 15 ms a 160 Ω load joins the bottom half only: the halves stay within 1.5 % of each other and the link within 1 % of 800 V. - `batteryCharger` is a synchronous buck stage that charges a pack of four lithium-ion cells from 24 V. It holds 5 A until the pack reaches 16.6 V, and then it holds 16.6 V while the current falls. The battery capacity is set very small, so that the whole charge fits in a run of 0.6 s. - `batteryChargerLongRun` is the same charger on a real pack: four Molicel INR-21700-P45B cells in series, 4.5 Ah, with the charge voltage (4.2 V a cell), the standard charge current (4.5 A) and the DC resistance (15 mΩ a cell) from the cell's data sheet. A switching run of its 1.5-hour charge would take billions of steps; run `simulation.batteryRun` with `tEnd` 5400 instead, and the charge from 20 % runs in under a second: 4.5 A for about 44 minutes, then the current falls at 16.8 V until the pack is full. Isolated - `flyback` is an open-loop flyback with a coupled inductor. - `flybackClosedLoop` holds 12 V from 12 V through a 1:1 coupled inductor with a PI controller. - `forward` is a single-switch forward converter: 48 V to 12 V at 5 A through a 1.6:1 transformer. A reset winding with as many turns as the primary returns the magnetising current to the input while the switch is off, so the drain rises to twice the input, 96 V, and the duty cycle stays below 0.5. - `activeClampForward` is the same 48 V to 12 V converter with an active clamp instead of the reset winding. A clamp switch and a 470 nF capacitor hold the primary at −48 V while the main switch is off, so the drain sits flat at 96 V and the magnetising current swings evenly about zero. - `pushPull` is a push-pull converter, 48 V to 12 V at 5 A. Two switches take turns on the halves of a centre-tapped primary, each on for 0.4 of the 100 kHz period, and a centre-tapped secondary with two diodes rectifies both halves into one LC filter, so the output is `2·D·Vin·Ns/Np` less a diode drop. The switch that is off holds twice the input, 96 V; at each turn-off the leakage inductance drives its drain to about 120 V, where an RCD clamp catches it. The magnetising current swings evenly about zero, because the two halves give the core equal and opposite volt-seconds. - `halfBridgeDcdc` is a symmetrical half-bridge converter with a current-doubler rectifier, 380 V to 12 V at 20 A (240 W), each switch on for 0.4 of its 100 kHz period. Two split capacitors hold the midpoint `v(mid)` at 190 V, so the primary sees ±190 V and no DC reaches the transformer. The secondary has no centre tap: two output inductors each carry half the load, and their ripples, half a period apart, partly cancel, so `i(L1)+i(L2)` ripples by about a third of one inductor's 3.6 A. The transformer sits on the isolation barrier, and the modulator is a module below the primary. - `twoSwitchForward` is a two-switch forward converter, 48 V to 12 V at 5 A, 100 kHz, D = 0.4. A high-side and a low-side switch turn on together, and when they turn off two clamp diodes return the magnetising current to the input, so the core resets with no reset winding and each switch stands only 48 V. Read `i(Lm)`: it rises to 0.38 A and falls back to zero inside every period. The `Vout` and `ILo ripple` measurements read the output. - `classEAmplifier` is a class-E resonant amplifier: one switch at 1 MHz and D = 0.5, fed from 24 V through a 470 µH choke, with a 2.92 nF shunt capacitor and a series tank (0.844 nF, 31.8 µH, loaded Q of 20) into 10 Ω, designed with Raab's idealized constants. Read `v(sw)`: it rises in humps to about 87 V (about 3.6 times the supply) and each hump comes back to zero at a small fraction of its steepest slope just before the switch turns on, and the body diode holds it there, so the turn-on loses almost nothing. The output is about 33 W; `pout` over `pin` gives the efficiency, about 98.7 %, set by the switch's 50 mΩ on-resistance. - `classDAmplifier` is a class-D audio amplifier: a half bridge on ±40 V rails switched at 400 kHz by a comparator that compares a 1 kHz, 1 V input tone (scaled to a modulation index of 0.8) with a triangle carrier, with a 10 ns dead time, and a second-order Butterworth LC filter (60 µH, 469 nF, 30 kHz corner) into an 8 Ω speaker. The modulator is a module; the input `va`, the reference `ref`, the carrier `tri` and the gates join it to the rest by label. Read `vo`: a 22.3 V rms sine (about 62 W) whose THD is about 0.5 % in the audio band (`scope.measure` with `thd`); `v(sw)` is the ±40 V pulse train, and the filter leaves about 0.19 V of the 400 kHz carrier at the speaker, `(fc/fsw)²` of the switch node's. The dead time is the main distortion; the Summary's efficiency, about 99.5 %, is set by the switches' 42 mΩ on-resistance (Infineon BSC520N15NS3G). - `sicHalfBridgeFiber` is an 800 V SiC half bridge (two Wolfspeed C3M0016120K at the dynamic switching level) whose gate signals cross the barrier on fiber: the PWM module and two `fiberTx` on the control ground, two `fiberRx` on the power side, each on its switch's source with its own 15 V supply. Each gate edge comes 55 ns after its command (the fiber parts' typical values). The schematic draws the barrier between the transmitters and the receivers, and `fiber.linkBudget` gives 14.6 dB of margin. - `llcHalfBridge` is an LLC resonant half bridge run at its resonant frequency of 100 kHz. It makes about 48 V from 400 V through a 4:1 transformer, and the resonant current is close to a sine. - `dab` is a dual active bridge. Two full bridges and a 2:1 transformer move about 4.4 kW from a 400 V bus to a 200 V bus. The phase shift between the bridges (the variable `Phs`, 30 degrees) sets the power. - `threePortDab` is a three-port dual active bridge (a triple active bridge): a 400 V source, a 200 V battery and a 100 V load, each a full bridge, on one transformer core at 50 kHz. Two phase shifts set the power flow: the battery bridge lags the source by `Phs2` (20 degrees) and the load bridge by `Phs3` (30 degrees), so the source gives about 6.3 kW, the battery takes 2.3 kW and the load 4.1 kW. Seen as a delta of one inductance between each pair of ports, every pair is a two-port dual active bridge, and the port powers follow its phase-shift equation. The three modulators are the module `Mod`. To find the phase shifts for the powers you want, run the command `design.multiportDab` with the port voltages, turns ratios and inductances and the power wanted at the battery and the load; it returns `Phs2` and `Phs3` in degrees, and each pair's mesh inductance and power. - `threePortDabClosedLoop` is the same three-port bridge with two loops closed on its phase shifts. A PI on the battery current sets `Phs2` and a PI on the load port's voltage sets `Phs3`, each updated once per switching period. The battery set point steps from 5 A charging to 5 A discharging at 2 ms: the battery bridge goes from lagging the source to leading it, the source's power falls from about 3 kW to 1 kW, and the 2 kW load stays at 100 V. - `threePhaseDab` is a three-phase dual active bridge: an 800 V bus and a 400 V bus, each with a three-phase bridge, joined by three 2:1 transformers in wye-wye with 60 µH of leakage per phase, at 50 kHz. Each bridge makes the six-step wave, and the secondary bridge lags the primary by `Phs` (30 degrees), which moves about 10.4 kW to the 400 V bus; a negative `Phs` sends the power back. The power follows the three-phase phase-shift equation of De Doncker, Divan and Kheraluwala (1991), and with the 400 V side at its share every primary switch turns on at zero voltage. The two sides have separate grounds, with the transformers as the isolation barrier. The six modulators are the module `Mod`. - `solidStateTransformer` is a solid-state transformer from the 230 V, 50 Hz mains to an isolated, regulated 200 V at 1 kW. The front end is the `pfcBoost` stage, which draws a sine from the mains and holds a 400 V link; the isolated stage is a dual active bridge at 20 kHz through a 2:1 transformer. A PI on the output sets the bridge's phase shift `phs` (about 20 degrees at full load), updated once per switching period, and the power follows the phase-shift equation of `dab`. The output loop is much faster than the 100 Hz ripple on the link, so the output barely shows it. Each stage's control is a module: `PfcCtl` and `DabCtl`. - `solidStateTransformerAc` carries the same two stages on to an AC output: a single-phase inverter with sine PWM and an LC filter on the isolated 200 V bus makes 115 V, 50 Hz at 1 kW, so the mains reaches the load as AC through the 20 kHz link. A single-phase load takes its power at twice the output frequency; the bus capacitor (1 mF) and the bridge's loop share that 100 Hz pulsation, so the phase shift `phs` swings with it while the bus stays within a few volts of 200 V. The inverter's modulators are the module `InvCtl`. - `psfb` is a phase-shifted full bridge. A PI moves the phase between the two legs to hold 48 V from 400 V at 1 kW through a 6:1 transformer. Both legs switch at zero voltage at full load: the leading leg on the reflected load current, the lagging leg on the energy in the 30 µH series inductor. That inductor also costs a duty-cycle loss of about 0.1. - `ucc28950Psfb` is the UCC28950 data sheet's typical application (SLUSDB2B section 7.2, Figure 7-3, Table 7-1): a 600 W phase-shifted full bridge from 390 V to 12 V at 100 kHz. The IC is the library's `psfbController` with the UCC28950's electrical characteristics, and the parts are the ones the section 7.2.2 procedure sizes: the 2.8 mH transformer, the 26 µH shim inductor, 7.5 mF of output capacitance, and the 2.37 kΩ / 9.09 kΩ divider that sets 12.09 V. It runs at 5 A, the load the loop is compensated at; the controller runs peak current mode as the data sheet's design does, with RSUM from equation 146. Its supply and load are the connectors J1 (input) and J2 (output), which the test bench drives in a run: 390 V on J1 and a 2.4 Ω load (12 V at 5 A) on J2 (Properties › Simulation › Test bench ports). It opens with `Vout`, `Vout ripple` and `Pin`, the power the bench supply delivers. The synchronous rectifier is a diode bridge, and the example's description lists what else is left out. - `uc2842Flyback` is the UCx84x data sheet's typical application (SLUS223H section 8.2, Figure 8-2, Table 8-1): a 48 W off-line flyback from 115 VAC, 60 Hz to 12 V at 4 A, peak current mode at 111.7 kHz, with its loop closed on the secondary through a TL431 and an optocoupler. The IC is the library's `pwmController` as the UC2842 (the UCx842's 16 V / 10 V UVLO), and every part is the one Figure 8-2 prints: the 180 µF bulk, the 1.5 mH transformer with NP:NS and NP:NA of 10, the 10 nF ∥ 50 kΩ clamp, RCS 0.75 Ω with 4.2 kΩ / 100 pF, RRT 15.4 kΩ and CCT 1000 pF, the 10 nF / 24.9 kΩ slope compensation from the RT/CT ramp, 2200 µF with the 43 mΩ ESR the text gives, the 9.53 kΩ / 2.49 kΩ divider, the 88.7 kΩ + 0.01 µF TL431 zero, RLED 1.3 kΩ and the 10 kΩ ∥ 10 nF error-amplifier pole. It opens with `Vout` (12.06 V by hand), `Vout ripple`, `Isw peak` (below equation 18's 1.36 A) and `Isw rms` (below equation 19's 0.97 A). The ripple is about 0.4 V, almost all of it the ESR carrying the rectifier's current step: more than Table 8-1's 100 mV, which the printed 2200 µF and 43 mΩ without a post filter do not give. The soft-start network, the gate and VCC clamps, the transformer's leakage and the optocoupler's part are not printed, and the example's description lists each. - `ucc28c42Flyback` is the UCCx8C4x data sheet's typical application (SLUS458I section 8.2, Figure 8-3, Table 8-1): the same 48 W off-line flyback class, 115 VAC, 60 Hz to 12 V at 4 A, around the BiCMOS UCC28C42 (the library's `pwmController` with its 14.5 V / 9 V UVLO and 1 V current-sense limit). Every part is the one Figure 8-3 prints, and where it differs from the UC2842 design it is the BiCMOS sheet's own: RCSF 3.8 kΩ for the 1.9 V RT/CT ramp of equation 37, the 420 kΩ start-up resistor and the 18 V Zener on VDD; the rest is the 180 µF bulk, the 1.5 mH transformer with NP:NS and NP:NA of 10, RCS 0.75 Ω, RRT 15.4 kΩ and CCT 1000 pF, 2200 µF with 43 mΩ ESR, the 9.53 kΩ / 2.49 kΩ divider, the 88.7 kΩ + 0.01 µF TL431 zero, RLED 1.3 kΩ and the 10 kΩ ∥ 10 nF error-amplifier pole. It opens with `Vout` (12.06 V by hand), `Vout ripple`, `Isw peak` (below equation 12's 1.36 A) and `Isw rms` (below equation 13's 0.97 A). The data sheet gives no oscillator equation, so U1 keeps the UCx84x's 1.72/(RT·CT) = 111.7 kHz against the text's 110 kHz; the soft-start network, the transformer's leakage and the optocoupler's part are not printed, and the example's description lists each. - `qrFlyback` is a quasi-resonant flyback, 325 V to 12 V at 2 A. After the core has given its energy to the output, the drain rings, and the switch turns on in the first valley of that ringing, at about 226 V instead of 426 V. A voltage loop sets the on-time; the frequency follows the load (83 kHz at full load). - `activeClampFlyback` is an active-clamp flyback, 375 V to 20 V at 5 A (100 W) and 120 kHz, with two C3M0060065D switches and a 6:1 transformer with 3 µH of leakage. The clamp switch `Qc` and the 1 µF clamp capacitor `Cc` sit across the primary; `Qc` is gated as the complement of `Q1` with a 250 ns dead time. The leakage energy rings into `Cc` and on to the output instead of heating a resistor, the clamp holds `vc` near 126 V, so the drain `v(SW)` peaks near 504 V, and the magnetising current `i(T1.Lm)` falls to −0.65 A before `Qc` turns off. That negative current discharges the drain within the dead time, so `Q1` turns on at zero voltage. A PI (module `Ctrl`) holds `v(VOUT)` at 20 V. Replace `Qc` by a diode and put a resistor across `Cc` to see the resistor clamp: the drain peaks higher and `Q1` turns on hard. - `cllc` is a CLLC resonant converter between two 400 V sides at 2 kW: two SiC full bridges, a 1:1 transformer and the same resonant tank on each side. Both bridges switch together at the resonant frequency, so it works as a DC transformer, every primary switch turns on at zero voltage, and power flows to whichever side is loaded. - `srcConverter` is a full-bridge series-resonant converter: a 390 µH and 6.8 nF tank (97.7 kHz) and a 2:1 transformer into a diode bridge and 20 Ω. The first-harmonic approximation gives its gain, `M = 1/√(1 + Q²·(fn − 1/fn)²)` with `Q` = 3.69. It runs at 1.15 times resonance by default, about 133 V out, with every switch turning on at zero voltage; set `fnorm` to 0.9 and the output rises to about 164 V, but the tank current now leads and the switches turn on hard. At resonance the output is about 198 V, the input over the turns ratio. - `inductionHeating` is a half-bridge induction heater: 325 V, a 100 nF capacitor and a 270 µH work coil with the workpiece's 12 Ω, resonant at 30.6 kHz. A comparator on the coil current drives the gates, so the bridge switches at the current's zero crossings and the frequency follows the resonance by itself: change `Lw` and it moves with it. The coil current is about 17 A peak and the workpiece takes about 1.76 kW. - `wptSeriesSeries` is an inductive wireless power transfer link at 85 kHz, the SAE J2954 frequency. A full bridge drives a primary coil, and a secondary coil across an air gap picks up the field; the coupling factor `k` is 0.2, far below a transformer. Each coil is tuned by a series capacitor (series-series compensation), so the link behaves as a current source: the secondary current is `V1/(ω·M)` whatever the load, about 5 A peak, and the 10 Ω load gets about 31 V and 100 W. Set `k` to 0.1 and the output current doubles while the primary current grows four times; double `Rload` and the output voltage doubles at the same current. Each coil carries its winding resistance (`Rc1`, `Rc2`, from a quality factor `Q` of 300), so the link passes about 96 % at k = 0.2. To see efficiency against coupling, run **Analysis › Parameter Sweep** on `k` (say 0.1 to 0.3) with two measures, `meanProduct` of `vab` and `i1` (power into the link) and `meanProduct` of `v2` and `i2` (power into the rectifier): their ratio follows `η = Rac/(Rac + Rc2) · (ω·M)²/((ω·M)² + Rc1·(Rc2 + Rac))`, falling to about 93 % at k = 0.1 as the primary current grows. - `wptSeriesParallel` is the same 85 kHz link with series-parallel compensation: the primary keeps its series capacitor, but the secondary coil is tuned by a capacitor across it and feeds the diode bridge through a 1 mH inductor. The primary capacitor is tuned to `L1·(1 − k²)`, not to `L1`, because the parallel secondary reflects a capacitive part into the primary; with it the bridge sees a pure resistance `(M/L2)²·Rac` and switches at zero current. The output is now a voltage source: the tank voltage is `V1·L2/M`, about 108 V peak at k = 0.2, whatever the load, so the 32 Ω load gets about 65 V and 135 W. Double `Rload` and the output voltage stays while the primary current halves; set `k` to 0.1 and the output voltage doubles. Sweep `k` with **Analysis › Parameter Sweep**, measuring `meanProduct` of `vab` and `i1` and of `v2` and `ir`: the efficiency goes from about 96.5 % at k = 0.2 to 92 % at k = 0.1, as the two mesh equations of the link say. - `wptDoubleLcc` is the same 85 kHz link with double-sided LCC compensation: on each side a series inductor `Lf` (30 µH), a capacitor `Cf` across the network tuned with it, and the coil with its series capacitor tuned to `L − Lf`, so no part depends on `k`. The primary coil then carries `V1/(ω·Lf1)` whatever the load or the coupling, and the rectifier is fed `M·V1/(ω·Lf1·Lf2)`, a current source: 50 V in gives 38 V and 74 W into 20 Ω at 96.4 % link efficiency. Halving `k` halves the output current but leaves the primary current alone. The square rectifier voltage drives a third harmonic through `Lf2`, so `v2` leads the fundamental of `io` by about 15°, and the bridge sees that same angle. Plot `i1`, `io` and `v(out)`; sweep `k` with `meanProduct(vab, iin)` and `meanProduct(v2, io)` for the efficiency curve. - `wptRobotDock` is a wireless charging dock for the 13S4P lithium-ion pack of `amrRobotSystem` (Samsung SDI INR21700-50E cells: 4.9 Ah and 14 mΩ each): a series-series link at 85 kHz (60 µH coils, k = 0.25 for the parked robot) charges the pack straight from its diode bridge, with no converter on the robot. The tuned link makes the secondary current `V1/(ω·M)` whatever it feeds, so 48 V in charges the pack at 4.7 A (about 230 W, 97 % link efficiency) at 20 %, 50 % or 90 % charge alike: the constant-current stage of a lithium-ion charge comes from the link itself. Misalignment lowers `k` and raises the current as `1/k` (7.65 A at k = 0.15), so a real dock must cut or lower `Vdc` when the robot parks off its pad, and to end the charge at constant voltage. Plot `i1`, `ibat` and `vbat`; set `soc0` or `k` to see each effect. - `wptEvCharger` is a wireless charger for an electric car in the WPT1 class of SAE J2954 (at most 3.7 kVA from the supply): a 400 V bus drives a double-sided LCC link at 85 kHz (200 µH pads, 50 µH LCC inductors, k = 0.2 for the aligned car) that charges a 96S20P pack of Samsung SDI INR21700-50E cells straight from its diode bridge. The ground pad carries `V1/(ω·Lf1)` = 19 A peak whatever the car does, and the pack is fed `M·V1/(ω·Lf1·Lf2)`, so it charges at 9.1 A (3.3 kW, 96.6 % link efficiency) at 20 % or 90 % charge alike. Unlike the series-series dock above, misalignment lowers the charge current in proportion to `k` (k = 0.15 gives about three quarters of it) while the pad's current stays put, so a car parked off its pad charges more slowly instead of drawing more current; the series capacitors see about 1.5 kV peak. Plot `i1`, `ibat` and `vbat`; set `k` or `soc0` to see each effect. Rectifiers - `rectifier` is a half-wave rectifier. - `bridgeRectifier` is a single-phase diode bridge with a 2200 µF capacitor on a 12 V rms winding. Two diodes conduct on each half cycle, the output ripples at 100 Hz, and the winding current flows in short pulses near each crest of the line. - `rectifier3Phase` is a three-phase diode bridge with a DC-link capacitor. The DC voltage settles close to 1.35 times the line-to-line voltage. - `scrRectifier3Phase` is a three-phase six-pulse thyristor rectifier on a 400 V, 50 Hz supply with 3 mH of source inductance per phase, feeding a 100 mH smoothing inductor and a 10 Ω load. A PLL-synchronised firing unit, in its own module, fires the six thyristors at the angle `alpha` (30° by default). The mean DC voltage follows `1.35·VLL·cos α` less the drop the source inductance causes, `(3/π)·ω·Ls·Id`, and each commutation takes the overlap angle µ (about 13° at 30°). Set `Ed` to 400 and `alpha` to 120 and the DC voltage turns negative: the bridge sends power back to the supply as a line-commutated inverter. - `cockcroftWalton` is a four-stage Cockcroft-Walton voltage multiplier: an ideal half bridge makes a 400 V, 50 kHz square wave (an AC peak of 200 V) and drives, through 10 Ω, a ladder of eight 100 nF capacitors and eight diodes into 160 kΩ. Unloaded, every stage adds twice the drive's peak, so the output is `2·n·Vpk` = 1600 V, less two diode drops per stage (the diodes are ideal; set `Vf` to see the drops). Loaded, read `vo`: about 1512 V with a 17.5 V sawtooth ripple. The textbook gives, with `I/(f·C)` = 1.89 V, a ripple of `n(n+1)/2·I/(f·C)` = 18.9 V and a droop of the peak of `(2n³/3 + n²/2 − n/6)·I/(f·C)` = 94.5 V; the run's droop is 80 V, because a square wave holds its peak through each half period and the diodes keep feeding the load from the drive, so the textbook is an upper bound here. The droop grows with the cube of the stage count, which is why a ladder is not made taller. The charge passed between capacitors at different voltages is lost as heat, so the efficiency is about `Vout/(2n·Vpk)`, 94 %. Change `Rload`, `fsw` or `C` with `circuit.variables` to watch both scale. - `electrolyzer12Pulse` is a twelve-pulse thyristor rectifier feeding a 200-cell water electrolyzer stack at about 395 V and 1.22 kA (0.48 MW). A 10 kV, 50 Hz supply feeds two transformers, one `Yy0` and one `Yd11`, whose 200 V secondaries are 30° apart; each drives a six-pulse thyristor bridge, and the two bridges are in series. The stack is a module holding the `electrolyzer` part: 200 cells of 0.5 m² at 70 °C on Ulleberg's polarisation law, so its voltage rises with the activation curve, not a straight line; set `Ncell`, `Acell` and `Tstack` for your stack. The firing unit fires both bridges at `alpha` (40° by default), the delta bridge 30° earlier. The mean DC voltage is twice the six-pulse bridge's, `2·(1.35·VLL2·cos α − (3/π)·ω·Lk2·Id)`. Run `analysis.fft` on `ia` with `fundamental` 50 over whole line cycles: each secondary carries the six-pulse harmonics 5, 7, 11, 13, but in the supply current the 5th, 7th, 17th and 19th cancel and only the orders 12k ± 1 (11, 13, 23, 25) remain, at about 1/h of the fundamental. - `electrolyzerInterleavedBuck` feeds the same 200-cell stack from a 1 kV DC link, the DC side of an active-front-end supply: four buck phases at 10 kHz, their carriers a quarter period apart, into one output. The stack is stiff (84 mΩ at its operating point) and the phases share only through their few milliohms, so a 10 ns shift of one gate edge would move tens of amperes between them. Each phase therefore has its own average-current loop (the `CurrentLoops` module): its inductor current is sampled once a period in the middle of the on time, where it equals its average, and a PI adds to the feedforward `vo/Vdc` to set that phase's duty (`d1` … `d4`). The loops hold the stack at `Iref` = 1.27 kA, where it takes about 399 V and the duty settles near 0.4, and they keep each phase at a quarter of it even when one switch has ten times the others' on resistance. Each inductor ripples 120 A peak to peak, but the sum `io` ripples at 40 kHz and only 30 A, a quarter of that; set `Iref` so the duty settles at 0.5 and the sum's ripple all but vanishes, since two phases are always on. - `electrolyzerAfe` is the whole active-front-end supply: a two-level IGBT bridge at 5 kHz draws 0.51 MW from a 690 V, 50 Hz grid through an LCL filter (0.5 mH on the bridge side, 100 µF damped by 0.41 Ω, 0.1 mH on the grid side, in the module `LclFilter`) and holds a 1.1 kV link, which feeds the four current-controlled buck phases and the 200-cell stack of `electrolyzerInterleavedBuck`. The link is 1.1 kV, not 1 kV, because the bridge must make the grid's 976 V line peak plus the inductors' 113 V drop and SVPWM reaches a line peak only as high as the link. The control (module `AfeControl`) locks a PLL to the grid, feeds the stack's power forward as the d-axis current `2·vo·io/(3·Vpk)` (600 A peak), trims it with a PI on the link voltage, holds the q-axis current at zero and closes two dq current loops; the dead times are in the module `GateDrive`. The run starts near its operating point (the line currents and the q-axis PI preset), so expect the link to dip only to about 1050 V and to be within 1 % of 1.1 kV after about 25 ms, the line currents to be sines in phase with the phase voltages (`idm` 600 A, `iqm` 0) and the stack to take about 99.5 % of the grid's power. Run `analysis.gridHarmonics` on `ia` over the last two line cycles: the TDD is about 0.6 % and every order passes even the strictest row of IEEE Std 519-2014, Table 2, where `electrolyzer12Pulse` fails. The grid has its own inductance (120 µH a phase), so its short-circuit current is 25 times the rated current: give `analysis.gridHarmonics` that `iscRatio` for the row it really falls in. The filter keeps the bridge's switching ripple off the grid: at 4.9 kHz only about 8 % of the bridge-side current `i(La)` reaches `ia`, the ratio of the damped capacitor branch to the grid side (Liserre, Blaabjerg and Hansen, IEEE Trans. Ind. Appl. 41(5), 2005). Its switches and diodes name 1700 V power modules of the device library (an Infineon FF600R17ME4 per bridge leg, the IGBT and diode of an FF450R17ME4 per buck phase), so `analysis.losses` over the same window gives their data-sheet losses at 125 °C: about 8.7 kW in the bridge and 16.3 kW in the buck, 14 kW of it switching, since 10 kHz is fast for a 1700 V IGBT. With every loss counted the stack takes about 95 % of the input; the circuit itself still passes 99.5 %, because the switching energies are counted rather than drawn from it. Side by side, at the same 0.5 MW stack: on `ia` over whole line cycles, `analysis.gridHarmonics` at each row of IEEE Std 519-2014, Table 2 (`pulseNumber` 12 for the twelve-pulse rectifier), and the power factor `P/(Vrms·Irms)` of phase a. | Supply | TDD | Table 2 rows passed | Power factor | |---|---|---|---| | `electrolyzer12Pulse` (α = 40°) | about 13 % | none, not even Isc/IL ≥ 1000 with the √(q/6) allowance | about 0.73, `cos(α + μ/2)·0.989` | | `electrolyzerAfe` | about 0.6 % | all five, Isc/IL < 20 included | over 0.99 | At the front end's own grid (Isc/IL = 25, row 20–50) the twelve-pulse current fails its TDD limit of 8 % and its 11th harmonic (about 9 % of IL against 3.5·√2 = 4.9 %). Its power factor follows the firing angle and the overlap μ (Mohan, Undeland and Robbins, ch. 6), so a thyristor supply also needs reactive compensation that the front end does without. `crates/engine/tests/example_electrolyzer_supplies_ieee519.rs` checks these figures (slow tier). - `viennaRectifier` is a three-phase Vienna rectifier: a diode bridge with one switch per phase and a split DC link. It draws 5 kW at unity power factor from a 400 V grid and holds the link at 800 V, with dq current control and a DC voltage loop. Inverters - `halfBridge` and `inverter3` are a half bridge and a three-phase inverter with sine-triangle PWM. - `inverter3Thermal` adds dq current control and a thermal model for every device. - `fullBridgeSpwm` is a single-phase full bridge with sine PWM and an LC filter. It makes a 50 Hz output of about 320 V peak from a 400 V link. - `upsInverter` is the island-mode inverter of an online UPS: a 400 V full bridge with unipolar PWM at 20 kHz and a 1 mH, 20 µF LC filter make 230 V rms at 50 Hz. A proportional-resonant voltage loop (with load-current feedforward) runs around a proportional inductor-current loop, both in the `upsControl` module. The load steps from 500 W to 1 kW at 65 ms and a diode rectifier with a 220 µF capacitor comes on at 120 ms. Read `vo` against `vref`: the output holds 230 V rms within 1 % with a THD of about 0.2 % on the linear load and under 1 % with the rectifier, and the load step costs a dip of about 6 V that is gone within 2 ms. The `Vout rms` and `Vout rms rect` measurements read the RMS at 1 kW and with the rectifier. - `upsOnline` is an online (double-conversion) UPS around `upsInverter`'s bridge, filter and control: the 230 V, 50 Hz mains, a 1:1.4 input transformer and a diode bridge charge a 1 mF link to about 436 V, and a 96-cell lithium-ion battery (about 393 V at rest) sits on the link behind a diode. `Smains` opens at `tFail` = 100 ms: the link falls onto the battery within about 20 ms and the battery takes the 1 kW load (`ibat` goes from zero to about 2.6 A), while `vo` stays at 230 V rms with a THD under 1 % in both modes. The run has no charger, so the battery only discharges. To stage the failure (or the return of the mains) as an IEC 62040-3 mode transfer, set `tFail` past the run and run Analysis › UPS Mode Transfer Test (`analysis.upsTransferStage`) on `Vmains`: the output stays within curve 1 both ways. With `Ncell` at 70 (286 V, under the output's 325 V peak) the output clips on the battery and fails every curve. - `sogiPllInverter` is a 3 kW single-phase grid-tied inverter whose point is its grid synchronisation. A SOGI-PLL, built from integrators and products in the `Pll` module (`sogiPll`), locks to a 230 V, 50 Hz grid that carries a 3 % 5th harmonic (`h5`), sags by 30 % from 0.1 s to 0.15 s and steps to 51 Hz at 0.2 s; the `Ctl` module (`gridCurrentCtl`) sets the grid current with a proportional-resonant controller and grid-voltage feedforward. Read `perr` (the PLL's phase error, degrees) and `fpll`: before the sag the error stays under 0.2°, the frequency estimate is within 0.2 Hz of 51 Hz 60 ms after the step, and the grid current `ig` has a THD of about 2 %. Set the variable `ksogi` to 0 and the PLL never follows the step. The `Grid current rms` and `Injected power` measurements read the current and `pg` before the sag. - `npcInverter` is a three-level neutral-point-clamped inverter on a split 800 V link. Each phase has four switches and two clamp diodes, so the output takes three levels and every switch blocks only half of the link. Sine PWM makes a line-to-line voltage of 554 V peak at 50 Hz. - `flyingCapInverter` is a single-phase three-level flying-capacitor leg on a split 800 V link. A 47 µF capacitor between the two upper and the two lower switches makes the middle level; the two switch pairs compare the same sine reference (index 0.8) with 10 kHz carriers half a period apart, so the two middle states last equally long, the capacitor holds 400 V by itself, and the output's first harmonics sit at 20 kHz, twice the carrier. The output is 320 V peak at 50 Hz into 16 Ω and 10 mH (3.1 kW). The modulator and the capacitor's sensing (`vfc`, and `vfcPu` per unit) are in the module `Ctrl`. - `anpcInverter` is a single-phase three-level active NPC leg: the NPC leg with two clamp switches in place of its diodes, on the same link and load. A switching-state table of six formula blocks drives the gates; the variable `zs` picks the zero state, so with `zs` = 0 the outer switches commutate at 10 kHz and with `zs` = 1 the inner ones do, which moves the switching losses with the same output. The midpoint drift of the link capacitors is `vnp`. - `tTypeInverter` is a three-level T-type inverter on the same kind of split 800 V link. Each phase is a two-level leg of 1200 V SiC switches plus a bidirectional switch of two 650 V SiC switches from the output to the midpoint, so the output takes three levels with four switches and no clamp diodes. Sine PWM with a modulation index of 0.9 makes a line-to-line voltage of 624 V peak into an 8 kW load. Each phase has its own modulator module. - `fourLegInverter` is a four-leg three-phase inverter on an 800 V split DC link feeding an unbalanced resistive star load: 100 %, 50 % and 20 % of a 10 kW rating on phases a, b and c (`ka`, `kb`, `kc`), through a 2 mH, 20 µF filter per phase, at 20 kHz with 100 ns of dead time. The fourth leg drives the load neutral. Its modulator (a module, gates by label) adds a common offset, minus the mean of the largest and the smallest phase reference, to the three phase references and gives the fourth leg that offset alone, the carrier-based form of 3D space-vector modulation (Zhang, Prasad, Boroyevich and Lee, IEEE Trans. Power Electron. 17(3), 2002). Each phase leg minus the neutral leg then averages its own 230 V rms reference whatever the load: `va`, `vb` and `vc` read 226.8, 231.0 and 230.0 V rms with 14.4, 7.4 and 3.3 A, and the neutral leg carries their sum back, `ineutral` = 10.1 A rms. The circuit variable `legs` = 3 stops the fourth leg and leaves the neutral floating: the star point moves and the phases read 158, 243 and 317 V. `legs` = 3 with `split` = 1 ties the neutral to the link's midpoint instead: the neutral current then flows through the two link capacitors, and with 1 mF each phase b sags to 214 V (`Cdc` = 4.7m brings it to 226 V). 400 V of link could not make 230 V rms: with a fourth leg the phase peak is at most `Vdc/√3`. - `chbInverter` is a five-level cascaded H-bridge inverter. Two H-bridge cells, each on its own isolated 400 V source, are in series, so the output takes the levels 0, ±400 V and ±800 V. Each cell uses unipolar sine PWM at 2.5 kHz, and the carrier of the second cell is shifted by a quarter period (π/N for N = 2 cells). The first harmonics of the output then sit at 2·N·fc = 10 kHz, four times the switching frequency of each switch. With a modulation index of 0.9 the fundamental is 720 V peak into a 5.4 kW RL load, and each cell delivers half the power. The modulator is one module whose pins are the eight gates. Plot `vo`, `io` and `v(mid)`, the output of the second cell. Motor drives - `imVf`, `imIfoc`, `pmsmFoc`, `pmsmSmo` and `dcMotor` are the drives of chapter 10. - `imDtc` is direct torque control of the induction motor of `imIfoc`, after the classic scheme of Takahashi and Noguchi. A flux estimator integrates the measured stator voltage minus the resistive drop. Two hysteresis comparators, one for the flux and one with three levels for the torque, pick the next switching state of the inverter from a table every 10 µs. There is no current loop and no PWM. The motor is first magnetised for 0.15 s. Then the torque reference is 2 N·m, and at 0.25 s it steps to 5 N·m. The torque follows within about a millisecond, and the stator flux stays in its band of 0.5 ± 0.01 Wb. Plot `Te(M1)` with `Tref`, and `psis`. - `bldcSixStep` drives a brushless dc motor with six-step commutation. The Hall signals of the machine pick the two phases that conduct, and a speed PI sets the duty cycle until the motor reaches 150 rad/s. - `stepperMicrostep` drives a NEMA 17 class two-phase stepper from 24 V through two H-bridges. A hysteresis chopper holds each winding current to a sine and cosine microstep table (1/8 step by default, `MS` = 1, 2 or 8), and the rotor turns one 1.8° step per 8 table steps, one turn per second. - `srmDrive` drives a three-phase 6/4 switched reluctance machine from 48 V. Each phase has an asymmetric half bridge. A position sensor gives the electrical angle, a table opens each phase for 120° while its inductance rises, and a hysteresis comparator holds the current at 8 A by chopping. The phases take turns, the average torque is about 0.88 N·m, and a fan load brings the speed to about 98 rad/s in 1.5 s. - `dcMotor4q` is the four-quadrant dc drive: a maxon RE 40 (article 148867, 24 V) on a bipolar-PWM H-bridge from a 24 V bus, with a 20 kHz current PI inside a speed PI, a 20 A limit and a reference that ramps to +400 rad/s, then to −400 rad/s. The bus sits behind a diode that cannot pass current back, so braking through zero charges the 2 mF link (second quadrant, negative armature current at positive speed) and a brake chopper clamps it below 28 V. - `matrixConverter` is a three-phase direct matrix converter. Nine bidirectional switches, each two MOSFETs in anti-series, join every input phase of a 400 V, 50 Hz supply to every output phase, with an LC filter on the input and a star RL load on the output. Venturini's modulation gives each switch its share of every 10 kHz period, `m = (1 + 2·v_in·v_out/V_im²)/3`, so each output averages a 30 Hz sine at half the input voltage, about 16 A in the load, while the supply current stays a 50 Hz sine. In each output exactly one switch is on at a time, never two (a short between input phases) and never none (an open inductive load); the monitor `mon` stays at zero. - `amrRobotSystem` is a whole autonomous mobile robot's electrical system over a 40 s pick-and-return task: 10 m to a shelf with a 90° turn on the way, a 15 kg payload lifted 0.5 m, held and lowered, and 10 m back with it, taking the corner the other way. A 13S4P pack of Samsung SDI INR21700-50E cells (47.2 V nominal, 19.6 Ah) feeds a 48 V bus with two wheel drives (maxon EC 45 flat motors through a 20:1 gear on 75 mm wheels, 0.5 m apart), a lift joint (the same motor on a 5 mm ball screw), a turntable joint (the same motor through a 50:1 gear, turning the set-down payload a quarter turn before the robot drives back) and three rails: 48 → 24 V for the actuators, 48 → 12 V for the compute and 12 → 5 V for the sensors. The pack's BMS (a TI BQ76952 driving two CSD19536KTT FETs back to back) opens its discharge FET below 2.5 V per cell or above 39.2 A, and its charge FET above 4.2 V per cell or 19.6 A into the pack, the cells' data-sheet limits; a trip latches, and the open FET's body diode still passes the other direction. Over the task both FETs stay on and lose 0.15 J; `gdsg` and `gchg` show their gates. Lower `Iocd` or `Vov` to watch a protection trip. Every drive and converter has an undervoltage lockout on the bus (`uven`): it stops below 29.9 V (`Vlo`, 2.3 V per cell, under the BMS's trip) and restarts above 32.5 V (`Vlon`), so once the BMS cuts the pack off the loads drain the bus capacitor only down to the lockout and the bus then holds. Each stage is an averaged module joined by labels: the motors' copper loss and the EPC2302 bridges' conduction loss are in, switching, iron and friction losses are not yet. Braking and lowering send energy back to the pack. On the turns the inner wheel slows to 0.75 m/s and the outer one speeds up to 1.25 m/s, so as a turn begins one drive brakes into the bus while the other draws: plot `pL` with `pR`. Over the task the pack gives 1.90 kJ: the wheels take a net 18 J, the lift 66 J (holding the payload costs its copper loss; lowering returns the lift's 74 J of potential energy), the turntable about 1.2 J (the turn starts and ends at rest, so only its ramps' copper loss remains), the 24 V rail 0.50 kJ and the 12 V rail with the 5 V one 1.32 kJ. The charge falls from 80 % to 79.95 %, and `Meter.runtime` gives 15.5 h at the task's mean power. `crates/engine/tests/amr_robot_system.rs` checks the wheel, lift and turntable energy against their equations, each wheel's speed on the turns and the quarter turn they give, the pack's energy against its consumers and its charge against its current, the FETs' loss against their resistance, both protections tripping, and the lockout stopping every load once a tripped pack leaves the bus to its capacitor. The run takes 1 ms steps and finishes in under a second. The task repeats every `Ttask` = 40 s, so `simulation.batteryRun` with `cycle` 40 and `model` `asDrawn` runs a whole shift in whole tasks: two hours take 13 tasks on the solver and 6 jumps, and the charge falls to 70.5 % (chapter 4, "A repeating mission"). The switched drives and converters follow. - `amrRail12Gan` runs the 48 V to 12 V rail of `amrRobotSystem` switched, beside the averaged rail the system uses: a 500 kHz synchronous buck of two EPC EPC2302 GaN switches with 20 ns of dead time, 10 µH and 47 µF, on the 52 V bus into the same 25 W load, over 3 ms. The switched rail holds 12 V with a 1.9 A inductor ripple and draws 25.15 W where the averaged one draws 25.006 W: 99.4 % against 99.98 %. The difference is the GaN switch conducting in reverse at 3.3 V through each dead time, `2·td·fsw·3.3 V·Iout` = 0.14 W, which the averaged model leaves out. Gate charge, output capacitance and inductor losses are not modelled, so the real rail loses more still. The load is a 5.76 Ω resistor rather than a constant-power load: a constant-power load is a negative resistance that makes the undamped output filter ring up. - `amrRail24Gan` does the same for the 48 V to 24 V actuator rail, at the 30 W it carries while the gripper holds the payload: the same two EPC2302 switches, 500 kHz and 20 ns, with 47 µH and 22 µF so that the 19.2 Ω load damps the filter (Q of 13 at 4.95 kHz, against 41 with the 12 V rail's 10 µH and 47 µF). The switched rail holds 24 V with a 0.55 A ripple and draws 30.09 W where the averaged one draws 30.002 W: 99.7 % against 99.99 %. At half the 12 V rail's current, the conduction loss the average keeps falls to a quarter, while the dead-time loss, 0.083 W, falls only to about half, so the higher the rail's voltage at the same power, the larger the share of the loss the average leaves out. - `amrRail5Gan` switches the 12 V to 5 V sensor rail, fed from the 12 V rail, at its 8 W: the same two EPC2302 switches, 500 kHz and 20 ns, with the 12 V rail's 10 µH and 47 µF (Q of 6.8 at 7.3 kHz into 3.125 Ω) and a trimming integrator four times stronger, since a 12 V input gives the loop a quarter of the 52 V bus's gain. The switched rail holds 5 V and draws about 8.11 W where the averaged one draws 8.004 W: 98.7 % against 99.96 %. Relative to the power, the dead-time loss is `2·td·fsw·Vrev/Vout`, and the GaN channel's 3.3 V reverse drop is two thirds of 5 V, so this rail loses 1.3 % of its power to the dead time, against 0.55 % on the 12 V rail and 0.28 % on the 24 V rail. - `amrWheelGan` runs the left wheel drive of `amrRobotSystem` switched, beside the averaged wheel module the system uses: three legs of EPC2302 GaN switches at 40 kHz with 50 ns of dead time drive the maxon EC 45 flat motor under `robotJointServo`'s field-oriented current loop, on the 52 V bus, at the end of the task's first acceleration (1 m/s, 0.5 m/s², carrying the payload). The current reference is the averaged module's torque over the torque constant, 0.476 A at 340 Hz, and the shaft is held at the operating point's speed. Over the last 5 ms of a 10 ms run the switched drive draws 15.571 W where the averaged module draws 15.564 W, 0.04 % apart: the motor's own copper loss, 1.17 W, dwarfs the bridge's conduction and the 12 mW the GaN switches lose conducting in reverse through the dead times, so the averaged model the system runs for its 40 s task leaves out little. Iron and friction losses are in neither model. - `amrLiftGan` does the same for the lift joint while it raises the 15 kg payload at 0.1 m/s on the 5 mm-lead ball screw: the averaged `liftJoint` module's torque, 117.1 mN·m at 125.7 rad/s, over the torque constant gives the switched FOC drive's 1.032 A at 160 Hz. The run is 12.5 ms and the last 6.25 ms are one whole electrical period. There the switched drive draws 20.24 W where the averaged module draws 20.21 W, 0.15 % apart: the motor's copper loss, 5.50 W, is 27 % of the power lifting, more than three times the wheel's share, and the dead time costs 26 mW. Iron and friction losses and the screw's efficiency are in neither model. - `amrTurntableGan` does the same for the turntable joint at the end of its first ramp, where it works hardest: the set-down 15 kg box (0.3125 kg·m²) reaching 2 rad/s while still speeding up at 10 rad/s² through the 50:1 gear. The averaged `turntableJoint` module's torque, 71.6 mN·m at 100 rad/s, over the torque constant gives the switched FOC drive's 0.631 A at 127.3 Hz. The run is two electrical periods, 15.71 ms, and the tests read the second. There the switched drive draws 9.24 W where the averaged module draws 9.21 W, 0.34 % apart: the motor's copper loss, 2.06 W, is 22 % of the power, between the wheel's share and the lift's, and the dead time costs 16 mW. Iron and friction losses and the gear's efficiency are in neither model. - `robotJointServo` is a robot-joint servo drive. A 48 V link feeds a three-phase inverter of EPC2302 GaN FETs switched at 40 kHz. It drives a maxon EC 45 flat motor (the 48 V winding, 402687) through a 50:1 strain-wave gear into a 0.025 kg·m² joint load. An 18-bit encoder on the motor closes three cascaded loops, all in one control module joined to the power stage by labels: a 2 kHz current loop on currents sampled once per PWM period, a 200 Hz speed loop and a 20 Hz position loop. The joint moves 0.2 rad at 2 rad/s, then takes a 1 mrad fine step and a 5 N·m load step. `analysis.loopGain` measures each crossover within a few percent of its design value, and the steps follow the linear cascade. - `regenBrake` brakes an AMR wheel (10 kg on a 75 mm wheel through a 20:1 gear, 1 m/s) to rest in 0.4 s with the 48 V GaN drive of `robotJointServo`. The battery's BMS has opened its charge FET, so the bus cannot send energy back and the 1 mF link would climb to about 100 V. A brake chopper (a 10 Ω resistor switched by a GaN FET, on above 58 V, off below 56 V) holds the link in its band. Of the 5.6 J of kinetic energy, the windings take 1.8 J and the brake resistor 3.5 J. - `evDriveCycle` drives a mid-size electric car over the FTP-75 urban schedule (the EPA's UDDS speed trace, 1369 s and 11.99 km, stored with its source). The car is the EPA test-car-list sedan of 5000 lb test weight with its coast-down coefficients A, B and C; the wheels must give `m·dv/dt + A + B·v + C·v²`. A 96S46P pack of INR21700-50E cells (348 V nominal, 78.5 kWh) supplies that wheel power through an ideal traction drive, a controlled current source on the HV bus. While the car brakes, the battery management lets back only what the cells allow: at most their 4.9 A maximum charge current each and no more than holds each cell at its 4.2 V charging voltage; the friction brakes take the rest (`Meter.efric`, with `Meter.eregen` and the regen share `Meter.regen`). A 12 V system hangs on the HV bus: an averaged 3.6 kW DC-DC (TI TIDA-020031, at its 95 % full-load efficiency target, up to 300 A) feeds 400 W of low-voltage loads, 1.5 kW from 300 s to 360 s, on a 4S16P battery of A123 ANR26650M1-B LFP cells (13.2 V, 40 Ah) that floats while the converter carries the loads and gives the rest above its limit (lower `Ildc` to see it); plot `vlv`, `idcout` and `iblv`. Each part is a module joined by labels: the drive cycle, the road load, the drive, the 12 V system and an energy meter that gives the pack energy, the distance, the wheel energy out and back and the consumption `Meter.kwh100`. Over the cycle the wheels take 6.5 MJ and braking gives back 3.8 MJ (59 %), the DC-DC draws 0.65 MJ for the 12 V loads' 0.61 MJ (`Meter.eldc`, `Meter.elv`), so the pack gives 3.3 MJ, 7.7 kWh/100 km, and its charge falls from 90 % to 88.9 %. The 12 V bus stays between 13.07 and 13.33 V. At 90 % charge all of the braking stays under the limit; started full (`soc0` 1), the pack stays at 403.2 V, the friction brakes take 1.15 MJ and the regen share falls from 59 % to 41 %. The run takes 0.1 s steps and finishes in well under a second. This is the first part of the EV system example: the averaged inverter and PMSM with their losses, and the on-board charger follow. Grid - `gridTieInverter` feeds a 10 A peak current into a 230 V, 50 Hz grid through an LCL filter. A phase-locked loop follows the grid, and a resonant current controller keeps the current in phase with the voltage. - `afe3Phase` is a three-phase active front end. It draws 5 kW from a 400 V grid at unity power factor and holds its DC link at 700 V, with dq current control and a DC voltage loop. - `statcom` is a STATCOM: a two-level bridge on a floating 700 V link that exchanges only reactive power with a 400 V grid. Its q-axis current steps from 0 to 20 A at 50 ms, so it supplies 9.8 kvar like a capacitor, and to −20 A at 150 ms, so it takes 9.8 kvar like an inductor. The link holds its voltage with a small d-axis current that covers the losses. Plot `iqm` with `iqref`, and `ia` with `va`. - `svcTcr` is a static VAR compensator on a weak 11 kV, 50 Hz bus (90 MVA short-circuit level, a short-circuit ratio of about 3): a delta-connected thyristor-controlled reactor (TCR, 16 Mvar at full conduction) beside a 14 Mvar capacitor bank tuned to 4.7 times the line frequency. A PI on the bus voltage sets the firing angle `alpha` between 90 and 180 degrees, and the TCR's fundamental susceptance follows `B(α) = (2π − 2α + sin 2α)/(π·ω·Lr)` (Miller 1982; Mathur and Varma 2002). An inductive load (0.5 MW, 6 Mvar) switches in at 0.7 s: the bus dips, then `alpha` rises from about 110 to 131 degrees and the bus is back at 11 kV within about 0.2 s. The firing control is the module `SvcControl`. Plot `vbus`, `alpha`, `bTcr` and `qsvc`. - `droopLoadSharing` shows two grid-forming inverters on an island: a 10 kW and a 5 kW inverter (averaged bridges) feed a 400 V, 50 Hz load bus over their own lines, each with a `droop` block in its control module. With the same 1 % P-f and 5 % Q-V droops they share the load 2:1, before and after a load step at 0.5 s, with no link between them, and the bus frequency falls with the load. Plot `p1` with `p2`, `q1` with `q2`, and `w1` with `w2`. - `aiPsuHoldup` opens one 3 kW rack PSU (OCP Open Rack V3 48V PSU, Rev 0.96): the PFC's 400 V bulk capacitor, sized for the 20 ms hold-up at full load (1.71 mF), and the LLC stage behind it, both averaged and lossless. The mains fails at 50 ms; the bulk gives the load's 3 kW, its voltage squared falling in a straight line, and the 48 V bus stays inside 47.5–51 V until the bulk reaches 300 V (the example's choice for where the LLC stops regulating), 20 ms later. Plot `vbulk` with `vbus`. - `aiPsuLlc` opens the same PSU's DC/DC stage switched in full: a 3.3 kW half-bridge LLC from the 400 V bulk to the 50.5 V bus (Infineon AN094110 Rev 1.0: `Lr` 10.5 µH, `Cr` 465 nF split with clamping diodes, a 15:4 transformer, an 18 mΩ half bridge, synchronous rectifiers drawn as 0.62 mΩ ideal diodes). The controller module `CTRL` sets the switching frequency from the bus voltage through a PI and a VCO limited to 45–250 kHz, and holds the bridge off below the 350 V input UVLO. At 1 ms the load steps from 35 A to 59.4 A (3 kW) at 1 A/µs and the bus moves by about 0.3 V, within the note's 1 V. At 2 ms the mains fails; the bulk, sized by the note's hold-up equation for 20 ms at 3 kW (3.26 mF), falls towards 350 V while the LLC lowers its frequency from about 79 kHz to about 61 kHz, below the tank's 72 kHz resonance, to keep the bus within 0.2 V of 50.5 V; the bulk reaches 350 V 20.3 ms after the failure and the UVLO stops the bridge. Plot `vbus` with `vbulk`, and `fsw`. - `aiPsuPfc` opens the same PSU's PFC stage switched in full: a 3.3 kW totem pole from the 230 V, 50 Hz line to the 400 V bulk (Infineon AN205739 V1.0: a 500 µH choke, a 65 kHz fast leg of 62 mΩ SiC MOSFETs, a return leg of 17 mΩ MOSFETs drawn as ideal diodes, 1.88 mF of bulk). The controller module `CTRL` runs average current mode with duty feed-forward: a PI on the bulk voltage, its 100 Hz ripple taken out by a notch and crossing over at the note's 35 Hz, sets the peak `ipk` of the line current, and a fast PI makes the current follow the line voltage. At full load the bulk sits on 400 V with 14 V of ripple and the power factor is above 0.99. At 42.5 ms the line is lost for 10 ms: the bulk falls to about 350 V, above the 300 V trip, and comes back to 400 V. At 110 ms the load drops to 10 % and at 180 ms it steps to 90 % at 0.2 A/µs; the bulk stays within 379–419 V. Plot `vdc` with `iac` and `vac`, and `ipk`. - `aiServerVrm` opens the power below the rack bus, switched in full: the intermediate bus converter (module `IBC`) and a 16-phase GPU core regulator. The IBC is the fixed 4:1 48 V → 12 V converter of Liang et al., CPSS Trans. Power Electron. Appl. vol. 7 no. 3 (2022), Table IV (97.92 % efficient at 720 W), drawn as an ideal 4:1 transformer behind the resistance that loses that 2.08 %, two modules sharing the rail and drawn as one, from the 50.5 V bus of `aiRackWorkload`. The regulator is 16 modules `PH1` to `PH16`, each a 1 MHz synchronous buck phase (Infineon BSC0902NS high side and BSC0901NS low side, the paper's 85 nH, 0.39 mΩ inductor, the TI TPS28225's 14 ns dead time) with its own current loop; their carriers are 1/16 of a period apart, so the ripples largely cancel at the core. The controller module `CTRL` holds the core at 0.8 V with a PI that sets the phases' common current reference `iref`. On the core sit 200 Murata 47 µF MLCCs (ESL 0.82 nH each, from the self-resonance) and ten Panasonic 1000 µF polymer capacitors. The GPU (`Igpu`) steps from 650 A to 1000 A at 1000 A/µs at 30 µs, holds 35 µs and steps back. Through both edges the core stays inside 10 % of 0.8 V (0.72–0.88 V) and settles within 2 %; the phases share the current; the IBC is about 99 % efficient at the run's current and the regulator about 86 %; the voltage loop crosses over near 95 kHz with about 57° of phase margin. Plot `vcore` with `igpu`, `iL1` with `iL9`, and `v12s`. - `aiServerChain` opens the whole chain on one rack bus slot, through a mains failure: a 3 kW PSU (module `PSU`, averaged as in `aiRackWorkload`), a 3 kW battery backup module (an 11S6P pack of 1.5 Ah cells and a 150 kHz boost to 48 V, after Analog Devices' ORv3 BBU design article; controller module `BBUCTRL`), the 4:1 IBC to 12 V (module `IBC`) and the GPU core regulators averaged (module `VRM`), feeding three GPUs on the training workload. The mains fails at 5 ms; once the PSU's hold-up is over the BBU holds the bus at 48 V and carries every swing of the workload, the bus never below 46 V. The default run is the 30 ms hand-over, switched; `simulation.batteryRun {tEnd: 240}` runs the BBU's 4 minutes on the averaged model in a few seconds of solver time, the pack falling from full to about 64 %. Plot `vbus` with `ipsu` and `ibbu`, and `soc`. - `aiRackHvdc` opens an AI rack fed at ±400 V DC (800 V pole to pole) instead of from AC. A power sidecar (module `Sidecar`, after the OCP Diablo 400 rack specification 0.7.0: each rail 410 V at no load and 400 V at full load, Table 4) feeds six 18 kW ±400 V to 50 V PSUs (module `PSU`, after the OCP ±400 V to 50 V 18 kW PSU specification 1.0.0: 50 V at no load, 49 V at full load, at least 97.5 % efficient at full load, a 6 ms hold-up), which carry a 90 kW GPU training workload on a 60 mF bus. The PSUs draw from the rails only while their input is inside ±380 V. At 1.1 s the DC feed is lost: the PSUs hold the bus for 6 ms from their own bulk capacitors, signal the loss to the 50 V battery backup (module `BBU`) 1 ms after it, and the BBU ramps up in 5 ms and carries the load from then on. The bus stays on the droop line, between 48.5 and 50 V, throughout. Plot `vbus` with `ipsu` and `ibbu`, and `vin` with `iin`. - `microgridIslanding` is a microgrid that loses its grid. A 10 kW battery inverter forms the voltage with a `droop` block set to 2 kW, a 6 kW PV inverter follows the bus with a phase-locked loop, and the local loads take about 12 kW. While the grid is connected it holds 50 Hz, so the battery delivers its set point and the grid supplies the rest. At 0.5 s the grid breaker opens: the battery takes over what the grid supplied, the island settles at about 49.83 Hz on the battery's droop line within 0.1 s, and the PV keeps delivering. Plot `p1` with `ppv` and `pgrid`, and `w1` with `wpv`. - `microgridResync` is the same microgrid going back onto the grid. The island forms at 0.5 s; from 1 s a synchroniser module (`SyncCtrl`) measures the phase angle between the bus and the grid side of the tie and, through a PI, shifts the battery's droop until the island runs in step with the grid. A sync check closes the tie once the frequency, voltage and phase-angle differences are within 0.3 Hz, 10 % and 20° (IEEE Std 1547-2003, clause 4.1.3, Table 5, for 0 to 500 kVA); the synchroniser waits for 1° (`dphiClose`) to keep the surge small. The tie closes at about 1.6 s, and the battery then hands the load back to the grid and returns to its 2 kW set point. Plot `dphi` with `tie`, `w1`, and `p1` with `pgrid`. - `vsmLoadSharing` is the same island with a `vsm` block (a virtual synchronous machine with an inertia constant of 2 s) in each control module instead of the droop. The steady state is the droop's: 2:1 sharing on the same droop line. After the load step the frequency falls gradually, slowed by the virtual inertia, and settles in about 0.15 s. Plot `w1` with `p1`. - `hvdcMmc` is a point-to-point HVDC link. Two three-phase MMC stations of arm-averaged arms, each on its own 220 kV grid, are joined by a 100 km, ±200 kV overhead line drawn as two pi-section lines. Station A sets the power: it ramps to 400 MW and then reverses to −200 MW, while the DC voltage keeps its polarity. Station B holds the DC voltage at 400 kV. The difference between `PA` and `PB` is the line's loss. - `lccHvdc12Pulse` is a line-commutated HVDC link scaled down to a few hundred volts. Each station has two transformers, one `Yy0` and one `Yd11`, feeding two six-pulse thyristor bridges in series: a twelve-pulse converter. The two stations, each on its own 400 V grid, are joined by smoothing reactors and a DC line, with the earth as the return. The rectifier sets its firing angle with a PI so that the DC current follows its order, which steps from 8 A to 10 A at 0.2 s. The inverter fires early enough that each thyristor it turns off keeps 18° of reverse voltage, its extinction angle. Each station's DC voltage follows `2·(Vd0·cos α − (3/π)·ω·Lk·Id)`, the overlap of about 24° shows in the thyristor currents, and the supply current has the 11th and 13th harmonics but almost none of the 5th and 7th. Renewable energy - `pvMppt` is a solar charger. Two modules in series feed a boost converter that charges a 104 V battery. A perturb-and-observe tracker moves the duty cycle step by step until the array gives its most power, about 558 W. - `qzsiInverter` is a quasi-Z-source inverter for a PV string. A 200 V source feeds an impedance network of two inductors, two capacitors and a diode ahead of a three-phase bridge. In shoot-through intervals both switches of a leg are on, the DC link falls to zero and the inductors charge, so the bridge sees 400 V with a shoot-through duty `D0` of 0.25. Simple-boost control puts the shoot-through only in the zero states, so the output is that of sine PWM: a 140 V phase peak at 50 Hz with `M` = 0.7. The input current never stops. Change `D0` and compare `vc1` and `vc2` with `(1−D0)/(1−2·D0)·Vin` and `D0/(1−2·D0)·Vin`. - `h5Inverter` is a transformerless PV inverter, 400 V of PV into a 230 V, 50 Hz grid at 10 A peak (1.6 kW), with a 2 mH inductor in each line. Without a transformer the PV array's capacitance to its earthed frame (`Cpv`, 150 nF here, split between PV+ and PV−) closes a loop through the earthed grid neutral, and the ammeter `AmL` in the frame's earth path measures the leakage current `ileak`. The fifth switch `Q5` between PV+ and the bridge opens while the bridge freewheels through its upper switches, so the bridge never connects both legs to the same rail: the common-mode voltage `vcm = (va + vb)/2`, measured from PV−, stays at 200 V with nothing at the switching frequency, and about 29 mA RMS leaks. Set `fb` to 1 and the same circuit runs as a plain full bridge with unipolar PWM: `vcm` then jumps between 0, 200 V and 400 V and carries `(2·Vdc/π)·J0(π·M/2)` = 160 V at 20 kHz, and about 1.7 A RMS leaks, 57 times as much. `fb` = 2 runs it bipolar, which keeps `vcm` steady too, at the price of a two-level output. - `hericInverter` is the HERIC transformerless PV inverter on the same PV array, grid and filter: two back-to-back switches across the bridge outputs (`Q5`, `Q6`) carry the freewheeling current while all four bridge switches are off. The floating bridge stays at half the PV voltage, since its four equal output capacitances share the charge, so `vcm` holds at 200 V and about 24 mA RMS leaks; with `fb` = 1 (bypass off, unipolar PWM) it is about 1.7 A, 68 times as much. Plot `ig`, `vg`, `vcm` and `ileak`. - `pvMicroinverter` is a module-level microinverter: one 350 W panel (the AUO PM072MW0 data sheet's 38.48 V, 9.10 A maximum power point) into a 230 V, 50 Hz grid. Two flyback cells, 1:6 and 50 kHz, half a period apart, run in discontinuous conduction with the duty `Dpk·|sin(ωt)|`, so each draws a power that goes as sin² and together they deliver a rectified-sine current into the film capacitor `Cf`; the unfolding bridge `Qu1`…`Qu4` flips every other half cycle at the grid's zero crossings. No current loop is needed: a perturb-and-observe tracker, sampling once per line period, moves only `Dpk`, and the panel settles at about 348 W, 99.4 % of its maximum. The 10 mF input capacitor `Cin` carries the power's 100 Hz ripple (about 3 V peak to peak on the panel). The grid current has a distortion of about 3.6 % and a power factor of 0.996, and the switches and diodes take about 2.9 W. The flyback transformers are the isolation barrier. Plot `vpv`, `ppv`, `ig` and `vg`. - `passiveBalancing4s` is a pack of four lithium-ion cells in series at rest. The cells start at different charges (70 to 80 %) and differ a little in capacity and resistance. Each has a 33 Ω bleed resistor and a switch across it; the module `Bal` finds the lowest cell voltage and switches on the bleed of every cell more than 15 mV above it, until it is within 5 mV. The fuller cells come down to the emptiest one in about 3 s and their extra charge becomes heat in the resistors. The cell capacity is set to about 1 mAh so that this fits in a run of 6 s. Plot `v1` to `v4`, `soc1` to `soc4` and the gates `g1` to `g4`. - `activeBalancing4s` balances the same four cells with a switched-capacitor balancer. Each cell has a pole of two switches across it, and a 4.7 mF capacitor joins each pair of neighbouring poles. One 1 kHz clock flips every pole together, so each capacitor sits across one cell and then the next, and carries charge from the higher to the lower. Nothing is sensed or decided. The cells meet at the pack's mean charge (74.9 %), not at the lowest cell, and the switches lose about 4 mJ against the 0.17 mAh the bleed resistors of `passiveBalancing4s` burn. Plot `v1` to `v4`, `soc1` to `soc4` and `i(Cf2)`. - `inductorBalancing4s` balances the same four cells with inductors. Three buck-boost stages each span two neighbouring cells: an upper and a lower switch across the pair and a 10 mH inductor from their pole to the joint between the cells. One 1 kHz clock drives every stage at a duty of one half, so each inductor's mean voltage is half the difference of its two cells, and its current carries charge from the higher cell to the lower one; `En` 0 holds every switch off. As with the switched capacitors, nothing is sensed, and the cells meet at the mean charge (74.9 %), within about 2 mV by 8 s, losing under 0.01 % of the charge. Plot `v1` to `v4`, `soc1` to `soc4` and `i(L2)`. - `hybridStorage` shares a pulsed load on a 48 V DC bus between a battery and a supercapacitor. Each store has its own bidirectional buck-boost (a half bridge and a 100 µH inductor at 50 kHz): the battery is seven lithium-ion cells (about 26 V), the supercapacitor 0.1 F starting at 24 V. The load draws 5 A, with 25 A pulses for 4 ms in every 16 ms. The control module `Ctrl` adds the bus voltage loop to the load current and passes the sum through a low-pass filter (`tauF` 20 ms): the filtered part is the battery's, the rest, the pulses and their edges, the supercapacitor's, and a slow trim (`Kw`) has the battery bring the supercapacitor back towards `Vsc0`, inside its window of 18 V to 30 V. Each share goes through an average-current loop on its inductor. Read `ibat`: a smooth wave about 19 A that peaks at 24 A, where with `Split` set to 0 (battery only) it follows the load to 52.5 A, 54 % more; the battery's rms current falls from 26.3 A to 19.2 A and its mean stays the same. `isc` carries the pulses (about 36 A out and 18 A back), `vsc` swings between 23 V and 24.7 V and `vbus` stays within 1.5 V of 48 V. Set `tauF` to 50u and the filter passes the pulses on to the battery again. - `packThermal4s` is a pack of four LiFePO4 cells in series delivering 10 A for 10 minutes. Each cell's loss, `I²·r0` = 1.14 W, flows into the core of its own two-node thermal model: the core's heat capacity, the conduction to the can, the can's heat capacity and the convection to the 25 °C air, all measured on a 2.3 Ah A123 26650 cell by Lin et al. (J. Power Sources 257, 2014, Table 1). The battery names its core net with its `thermal` param. After 10 minutes the core is 4.9 K above the air and the can 3.0 K, so a sensor on the can reads 1.9 K low; settled, they would be 5.8 K and 3.6 K. Give one cell `rAge` 1.5 and its core rises half as much again: the pack's hot spot. `ea` is 0 because the paper only plots how the resistance follows temperature; set it to have each cell's resistance follow its core. Plot `T(tc1)` to `T(tc4)`, `T(ts1)` to `T(ts4)` and `soc1` to `soc4`. - `agedPack4s` is a pack of four 75 Ah graphite/NMC cells in series, the cell of NREL's life model (Smith et al., NREL/CP-5400-67102, 2017: 75.1 Ah and 0.984 mΩ new), each aged by `battery.age` for 300 days of one 50 % cycle a day: three at 25 °C (`soh` 0.9298, `rAge` 1.5575) and `B2` by the pack's hot spot at 35 °C (0.8648 and 2.2629). From 95 % the pack delivers 75 A (1 C) for 45 minutes. The same current takes charge out of every cell, so `B2`, with less capacity, falls 7.5 % faster and ends at 8.4 % while the others are at 14.4 %; it is also the lowest cell from the start, 52 mV down on its larger resistance. A BMS's undervoltage cutoff trips on `B2` first, so the pack delivers only what its weakest cell holds and the rest is stranded. The rest-voltage table is the battery part's illustrative default, since the paper gives none. Age a cell for another life with `battery.age` and `apply`, or from a run with `fromRun`. Plot `soc1` to `soc4` and `v1` to `v4`. Power quality - `pfcBoost` is a boost power-factor corrector. It draws a sine current from 230 V, 50 Hz and holds 400 V DC for a 1 kW load. An outer loop sets the size of the current and an inner loop makes it follow the rectified voltage. - `ucc28180Pfc` is the UCC28180 data sheet's design example (SLUSBQ5D section 9.2, Figure 29): a 360 W universal-input boost PFC at 118 kHz, run at 115 VAC, 60 Hz. The IC is the library's `ccmPfcController` with the UCC28180's electrical characteristics, and every external part is the one Figure 29 prints: L2 327 µH, C16 270 µF, R4 32 mΩ, RFREQ 17.8 kΩ, CICOMP 2700 pF, the 1.004 MΩ / 13.3 kΩ divider, and 22.6 kΩ, 4.7 µF and 0.47 µF on VCOMP. Figure 29's 13.3 kΩ sets 382.5 V where the text's 13 kΩ gives 391 V; both are inside Table 1's 379 V to 402 V. It opens with `Vout`, `Vout ripple` (the twice-line ripple, 9.25 V by hand), `Iline rms` and `Pline`; Pline over 115 V times Iline rms is the power factor. The EMI filter, the switching losses and capacitor ESR are left out, and the example's description says so. - `ucc28056Pfc` is the UCC28056 data sheet's typical application (SLUSD37E section 9.2, Figure 26 and Table 1): the 165 W transition-mode boost PFC preregulator with a 390 V output, run at 230 VAC, 50 Hz and full load. The IC is the library's `tmPfcController` with the UCC28056's electrical characteristics: each on-time starts at the drain's valley, which the ZCD/CS pin finds through a divider from the drain instead of an auxiliary winding, and the COMP voltage sets the on-time with line feed-forward. Every part is the one Figure 26 prints: L3 200 µH, C16 + C17 136 µF, R9 ∥ R10 65 mΩ, the 9.72 MΩ / 24.3 kΩ ZCD/CS divider, the VOSNS divider for 390 V and the 33 nF, 180 kΩ and 1 µF COMP network. The EMI filter, the inrush parts and the VCC filter are left out (the line is ideal and VCC a 12 V source). After one run it reads Vout 388.5 V, a twice-line ripple of 10.8 V peak to peak (equation 97: 9.9 V), an inductor peak of 2.27 A and 165.5 W from the line. - `ucc256404Llc` is the UCC256404 data sheet's design example (SLUSD90F section 8.2, Table 8-1 and the section 8.2.2 procedure): a half-bridge LLC converter from a 390 V bulk to 12 V, run at the 10 A of Table 8-1's ripple row. The IC is the library's `llcController` with the UCC256404's electrical characteristics, and every value is the one section 8.2.2 selects: CR 30 nF, LR 85 µH and LM 510 µH (99.7 kHz), NPS 16.5, the 3 × 4.99 MΩ / 41.2 kΩ BLK divider (start at 365 V), CISNS 150 pF with RISNS 133 Ω, the 68 pF / 8.2 nF VCR divider, the 30.9 kΩ / 5.36 kΩ BW divider on the bias winding, and CLL/SS 68 nF with 549 kΩ / 316 kΩ. The data sheet gives no output capacitance, MOSFET or rectifier part, so those keep the library circuit's values; the secondary regulator and optocoupler are a PI on the output; the example's description lists each. It opens with `Vout` (12 V), `Vout ripple` (below Table 8-1's 120 mV), `Ir rms` (between equation 26's 0.673 A and equation 28's 1.367 A) and `VCR pin pk-pk` (below equation 65's 4.17 V). - `uc3854Pfc` is the UC3854 data sheet's typical application (SLUS336A section 9.2, Figure 9 and Table 1): the 250 W boost PFC preregulator at 100 kHz, run at 115 VAC, 60 Hz and full load. The IC is the library's `multiplierPfcController` with the UC3854's electrical characteristics: average current mode with a multiplier that follows the line through IAC and RMS feedforward through VRMS, so the input power stays the same at any line. Every external part is the one Figure 9 prints: 1 mH, 450 µF, R14 0.25 Ω, IAC 910 kΩ / 220 kΩ, the VRMS filter 910 kΩ, 91 kΩ, 20 kΩ with 0.1 µF and 0.5 µF, RSET 15 kΩ with CT 820 pF, 24 kΩ, 620 pF and 62 pF on the current amplifier, the 511 kΩ / 10 kΩ divider with 180 kΩ and 47 nF on the voltage amplifier. Where Figure 9 and its text differ, the drawn part is used (PKLMT's R12 1.6 kΩ, a 4.8 A trip, where the text computes 6 A with 2 kΩ). R7 makes the voltage loop proportional, so the output sits near 396 V at full load, above the divider's 390.75 V. It opens with `Vout`, `Vout ripple` (the twice-line ripple, 3.7 V by hand), `Iline rms` and `Pline`; Pline over 115 V times Iline rms is the power factor (0.99 in section 9.2). The EMI filter, the bias winding that supplies VCC, the MOSFET's part and capacitor ESR are left out, and the example's description says so. - `ucc38050Pfc` is the UCC38050 data sheet's typical application (SLUS515G section 8.2, Figure 19 and Table 1): the universal-line 100 W transition-mode boost PFC preregulator, run at Table 1's 85 VAC, 60 Hz and full load. The IC is the library's `crmPfcController` with the UCC38050's electrical characteristics: each switching cycle starts when the zero-current detector sees the inductor current end and stops when the switch current reaches the multiplier's threshold, so the line current follows the line. Every external part is the one Figure 19 prints: L1 1.0 mH, C5 560 nF, C3 220 µF, R7 0.2 Ω, the MULTIN string 1.1 MΩ + 1.1 MΩ over 15 kΩ and 1 nF from D2 and D3, CS 330 Ω with 1 nF, the 1.02 MΩ / 6.34 kΩ divider (404.7 V), 11.5 kΩ with 1 µF and 120 nF on COMP, ZCD 22 kΩ with 18 pF, and the 10 Ω gate resistor. Figure 19 prints no turns ratio for the auxiliary winding, so it is sized by the data sheet's ZCD rules (1/15). It opens with `Vout`, `Vout ripple` (the twice-line ripple, 2.98 V by hand), `Isw peak` (equation 3's 2·√2·PIN/VAC, about 3.4 A) and `Pline`. There is no line-current RMS row: with only C5 before the bridge, the line current carries the triangular switching current itself. The bias winding that supplies VCC, the IRF840's own data, the fuse and capacitor ESR are left out, and the example's description says so. - `crmPfc` is a critical-conduction-mode boost corrector for 150 W at 400 V. The on-time is the same in every switching cycle, and an auxiliary winding on the boost inductor starts the next cycle once the inductor current is back at zero. The average current then follows the line voltage with no current loop, and the switching frequency moves over the half-cycle, from about 42 kHz at the mains peak to several times that near the zero crossing. - `interleavedPfc` is a two-phase interleaved boost corrector for 2 kW. The two legs switch half a period apart, so their ripple currents cancel in the sum. The cancellation is complete where the duty cycle is 0.5. - `coupledBoost` is a two-phase interleaved boost from 24 V to 200 V at 300 W and 100 kHz, its two phases half a period apart on one inverse-coupled inductor pair with 100 µH leakage. The variable `k` sets the coupling (0 gives two separate 100 µH inductors). Average current-mode control: a voltage PI sets the input-current reference, a current PI trims the duty. Set `Vin` to 100 V and `Pout` to 1500 W for a duty of 0.5: the input ripple falls to about 0.07 A against about 5 A in one uncoupled phase, and with `k` = 0.6 each phase ripples about 1.3 A instead of 5 A at the same leakage. - `totemPolePfc` is a totem-pole bridgeless corrector for 1 kW. A GaN half bridge (GS66508T data) switches at 65 kHz and a pair of silicon rectifiers takes the return current at 50 Hz, so the current passes through one rectifier instead of two in a diode bridge. A comparator on the line voltage picks which GaN switch is the boost switch in each half cycle. The control is a module; open it to see the two loops. - `bridgelessPfc` is a dual-boost bridgeless corrector for 400 W, 230 V in and 400 V out. Each mains terminal has its own boost inductor (2.2 mH) with a switch to the output return, a fast diode to the output and a slow diode from the return; one gate signal at 65 kHz drives both switches, so the line current crosses one fast and one slow diode per half cycle instead of two bridge diodes. The ammeter at the line terminal reads both half cycles. The control is a module (the same average-current loops as `totemPolePfc`); read `vdc` settling to 400 V and `iac` following `vac`. - `activePowerFilter` is a shunt active power filter. A 10 kW six-pulse diode rectifier draws a line current with a THD of about 26 %. A two-level inverter at the point of common coupling supplies the harmonics and the reactive part of that current, so the grid supplies a sine with a THD of about 3 %. Measure `isa` and `iLa` with the total harmonic distortion option of the scope measurement. Control - `pcmBuckArch` is a 12 V to 5 V, 2 A synchronous buck closed through the architecture blocks of a peak-current-mode controller: `pcmModulator` at 500 kHz with a slope-compensation ramp of half the sensed down-slope, an `opAmp` type II error amplifier, `softStartRef`, `uvloComparator` and `ocpHiccup`. The output rises with the 470 µs soft start and holds 5 V when the load halves at 1 ms. Plot `v(comp)` to see the control voltage the averaged modulator predicts. - `cotBuckArch` is a 12 V to 3.3 V buck with a 550 ns constant on-time: it switches near 500 kHz, and the feedback valley sits on the reference. Lower the ESR of `Resr` below `tOn/(2·C)` and the pulses bunch together. - `hystBuckArch` is the same buck with a 10 mV hysteresis window at the feedback. Its frequency follows the ESR: double `Resr` and it doubles. The blocks are described in [Models](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/10-models/#architecture-blocks-for-power-ic-design). ## The power electronics course Four lessons of a power electronics course are built on these examples: diodes and rectifiers, the buck, the boost and buck-boost, and the flyback. Click **Guided Lessons** in the activity bar and choose **Course 1** to **Course 4**. Each lesson opens its circuit, asks you to predict a number, and checks your answer against your own run; **Next** waits until it is right (a small **Skip this step** link moves on anyway). The theory, the answers and a lab handout for each lesson are on the website's course pages (`/course`), with a page for instructors. ## Things to try - Open a closed-loop example and run it. The output voltage settles at the reference. Change the circuit variable `Vref` in Circuit > Variables and run again to see the loop follow. - Change the load resistor `R1` and run again. A closed-loop converter holds its output; the open-loop one does not. - In `fullBridgeSpwm`, change `Mi` (the modulation index) and measure the fundamental with the total harmonic distortion option of the scope measurement. - In `dab`, change `Phs` and run again. The power grows with the phase shift up to 90 degrees. - In `threePortDab`, set `Phs2` to −10 and run again. The battery bridge now leads the source, so the battery discharges and, with the source, feeds the load (`i(V2)` turns negative). - In `threePortDabClosedLoop`, set `Idis` to 0 and run again. After the step the battery neither charges nor discharges, and the source alone feeds the load; plot `phs2` and `phs3` to see both loops move. - In `threePhaseDab`, set `Phs` to −30 and run again. The secondary bridge now leads, so the 400 V bus gives about 10.4 kW back to the 800 V bus (`i(V2)` turns negative). - In `solidStateTransformer`, set `Rload` to 80 and run again. The output stays at 200 V while the phase shift `phs` falls to about 10 degrees, and the mains current halves. - In `solidStateTransformerAc`, plot `vout` and `phs` together: the phase shift follows the 100 Hz pulsation of the output power. Set `Vout` to 100 and run again; the modulation index `Mi` follows, and the output drops to about 99 V rms. - In `pfcBoost` and `afe3Phase`, measure the power factor with the power option of the scope measurement, for example the voltage `vac` and the current `iac`. - In `interleavedPfc`, plot `il` and `i(L1)` together and zoom in on a few switching periods. The ripple of the total current is much smaller than the ripple of one inductor. - In `imDtc`, change the torque band `dTe` or the flux band `dPsi` and run again. A narrower band gives less ripple and more switching. - In `batteryCharger`, change the circuit variable `Icc` and run again. The current holds the new limit until the pack voltage reaches `Vcv`. - In `batteryChargerLongRun`, run `simulation.batteryRun` with `tEnd` 5400 and plot `ibat` and `soc`. Then run `simulation.batteryZoom` with `at` 1800 and `span` 0.005 to see the inductor ripple half an hour into the charge. - In `passiveBalancing4s`, set the circuit variable `Rbleed` to 100 and run again. The bleed current falls to about 40 mA and the cells need about three times as long to come together; set `Vth` to 1 and they stay apart. - In `passiveBalancing4s`, age the fullest cell with `battery.age {days: 300, temp: 45, voc: 4.2, component: "B2", apply: true}` (300 days stored full at 45 °C: `soh` 0.86, `rAge` 2.8) and run again. With 14 % less capacity the same bleed current empties it faster: `B2` bleeds for 2.2 s instead of 2.6 s, and the pack still ends balanced. - In `activeBalancing4s`, set `Cfly` to 1m and run again. Each capacitor now acts as about 1 Ω instead of 0.21 Ω, and the cells take several times as long to meet. - In `activePowerFilter`, set the current gain `Kpi` lower, for example to 10, and run again. The filter follows the load's harmonics less closely, and the THD of the grid current rises. - In `droopLoadSharing`, set the inductance `l` of `Line2` to 3m, the same as `Line1`, and run again. Active power still shares 2:1, but reactive power no longer does. - In `microgridIslanding`, set the circuit variable `Pbat` to 5k and run again. On the grid the battery now delivers 5 kW and the grid less; after islanding the frequency settles closer to 50 Hz. - In `microgridResync`, set the circuit variable `dphiClose` to 20 and run again. The tie closes earlier, at the 20° edge of the limit, and the power through it surges several times higher. - In `vsmLoadSharing`, set the circuit variable `H` to 0 and run again. Without inertia the frequency drops at once at the load step; it ends at the same value. - In `matrixConverter`, set the circuit variable `fout` to 70 and run again. The output now runs faster than the input; the modulation is the same law, so any output frequency works. Set `Cf` to 1u and the supply current carries the 10 kHz switching pulses. - In `switchedCap`, set `Cfly` to 11u or `fsw` to 100k and run again: the output resistance doubles, as the slow-switching limit `3/(16·C·fsw)` says. Set `Cout` to 47u and it reads about a quarter below the estimate, since a small output capacitor shares charge with `C1` and the output is no longer a stiff source. - In `threeLevelBoost`, set the circuit variables `Kpb` and `Kib` to 0 and run again. With no balancing loop, the load step pulls the halves apart until each load draws the same current: about 435 V on top and 365 V below, so one switch blocks more than half the link. Set `phB` to 0 instead and the middle level is gone: the inductor ripples at 50 kHz and about five times higher. - In `fourLegInverter`, set the circuit variable `legs` to 3 and run again. Without the fourth leg the unbalanced load pulls its star point off centre and the three phase voltages part by about 160 V; set `split` to 1 as well and the link's midpoint holds the neutral, but only as well as the link capacitors can carry the neutral current. - In `hvdcMmc`, set `v0` of `LineP` and `LineN` to 0 and run again. The line now starts uncharged: switched onto ±200 kV, it rings at its top mode near 4.5 kHz, and the ringing in `idc` and the line currents takes a few hundred milliseconds to die out. - In `lccHvdc12Pulse`, set the circuit variable `gamma0` to 10 and run again. The inverter now runs with less margin and a higher DC voltage, higher than the rectifier can reach at its 5° limit, so `alphar` sits at 5° and the DC current settles below its order. With `group` of `TDr` set to `Yy0`, the station becomes six-pulse, and the 5th and 7th harmonics come back in `iar`. All values in the examples are illustrative. They are chosen to show the circuit working, not to match a product. ## For people who add examples An example is a function in `crates/circuit/src/examples/`, in the file of its category. A row in the catalogue (`catalog.rs`) gives it a category, a one-line description in English and in Traditional Chinese, and the signals the scope shows when it opens. The menus and the window read that table, so nothing else in the interface changes. Every example needs a test that simulates it and checks a physical result. --- # 16. Automatic design URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/16-automatic-design/ Automatic design turns a specification into a converter that has been checked. You write the spec: the input range, the output, the load, and any limits you care about. Voltecx chooses a topology, draws it, sizes the parts, closes the voltage loop, checks every corner of the spec by simulation, tunes what it can, and writes a report. The command is `design.auto`. This chapter is about the whole pipeline. It also describes each tool the pipeline is built from, because you can run each one alone. Read "What is an estimate" before you trust any number outside the simulator. > **Needs sign-in to Voltecx Cloud.** `design.auto` runs on Voltecx Cloud, not on your computer. Sign in first under **Help > Licence** (chapter 1, "Voltecx Cloud account"). Only the spec and the options you give are sent; the open circuit stays on your computer, and the design comes back into it. `analysis.pareto`, the design report (`report.export`, `report.designSummary`) and PSIM import run there too. The menu items say so when you hover over them, and their forms say so above the fields, with your sign-in state: signed in, waiting for approval in the browser, or not signed in. The command-line tool has no link to Voltecx Cloud of its own: run these commands through a signed-in desktop app (`powercraft-cli app`); otherwise they answer that they run on Voltecx Cloud. ## What to expect - `design.auto` makes a starting design and checks it against your spec. It does not promise a pass. When the design does not pass, the report names the stage that stopped it and the rows that failed, with a next step for each. - Every number in the report comes from a simulation or from a textbook equation that the report prints beside it. Nothing in the run is random except the Monte Carlo yield, which uses a seed you can set. The same spec and seed give the same circuit and the same report. - The run has hard limits on the number of simulations and the number of solver steps. A run that reaches a limit stops and says so. - `design.auto` replaces the content of the open circuit. When no circuit is open, it makes a new one. Save your work, or open **File > New Circuit** first. A run from the Auto Design window asks you first: see "Review before it replaces the circuit" below. ## Write a spec A spec is a JSON object. Three fields are required: `vin`, `vout` and `iout`. Everything else is optional. A limit you leave out is not checked, and the report lists it as not checked. The same spec is used by `design.auto`, `spec.verify`, `design.robustLoop` and `analysis.pareto`. Values are numbers in base units: volts, amperes, seconds, hertz, percent and degrees. A value may also be a string with an SI suffix, such as `"4m"` or `"500k"`. A name that is not a spec field is an error, and the message gives the path (`spec.vin.maxx`). A missing required field is an error that lists every missing field at once. | Field | What it means | |---|---| | `vin` | The input voltage range as `min`, `nom` and `max`, in volts. The three must be in that order | | `vout` | The output as `nom`, in volts, and `tolPct`, the allowed error in percent. A negative `nom` asks for an inverting converter | | `iout` | The load current range as `min` and `max`, in amperes. `max` must be above 0 | | `ripple` | `maxPp`: the largest peak-to-peak output ripple, in volts | | `loadStep` | The load jumps from `from` to `to` amperes, ramping at `slew` A/µs when given, and goes back to `from` after the output settles (`release`, true by default). `maxDroopPct` is the largest dip or rise of the output in percent, after either edge. `maxSettle` is the longest time to recover, in seconds, and is optional. A spec with a DC output and no `loadStep` is held to a default one: from half to full load and back at 1 A/µs, within 10 %. It is marked `"assumed": true` in the reply's spec and rows and named in its notes, and `design.auto` then also designs a buck's loop for it, keeping the crossover at or above a fiftieth of the switching frequency it starts from. On other converters (a boost's right-half-plane zero, a SEPIC, a flyback, a resonant converter) `design.auto` reads and shows the default step without designing for it (`"gate": false`), and a miss is an open item. Write `"loadStep": false` to leave it out. Each edge is reported in volts and millivolts (`undershootV`, `overshootV`), with its settling time to the tolerance band (`settleS`, `settleBandV`) | | `lineStep` | The input jumps from `from` to `to` volts, at the load `iout` (optional). `maxDeviationPct` is the largest output deviation in percent. `maxSettle` is optional | | `startup` | `maxTime`: the longest time to reach the output, in seconds. `maxOvershootPct` is the largest overshoot in percent, and is optional | | `efficiency` | A list of points. Each has `iout`, an optional `vin`, and `minPct`, the lowest efficiency in percent at that point. At most 16 points | | `tjMax` | The highest junction temperature of any switch or diode, in degrees Celsius | | `ambient` | The ambient range as `min` and `max`, in degrees Celsius. It adds temperature corners | | `pmMinDeg` | The lowest phase margin of the loop, in degrees | | `gmMinDb` | The lowest gain margin of the loop, in decibels | | `corners` | A list of operating points, each with `vin`, `iout` and an optional `ambient`. When you leave it out, Voltecx uses every combination of the minimum, nominal and maximum input, the minimum and maximum load, and the two ambient limits. At most 64 corners | | `loop` | How the loop gain is measured. `signal` is the signal to break the loop at (the default is the input of the PI block). `fStart` and `fStop` are the sweep limits in hertz (the defaults are the switching frequency divided by 500 and by 20). `points` is the number of frequencies, from 3 to 40, default 8. `amplitude` is the size of the injected signal. `at` is `vinCorners` (the default) or `nominal` | | `monteCarlo` | A yield test with random part values. `tolerances` maps a part parameter such as `C1.c`, or a circuit variable, to a tolerance from 0 to 1. `runs` is 20 by default and at most 200. `seed` is 1 by default. `distribution` is `uniform` or `gauss`. `minYieldPct` is the share of builds that must pass | | `bind` | Names for a circuit that Voltecx does not recognise as a converter: `source`, `load`, `outNet` and `fsw`. You do not need it for a design that `design.auto` drew | | `tEnd` | The shortest start-up run, in seconds, at most 10. The default is the circuit's own end time. A run also lasts at least eight closed-loop time constants of the loop's crossover, and it goes on while the output is still settling, up to eight times its first length. A row read while the output was still settling says so in its note | | `referenceCheck` | `true` by default. The nominal corner is run again on the reference solver, and a row where the two solvers disagree is flagged. Set it to `false` to save time | `design.auto` reads these fields to design the circuit: `vin`, `vout`, `iout`, `ripple`, `tjMax`, `ambient.max` and `pmMinDeg`. All the other fields are handed to `spec.verify`, which uses them to check the result. ### Options for the run Eight more objects sit in the spec next to the requirements. `design.auto` reads them and takes them out before the spec goes to `spec.verify`. | Field | What it does | |---|---| | `auto.mode` | `direct` (the default) sizes from the ranking and the textbook equations. `pareto` adds a stage that searches with `analysis.pareto` and takes the switching frequency and the ripple from the knee of the front. It works for a buck, a synchronous buck, a boost, a synchronous boost and a buck-boost | | `auto.bestEffort` | `true`, `false` (the default) or a list of gate names. A gate in the list may fail without stopping the run, and the failure stays in the report. The gate names are `feasibility`, `pareto`, `magnetics`, `robustLoop`, `verify`, `gateDrive`, `senseNetwork`, `isolatedFeedback`, `protection`, `analogControl`, `digitalize`, `codegen`, `emi`, `auxRails`, `layout`, `bom`, `life`, `cost`, `protectionCases` and `kicad` | | `auto.outputDir` | A folder for the files the run writes: the firmware and the software-in-the-loop files, `bom.csv` and the KiCad project. Without it those stages run but write no files, and say so. It needs a folder the program may write to | | `auto.debugAids` | `true` adds the debug aids of `design.debugAids` (0 Ω links, isolation links in the IC supplies, the inductor's current loop, the loop-injection resistor with its test points, DNP snubbers and gate-resistor footprints, test points, DNP bulk footprints) after the emi stage, so the layout, the bill of materials and the KiCad project include them, and the report gets a Bring-up section. The default is `false` | | `auto.blocks` | `true` hands the circuit back grouped into one block per design step (`circuit.groupBlocks`): POWER_STAGE, EMI_FILTER, PROTECTION, SENSING, CONTROLLER and GATE_DRIVE, laid out in power-flow order with the control row joined by net labels, each block with its key values over it. The parts the gate drive, sense, feedback, protection and EMI stages added go into their step's block. It runs after the KiCad stage, so the layout, the bill of materials and the KiCad project see the flat circuit; the netlist is the same. The default is `false` | | `auto.model` | `averaged` (the default) runs the verifications' corners below full load, their load and line steps and their loop gain on the circuit-averaged model of a buck, boost, buck-boost, SEPIC or flyback (the switch and diode replaced by their averages over a period, in continuous and discontinuous conduction), and the worst case's output mean over the tolerance box; the full-load corners (the worst ripple and stress), the efficiency, the junction temperatures and the worst case's ripple stay on the switching circuit, and each full-load corner runs on both models so the report shows how well they agree (within 1 % of the output). After each verification the averaged model runs to steady state at the circuit's operating point and its capacitor voltages, inductor currents and loop duty become the circuit's starting values, so the switching runs after it (efficiency, temperatures, stress, parts, emission, bill of materials) and the worst case's ripple runs, each started at its own input's steady state, last about four loop time constants instead of the slowest corner's settle time; the ripple runs are still continued while their output settles. The run then takes under half the solver steps. `switching` runs everything on the switching circuit. An LLC or phase-shifted full bridge always runs switching | | `emi.class` | `A` or `B`. The default is `B` (CISPR 32) | | `emi.marginDb` | How far below the limit the spectrum must stay, from 0 to 40 dB. The default is 0 | | `emi.filter` | `auto` (the default), `none`, `oneStage` or `twoStage` | | `emi.apply` | `true` puts the sized input filter into the circuit whenever one is sized. The default is `false`: the filter goes in only when the circuit misses `emi.marginDb` without it and the converter has an input capacitor (the filter is sized for one that holds the switching ripple; without it the run says so in the open items). Either way, the filtered circuit is verified again at every corner (regulation, ripple and loop margins; the transients, losses and tolerances the filter does not change are left out to stay inside the step budget) | | `digital.format` | The number format of the firmware, as `design.digitalize` names it. The default is `q31` | | `cost` | A cost target: `max` is the most one board may cost in US dollars, `qty` the boards built at once (1 by default; each part is priced at the quantity break of its pieces times `qty`) and `prices` the prices as `bom.export` takes them. With `max` the bill of materials picks the cheapest of the best candidates, and the `cost` gate fails when one board costs more ("not feasible at this cost") or when a line has no price, which it names. Voltecx ships no prices it has not read on a cited page, so give `prices` or set `NEXAR_TOKEN` | | `life` | A life target: `years`, the shortest capacitor wear-out life asked, and `ambient` in °C (default the spec's `ambient.max`, else 40). Before the bill of materials each electrolytic, polymer or hybrid capacitor that wears out sooner is swapped for the first `bom.export` alternate that lasts (`design.reliability`'s formula). The `life` gate judges the parts bought, and the report's Cost and life chapter lists the swaps and the `design.tradeoff` table. With `missionProfile` (the parameters of `design.lifetime`: `profile` or `csv`, `model` and the rest) the `life` gate also checks the power semiconductors' thermal-cycling life under that profile, and the chapter shows it | | `control.implementation` | How the loop is built. `digital` (the default) turns the compensator into firmware. `analogOpAmp` builds it as a Type II or III network around an LM358B op-amp with a TL431 reference; `controllerIc` around the error amplifier and modulator of a PWM controller IC: the LM5145 for a buck, the UCx843 for a boost, SEPIC or flyback. On a boost or a non-isolated flyback the UCx843 runs in peak-current mode, in the circuit: the IC drives the switch, its current-sense comparator reads `Rcs` with the 1 V clamp, and slope compensation from its oscillator ramp keeps a duty above 50 % stable (see analogControl below). On a SEPIC it is still modelled as its error amplifier and reference with a voltage-mode modulator (a ramp of `vcsMax` on its current-sense pin); there its peak-current-mode behaviour is not simulated, so that is not a full simulation of the IC. Both use E96 resistors and E12 capacitors and need a buck, boost, SEPIC or flyback with a positive output. An isolated flyback (`isolated: true`) keeps the UC3843, TL431 and optocoupler loop of the closeLoop stage: that is its analog implementation, and the report names it, with no op-amp part. The AI assistant asks which one when the spec names none | | `control.mode` | `voltage` (the default) or `peakCurrent`; `"control": "peakCurrent"` is short for `{"mode": "peakCurrent"}`. Peak current mode on a non-isolated buck or boost builds the loop in the circuit in the pcmLoop stage below, with an op-amp error amplifier (`implementation` analogOpAmp, the default here; digital is refused). A digital voltage-mode run whose load step needs a crossover above what its loop can use offers peak current mode in `explain.tryInstead`. With neither `control` nor `digital` in the spec, a non-isolated boost or synchronous boost whose robust voltage-mode loop passes but crosses below a five-thousandth of fsw (a high-ratio boost's light-load resonance holds it near 10 Hz, too slow to verify within the solver steps) is moved to peak current mode by the run itself: the pcmLoop note and `control.chosenBecause` give the reason, and `options.control` shows the loop built. Name `control` to keep voltage mode | | `feedback` | Only for an isolated flyback: the optocoupler of the TL431 feedback. `optocoupler` names one bin of the TCET1100 family, or `ctrMin` and `ctrMax` (at the LED current `ctrAtIf`, 5 mA by default) give a range of your own; not both. `ageing` is the share of the CTR left at end of life, 0.5 by default. Without it every bin is tried in turn | | `auxRails` | Auxiliary rails and a post-regulator, each an LDO: `rails` is a list of `{name, vout, iout, from}` (`from` is `vin`, the default, or `vout`), with `rippleMaxPp` (1 % of `vout` by default), `sourceRipplePp` (the feed's ripple) and `part` (an LDO from the catalogue) optional; `postRegulator` `{vout}` is a rail from the output carrying the whole load (`iout` defaults to `iout.max`). See "Auxiliary rails" below | ### Shorthand You can write the five main fields as plain numbers. Voltecx writes them out in full before it reads the spec, and the reply of `spec.verify` and `design.auto` shows the full spec in `spec`, so you can see what was assumed. | Shorthand | Means | |---|---| | `"vin": 12` | `min`, `nom` and `max` are all 12 V | | `"vin": [10.8, 13.2]` | `min` is 10.8 V, `max` is 13.2 V, and `nom` is the midpoint, 12 V | | `"vout": 3.3` | `nom` is 3.3 V and `tolPct` is 2, a 2 percent tolerance | | `"iout": 5` | `max` is 5 A and `min` is 10 percent of it, 0.5 A | | `"ripple": 0.05` | `maxPp` is 0.05 V | | `"efficiency": 85` | One point: at least 85 percent at `iout.max` | So `{"vin": 12, "vout": 3.3, "iout": 5}` is a complete spec. The full form still works, and you can mix the two. A shorthand number must be above 0, except `vout`, which may be negative but not 0. The two values of `[min, max]` must be in that order. A shorthand that breaks a rule is an error that names the field, such as `spec.vin`. ### An example: 12 V to 3.3 V, 5 A This spec asks for a buck converter from a 12 V input that may vary by 10 percent, with 3 percent output accuracy, up to 5 A, and 50 mV of ripple. It also sets limits for a load step, start-up, efficiency, temperature and loop margins. The limits are an example. Choose your own. ```json { "vin": { "min": 10.8, "nom": 12, "max": 13.2 }, "vout": { "nom": 3.3, "tolPct": 3 }, "iout": { "min": 1, "max": 5 }, "ripple": { "maxPp": 0.05 }, "loadStep": { "from": 1, "to": 5, "maxDroopPct": 5, "maxSettle": "1m" }, "startup": { "maxTime": "3m", "maxOvershootPct": 5 }, "efficiency": [{ "iout": 5, "minPct": 85 }], "tjMax": 125, "ambient": { "min": 0, "max": 50 }, "pmMinDeg": 45, "gmMinDb": 6 } ``` ### Answer the requirements interview first You rarely know every field of a spec at the start. `spec.questions` asks for what is missing before anything runs. Give it what you know, and it returns the open questions in three groups: | Group | Questions | |---|---| | Must | Application (server PSU, EV or battery charger, LED driver, battery backup unit, solar, motor drive, consumer adapter or other), input voltage, output voltage, load current, galvanic isolation | | Important | Output ripple, efficiency at full load, load-step droop (from half to full load), ambient temperature, cooling, size or cost priority, protections, magnetics from the catalogue or custom-wound, discrete or coupled magnetics | | Optional | EMI class (CISPR 32 A or B), standards, control implementation (digital, analog op-amp or a PWM controller IC), auxiliary rails, service life; for an isolated design also the transformer core shape (PQ, RM, EFD, ETD or planar) and winding constraints | The application comes first, because the suggested efficiency, EMI class, standards and service life follow from it. Each question has a suggested default and one line on why it matters. The input, output and load have no default: you must give them. To take the defaults of a group, call it again with `accept` set to `must`, `important`, `optional` or `all`, or to a list of question ids. A question for a field you already gave is never asked again. ```text spec.questions {"spec": {"vin": [10.8, 13.2], "vout": 3.3, "iout": 5}, "accept": "all"} ``` When `round` is `confirm`, the reply holds a `summary` table (each answer and whether you gave it or took the default) and `designAuto`, the parameters for `design.auto`. Check the table, then run `design.auto` with those parameters. The application, cooling, magnetics, protections, standards, service life, control implementation and auxiliary rails are kept in `preferences`: `design.auto` does not read them yet, so keep them with the design notes. In the desktop app, **Design > Automate > Requirements Interview** shows the same questions as a short form. The default is the hint in each field, and hovering over a label shows why it matters. **Use the defaults** takes a group's defaults. When every must question is answered, the window shows the spec summary, and **Confirm and Run Auto Design** starts the run. The agent panel asks the same questions in rounds, must first, and runs `design.auto` only after you confirm the summary. A script that already has the full spec calls `design.auto` directly and skips the interview. ![The Requirements Interview window, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/automatic-design/04-interview.png) 1. The input voltage, typed as min, max. 2. **Use the defaults** for the must group. ### The spec is saved with the circuit `design.auto` keeps its spec with the circuit, in its own undo step, and the spec is saved in the `.voltecx` file. After you open the file again, in the app or with `--in`, the Test Bench lists its cases, `spec.verify` verifies, `emi.conducted` takes its limit and `design.thermal` takes `tjMax` and the hottest ambient without the spec typed in again. Each reply says where the spec came from: `specFrom: "circuit"`, `fromSpec`, or an input with `source: "spec"`. A value you give in the call still wins. A circuit that `design.auto` did not make, such as an example or an imported file, gets a spec with `spec.set {"spec": {...}}`, and `spec.set {"spec": null}` removes it. Each is one undo step. Besides the fields above, a stored spec may hold `holdUp {time, vMin}` for the Test Bench and `emi {limit, class, marginDb, targetMarginDb}` for `emi.conducted`, such as `"emi": {"limit": "cispr25Class3"}` for a 12 V automotive supply. With **View > Studio Layout (Preview)** on, the **Spec** document shows the stored spec: one row per requirement with its target, its status (**Pass**, **Fail**, **Low margin**, or **Defined** before a verification checks it), **Proven by** and **Set by**. **Low margin** is a pass within a tenth of its limit (10 K for a temperature); hover over it to see how much is left and at which corner, and that closest row gives the **Result** and **Proven by**. **Verify all** (F7 while the Spec page is in front; elsewhere F7 stays Continue / Pause) runs `spec.verify`. After it, **Proven by** names the run that decided each row and its corner, such as "Load step run at corner 43 V, 2.5 to 5 A". A failing row names the run and corner that failed it. Click the link to open that verification's report, which lists every corner's run. A row decided by a start-up, corner or load-step run also has **Show the run**: it runs that corner again in the Test Bench, on a copy of the circuit, and opens the Test Bench on that case's scope with the row's limit drawn on the waveform. The loop gain, efficiency and thermal rows have no such run, so they show no link. **Set by** reads **CLI** for a spec that `powercraft-cli` set while linked to the window, and the version history names that step "Set Design Spec (by CLI)". ```sh powercraft-cli run --in work/pol.voltecx --cmd testbench.list --params '{}' ``` ## Run it Whatever door you use, the call has the same shape. `spec` is required. The other parameters are listed below. | Parameter | What it does | |---|---| | `spec` | The spec, as an object or as its JSON text | | `isolated` | `true` asks for an isolated topology and draws it isolated: the secondary returns to its own ground, and the loop crosses the barrier through parts made for it. See "An isolated design" below. The default is `false` | | `priority` | `balanced` (the default), `efficiency` or `size`. It changes how the topology ranking weighs losses against size | | `topology` | `buck`, `syncBuck`, `boost`, `syncBoost`, `buckBoost`, `sepic`, `fourSwitchBuckBoost`, `flyback`, `llc` or `psfb`. It skips the ranking and draws this one | | `fsw` | The switching frequency in hertz. The default is the frequency the ranking used to estimate the losses, which is 100 kHz for a DC-DC converter | | `seed` | A whole number, 1 by default. It seeds the Monte Carlo yield when the spec names no seed | | `limits` | The caps of the run. See "The caps" below | | `reportPath` | A path without an extension. The report is also written as `.json`, `.md`, `.html` and `.svg` files. It needs a folder the program may write to | | `lang` | `en` (the default) or `zh-Hant`. The language of the Markdown and HTML report | ### In the desktop app Choose **Design > Auto Design**. The window is a form. Its **Spec** section holds the spec, and you can save the spec as a JSON file and load it again. The items of **Design > Automate** open a form or run one of the tools described below: **Requirements Interview**, **Verify Against Spec**, **Suggest Topology**, **Compare Topologies and Control**, **Design Magnetics**, **Compare Magnetics** (`magnetics.compare`: buy or wind, the custom designs against the catalogue's inductors), **Robust Loop**, **Pareto Front**, **Digitalize Compensator**, **Conducted EMI**, **Radiated EMI**, **Layout Hints**, **Verify Generated Code**, **Diagnose Waveforms** and **Debug Aids**. **Export BOM**, **Export KiCad Project** and **Manufacturing Outputs** are in **Design > Manufacturing**; the first two are also **File > Export > Bill of materials** and **File > Export > KiCad project**, where Altium and KiCad users look for them. **Design > Design Steps > Protection** opens the form of `design.protection`. ![The Automate submenu, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/automatic-design/01-menu.png) 1. Automate. 2. Auto Design. 3. Verify Against Spec. 4. Suggest Topology. 5. Design Magnetics. The form, filled in with the first values of the 12 V to 3.3 V, 5 A example above: ![The Auto Design window, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/automatic-design/02-form.png) 1. The nominal input voltage. 2. The output voltage. 3. Save spec. 4. Optimise for: Balanced, Efficiency or Size, one click each. 5. Design converter. After a first run, a note beside it says about how long a run takes ("About 40 s"), from how long the last one took; a wider spec takes longer. The rows show what state they are in. An empty row shows a typical value as a hint in grey italics, such as *e.g. 12*. The hint is never sent. A value you type, or one read from the circuit (marked "from circuit"), is drawn in the normal text colour. The required rows carry a red `*`. A required row left empty is drawn with a red border and the note **Required.** once you leave it or press **Design converter**. It then names every empty required row below the form and puts the cursor in the first one. **Use typical values** copies each hint into its empty row in one click; the rows then hold those numbers like typed ones, and **Undo typical values** empties them again. The form also checks each number against the range the design takes before it sends the spec, so a spec that cannot be designed never goes to Voltecx Cloud. A voltage, frequency or time must be above 0, the smallest load must not be negative, a percentage is above 0 and at most 100 %, a temperature is from −60 °C to 250 °C, and the phase margin from 0° to 180°. Rows that bound one another must be in order: the minimum input not above the nominal or the maximum, the smallest load not above the largest, the coldest ambient not above the hottest, and a load step must step. A row that breaks a rule gets a red border and, under its group, a line that names it, such as *Input voltage, minimum must not be above Input voltage, nominal (48 V)*. The line shows once you leave the row or press **Design converter**, which then opens the row's group and puts the cursor in it. A run from the window does not touch the open circuit until you say so. ### Review before it replaces the circuit When the run ends, the result window shows the design at its top as a card, the same card the agent panel uses: what it adds, what it removes, and each changed value as `L1 inductance 100 µH → 47 µH`, with **Accept** and **Reject**. The open circuit is unchanged while the card waits. **Accept** puts the designed circuit in its place as one undo step named Auto Design, so one Cmd+Z (or the card's **Undo**) gives your circuit back. **Reject**, or closing the window, leaves the circuit as it was. If you edit the circuit before you decide, the card says it is out of date and Accept is refused rather than overwrite your edits: undo them, or run the design again. Automation gets the same step with `job.start {"command": "design.auto", "params": {..., "review": true}}`: the reply's `proposal` holds the card's id and summary, `proposal.list` lists it with `replaces: true`, and `proposal.accept` or `proposal.reject` decides it. Without `review` a job, and a direct call, replace the circuit as before. The run goes to the background. The status bar shows its progress and a Cancel button, and Esc in the console stops it. When it ends, a window shows the summary of the report, with an **Open report** button. The verification table is drawn as a table. You can also type the command in the console (View > Console, or ⌘⇧Y, or Ctrl+Shift+Y on Windows and Linux), with the spec as JSON on one line: ```text design.auto {"spec": {"vin": {"min": 10.8, "nom": 12, "max": 13.2}, "vout": {"nom": 3.3, "tolPct": 3}, "iout": {"min": 1, "max": 5}, "ripple": {"maxPp": 0.05}}} ``` For a report file, add `reportPath` and start the app with `--automation-write-root DIR` (chapter 11). The agent panel can ask for a design. It runs `design.auto` on a scratch copy and shows the result as a new-circuit card that you accept or reject. It can also run `spec.verify`, which changes nothing (chapter 12). A background run works on a copy of the circuit and merges its result back when it ends. The checkpoints and undo steps the run makes stay with that copy, and the report says so in its open items. The stage hashes in the report still identify each state. ### On the command line Write the call in a file, for example `design-call.json`: ```json { "spec": { "vin": { "min": 10.8, "nom": 12, "max": 13.2 }, "vout": { "nom": 3.3, "tolPct": 3 }, "iout": { "min": 1, "max": 5 }, "ripple": { "maxPp": 0.05 } }, "reportPath": "pol-report" } ``` Then run it. `--root work` is the folder the report may be written to, and it must exist. `--out` saves the designed circuit. ```sh mkdir -p work powercraft-cli run --new '{"name":"pol"}' --root work \ --cmd design.auto --params "$(cat design-call.json)" --out work/pol.voltecx ``` The command prints one line of JSON, which holds the whole report. The files `work/pol-report.json`, `.md`, `.html` and `.svg` hold the same report in readable form. `powercraft-cli run` exits with code 0 when the command ran, even when the design did not pass. Read the `pass` field of the reply, or open the Markdown file. A call with a bad parameter exits with code 1 and prints the reason. Nothing is changed in that case. A design is not finished until it holds up in a plain simulation. `powercraft-cli sim` runs the saved circuit and checks numbers against limits, and its exit code says whether they hold (chapter 13): ```sh powercraft-cli sim work/pol.voltecx --tend 5m \ --expect 'mean(v(out), 4m, 5m) in 3.2..3.4' \ --expect 'pp(v(out), 4m, 5m) < 0.05' ``` The window from 4 ms to 5 ms is an example. Choose a window after the start-up of your design. The exit code is 0 when both limits hold and 3 when one does not. ### From the assistant Ask the built-in assistant (the agent panel, or `powercraft-cli chat`, chapter 11) to design from your spec: it runs `design.auto` with the params above as a job, shows the progress and can stop it. For `reportPath`, start `chat` with `--automation-write-root DIR`. ## What each stage does The run is a fixed list of stages. Each stage is an existing command. A stage that ends leaves a checkpoint, so you can find any state again. | Stage | Command it runs | What it does | |---|---|---| | feasibility | `spec.feasibility` | Before anything is sized, checks that the spec is within reach: the efficiency against the semiconductors' losses alone, the ripple against the best catalogue capacitor bank, the junction temperature on the best catalogue heatsink. An efficiency, ripple or topology out of reach fails this gate and stops the run, with the smallest relaxation of each kind in `explain.tryInstead`. `spec.auto.bestEffort` with `feasibility` designs anyway. A junction too hot even there is an open item, as the run's other temperature findings are | | suggest | `topology.suggest` | Ranks the topologies for your spec and picks the best one that `design.auto` can design. A topology that ranked higher but cannot be designed yet is listed in the open items | | pareto | `analysis.pareto` | Only with `auto.mode` set to `pareto`. Searches the design space and keeps the switching frequency and ripple of the knee | | template | `circuit.template` | Draws the topology (`buck`, `syncBuck`, `boost`, `syncBoost`, `buckBoost`, `sepic`, `fourSwitchBuckBoost`, `flyback`, `llc`, `psfb` or `multiphaseBuck`, with the phase count the ranking chose) and sizes its parts from textbook equations. The drawing replaces the content of the open circuit, in one undo step, and keeps its name | | converter | `design.converter` | Sizes the inductor and the output capacitor for a ripple of 70 percent of your ripple limit (1 percent of the output when the spec has none), then simulates to check. For a SEPIC it sizes both inductors and the coupling capacitor. It is skipped for a flyback and a phase-shifted full bridge, which keep the values `circuit.template` sized from your spec (nominal input, output, full-load current and ripple; the full bridge's turns ratio from the lowest input). For an LLC, `design.llc` sizes the tank for your whole input range instead and checks it by simulation at the nominal input | | magnetics | `magnetics.design` | Designs each inductor or transformer (core, material, gap, turns and wire) from its simulated current and writes the best design into the circuit. A coupled part is checked on its magnetising current. When the first design moves the part's own ripple past 5 percent, the stage designs it once more. A coupled part that cannot be designed is an open item | | inductorPart | none | Chooses the catalogue inductor for every inductor that `magnetics.design` designed, and writes it into the circuit. It rates the part as the bom stage does: at the ends of the input range too, and with the current the load draws once the loop holds the output at the spec's voltage (the open-loop output can stand below it). The part's own inductance, DCR and saturation current go into the circuit, and the loop's corners use its data sheet's tolerance | | closeLoop | none | The fixed duty block gives way to a voltage sensor, a reference, an error sum and a PI block that drives the PWM, for a buck, a synchronous buck, a boost, a synchronous boost, an inverting buck-boost, a SEPIC and a flyback. For the inverting buck-boost the sensor is inverted and the reference is the output magnitude. The SEPIC's PI is designed on its fourth-order averaged model, behind a second-order low-pass, with the crossover below a fifth of the right-half-plane zero and a tenth of fsw. It is checked at the lowest, nominal and highest input at full load and at the lightest load wherever that still conducts continuously, where the output resonance rings hardest. A resistor and capacitor across the coupling capacitor damp its resonance. After tuning moves a part, the SEPIC's and the flyback's loops are designed again. The flyback's PI is designed from its small-signal model over the corners of the input and load range, behind a second-order low-pass. With `isolated` the flyback gets no PI: a UC3843-class controller, a TL431 and an optocoupler close its loop in the circuit, and an LLC's controller reads the output through an isolated amplifier (see "An isolated design"). The phase-shifted full bridge's template already holds a PI on the phase shift, which is kept, and so are the multiphase buck's voltage PID and its current-sharing PI per phase. The four-switch buck-boost gets the controller of the closed-loop example: the ratio Vout/Vin fed forward from the measured input, two tables that split it into the buck and boost legs' duties (buck region up to 0.85, boost region from 1/0.85, both legs in between), and a PI behind a second-order low-pass that trims the reference ahead of 1/Vin, so the loop gain is the same at every input. That PI is designed on the two-leg averaged model at the lowest, nominal and highest input at full and light load, with the crossover below a fifth of the lowest right-half-plane zero and a tenth of fsw. Its template draws an input capacitor sized for the input current of its region. The LLC keeps an open loop (its frequency loop is not done yet), and the open items say so. When the call names a topology whose loop stays open and the input is a range, its output follows the input, so this stage's gate fails and the run stops before the verification; `explain.tryInstead` names the best ranked topology design.auto designs end to end | | robustLoop or voltageLoop | `design.robustLoop` or `design.voltageLoop` | When the spec has a load step, or the converter has a right-half-plane zero, the loop is designed over every corner of the input and load range, including the 1.5 sampling periods of firmware delay and the discontinuous conduction at light load. Otherwise `design.voltageLoop` designs it at the nominal point. For a buck, that design is then read at the highest input and the lightest load, where the output filter is least damped; when it loses its gain or phase margin there, or crosses 0 dB more than once, the loop is designed at that corner instead, so a large output capacitor does not leave it ringing at light load. Neither command models a SEPIC: with a load step, this stage reads the step's dip on the SEPIC's averaged model, closed by its PI, its low-pass and the firmware delay, at the lowest, nominal and highest input, and holds it 20 percent deeper against your limit (the model reads the dip shallower than the switching circuit). The SEPIC's crossover cannot rise past its resonances, so when the dip is too deep the stage raises the output capacitor to the smallest E12 value, up to 10 times what the ripple needs, at which the PI designed again keeps it, and runs again. A larger capacitor lowers the crossover, so the runs after it are longer and may need a larger `limits.maxSimSteps`. The phase margin it aims for is 10 degrees above your `pmMinDeg`, kept between 60 and 85 degrees. When a catalogue inductor is in the circuit and neither a compensator nor a part change keeps every corner, the run picks the catalogue inductor again for a lower inductance, or rewinds the custom design when the catalogue has none, and designs the loop again. A catalogue part is never rewound | | pcmLoop | `design.voltageLoop {"mode": "peakCurrent"}` | Only with `control.mode` peakCurrent on a non-isolated buck or boost, in place of robustLoop or voltageLoop (and analogControl later). The PWM and the ideal loop blocks give way to a `pcmModulator` `UPCM` driving the gate net the PWM drove, a current meter `Isns` in series with the inductor and the sense source `Esns`, an LM358B error amplifier `UEA` with its TL431 reference `Vea` and 5 V supply `Vaux`, the E96 divider `Rtop`/`Rbot` and a Type II network `Rz`, `Cz`, `Cp` from COMP to FB. The sense gain Ri puts the modulator's clamp `vcMax` (its cycle-by-cycle limit) 1.5 times above the highest control voltage the corners need; the ramp is the recommended one, Qp = 1 at fsw/2 at the corner of highest duty and lowest inductance (Ridley 1991; TI SLUS223H Eq. 39 and 41). With a load step, the output capacitor is raised (E12, at most 10 times) until the dip ΔI/(2π·fc·C) fits at the crossover the current loop reaches. design.voltageLoop then reads the loop back from the circuit, writes the network and checks every corner. Its gate: Qp at most 2 and a positive one at every corner, 45° of phase margin and 6 dB of gain margin at each, one crossing, and the dip. `control` reports the modulator, the slope, the corner check, the capacitor change and the dip | | remedy | none | When the robust loop names one part change that fixes it (a larger output capacitor, a lower switching frequency, a smaller inductor), the run makes it in this stage and runs the loop design again, at most `limits.maxIterations` times. Candidates are E12 capacitors up to ten times the ripple-sized value and switching frequencies up to 500 kHz | | verify | `spec.verify` | Runs every corner of your spec and returns one row for each requirement. Each start-up run lasts at least eight closed-loop time constants and goes on while the output is still settling | | tune | `analysis.tuneToSpec` | Runs only while the verification fails. It changes a part value for the failing rows that a part value can fix: the output ripple (by the output capacitor, up to ten times its value) and, for an open loop, the output voltage (by the duty). Other failing rows are left with the next step that `spec.verify` names. After a tuning round that applied something, the verification runs again | | parts | `design.parts` | Assigns a library device to every switch and diode: the lowest-loss part that can be bought and that carries both ends of the input range at full load. An illustrative device is used only when no vendor part qualifies. When it changed a device, the verification runs once more | | deadTime | `design.gateDrive` | A synchronous buck or boost only, after the parts stage. The template's dead time is four solver steps; this stage sets it to what the chosen driver's delay matching and the switches' turn-off edge need, plus 25 percent, in whole nanoseconds, so the body diodes do not carry the load current longer than the board would. With an open loop the duty moves by the change of td·fsw. The verification after it runs on that dead time, and the report's Values table shows it. No simulation | | efficiency | `design.efficiency` | The efficiency at four loads from 25 to 100 percent, and the loss of each device at full load | | thermal | `design.thermal` | The junction temperature of each device at full load, at your hottest ambient and with your `tjMax`. Each device's temperature, margin and verdict are read with the cooling the stage picked (a heatsink and pad, or the board copper of an SMD part); the static value through `rthCase` stays as `staticTjC`. A device the cooling catalogue has no data for, or cannot cool, is not rated (no Tj, margin or pass from the assumed heatsink) and is an open item with its loss and the thermal resistance its cooling needs | | operatingTemperature | none | When a junction ended far from the temperature its device was modelled at, the conduction model is read again at that temperature, and efficiency and thermal run again. It runs no simulation of its own | | stress | `analysis.stress` | The voltage, current and power of each part over the second half of a new run, against the rating | | worstCase | `analysis.worstCase` | The output over the tolerance box of the input, the inductor and the capacitor. The mean is read over the second half of each run, the ripple over its last switching periods (the window of the verification's ripple row). A ripple above the spec's becomes an open item | | safety | `design.safety` | Only with `isolated`. Finds the two sides of the barrier and lists the clearance and creepage each pair of nets across it needs, or the IEC 62368-1 table cells it lacks, which become an open item. For an isolated LLC or phase-shifted full bridge it also lists, as open items, the gate drive and the protection that `design.auto` does not design for them. No gate | | gateDrive | `design.gateDrive` | Picks a gate driver for every switch the parts stage chose and sizes the gate resistors and the bootstrap, with each Qg scaled to its drive voltage. No simulation. Its gate is the command's checks: the bootstrap recharge, the dead time and the VGS ratings. The driver, resistors and bootstrap parts become lines of the bill of materials. When the gate passes with a half-bridge or a low-side driver, the run puts that gate drive into the circuit just before the bill of materials (`design.gateDrive {apply: true}`) and verifies the circuit with it at the corners again (`gateDrive.appliedVerify`), so the circuit, the bill of materials and the KiCad schematic hold the same parts. Isolated drivers stay on the bill of materials only | | senseNetwork | `design.senseNetwork` | The divider and anti-alias filter from the output (and a current-sense amplifier) into the STM32G474 ADC, written into the circuit as `R1_vout`, `R2_vout` and `Caa_vout`, so the bill of materials and the KiCad schematic hold them too. No simulation | | isolatedFeedback | none | For a flyback: the feedback across the isolation barrier, a TL431C and an optocoupler of the TCET1100 family driving the COMP pin of a UC3843-class peak-current-mode controller (TI SLUS223H), with a type II network, checked at the highest CTR, the lowest CTR and the lowest after ageing of the bin. With `isolated` these parts are in the circuit (the closeLoop stage put them there) and the stage reports them; without, the simulated circuit keeps its PI and the parts only go on the bill of materials. For an isolated LLC or phase-shifted full bridge it reports the isolated amplifier the controller reads the output through. See "An isolated design" below | | protection | `design.protection` | Sizes the current-sense shunt, the peak-current trip, the blanking, the over-voltage and under-voltage thresholds and the soft start from the verified spec and the switch the parts stage chose. It runs no simulation. Its gate: the trip is above the highest normal peak, the blanking is shorter than the shortest on-time, and the soft start is within `startup.maxTime`. An LLC, a phase-shifted full bridge, a SEPIC, a four-switch buck-boost or a PFC is skipped with a note. A buck output below the INA180's 2.7 V supply minimum powers the amplifier from the controller's 3.3 V rail (`senseSupply`), and the stage says so | | startup | `analysis.stress` | A flyback only: a copy of the circuit is switched on from rest at the highest input and full load. Every capacitor starts empty except the input ones, and the controller starts at its drawn duty, where the generated firmware starts it. When the protection stage sized a soft start, the reference ramps over it. Each switch and diode is rated over the whole run. A part beyond its derated rating is an open item with its peak voltage and current, and the start from zero duty is simulated as well, so the item says whether that start keeps every part within. No gate | | analogControl | none | Only with `control.implementation` analogOpAmp or controllerIc, in place of senseNetwork, digitalize and codegen. An isolated flyback is skipped with a note: its loop is the UC3843, TL431 and optocoupler of closeLoop, and `control` names them without an amplifier. For the others, the loop's compensator (its PI, Type II or III network, and a flyback's low-pass) becomes the error amplifier's network: the output divider, the reference, the Type II or III network (a PI gets a pole a decade above the crossover, a flyback's low-pass a pole and an RC on the amplifier's output) and the PWM comparator, grouped as the subsystem `XCOMP` in place of the ideal blocks. Its gate: the network changes the compensator by at most 2 dB and 10° at the crossover, the amplifier keeps 20 dB of gain over the noise gain there, slews half the ramp at the crossover, and its output swing covers the largest duty. With controllerIc on a boost or a non-isolated flyback the loop is the UCx843 in peak-current mode instead (TI SLUS223H): the ideal loop blocks and the PWM block give way to the IC `U1` (timing RT = 1.72/(fsw·1 nF), a 12 V bias `Vcc`, OUT driving the switch through `GateCmp`), the sense resistor `Rcs` in the switch's source, sized so the 0.9 V lowest threshold carries 1.2 times the highest full-load peak, and its filter `Rcsf`/`Ccsf` (100 pF, less when that is slower than a tenth of the shortest on-time; the UCx84x has no leading-edge blanking of its own). Above a duty of about 0.18 the slope compensation `Cramp` (10 nF) and `Rramp` (the data sheet example's ratio to RT) adds a share of the 1.7 V RT/CT ramp to CS, sized for QP = 1 at the highest duty (Eq. 39 to 44, with the sensed current divided by the same resistors); the model has no RT/CT pin, so the ramp is the source `Vosc` driven by a sawtooth `Osc` in step with the clock. The IC's own error amplifier carries a Type II network (`Rtop`, `Rbot`, `Rz`, `Cz`, `Cp`) designed on the current-mode plant (the data sheet's Eq. 25 to 37 for the flyback, the same power-balance model for the boost) at every corner, crossing at a tenth of fsw or a fifth of the lowest right-half-plane zero. Its gate: the phase and gain margins at every corner, 1/QP = π·(Mc·(1 − D) − 0.5) above zero at every continuous-conduction corner (no subharmonic oscillation), 20 dB of amplifier gain over the noise gain, COMP within 5 V, the 0.9 V limit above the highest peak and the filter's time constant. `control.mode` is `peakCurrent`; `control.sense`, `control.currentLimitA` (the limit at the 1 V threshold) and `control.corners` report it, and gateDrive is skipped because the IC drives the switch. The circuit is then verified again, on the switching circuit whatever `auto.model` says (the averaged view's step of a fifth of a period cannot resolve the error amplifier), so the verification's gate is judged on the analog loop. The report's Control section and `control` list the amplifier, the parts and the checks | | digitalize | `design.digitalize` | Turns the loop design into firmware in the number format of `digital.format` | | codegen | `codegen.verify` | Compiles the generated C of the control blocks and compares it with the model | | emi | `emi.conducted` | Estimates the conducted emission against your class and margin. When the circuit misses the margin without a filter (or with `emi.apply`), it puts the sized input filter in the circuit, so the bill of materials, the KiCad project and the layout include it, and verifies the filtered circuit at low line and full load (`emi.filteredVerify`). The gate also holds the filter to Middlebrook's condition at `Vin_min^2 / P` (low line, full load). When the margin needs the filter but it could not go in (the converter has no input capacitor), the gate fails: it never passes on a filter that is not in the circuit. This failure does not stop the run (the LLC and the phase-shifted full bridge draw no input capacitor): the later stages still design the rest, and the verdict names emi as failed | | debugAids | `design.debugAids` | Only with `auto.debugAids`. Adds the debug aids to the circuit in one history step; DNP parts stay out of the simulation. The report's Bring-up section gives the order: the stages one at a time through the 0 Ω links, the gate waveforms at the test points, then the loop gain at the injection resistor | | controlModules | none | Only for an isolated LLC or phase-shifted full bridge. Wraps the control blocks of each side of the barrier into a module, `Ctrl` on the primary and `SrCtrl` (a synchronous rectifier's gate logic) on the secondary, so only named pins show at the top level. The netlist stays the same | | auxRails | none | Only with `spec.auxRails`. Picks an LDO for each rail from the cited catalogue, checks it on paper and draws the rails into the circuit as one subsystem; its parts go on the bill of materials. See "Auxiliary rails" below | | layout | `layout.hints` | The hot loops, their inductance budgets and a checklist | | bom | `bom.export` | The bill of materials at offline prices. A magnetic part that the run designed is a custom wound line. The catalogue inductor in the circuit is kept (`keep`) whenever it carries the stress; its gate fails when the bill of materials still buys another inductor than the one simulated. A designed capacitor bought at another value, or a capacitor the capacitorPart stage named and the bill of materials replaced, is said in the stage's note | | protectionCases | `testbench.list`, `testbench.run` | The Test Bench's protection cases on the circuit as the run leaves it, input filter and gate drive in: the current trip (the peak inductor current at full load), the over-voltage trip (the start-up peak at the highest input and lightest load), the under-voltage start (the input the converter sees at the lowest input and full load) and the inrush at switch-on, each with the limits `design.testPlan` gives. Its gate fails when a case fails or cannot be measured; the failing cases are its requirements, each with its fix (the soft start against the over-voltage trip, the under-voltage start against the input after the source's and the filter's drop). The runs stay in the circuit's Test Bench, so `testbench.results` shows them and `testbench.run` reads the same numbers. A design whose test plan has none of these limits skips the stage with a note | | kicad | `file.exportKicad` | Writes the KiCad project into `auto.outputDir` | | blocks | `circuit.groupBlocks` | Only with `auto.blocks`. Groups the circuit into one subsystem per design step in one history step; one undo gives the flat circuit back. No gate | Verify and tune repeat for at most `limits.maxIterations` rounds. The loop ends when the verification passes, when a tuning round changes nothing, or when the rounds are used. Most stages have a gate: a pass or fail with the reason and the next fix. A failing gate stops the run, unless `auto.bestEffort` lists it. Then the run goes on and the failure stays in the report. ### The caps The `limits` object holds the caps. Every cap has a default and a largest value. | Cap | Default | Largest | What it limits | |---|---|---|---| | `maxIterations` | 2 | 5 | The verify and tune rounds after the first verification. 0 means verify once | | `maxSims` | 300 | 2000 | The simulations of the whole run. No stage starts once they are spent | | `maxSimSteps` | 30,000,000 | 500,000,000 | The solver steps of the whole run. Every simulation is held to what is left | | `tuneSims` | 40 | 200 | The simulations of one tuning round | When a cap stops the run, `stoppedBy` says which one (`maxSims` or `maxSimSteps`), the verdict starts with NOT DONE, and the stage that could not start is marked capped. A run that you cancel reports `cancelled`. A failure of the suggest or the template stage stops the run, and `stoppedBy` is `failed`. ## Read the report The reply of `design.auto` is the report. With `reportPath` the same content is written as files. The fields you read first: | Field | What it tells you | |---|---| | `pass` | `true` only when the last verification passed and the run did not stop early | | `verdict` | One line in English and Traditional Chinese, such as `PASS: all 12 checked rows pass; 5 items unchecked.` A pass counts the items it did not check, and names the design stages (gateDrive, senseNetwork, protection) that were skipped for the topology, which it does not cover | | `failingGate` | `null` on a pass. Otherwise the stage that stopped the run or the verification, with the failing requirements and the reason | | `explain` | `null` on a pass. Otherwise `why`, one or two plain sentences with the run's numbers, and `tryInstead`: the changes to try, each with its `change` (a JSON merge patch on the call), `label`, expected `effect` and `params` (the whole call with the change made, ready to run again). The assistant's design card shows them with a Try button each | | `stoppedBy` | `null`, or the cap or the failure that ended the run early | | `verify.rows` | The verification table. See below | | `openItems` | What is left to do: a failing row with its next step, an under-rated part, a thermal check that fails, a loop that was left open, and a verification of an older circuit | | `notChecked` | What nobody checked. See below | | `stages` | One entry per stage, with `status`, `round`, a note, the `checkpoint` and the `circuitHash` after it | | `values` and `finalValues` | The sized values with the formula for each, and every part value of the circuit as it ends | | `loop` | The compensator and the Bode data of the loop design, and the loop gain measured by `spec.verify` | | `efficiency`, `losses`, `thermal`, `stress`, `worstCase` | The results of those stages | | `protection` | The protection `design.protection` sized: its headline numbers, values, formulas, notes and checks, or `skipped` with a note | | `used` | The rounds, the simulations and the solver steps the run spent | | `historySteps` | How many undo steps the run made on the circuit | | `markdown`, `html`, `files` | The report as text, and the files written | A stage has one of these statuses: `done`, `failed`, `skipped` (it did not apply, with the reason in its note), or `capped` (a cap stopped it). Each row of `verify.rows` has a `requirement`, a `label`, the `measured` value at the worst corner, the `limit`, the `unit`, the `margin`, and a `status` of `pass`, `fail`, `skipped` or `info`. A failing row has a `nextFix` in plain words. `corner` says which operating point was the worst. `solversAgree` is `false` when the reference solver gave a different result for that row. The requirement names are `regulation`, `ripple`, `startupTime`, `startupOvershoot`, `droop`, `loadSettle`, `lineDeviation`, `lineSettle`, `efficiency`, `tj`, `stress`, `phaseMargin`, `gainMargin` and `yield`. A row exists only when your spec asks for it. A verification passes when no row fails and at least one row passes. ### The not-checked list A pass is only as wide as what was checked. The `notChecked` list is the honest part of the report. It holds what `spec.verify` left out and what `design.auto` itself does not do: - `emi`: conducted and radiated emissions are not simulated by the verification. Use `emi.conducted` for an estimate. - `protection`: over-current, short-circuit and over-voltage protection are not exercised. - `magnetics`: core saturation and core loss are not checked. Use `magnetics.design`. - `ambient`: your spec gave no ambient range, so there are no temperature corners. - `stress`: no part has a library device assigned, so there is no rating to compare with. - `referenceCheck`: you turned the reference solver off. - A requirement your spec leaves out, with the reason `The spec does not ask for it.` - A requirement that could not be measured at some corner, with the reason. - `magneticsDesign`, `robustLoop` and `bom`: the stage did not finish, or the robust loop did not apply (the spec has no load step), with the reason. - `radiatedEmi`: radiated emission is not estimated by the run. `emi.conducted` covers the conducted band only. Run `emi.radiated` yourself for a pre-compliance estimate. - `firmwareInLoop` and `firmwareSil`: the fixed-point compensator is checked on the loop model only, and the generated C is checked only when the codegen stage ran. - `layout`: layout parasitics and the gate drive are not simulated. `layout.hints` gives budgets and a checklist. - `partTolerances`: the worst case uses 20 percent on the inductor and the capacitor. That is an assumption, not a data sheet value. `emi` and `magnetics` leave this list when the run's own stage for them finished. ### Hand the report over in one step The design report needs sign-in to Voltecx Cloud, like the Auto Design run it reports on. `report.designSummary {dir, lang}` (Export Design Summary Folder in Quick Open) writes the report of the latest `design.auto` run on the active circuit as a folder to hand over, and makes the folder when it is not there. `index.html` is one self-contained page. `report.md` shows `schematic.png` and each plot as `plot-.svg` beside it: the schematic as built (`schematic.svg` has the designators and values), the Bode plot and the key waveforms of the latest simulation. `lang` is `en` or `zh-Hant`. Without an Auto Design run you get the schematic and the waveforms alone. The folder also has `loss-chart.svg`, the loss chart of chapter 6, in a "Where the losses go" section; `"lossChart": false` leaves it out, and `lossChartSkipped` in the reply says why it is missing when `design.efficiency` cannot budget the circuit. The reply lists the files written. ### Go back In a direct call, such as `powercraft-cli run`, every stage leaves a checkpoint and every edit is one undo step. Press Cmd+Z `historySteps` times, or call `checkpoint.list` and `checkpoint.restore` with the checkpoint id of the stage you want. In a background run, see the note in the desktop app section. ## What is an estimate Voltecx simulates. A simulation is as good as its models and its data. These are the places where the numbers are estimates, and where the data comes from. - The sizing equations are textbook equations for an ideal converter in continuous conduction (R. W. Erickson and D. Maksimovic, Fundamentals of Power Electronics, 3rd ed.). The printed formulas show what was used. The loop design follows the same book. - Device data. The built-in vendor library has 22 parts, digitised from the manufacturers' data sheets. Ten are Wolfspeed, Infineon and ROHM IGBTs, SiC MOSFETs and diodes rated from 600 V to 1200 V. Twelve are low- and mid-voltage parts: silicon MOSFETs from Texas Instruments, Infineon and Nexperia rated from 30 V to 150 V, three Infineon silicon MOSFETs rated 250 V and 300 V for flyback switches, and Nexperia Schottky and ultrafast diodes rated from 45 V to 200 V. Each part carries its data sheet, revision and the figures it was read from in its `source` field. The data sheets of the low-voltage MOSFETs give gate charge and switching times but no switching energy, so these parts add no switching loss; their notes list the charges and times for a hand estimate. The data sheets of the three small diodes give no junction-to-case transient curve, so they have no thermal chain, and the thermal check uses its default resistance for them. The generic devices in the library are illustrative: they are not parts that anyone sells, and `bom.export` marks a line that uses one as `illustrative`. For a low-voltage design, look at which device each switch received before you read the efficiency and the temperature. - Passive parts. The catalogue behind `bom.export` has capacitors (Murata, KEMET, WIMA and Panasonic, with 500 V and 630 V parts for snubbers), chip resistors and wirewound power resistors (Vishay Dale) and inductors (Coilcraft XAL, and the 220, 330 and 470 uH Coilcraft AGP4233 through-hole parts for large input inductors), all read from the manufacturers' data sheets. A transformer or inductor that `magnetics.design` designed is listed as a custom wound part with its core, turns, wire, gap and losses. A value that a data sheet does not give is left out. The DC bias curves of ceramic capacitors were read from figures and are coarse. - Magnetics. `magnetics.design` searches the OpenMagnetics MAS starter set (Apache License 2.0; the files and their licence are in `crates/magnetics/data`) and ferrite sets of the ETD, PQ, RM, EFD, planar E and planar ER families read from the Ferroxcube and TDK data sheets (21 shapes in 3C95, N87 and N97; each record names its sheet, revision and table, and the shapes use the sheet's Ae, le, Ve and Amin). It is a subset of the cores, materials and wires. The windings of the round-post and planar sets are fitted into a straight-sided window, an approximation. A set with a coil former in the Ferroxcube data handbook is wound on it (the former's winding width, area and average turn; `best.bobbin`); `bobbin: false` uses the bare core window. `magnetics.femmExport` draws only E pairs, planar E sets, ETD sets and ring cores, and none of the core shapes has a KiCad library footprint: the bill of materials names the shape, and the board needs the bobbin maker's footprint. The temperature rise is an estimate for natural convection, and the simulator models saturation as two straight slopes. Confirm a chosen core, gap and wire against the manufacturer's data sheet. - Prices. The offline price list is empty on purpose, because data sheets have no prices. A price comes from the `prices` parameter, or from Nexar when the `NEXAR_TOKEN` environment variable is set. That lookup is the only part of this chapter that uses the network. A part without a price is left unpriced, and the total covers the priced lines only. - EMI. `emi.conducted` is a pre-compliance estimate. A model of a LISN goes on a copy of your circuit, the spectrum comes from the simulated input current, and it is held to a CISPR 32 class limit band by band. It is not a compliance measurement. The result depends on the parasitics your circuit has, and a schematic has few. - Layout. `layout.hints` finds the hot loops of the circuit and gives each an inductance budget. It is guidance from the circuit, not a board design. `file.exportKicad` writes a schematic, a project file and design rules. It does not write a board. - Optimisation. `analysis.pareto` searches an analytic model and re-simulates a few points. The report says how far the two differ. - Part tolerances in the worst case are an assumption of 20 percent. ## The tools, one by one You can run every tool on its own, on any circuit. In the console, a line is `command {JSON}`. On the command line, use `powercraft-cli run --in FILE --cmd ID --params 'JSON'`. A tool that says it changes nothing never edits your circuit. ### spec.verify It checks the circuit in memory against a spec and returns the table of rows and the not-checked list. It runs every corner on copies of the circuit, so it never edits it. It recognises a buck, a boost, a buck-boost, a SEPIC, a flyback and a forward by their structure, and finds the source, output and load of a dual active bridge (DAB), a phase-shifted full bridge and an LLC. A DAB whose output is a DC source (a battery or a bus, as the `dab` example draws it) is checked with that source replaced by a resistor drawing each corner's current, on the copy only. For a different circuit, name the parts in `bind`; the error lists the circuit's DC sources and resistors to ground to pick from. ```sh powercraft-cli run --in work/pol.voltecx --cmd spec.verify --params '{"spec": { "vin": {"min": 10.8, "nom": 12, "max": 13.2}, "vout": {"nom": 3.3, "tolPct": 3}, "iout": {"min": 1, "max": 5}, "ripple": {"maxPp": 0.05}}}' ``` It is the stop condition of every automatic loop. ### topology.suggest It ranks topologies for a spec from a fixed rule table. Hard limits remove what cannot work, such as a step ratio outside the duty range, then a first-order loss estimate with the device library ranks the rest. It never names a topology outside its table. It changes nothing and needs no circuit. ```json { "vin": 12, "vinMin": 10.8, "vinMax": 13.2, "vout": 3.3, "iout": 5, "priority": "efficiency" } ``` Give `pout` or `iout`. Other parameters are `isolated`, `bidirectional`, `input` (`dc` or `ac`), `output` (`dc`, `ac` or `ac3`) and `fsw`. The reply has `best`, a `candidates` list with the rank, the score, the expected efficiency (semiconductor losses only), the template and whether it is ready, and a `dropped` list that gives the reason for each topology that was removed. The score weights are Voltecx's own choices. The reasons name the textbook behind each rule. ### design.exploreTopologies Where `topology.suggest` ranks a fixed table, this one searches. It builds candidate power stages from building blocks: every wiring of one switching cell (a complementary switch pair) with one or two inductors and an inner capacitor between the input, the output and ground; three-level flying-capacitor cells in place of a two-level cell; two interleaved phases; tapped inductors at a few turns ratios; two inductors on one core; 2:1 and 1:2 resonant switched-capacitor cells; two converters with their inputs in parallel and outputs in series; and two in cascade. Of the hundred thousand or so it looks at, it keeps only the circuits that obey the rules of a working converter, in every switching state: no loop of the input, capacitors and closed switches (a short or a hard-charged capacitor), a path for every inductor's current when a switch opens, volt-second and charge balance with a unique solution, every switch both carrying current and blocking voltage, and every inductor and capacitor taking part. `explored.rejectedByRule` counts what each rule threw away. The survivors are fitted to your spec: the duty at the nominal and extreme inputs, each switch's blocking voltage and currents (and whether a diode could replace it, whether it must block both ways, whether its gate driver floats), a device from the library for each switch, and a rough sizing. The best ones are simulated to their steady state, first with ideal parts (they must deliver your output) and then with the library's MOSFETs and ceramic capacitors (which gives the efficiency). Each candidate comes back with its gain formula and curve, its stresses, the runs, a score, its trade-offs, and an `open` call. It never says a candidate is new. A candidate is either "known topology" with the book or paper that describes it, or "not in our catalogue — may be novel; check the literature". The catalogue is small, so the second label often means a circuit that is in the literature but not in Voltecx. ```json { "spec": { "vin": 400, "vout": 100, "iout": 2 }, "n": 5, "constraints": { "maxSwitchVoltage": 250 } } ``` With the switches limited to 250 V, the two-level buck is out and the three-level flying-capacitor buck ranks first. `constraints` also takes `families`, `maxSwitches`, `maxMagnetics`, `minDuty`, `maxDuty` and `commonGround`. To put a candidate on the canvas, run its `open` call, `design.topologyCandidate`: it opens in a new tab, laid out, with the library's devices and open loop at the ideal duty. In the agent panel, ask "invent a topology for …" or "what else could do this?": the assistant runs the search, explains the trade-offs and shows the one you pick as a card to accept. ### spec.feasibility It says whether a DC-output spec can be met at all, before anything is sized. Each bound errs on the side of the spec, so an item it calls infeasible is out of reach of any design, and one it calls feasible may still fail later. It changes nothing and needs no circuit. ```json { "spec": { "vin": 48, "vout": 12, "iout": 10, "efficiency": 99, "ripple": 0.01 }, "targets": { "costUsd": 5 } } ``` Other parameters are `isolated`, `topology`, `fsw`, `prices` (as `bom.export` takes them) and `airflow`. The reply has `feasible`, a `verdict`, and one item per check: `efficiency` (the topology's semiconductor loss estimate at each efficiency point), `ripple` (at most 32 catalogue capacitors in parallel at the template's 20 % inductor ripple), `thermal` (the hottest device on the best catalogue heatsink and pad at the hottest ambient), `size` (the smallest catalogue inductor, judged against `targets.magneticsAreaMm2`) and `cost` (the cheapest priced parts, judged against `targets.costUsd`). An infeasible item lists `relaxations`: the smallest change of each kind, as a JSON merge patch on the call, such as a lower efficiency or a lower `fsw`. Without a target or prices, size and cost report their floor and stay unchecked; the shipped catalogue has no prices. ### design.compare It answers "why this topology, and which control method?" with numbers. It runs `topology.suggest` with the same spec parameters, then fills a table for the first `top` candidates (5 by default): | Column | Where it comes from | |---|---| | Efficiency | The ranking's semiconductor losses plus each inductor's core and copper loss from `magnetics.design` (smallest catalogue core first) | | Device stress | Highest blocking voltage and switched current from the ranking, and the inductor peak | | Part count | Semiconductors (with parallel devices) and magnetic parts | | Magnetics volume | The wound volume of each designed inductor | | Cost | Each device by its part number, from the price list you imported (Add prices under the Compare Topologies table, or `parts.importPriceList`), then the catalogue price list; devices without a price are listed as unpriced. The result window leaves out a column no row has a value for (often Cost, since the offline price list is empty) and names it under the table | | Control difficulty | Level 1 to 3 with the reason and its source (right-half-plane zero, plant order, isolated feedback, frequency or phase-shift control), and the highest usable crossover | Each row gets pros and cons from where it is best or worst in a column, and the chosen topology (the one `design.auto` would draw, or the one you name with `topology`) gets a sentence on why it won and what it gives up. On the chosen buck, boost or inverting buck-boost it then designs four control methods for the same phase margin (`pm`, 60° by default): voltage mode with a Type III network, peak current mode with a Type II network (Ridley's model, ramp for Qp = 1), average current mode with two PIs, and a digital PI with 1.5 periods of delay. For each it reports the crossover, the phase and gain margin, a load step from half to full load simulated on the averaged model (dip, overshoot, settling time) and the effort (loops, sensors, compensator parts, firmware). A PI crosses below the output filter's resonance with its zero above it, and its crossover is the highest that keeps the resonance peak at least 6 dB under 0 dB (the default `gmMinDb` of `design.robustLoop`), so on an undamped high-Q filter it is slow rather than refused. ```json { "vin": 12, "vout": 3.3, "iout": 3, "top": 4 } ``` Other parameters: `rippleRatio` (inductor ripple, 0.3), `vripplePct` (output ripple for the capacitor, 1 %), `ambient` (40 °C) and `control` (false leaves the control comparison out). Isolated, resonant, PFC and inverter topologies have no magnetics sizing or control comparison here yet; the reply says so instead of guessing. In the app it is **Design › Automate › Compare Topologies and Control**, a task of the Design page: its spec is the input, output voltage and load current, read from the circuit, and the result shows beside it, the topologies first, then the control methods of the chosen one. The assistant uses it to answer "why this one?". ![Compare Topologies on the Design page for 12 V to 3.3 V at 3 A, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/automatic-design/03-compare.png) 1. **Why the synchronous buck converter**: why the chosen topology won. 2. **Side by side**: the topology table, the chosen one first. 3. The chosen topology. **Control, for the synchronous buck converter** follows further down with the control methods. ### magnetics.design It designs an inductor or a two-winding transformer from the magnetics catalogue. It tries every E shape and every ETD, PQ, RM, EFD and planar set in every ferrite with the gap ground to the inductance, and every ring core, with each number of turns and each wire. A candidate fails when its peak flux is above the share of saturation you allow (`bsatMargin`, 0.8), when it runs hotter than `tMax` (100 degrees Celsius), when its copper does not fit the window (`fillMax`, 0.4), or, for a transformer or coupled inductor, when whole turns miss the turns ratio by more than 2 percent. The others are ranked by the size of the core, the smallest first, then by total loss: the smallest core that does the job, wound for the least loss. `rank: loss` ranks by total loss first instead; `design.auto` uses it, because the spec's efficiency is a budget the search cannot see. The currents come from the circuit, or from the call. For the circuit, name the part and run a simulation first: ```sh powercraft-cli run --in work/pol.voltecx --cmd simulation.run \ --cmd magnetics.design --params '{"component": "L1", "top": 3}' ``` For the call, give the inductance, the frequency and two of `idc`, `ripple`, `ipk` and `irms`. This needs no circuit: ```json { "l": 2.2e-6, "fsw": 100000, "idc": 5, "ripple": 1.5 } ``` With `apply: true` and a part in the circuit, the best design is written into the part (`l`, `dcr`, `isat`, `lsat` and `rcore`) in one undo step, and `verify` simulates the circuit with it and compares the ripple and the peak current. The reply lists the formulas it used, the winning designs with the loss of the core and the copper, and why the others were rejected. #### Winding layers, interleaving and leakage The best design also carries its winding arrangement (`best.winding`): every layer from the core outward with its turns, its position, the magnetomotive force (MMF) on its two faces, Dowell's AC resistance factor at the switching frequency and its loss. Each layer's factor comes from the MMF on its faces (P. L. Dowell, Proc. IEE 1966, in the per-layer form of Erickson and Maksimović, chapter 13): the outer layers of a winding, which sit in a stronger field, lose more. Foil uses its thickness; litz is treated as layers of strands (Bartoli, Noferi, Reatti and Kazimierczuk, IEEE PESC 1996). The leakage inductance comes from the energy of the field in the window, layer by layer; for one primary block and one secondary block it is McLyman's formula (chapter 17). For a transformer, `arrangement` sets the order of the winding sections from the core outward: `"P/S"` (the default), `"P/S/P"`, `"S/P/S"` and so on, up to eight. Splitting the primary around the secondary halves the layers from zero MMF to the peak, so the AC loss falls and the leakage drops to about a quarter; it also adds capacitance between the windings and a second set of insulation. `layerInsulation` is the tape between two layers of one section, in metres. The reply puts the other usual arrangement (`alternative`, P/S/P beside P/S) next to the chosen one with its loss and leakage, and `design.auto` notes when it would cut the winding loss by a tenth or more. The result window draws the arrangement as a cross-section: the core side on the left, each layer coloured by its winding, the insulation as gaps and the MMF across the window as a line over them. Hover a layer to see its turns, factor and loss. Where the core's data sheet gives core loss, `best.dataSheetLoss` lists those points (frequency, flux, temperature, the maker's maximum and the document) beside the model's value at the same point. Cores whose sheets give no loss get no such list: no loss value is made up. ### magnetics.buildSheet It turns a design from `magnetics.design` into the build sheet a winding vendor needs. Pass the reply as `design`: ```json { "design": { "best": { "core": "...", "turns": 24 }, "inputs": [] }, "markdownPath": "T1.md", "csvPath": "T1.csv" } ``` The sheet lists the core and bobbin part numbers, the gap and the AL value, the turns, wire or litz, conductors in hand, layers and resistance at 20 degrees Celsius of each winding, the layer order and interleaving, the insulation and tape, the pin-out and the test limits: the inductance at the switching frequency, the leakage with the secondary shorted, the resistance of each winding, the turns ratio and the hipot voltage. The L, leakage and resistance limits are the design value plus or minus `tolerance` (0.1). Every field is filled or marked unknown or not applicable, with the reason. The bobbin part number is the coil former `magnetics.design` wound on (`best.bobbin`, from the Ferroxcube data handbook, with its winding width, area and average turn), or the one you give as `bobbin`; ring cores, planar sets and the shapes the handbook has no former for leave it unknown. The pin numbers stay unknown until you agree them with the vendor. The margin tape, the creepage, the clearance and the hipot voltage are meant to come from `design.safety`, but the build sheet does not read it yet and that command's distance tables are empty (#374); until then pass them in `insulation` (`betweenMm`, `marginMm`, `tapeLayers`, `creepageMm`, `clearanceMm`, `hipotV`). The reply has the sheet as JSON, `markdown` and `csv`; `lang: "zh-Hant"` writes them in Traditional Chinese. It changes nothing. ### magnetics.femmExport and magnetics.femmImport Voltecx has no field solver of its own. These two commands link a `magnetics.design` result to FEMM 4.2, a free 2D finite-element program, and read its answer back. `magnetics.femmExport` takes the design (the reply or its `best`) and writes a FEMM model: the planar cross-section of an E pair, a planar E set or an ETD set (its round post and outer legs drawn at their true sections over the depth) with the gap ground into the centre leg, or the top view of a ring core, with each winding (round wire, litz or foil, conductors in hand, layers) in the window. The core is a relative permeability (`muR`, by default the catalogue's initial permeability at the design temperature) or a B-H table (`bh`, pairs of A/m and T, up to 200 points), and the copper is at 20 degrees Celsius. `frequency` defaults to the design's switching frequency; 0 solves magnetostatics. `clearanceMm` (0.1) is the space between drawn regions. It returns the `.fem` text and a Lua script; with `femPath`, `luaPath` and `resultsPath` it writes them through the host's file service. ```sh powercraft-cli run --in work/pol.voltecx --root work --cmd simulation.run \ --cmd magnetics.design --params '{"component": "L1"}' # pass the reply of magnetics.design as "design": powercraft-cli run --root work --cmd magnetics.femmExport \ --params '{"design": {...}, "femPath": "L1.fem", "luaPath": "L1.lua"}' ``` Run the script in FEMM (File › Open Lua Script). It drives 1 A in each winding in turn and writes the self and mutual inductances and the winding resistance at the frequency. `magnetics.femmImport` reads that file (`path`, or its text as `results`), or values from another field solver such as Ansys Maxwell or COMSOL (`values`: `source`, `frequency`, `l1`, and optionally `l2`, `m`, `r1`, `r2`, `turns1`, `turns2`, `gapMm`); give exactly one of the three. It reports L, M, the coupling k, the magnetising inductance and the leakages. With `component` and `apply: true` it writes them into the part in one undo step named after the source: `l` of an inductor, `l1`, `l2` and `k` of a coupled inductor, or `lm`, `llk1` and `llk2` of a transformer (`ratio` sets the split; by default the turns). Limits: the model is a planar slice, so the end turns outside the core are left out. Rectangular wire is refused, because FEMM has no type for it. Voltecx does not run FEMM; you do, on Windows or under Wine. #### In the app Run **Design › Automate › Design Magnetics**. In its result window each design row (the best one first, then the other candidates) has icon buttons; hover one for its name: - **Export FEMM Model** asks where to save the `.fem` file and writes the Lua script beside it, with the same name. - **Import FEMM Results** asks for the results file the script wrote and writes the values into the selected inductor, coupled inductor or transformer (or, with none selected, the part the design was for) in one undo step. The result window shows L, M, k and the changes. - **Field Solve** runs `magnetics.fieldSolve`, Voltecx's own 2D solver (Preview, magnetostatic, linear core), on that design as a job with progress, and opens the field window: L, M and k above a map of |B| or |H| with its flux lines. L is extracted with each winding alone at 1 A, but the window draws the map at the **Operating point**: the peak current Design Magnetics sized the part for (or a current you type). That row shows the peak |B| in the core at that current (the value below which 99 % of the core's area lies, so a corner singularity does not stand for the core), its share of the material's hot Bsat, and the design's core and winding loss at its peak current. **Design current** goes back to the design's current; turn **At the operating point** off to see each winding at 1 A. It is greyed out while **Edit › Preferences › Simulation › Preview features (field solver)** is off; hover it to see where to turn it on. A 3D solve (`magnetics.fieldSolve` with `dimension: 3` and `field: true`) opens the 3D field window instead: the same values above a view of |B| in each element that you turn by dragging, pan with a right-drag and zoom with the wheel. **Section plane** (None, x, y or z, and a slider for where it cuts) shows the field inside the core, the gap and the air. **Smooth shading** blends the element values at the nodes for display; the probe and the legend still read element values. **Flux tubes** draws 24 flux lines that each carry the same share of the flux through the section (or, with no section, through the middle plane the most flux crosses), so where they crowd the flux density is high; where a tube runs behind an opaque surface it is drawn faint, so it does not cover the colours. A section that next to no flux crosses (under a tenth of the flux through that middle plane, such as the mid-plane across an extruded core's depth) seeds no tubes, and the window says so. **Bodies** sets each region's opacity: the window opens with the magnetic parts shown and the air and windings hidden (a section still shows them), so the air can be shown again or the core made see-through. As in the 2D view, the colour scale spans the magnetic parts up to their 99th percentile by volume, so a few singular corner elements do not turn the core dark; the legend then reads ≥ at its top, and the report's 3D |B| pictures use the same scale and say so in their captions. **Colour range** scales the colours over one body instead: in a thermal map, pick the core to see its own few kelvin of gradient beside a much hotter winding; the other bodies take the end colours, and the legend reads ≤ and ≥. **Design › Field Solver** holds the same work in one submenu: - **Field Solve**: as above. - **Core Loss from Last Run**: runs `magnetics.fieldCoreLoss` with the part's current over one switching period of the last run (a new run when there is none, or when the circuit changed since). The field window shows the total core loss, the peak |B| and where it is, the core's mean B(t) over the period, and the core-loss density map under the flux lines of the instant of the peak. On the |B| and |H| tabs, **At the peak \|B\|** draws every winding at its current at the instant of the peak, and **At an instant of the period** draws the field at the winding currents of one instant: drag the time, or press **Peak \|B\|** for the instant of the peak; the time is marked on the B(t) plot. While the scope's cursors are on and cursor 1 stands in the period, the time follows cursor 1, and moving the time moves cursor 1. A transformer is driven by its magnetising current. Under DC bias (a buck or boost inductor) the core loss of N87 and 3C90 is corrected with a Steinmetz Premagnetization Graph fitted from the Princeton MagNet measurements, and the reply gives the plain iGSE total beside it (`totalLossIgseW`); **Design Magnetics** applies the same correction. A *DC bias not covered* warning means the material has no DC-bias data, or the part runs outside the measured range (bias field, 50 to about 500 kHz, flux amplitude, 25 to 90 °C): the loss may read low there. - **FEMM Export** and **FEMM Import**: as the row buttons above. - **New Field Drawing** (Preview): asks whether the section is planar (with its depth in metres) or axisymmetric, runs `geometry.new` and opens the Field Drawing window, where you draw the outlines, label each region air, magnetic or coil, and set dimensions. It needs no part. Undo and Redo follow the drawing while its window has focus. The items act on the selected inductor, coupled inductor or transformer, else on the part of the last Design Magnetics run, else on the circuit's only magnetic part. A part with no design yet is designed first (Design Magnetics, with its defaults), and the item runs on the best design when it arrives. Field Solve and Core Loss from Last Run are Preview features: while Preview is off they stay in the menu, greyed out, and say where to turn it on. ### design.robustLoop It designs a voltage loop that keeps its margins at every tolerance corner. It reads the same spec, takes the lowest crossover that your load step allows, and reads the loop gain at every corner of the input, the load, the inductor, the capacitor, the ESR and the modulator delay. While a corner fails, it raises the phase margin it aims for, or lowers the crossover, and tries again. It stops when every corner passes, and it says why when none can. ```json { "spec": { "vin": {"min": 10.8, "nom": 12, "max": 13.2}, "vout": {"nom": 3.3}, "iout": {"min": 1, "max": 5}, "loadStep": {"from": 1, "to": 5, "maxDroopPct": 5}, "pmMinDeg": 45, "gmMinDb": 6 }, "tolerances": { "l": 0.2, "c": 0.2, "esr": 0.5, "delay": 0.5 }, "simulate": "worst" } ``` The tolerances are fractions from 0 to 0.9, and the values above are the defaults. `simulate` is `none`, `worst` or `all`: it measures the loop gain on a copy of the circuit with the design in place, at the corner with the least margin or at every corner. `apply: true` writes the design in one undo step, and only when every corner passes. ### analysis.pareto Needs sign-in to Voltecx Cloud: the search runs there, and only its params are sent. It finds the trade-off between objectives for a DC-DC converter. A seeded search (NSGA-II, Deb and others, 2002) varies the switching frequency, the ripple ratio, the switch, the diode, the core and the heatsink, with an analytic model. The reply has the front, its knee, the hypervolume, and a few points that were simulated again with the difference to the estimate. The same call and seed give the same front. It changes nothing. ```json { "spec": { "vin": {"min": 10.8, "nom": 12, "max": 13.2}, "vout": {"nom": 3.3}, "iout": {"min": 1, "max": 5}, "tjMax": 125, "ambient": {"min": 0, "max": 50} }, "objectives": ["loss", "volume"], "fsw": { "min": 100000, "max": 1000000, "steps": 12 }, "seed": 1 } ``` The objectives are `loss`, `efficiency`, `volume`, `cost` and `tj`; use one to four. The cost objective needs `prices`. The default grid is 20 kHz to 500 kHz. The model and the search are described in the reply under `notes` and `references`. ### design.digitalize, fixed point and software-in-the-loop When the controller is firmware, `design.digitalize` turns a compensator into a difference equation and shows what the firmware will really do. You give it a loop design (the reply of `design.voltageLoop` or `design.robustLoop`), or ask it to run one with `run`, or give a compensator by hand. It converts with Tustin's rule, prewarped at the crossover, or with matched poles and zeros. It writes the equation in the 2p2z or 3p3z form, and rounds the coefficients to `float32`, `q15`, `q31` or a format such as `q7.24`. Then it reads the loop gain again with the rounded coefficients, the computation delay and the PWM delay, so you see the phase margin the firmware will have. ```json { "run": "voltageLoop", "fs": 100000, "format": "q31", "method": "tustin", "computeDelay": 1, "pwmDelay": 0.5, "maxPmDrop": 10, "adcBits": 12, "vFullScale": 4.0, "prefix": "pol_comp" } ``` The computation delay can come from the ISR instead of `computeDelay`: give `tIsr`, or `cycles` and `fclk`, and `update`. With `update` set to `end` the delay is tIsr times fs samples; with `period` (the default) it is the next whole sample after the ISR ends, so an ISR that fits in the period gives the usual one sample. The extra delay ΔT costs 360° times fc times ΔT of phase margin at the crossover fc. The reply shows the ISR under `loop.delay.isr` (its load and whether it overruns), and the check `isrFits` fails when the ISR takes the whole period or more. ```json { "run": "voltageLoop", "fs": 100000, "cycles": 1437, "fclk": 170e6, "update": "end" } ``` The result passes only when the coefficients fit the format, the integrator is kept, the loop still crosses 0 dB, and the phase margin falls less than `maxPmDrop` degrees below the analog design. With `adcBits` it also checks that the format resolves the ADC, and with `dpwmBits` it checks the condition against limit cycles in the digital PWM (Peterchev and Sanders, IEEE Transactions on Power Electronics, 2003): one DPWM step must move the output less than one ADC step, and the integral gain must not be zero. Instead of `dpwmBits` you can give the timer counts of one period (`dpwmCounts`, such as TBPRD) or a high-resolution PWM (`hrpwm`: a step in seconds, or `f28379d` for 150 ps or `stm32g474` for 184 ps). The reply's `limitCycle` gives the DPWM bits, the ADC bits, the margin in bits, the risk and the bits needed. The reply has the header `pol_comp_coef.h`, the C99 code of the compensator, and a table of every format. Without `apply` it never edits the circuit. **One firmware path.** With `"apply": true` and a passing design, the compensator goes into the circuit: the `pi` or `tf` block that drives the PWM becomes a `ztf` block at `1/fs` with the stored coefficients, the same connections, the `pi`'s output limits as `lo` and `hi`, and its `y0`. The `ztf` feeds back its limited output, as TI's 2p2z and 3p3z controllers store their saturated output, so the integrator does not wind up. It is one undo step. From then on `simulation.run`, `spec.verify`, `file.exportCode`, `codegen.verify` and `codegen.pil` all run the firmware's compensator, not the analog one. In `q15` or `q31` the coefficients are stored in the format the whole controller's code computes in: the word with the fewest integer bits that holds every constant of that code, the reference included. On the 12 V to 3.3 V buck the compensator alone fits `q1.30`, but the 3.3 V reference needs two integer bits, so the coefficients are stored as `q2.29` and `file.exportCode {"precision": "q31"}` writes exactly those integers. The reply's `applied` says what was written; a design that fails a check, or that uses `vFullScale` or pole pairs, is not written and `applied.reason` says why. Run the design for the digital delay first (`"designParams": {"delayTs": 1.5}`): an analog design that did not plan for it usually fails the phase-margin check. ```json { "run": "voltageLoop", "designParams": { "controller": "pi", "delayTs": 1.5 }, "format": "q31", "apply": true } ``` With `reportPath`, automatic design writes the files it lists under `digital.files` into a `firmware` folder next to the report (below `auto.outputDir` when that is given), and `digital.written` lists them. For the code of the whole controller, `tools.codeGeneration` and `file.exportCode` (chapter 13) take `precision`: `float`, `double`, `q15`, `q31` or a format such as `q7.24`. `q15` and `q31` are a 16- or 32-bit word whose integer bits are chosen to hold every constant of the code, the rule `design.digitalize` stores its coefficients by; the reply's `format` names the one chosen (such as `q2.29`). A fixed-point result uses saturating arithmetic. `codegen.verify` is the software-in-the-loop test. It simulates the circuit, records the signals that enter the generated code, runs the model's own blocks on them, compiles the C with the C compiler of your computer (`-std=c99 -Wall -Wextra -Werror`), replays the same inputs through the code, and compares the outputs sample by sample. In fixed point the harness writes each input as the format's integer and reads each output back in the model's units. The reply gives the largest error and the first sample where the code left the tolerance. Without a C compiler, and in the browser, it answers `skipped` with the reason and still returns the test vectors. `path` also writes the files for a test on the target. ```sh powercraft-cli run --in work/pol.voltecx --cmd codegen.verify \ --params '{"precision": "q31", "prefix": "pol_ctl", "maxSamples": 500}' ``` `codegen.closedLoop` closes the loop with the code. On a copy of the circuit it switches off the blocks the generator writes and puts one C block in their place, holding the generated C with a small wrapper that fills the inputs struct from the block's pins, calls the step function and writes the outputs back, at the code's sample time. It simulates both circuits and compares the code's inputs and outputs (and any `signals`, such as `v(out)`) by relative RMS error; `tolerance` is 0.5 % by default. It needs no compiler, so it also runs in the browser. On the closed-loop buck example the PI written by Tustin's rule at 100 kHz follows the continuous one within 0.5 % over the 10 ms run; the largest difference is in the first quarter millisecond of the start-up. With `"apply": true` the C block stays in the circuit as one undo step, with the replaced blocks still drawn and switched off. Edit the firmware with `circuit.setCode` and simulate it; run `codegen.closedLoop` again and it compares the edited code with the replaced blocks, so an edit that breaks the controller fails. The first line of the code names those blocks: keep it. ### emi.conducted It estimates the conducted emission on the DC input and sizes a damped LC input filter. A LISN (50 microhenries, 0.1 microfarad, 50 ohms) goes on a copy of the circuit. The input current is read for a whole number of switching periods and analysed through a model of a 9 kHz receiver, with peak, quasi-peak and average detectors, against the CISPR 32 class A or class B limit, band by band. When the margin is below `targetMarginDb`, it sizes a one-stage or two-stage filter and measures again. ```json { "limit": "cispr32B", "filter": "auto", "targetMarginDb": 6 } ``` The circuit needs a DC input source (name it with `source` when there are several). The reply says `preCompliance: true` and the labels say it is an estimate. The circuit changes only with `apply: true`, which inserts the filter in one undo step. The filter's damping is sized for Middlebrook's condition (R. D. Middlebrook, 1976; Erickson and Maksimovic, *Fundamentals of Power Electronics*, ch. 10): the peak output impedance of the converter-side stage must stay 3 times (9.5 dB) below the converter's input impedance. `zinOhm` gives that impedance, such as `Vin_min^2 / P` at full load; without it the measured `V / I` is used. An undamped LC has no loss and always fails, so the damping branch (`Rf` in series with `Cb = n * C`) gets the smallest `n` whose optimal peak meets the margin (section 10.4). `C` here is the converter's own input capacitance, or the filter's `C` when the converter has none. The peak is read from the whole filter as drawn, with every stage; when a two-stage filter still peaks too high, the converter-side damping is sized again until it fits. The reply's `filter.middlebrook` gives the impedance, the peak, the margin in dB and whether it passes. With `"parasitics": true` the measured copies get the parts' parasitic elements, and the circuit stays as it is: capacitor ESR and ESL, inductor winding capacitance and switch Coss. A value the circuit already sets (`esr`, `esl`, `coss`, a `cossTable` or the dynamic level) is simulated as it is. Otherwise `parasiticValues` gives data-sheet values by part name: `{"Cin": {"esl": "2n", "esr": "5m"}, "L1": {"srf": "30Meg"}, "S1": {"coss": "200p"}}`. For a capacitor, `mpn` names a part of the capacitor catalogue and takes its data sheet's ESR (with the frequency it was read at). For an inductor, `cw` is the winding capacitance, or `srf` the self-resonant frequency, giving Cw = 1/((2π·SRF)²·L). A switch with an assigned device takes the device's Coss table at the input voltage (at the crest, √2·Vrms, for an AC mains input). The catalogue has no ESL and no inductor SRF, and illustrative devices give no Coss, so those values come only from you: a value nothing gives is never assumed, and the reply lists it under `parasitics.skipped` with what to give. The same window also runs with ideal parts: `parasitics.marginDb`, `idealMarginDb` and `changeDb` compare the two, and a note says it. When a filter with a common-mode stage is sized, its measurement takes each Y capacitor's ESR from the safety-capacitor catalogue, ESR = DF/(2π·f·C) from the data sheet's dissipation factor; the choke's data-sheet stray inductance and DC resistance are already in its model, and its winding capacitance comes only from `cw` (across each winding) once the choke is in your circuit. `parasitics.filter` lists what the filter's own parts had. With parasitics off, the reply says `"parasitics": {"on": false}`. ### emi.radiated It estimates the radiated emission from 30 MHz to 1 GHz, at every harmonic of the switching frequency, against the CISPR 32 class A or class B limit at 3 m or 10 m. Two sources are added: the switch node's trapezoid driving its capacitance to the chassis and the input or output cable as a common-mode antenna (150 ohms), and the hot loop's current as a small loop (Paul's common-mode and differential-mode formulas). It also tries three layout changes (halve the loop area, halve the switch node's capacitance, double the edge time) and says which one raises the worst margin most. ```sh powercraft-cli run --in work/pol.voltecx --cmd simulation.run \ --cmd emi.radiated --params '{"limit": "cispr32B", "distanceM": 3, "edgeTime": 5e-9, "loopArea": 2e-4}' ``` The swing `vSw` and the loop current `iLoop` default to the first hot loop of `layout.hints`, else to the input source. `fsw` defaults to the PWM, `duty` to 0.5 and `edgeTime` to 10 ns; a data sheet value is better. `cSw` defaults to the capacitors drawn from the hot loop's switch node to ground when the input's return is not ground (ground is then the chassis). After you route the board, give it as `path` (or its text as `text`): `loopArea` is then the area of the board's worst power loop from `layout.extract` (the vector area of its copper path, so a return on an inner layer counts), `loopAreaSource` is `board` and `loopAreaLoop` names the loop. When the board has a chassis or heat-sink fill under or over the switch node (a net named `PE` or starting with `CHASSIS`, `EARTH`, `HEATSINK` or `SHIELD`, or the net you give as `chassisNet`), `cSw` is the parallel-plate capacitance of the switch node's copper to it, `cSwSource` is `board` and `cSwNet` names the fill; fringing is left out, so the real value is somewhat higher. A ground fill that is the input's return does not count. A given `cSw` still wins. Otherwise `loopArea` (1 cm², in m²), `cSw` (10 pF) and `cableLength` (1 m) are typical values when nothing gives them, and the reply lists every key that took one in `assumed`; `inputs` says where each value came from (`loopAreaSource`, `cSwSource`, `cableLengthSource`). In the app it is **Design › Automate › Radiated EMI**, whose result window puts the assumed values in a box with fields and **Run Again**. `maxPoints` (120) caps the spectrum rows. It changes nothing. This is a pre-compliance estimate, not a measurement: the reply says `preCompliance: true` and the labels say so. It knows only the numbers you give or it assumes, not the real board, enclosure or cable routing. Use it to compare layout choices and to see how far you are from the limit, then measure in a chamber. ### layout.hints It reads the circuit, and the last simulation when there is one, and says where the layout matters. It finds the commutation loops with the parts in each, and gives each loop an inductance budget: the largest loop inductance whose voltage spike still fits the voltage margin of the switches. It gives the ring frequency of the loop with the switch capacitances. It also lists the gate loops, the Kelvin source pairs, the switching nodes to keep small, and the thermal resistance the copper under each device must stay below. It changes nothing. ```json { "edgeTime": 1e-8, "loopInductance": 5e-9, "ambient": 40 } ``` `edgeTime` is the current fall time used for the current slope. A value from the data sheet is better than the default. `didt` replaces it with a slope you know. The reply names its sources, and `checklist` is a short list of things to check on the board. ### layout.extract After you route the board in KiCad, it reads the `.kicad_pcb` (KiCad 6 to 10: footprints, pads and nets, tracks, arcs, vias, zone fills and the stack-up) and finds each power loop of the circuit on it by reference designator: the input capacitor, the high-side switch and the low-side switch or diode, and each switch's gate loop through its driver. It follows the shortest copper of every net in the loop and sums the partial inductances of the pieces, vias included (Ruehli 1972; C. R. Paul, *Inductance: Loop and Partial*, 2010, ch. 5). It also gives each switching node's capacitance to the planes it overlaps, from the stack-up's permittivity, and the ring frequency and overshoot this predicts. When a solid, uninterrupted zone fill lies on the copper layer right above or below a loop's own copper, it gives the loop's high-frequency (ring-band) inductance too: the DC value (`inductanceH`) less the mutual inductance with the loop's own mirror image at twice the dielectric's thickness (H. Johnson, M. Graham, *High-Speed Digital Design: A Handbook of Black Magic*, 1993, ch. 5, "Ground Planes and Layer Stacking"). `inductanceHfH` holds it, `imagePlane` says which layer and gap it used (or why not: no plane close enough, or a gap or slot under the loop), and `appliedInductanceH` is whichever `apply` inserts (the HF value when the check passes, else the DC one). ```sh powercraft-cli run --in work/pol.voltecx --root work --cmd simulation.run \ --cmd layout.extract --params '{"path": "pol/pol.kicad_pcb", "apply": true}' ``` `path` names the board (or give its text as `text`). A board drawn in Voltecx works the same way: with no `path`, `text` or `board` it reads the open project's board, a `path` ending in `.vxpcb` is read as one, and `board` takes a `.vxpcb`'s text; `board.format` in the reply says which was read. Its zones are filled as **Fill Board Zones** (`board.fillZones`) fills them, and every dielectric between copper layers needs a thickness in the stack-up, or the command names the layer to set. A board saved before you changed the circuit is read as saved, and a warning says so. `layout.ringing` takes the same `board`. `ipk` (the peak current the loop commutates, by default the switches' peak in the last simulation) and `coss` (added to the node capacitance) feed the overshoot estimate. With `apply: true` it inserts the parasitics in one undo step: a series inductor `Lpcb` per power loop next to its capacitor, and a capacitor `Cpcb__` from each switching node to each plane; a second run updates them. `rerun` (the same as `apply` by default) then runs `simulation.run`, `analysis.stress`, `emi.conducted` (unless `emi: false`) and `spec.verify` (with `spec`) again, so you see the overshoot and the margins with the board's own parasitics. `worstLoop` names the loop with the largest overshoot and says whether it came from the simulation or the estimate. `peecHz` (a list of frequencies, 0 for DC) also solves each complete loop's copper path with the PEEC solver of `field.peec` (chapter 21): every track a strip as wide as the track and as thick as its layer's copper, every via a rod of its drill, each split for the skin depth at the highest frequency. Each loop then gets `peec.frequencies` with R and L at each frequency. `peecTemperatureC` sets the copper temperature (20 °C by default, IEC 60028). `peecViaPlating` (`thicknessUm` and whether the board's drill is the finished or the drilled hole, both from your fabricator, since the board file gives neither) makes each via a plated tube; without it a via is a solid rod and its resistance a lower bound. `peecPlane` (`cellMm`, `marginMm`) meshes the zone fill under each loop into the solve as a floating plane, its slots and clearances cut out, so the plane's eddy current lowers L and adds its loss to R at high frequency. With `apply`, `peecApplyHz` (one of `peecHz`, such as a frequency near the predicted ring) writes each loop's PEEC resistance at that frequency into its `Lpcb`'s series resistance, which damps the ring in the simulation. `peec.quasiStatic.limitHz` is where the loop reaches a tenth of a wavelength in the stack-up's highest permittivity; rows above it carry an `aboveQuasiStaticLimit` warning and are outside the model. A loop may have up to 5000 filaments with its plane: up to 2000 it is solved by the dense LU, past that by GMRES (the reply's `solver` is `denseLu` or `gmres`; the two agree on the port impedance to about 1e-11). A loop that needs more gets an error asking for fewer or lower frequencies, never a coarser solve. Limits: the image-plane correction only looks at the layer right above or below the loop's own copper, and only when that layer's zone fill is solid under the whole loop; a plane further away, reached only through vias, or with a gap or slot under the loop, is not modelled, and `inductanceH` (DC) stays the upper bound. Package inductance and fringing are left out. A part whose footprint is missing on the board, or a net that is not routed, makes its loop incomplete, and the reply lists it. Without `apply` it changes nothing. ### layout.ringing It shows the ring a routed board's power loop puts on the switching node. It takes the loop inductance and the node's board capacitance from `layout.extract` (or `lH` and `cF` that you give), adds the off switch's output capacitance `coss` (from its data sheet at the bus voltage; by default the switches' `coss` in the circuit), and simulates the series RLC tank of a hard commutation on a scratch bench: the loop inductance carrying `ipk` into the node charged to the bus (`vBus`, by default the DC source across the input capacitor), damped by `rLoop` (by default the lowest switch on-resistance). The bench runs at 200 steps per ring period, so a ring of tens or hundreds of MHz shows even when the circuit's own step is far longer. ```sh powercraft-cli run --in work/pol.voltecx --root work \ --cmd layout.ringing --params '{"path": "pol/pol.kicad_pcb", "coss": 4.7e-10, "ipk": 10}' ``` `hand` is the hand calculation of the same tank: ring frequency 1/(2π√(LC)), damping ζ = R/2·√(C/L), characteristic impedance √(L/C) and the first overshoot (I·√(L/C) without damping). `simulated` is what the bench shows, `agreement` the ratio of the two, and `waveform` the switching-node voltage to plot. The open circuit is not changed. The ideal step and the stiff bus make the overshoot an upper bound, the output capacitance is one value though it falls with voltage, and package inductance is not on the board. ### bom.export It makes a bill of materials. For every part it picks a catalogue part that meets the stress of the last simulation, with the same derating as `analysis.stress`. It needs a simulation result. Capacitors, resistors and inductors come from the passive catalogue. Switches and diodes come from the vendor device library, or are the device already assigned. A line has the status `matched`, `assigned`, `illustrative` or `unmatched`. A ceramic capacitor count allows for the capacitance lost at the DC voltage, and inductors may be a series set. ```sh powercraft-cli run --in work/pol.voltecx --root work --cmd simulation.run \ --cmd bom.export --params '{"priceSource": "offline", "csvPath": "pol-bom.csv"}' ``` `prefer` is `size` (the default) or `cost`. `prices` maps a part number to a price in US dollars. `priceSource` is `auto` or `offline`: `auto` asks Nexar only when `NEXAR_TOKEN` is set. The CSV has the KiCad BOM columns first. The totals say whether the list is complete. Supply chain. `grade` is `any` (the default) or `automotive`: only parts whose manufacturer states automotive grade. `lifecycle` is `any` (the default), `avoid` or `active`: `avoid` leaves out parts recorded NRND, EOL or obsolete, and `active` keeps only parts recorded active. These facts come from `parts/supply.json`, each with its source and the date it was checked. A part with no record has an unknown status: `automotive` and `active` leave it out, and `avoid` keeps it. A line lists the candidates the requirement left out in `leftOut`, with the reason in English and Traditional Chinese. The requirement does not apply to heatsinks and pads, and an assigned device stays the part, with a warning. Each part carries its `supply` record: lifecycle, grade, AEC-Q standard and grade, temperature range and second sources. The CSV has Lifecycle, Qualification and Second Sources columns. No lifecycle status has been read from a manufacturer yet, so `active` leaves every line but the heatsinks and pads without a part for now. The grades on record are those the catalogue's data sheets state: KEMET C0G parts are commercial grade and the Murata GCM32ER71E106KA57 is automotive grade. `atLeast` names ratings measured elsewhere, per component, in the units of the `required` rows of `analysis.stress` (`voltageV`, `currentA`, `peakCurrentA`, `powerW`). The part must carry the larger of each. `design.auto` uses it for the buck, boost, inverting buck-boost and SEPIC: it measures the stress at the lowest and the highest input at full load and passes it in. The switch and the diode of the buck, the buck-boost and the SEPIC block the most at the highest input. The input inductor of the boost, the buck-boost and the SEPIC carries the most at the lowest. `keep` names, per component, a catalogue inductor part number the line takes when it meets the requirement, in the fewest in series; the usual pick is then an alternate. When it does not meet the requirement, the line takes the usual pick with a warning saying so. `design.auto` passes the inductor its inductorPart stage wrote into the circuit, so the part simulated is the part bought. ### file.exportKicad It writes the circuit as a KiCad 8 project: a schematic with a symbol for each part and the fields Reference, Value, Footprint, Datasheet, MPN, Manufacturer and Source, net labels on every pin, a project file with net classes, and a rules file. A net whose peak voltage reaches `hvThreshold` (50 V by default) gets a clearance rule. The track width of a power net comes from its current, `tempRise` and `copperOz`. Control blocks and meters are not drawn. An IC placed with `ic.place` is one symbol with its own pin names, and its Datasheet and Source fields come from its model. Its MPN stays empty, because the model stands for a class of parts (such as the INA180A3 class) and the package is not known; the warnings name it so you choose the part number. Footprint holds a KiCad library id only. A part whose data sheet names a package instead keeps it in a Package field, and the warnings list it, so you assign the footprint in KiCad. The load and any other part that `bom.export` leaves out stay in the schematic, but off the bill of materials and the board. Discrete packages map to footprints of the KiCad 8 standard library, and the schematic pins are numbered by the pads of the footprint. Voltecx places the footprints without Python or a script: run Update PCB from Schematic in KiCad, save the board, close it, and export again with the board as `board` (for example `"board": "pol.kicad_pcb"`). Voltecx then places the footprints in the board file itself, sets its solder mask web, and writes it back with nothing else changed. It places the hot loop side by side in loop order, the gate parts above their switch, and the control parts away from the switching node. Each IC's bypass capacitors go right after the IC, as `schematic.autoLayout` draws them beside it. Every part gets one rotation, so polarized parts of one kind face one way. The reply lists the placement rows, the polarized parts, the solder mask web, the parts placed, the references the board has no footprint for, and the SMT parts on the bottom side. Earlier versions also wrote a `_place.py` script for the pcbnew scripting console; it is no longer written. ```sh powercraft-cli run --in work/pol.voltecx --root work --cmd simulation.run \ --cmd file.exportKicad --params '{"path": "pol.kicad_sch"}' ``` The fields for the parts come from `bom.export`, which needs a simulation result. Without `path` the file texts are returned. Voltecx writes no board file, so the layout is yours to draw. ### file.manufacturingOutputs After you route the board in KiCad, it makes the files an assembly house needs, with kicad-cli: the design rules check (with the rules in the board and in the project's `.kicad_dru`, zones refilled, and the schematic parity), Gerbers of the fabrication layers, Excellon drill files with a PDF map, the position file, the bill of materials in the assembler's format and an assembly drawing PDF. The reply lists what still stands between the board and an order: unrouted nets, DRC errors, differences from the schematic, parts without an MPN, a step kicad-cli could not do, or kicad-cli itself. `ready` is true when that list is empty. It is in **Design > Manufacturing > Manufacturing Outputs**. ```sh powercraft-cli run --root work --cmd file.manufacturingOutputs \ --params '{"project": "pol/pol.kicad_pro", "dir": "pol/fab", "assembler": "jlcpcb"}' ``` `assembler` is `generic` (KiCad's position file, and a BOM with Designator, Qty, Value, Footprint, MPN and Manufacturer) or `jlcpcb` (a BOM with Comment, Designator, Footprint and LCSC Part #, taken from each symbol's LCSC field, and a CPL with Designator, Mid X, Mid Y, Layer and Rotation in millimetres). kicad-cli is found on the PATH or in KiCad's standard install folder. Without it (or in the browser build) Voltecx writes the Gerber X2 layers, the Excellon drill files, the position file, the bill of materials and the assembly drawing itself from the `.kicad_pcb` (the reply's `writer` is `voltecx`), and checks the board with its own design rules check into `-drc.json`: unrouted nets and errors are listed as with kicad-cli, with the rules in the `.kicad_pcb` and in the `.kicad_pro` beside it (the board minimums for clearance, track width, drill, annular ring, hole-to-hole gap and board edge, and each net class's clearance, with the nets its patterns and assignments give it), and the `.kicad_dru` rules that hold on every layer and whose condition is empty or names net classes or nets (`A.NetClass == 'HV'`, `A.NetName == 'sw'`): on the whole board the minimum clearance, track width, edge clearance, hole size, annular ring and hole-to-hole gap and the largest hole, for a class or a net its clearance, narrowest and widest track and edge clearance (a net's rule goes into the net's own copy of its class, named ` []`, so it holds for that net only). A rule only tightens a value. A rule on some layers or items only (a fab's `(layer outer)` rules, or a condition such as `A.Type == 'Via'`) and a router target (`opt`) leave nothing to check when the board-wide minimums already hold them. A stricter one is checked on its items when Voltecx can tell which they are: a track width (minimum or maximum) on `outer`, `inner` or one named copper layer, with no condition or `A.Type == 'Track'`, and a hole size (minimum or maximum, an oval hole's narrow width against the minimum and its length against the maximum) or annular ring (minimum or maximum), on every copper layer or on the `outer`, `inner` or one named copper layer of its `layer` clause, on every via and drilled pad, or on the ones the condition picks: `A.Type == 'Via'`, `A.Type == 'Pad'`, or `A.Pad_Type` `'Through-hole'` (plated) or `'NPTH, mechanical'` (unplated). A ring is measured on vias and plated pads only, as kicad-cli does (its annular-ring check passes over every pad that is not plated through-hole), so a ring rule on the `'NPTH, mechanical'` pads is read and finds nothing. On some layers a hole rule holds for the holes that reach them (a drilled pad reaches every copper layer, a via the layers of its span), and a ring rule measures the ring on those layers only (a pad's inner copper on the inner layers); the finding names the layer of the ring it reports. A clearance between two sides whose condition names a class, a net or a kind of item (`A.Type` `'Track'`, `'Via'`, `'Pad'` or `'Zone'`) of A and one of B (`A.NetClass == 'HV' && B.NetClass == 'LV'`, `A.NetName == 'sw' && B.hasNetclass('Signal')`, `A.Type == 'Pad' && B.Type == 'Via'`), on every copper layer or on the `outer`, `inner` or one named copper layer of its `layer` clause, is checked between the copper of those two sides only, either way round. Any other stricter rule (another condition) is left out. It also compares the board with the `.kicad_sch` of the same name beside it, as kicad-cli's schematic parity does: every symbol meant for the board needs one footprint of its reference and every footprint a symbol, with the same Value and the footprint the symbol names, and each pad must sit on a net that joins the same pins as in the schematic (a labelled net keeps its name). A schematic with hierarchical sheets is compared with the sheet files its boxes name, beside it or in a folder below it: a sheet drawn twice is compared once per drawing with the references KiCad keeps for each, and a local label `x` on sheet `A` must be the board's net `/A/x`. Each difference is listed in `drc.violations` and counted as a schematic difference. Without a `.kicad_sch` the reply says the parity could not be checked. The report's `rules` and the reply's `notes` say which rules were read and which were left out. Its assembly drawing is the one **Board Picture** draws with `assembly` on: the top face on the first page and the bottom on the second, each with the pads, silkscreen, fabrication and courtyard drawings, the board edge and a parts table. Only `.kicad_dru` rules it leaves out and a sheet file it cannot read still need kicad-cli: then the reply lists kicad-cli as missing and `ready` stays false. Otherwise `ready` can be true without KiCad installed. The flags are those of KiCad 10. KiCad 8 and 9 name some options differently, so a step may fail there, and the reply notes the version. The details are in `docs/workflows/manufacturing-outputs.md`. ### design.protection It sizes the protection of a buck, a boost, a buck-boost or a flyback. It is in **Design > Design Steps > Protection**. Give it a spec (the one `spec.verify` takes) or the reply of a verification run, with the circuit open. It works out: - the worst peak current over the corners of the spec, and the peak-current trip: the highest peak at full load with the inductor 20 percent low, plus the charging current of the output capacitor during soft start. The peak takes the converter's losses into account when you give its efficiency in `efficiencyPct` (`design.auto` passes the efficiency it measured); without it, the peak is that of a lossless converter, which is lower than the real one; - the current-sense shunt, from the sense amplifier or the controller that is already in the circuit (otherwise it assumes an INA180A3, or the 1 V input of a UCx843); - the leading-edge blanking time, from the gate charge of the switch; - the over-voltage and under-voltage thresholds, with their hysteresis. The over-voltage trip sits above the output's tolerance band plus an overshoot: `overshootPct`, else the spec's `startup.maxOvershootPct`, else 10 percent. When you pass a verification run, the highest start-up overshoot it measured is used if it is larger; - the soft-start time that keeps the start-up current under the trip. Every formula in the reply names its source: a TI application note, the textbook or a data sheet. A number that the catalogue cannot give is not guessed. The reply lists it in `notes`. An independent calculation checks the result, and the command does not change the circuit. `design.auto` does not run it, so run it yourself after the design. ### design.gateDrive It designs the gate drive of every switch in the circuit. It is in **Design > Design Steps > Gate Drive**. A switch whose reference terminal is off ground is high side and pairs with the switch below it. Each group gets a driver from the gate-driver catalogue (TI UCC27211, UCC27517 and UCC21520, Infineon 1EDN7511B and 1EDN8511B, every number from the cited data sheet): a low-side driver for a lone low-side switch, a half-bridge driver with a bootstrap for a high-side switch, and an isolated one with `isolate: true`. It sizes the turn-on and turn-off gate resistors for the driver's peak current or for an edge time `tEdge` (TI SLUP169), the bootstrap capacitor and the VDD bypass (TI SLUA887A), the drive power and the dead-time margin. ```sh powercraft-cli run --in work/pol.voltecx --cmd design.gateDrive --params '{"vdd": 10, "switchDevice": "texas-instruments/csd17573q5b"}' ``` The other parameters are `spec`, `fsw`, `devices` (switch name to library device id), `droop`, `dMax`, `deadTime`, `driver` (force one catalogue part number), `bootDiodeVf` (for a driver without its own bootstrap diode), and `dvdt` and `minPulse` (for the isolation choice below). `vdd` defaults to the switch's on-voltage, else 10 V. The gate charge a data sheet gives is measured at one gate voltage. The command scales each switch's Qg to the voltage that really drives it (VDD, less the bootstrap diode's drop on the high side), from the second point of the data sheet's gate-charge curve or the end of the plateau, and uses it for the bootstrap capacitor and the drive power; the reply shows it as `.qg`. For example, a CSD17573Q5B driven at 10 V needs 111 nC, not the 49 nC its data sheet gives at 4.5 V. When a part's curve cannot be scaled, the data sheet's Qg is kept and a note names the part and its test voltage. It also checks VDD against each device's VGS(max), and a negative off-voltage against its VGS(min); a failure fails `verify` and names the next step. A device without a VGS rating gets a note. `design.auto` runs it as the gateDrive stage. Without `apply` it changes nothing. With `apply: true` the gate drive of each half-bridge group goes into the circuit, in one history step, under the names the bill of materials gives its lines: the driver IC `U_` (the `halfBridgeDriver` model with the catalogue entry's delay, UVLO, output resistance and bootstrap diode), the turn-on resistor `RgOn_` from the driver output to the gate net `g_`, the turn-off resistor `RgOff_` with its diode `Dgoff_` in parallel, the bootstrap capacitor `Cboot_`, the VDD bypass `Cvdd_`, an external bootstrap diode `Dboot_` for a driver without its own, and the driver supply `Vdrv`. The driver's inputs read the switches' own gate signals, so the switches switch exactly as before; the gate nets show what the driver does. A lone low-side switch (a boost's or a flyback's) gets the driver IC `U_` (the `lowSideDriver` model with the catalogue entry's delay, UVLO and output resistance), its IN on the switch's gate signal and its GND on the switch's source, with the same gate resistors and turn-off diode; its sizing has no VDD bypass, so none goes in. Applying again replaces those parts in place. Isolated drivers have no simulation model yet: they stay on the bill of materials, and `notApplied` says so for each group. **The isolation of the gate signals.** When the gate signals must cross a barrier (`isolate: true`, a high-side switch on a bus above every bootstrap half-bridge driver of the catalogue, whose highest is the 2ED2304S06F's 650 V, or a phototransistor optocoupler on a gate signal), the reply's `isolation` weighs the library's isolation elements and picks the first that passes three checks: - **Speed**: the shortest pulse the part passes is at most the shortest gate pulse, `minPulse` (5 % of the period unless given). - **CMTI**: the rating is at least the switch node's slope, `dvdt`, else the bus over `tEdge` or the designed edge. - **Isolation voltage**: the bus is within the highest bus rating of the catalogue's isolated drivers (the UCC21530B's 1850 V). In order of preference, the elements are the UCC21750 isolated gate driver (150 V/ns), the ISO7710 digital isolator (100 V/ns), the high-speed logic optocoupler, a fiber-optic link (no galvanic path, so no CMTI or voltage limit) and the phototransistor optocoupler. A part whose CMTI Voltecx does not hold is not verified. `why` explains the choice in English and Traditional Chinese, and names each element passed over and the reason. `flags` names a phototransistor optocoupler that carries a gate signal: it is too slow for PWM. With `isolate: true` the check `isolation` fails when nothing passes. The design.auto report quotes the choice in its gateDrive gate. On the `sicHalfBridgeFiber` example, an 800 V bus with `tEdge: 5e-9` is 160 V/ns: above the UCC21750's 150 V/ns, so the choice is the fiber link. With `tEdge: 8e-9` it is 100 V/ns, and the isolated driver qualifies. ### design.inputProtection It sizes the input protection of a converter from the spec and the circuit, every part from a cited data sheet. It is in **Design > Design Steps > Input Protection**. - **Fuse** (Littelfuse 215 time-lag, 451 fast-acting): the smallest rating that carries the input current at 75 percent, and its pulse withstand for `pulses` switch-ons (100,000 by default). - **Hold-up**: the bulk capacitance that keeps the converter running for `holdUp.time` after the input is lost. - **Inrush**: an NTC (TDK S237 and S364), an active limit, or none (`inrush`: `ntc` by default for AC, `none` for DC), with the peak current, I²t and energy, held to `inrushMax`. - **Surge**: with `surge: {"level": 1..4}` a TVS (ST SM6T, SM15T) for the IEC 61000-4-5 test, checked against the switch's voltage rating with the input clamped. Without `surge` there is no TVS. - **Reverse polarity**: an N-MOSFET in the ground return or a series diode (`reverse`: `fet` by default for DC, `none` for AC), with its loss. ```sh powercraft-cli run --cmd file.openExample --params '{"name": "buck"}' \ --cmd design.inputProtection --params '{"spec": {"vin": {"min": 40, "max": 56}, "vout": {"nom": 12}, "iout": {"max": 5}}, "surge": {"level": 2}}' ``` For a mains input give `vinAc` (V rms) and `fline` (50 Hz). `efficiency` (1 by default, a lower bound on the input current), `cBulk`, `rSource`, `fuse`, `ntc`, `tvs`, `reverseDevice`, `switchDevice`, `switchRating` and `n` (a flyback's turns ratio) override what it reads from the circuit. The input current of an AC input is the unity-power-factor current, a lower bound. Without `apply` it changes nothing. The example `inputProtection` shows the parts in a circuit. With `apply: true` on a mains input (a PFC, say) it draws the inrush limit into the circuit in one undo step: `RT1`, the chosen TDK NTC, in series with the line behind the sine source; `K1`, the bypass relay's contact across it (an ideal switch, since the catalogue has no relay), closed by a timer in the controller `Trelay` after power-on (five charging time constants R·C, at least two line cycles); and a soft start `Ss` that brings the voltage reference up with the time constant `Tss`. In a grouped circuit the timer and the soft start go into the controller's block, which gets a `relay` pin. With the relay carrying the steady current, the NTC is chosen without its Imax bound. The Test Bench's `acInrush` case then runs the cold switch-on through them (chapter 18). ### design.safety It finds every isolation barrier in the circuit (the windings of a transformer or coupled inductor, and the parts you list in `barrier`: an optocoupler, an isolated driver, a Y capacitor; an optocoupler, isolated amplifier or digital isolator placed with `ic.place` joins each of its sides only without being listed, and the simulation's tie `Rtie` between an isolated design's grounds joins nothing) and gives each pair of nets across it, and from each side to protective earth (`earth`), its working voltage: peak and RMS from the last simulation, else from the spec. Then it applies the method of IEC 62368-1:2018 for clearance and creepage, basic and reinforced: procedure 1 at the peak, procedure 2 with the mains transient on the input side, the altitude factor above 2000 m, and creepage from the RMS voltage, pollution degree and material group. It is in **Design > Design Steps > Safety**. ```sh powercraft-cli run --cmd file.openExample --params '{"name": "flyback"}' --cmd simulation.run \ --cmd design.safety --params '{"pollutionDegree": 2, "materialGroup": "IIIb", "overvoltageCategory": "II"}' ``` The other parameters are `spec`, `t0` and `t1` (the window of the result), `altitude` (2000 m) and `mainsV`. **The distance tables are empty.** Voltecx has no licensed copy of IEC 62368-1, so every clearance and creepage in the reply is `null`, `missing` lists each table cell the result needs, and `verify` fails until the tables are filled (#374). What you get today is the barrier, its sides, the working voltages and the list of lookups to make in your own copy of the standard. The reply also lists what the transformer construction needs (triple-insulated wire, tape, margins). `file.exportKicad` adds a note per barrier to the schematic. It changes nothing, and it is not a safety approval. ### design.reliability It needs a simulation result. It gives three things. It is in **Design > Design Steps > Reliability**. - **Capacitor life.** Each electrolytic, polymer or hybrid capacitor of the catalogue (Panasonic EEU-FR, EEH-ZC and SVPF) has its ripple current compared with the rated ripple current of its data sheet. None of the three sheets prints the core temperature rise of the rated ripple, so a part within its rating is taken at the ambient temperature, and a part over it gets no life (`overRipple`). Then its series' own life formula from the Panasonic data sheet gives the life, capped at 15 years. The part with the shortest life is reported. `lifeTarget` (hours) makes it a check. - **Derating.** One row per part: the measured voltage, current, power and temperature against the rating of the part `bom.export` picks, times the factor of the rule set. `rules` is `nasa` (NASA EEE-INST-002, the default), `stress` (the factors of `analysis.stress`, common practice, not a standard) or your own `{name, voltage, current, power, tjMax}`. - **MTBF**, only when you give the failure rates. Voltecx ships none of the numbers of IEC 61709 or SN 29500, so `mtbf: {"handbook": "IEC 61709", "rates": {...}}` takes the FIT and stress factors per part from your copy; without them the MTBF is `null` and the missing parts are listed. ```sh powercraft-cli run --in work/pol.voltecx --cmd simulation.run \ --cmd design.reliability --params '{"ambient": 50, "lifeTarget": 50000, "rules": "nasa"}' ``` `ambient` is 40 degrees Celsius by default. `parts` names the catalogue part of a capacitor, `bom` passes options to `bom.export`, and `t0` and `t1` set the window. Only those three capacitor series have a wear-out formula; another capacitor is listed with no life. It changes nothing. ### design.lifetime It is in **Design > Design Steps > Lifetime**. It answers "how many years do the power semiconductors last under this mission profile?" for thermal cycling: bond-wire lift-off and solder fatigue from junction temperature swings. 1. **Mission profile.** `profile` is a table of rows `{t, loadPct, ambient}` (seconds, % of the rated load, °C), or `csv` the same as CSV text with columns `t`, `loadPct` and `ambient`. Values between rows are interpolated, and the profile repeats back to back (`perYear` sets how many passes a year instead). 2. **Junction temperature, fast.** There is no switching simulation per point. Each device's loss is looked up from `design.efficiency` run at a few loads spanning the profile, or from your `losses` table `{loadPct, devices}`; 0 % load counts as off. The loss is convolved with the device's junction-to-case Foster stages from its data sheet, the interface (`rthCase`) and the shared heatsink (`rthHeatsink`, `tauHeatsink`). Ripple within a switching or line period is not in Tj, and the Foster stages are added in series with the heatsink, an approximation the reply states. 3. **Rainflow counting** of each device's Tj over one pass, as ASTM E1049-85 (R2017) section 5.4.4 defines it, starting from the highest point so a repeating profile closes its largest swing. 4. **Cycles to failure** from a published power-cycling model (`model`): - `lesit` (default): Held et al., PEDS 1997, with the coefficients Brunko et al. (EPE'19 ECCE Europe, eq. 1) quote: A = 302500, α = −5.039, Ea = 9.89e-20 J. - `an21001-baseplate`, `an21001-nobaseplate`, `an21001-sintered`: Semikron Danfoss AN 21-001 Rev. 02 (2024-07-23), Tables 1 to 3, with `chip` the section 2.5 thickness class (`igbt`, `igbt1700`, `cal`, `rectifier`, `sic`). Cycles outside the note's tested range (ΔTj 30 to 120 K, Tjm 333 to 400 K, ton 0.04 to 60 s) are flagged. - `cips2008`: Bayerer et al., CIPS 2008. The paper's coefficients were not read from an accessible copy, so Voltecx ships none: give `cips {k, beta1…beta6, current, voltage, diameter, source}`. - `curve`: a power-cycling curve from the module's data sheet, `curve {points: [[ΔTj, Nf], …], source}`, interpolated on log-log axes. 5. **Miner's rule**: one pass consumes D = Σ n/Nf, and the life is 1/(D·passes a year) years. The device with the shortest life is `limiting`; `lifeYears` makes it a check. ```sh powercraft-cli run --in work/inverter.pcraft \ --cmd design.lifetime --params '{"profile": [{"t": 0, "loadPct": 100, "ambient": 40}, {"t": 600, "loadPct": 100, "ambient": 40}, {"t": 601, "loadPct": 20, "ambient": 25}, {"t": 1800, "loadPct": 20, "ambient": 25}], "model": "an21001-baseplate", "chip": "igbt", "rthHeatsink": 0.3, "tauHeatsink": 120, "lifeYears": 15}' ``` The reply lists each device's Tj range, largest swing, cycles and damage per pass, a histogram of swings, and the share of damage from cycles outside the model's range. A device whose data sheet has no Foster stages uses `rthJc` (default 1 K/W) with no thermal mass, which a note names. In `design.auto`, `spec.life.missionProfile` takes these same parameters and the `life` gate also checks this life against `spec.life.years`. It changes nothing. ### design.tradeoff It needs a simulation result. It is in **Design > Design Steps > Trade-offs**. It answers "what does a longer life cost?" for the capacitors of the bill of materials. The first row is the design as `bom.export` picks it. Each further row swaps one electrolytic, polymer or hybrid capacitor for one of its alternates. Every row gives: - the **efficiency**: the simulated full-load efficiency of `design.efficiency`, with the ripple heat I²·R of the swapped capacitor added to the input power; - the **size**: the board area of the parts' bodies from `bom.export` (the catalogue has no volume for every part, so this is area, not volume); - the **cost** of one board when `boards` boards are built, at each part's quantity break; - the **life**: the shortest capacitor life of `design.reliability` at `ambient`. `vsBaseline` and `gain` say what the row changes, such as "+12 % cost for +4.0 years of life", and `paretoOptimal` marks rows no other row beats on all four. `lifeYears` adds a life target to the check. ```sh powercraft-cli run --in work/flyback.pcraft --cmd simulation.run \ --cmd design.tradeoff --params '{"ambient": 85, "boards": 1000, "lifeYears": 10, "bom": {"exclude": ["R1"]}}' ``` A part without a price stays unpriced and the row's cost is marked incomplete; give `prices` (as `bom.export` takes them) to compare costs. It changes nothing. `bom.export` itself now takes `boards` (the build quantity the prices are read at) and `use` (a capacitor's catalogue part, as the life search pins it). ### design.fmea It builds a failure-mode table by fault injection. For each component (by default every resistor, capacitor, inductor, diode and switch) and each mode (`open`, `short` and `drift`, by `drift` = 1.2; diodes and switches take open and short), it runs a brief simulation with the fault and records the effect on the output voltage and the current, and whether the protection would have caught it. It is in **Design > Design Steps > FMEA** and runs as a long job. ```sh powercraft-cli run --in work/pol.voltecx --cmd design.fmea \ --params '{"components": ["C1", "L1", "Q1"], "modes": ["open", "short"], "spec": {"vout": {"nom": 3.3, "tolPct": 3}}}' ``` `output` (by default `v(out)`) and `current` (the first inductor's) name the signals. `tEnd`, `t0`, `maxSteps` and `solver` set each run. The output band comes from `spec`, or from `limits` (`vMax`, `vMin`, `iMax`). `trips` gives the protection thresholds (`iTrip`, `ovp`), or a `design.protection` reply. The reply has one row per fault (the measured extremes, the effect, and whether a trip would detect it) and the table as CSV and Markdown. The FMEDA columns (`fit`, `modeSharePct`, `severity`, `safeOrDangerous`, `diagnosticCoveragePct`) are left empty for you to fill in: the failure-rate and mode-distribution handbooks are not shipped. It never claims compliance with ISO 26262, IEC 61508 or any other standard, and the reply's `disclaimer` says so. `verify` (on by default) fails when a planned fault did not run (a cancelled job) or a fault beyond the limits is not detected. It changes nothing: `apply: true` is refused. ### design.testPlan It writes the production test procedure of the design, each limit with its source. It is in **Design > Design Steps > Test Plan**. - Power-on steps from the spec: the output inside its tolerance at every corner of input and load, the ripple, each efficiency point, start-up time and overshoot, and hold-up. - Trip steps from `design.protection`: the over-current trip, the over-voltage trip and release, and the under-voltage start and stop, each with its tolerance. - Input steps from `design.inputProtection`: the peak inrush, a reverse-polarity check, and each fitted fuse, NTC and TVS by part number. - A hipot step per isolation barrier from `design.safety`, with the working voltage. The test voltage is `null`, because the table of IEC 62368-1 it comes from is not shipped. - The equipment, with the range each must reach. ```sh powercraft-cli run --in work/pol.voltecx --cmd design.testPlan --params '{"spec": { "vin": {"min": 10.8, "nom": 12, "max": 13.2}, "vout": {"nom": 3.3, "tolPct": 3}, "iout": {"min": 1, "max": 5}, "ripple": {"maxPp": 0.05}}}' ``` It runs `design.protection`, `design.inputProtection` and `design.safety` itself, unless you pass their replies as `protection`, `inputProtection` and `safety`, or `false` to leave their steps out. `verifyRun` (an earlier `spec.verify` reply) adds the simulated values beside the limits. The reply holds the steps, the equipment and the fixtures, as text and CSV in English and Traditional Chinese. It changes nothing. ### design.compliance It writes a compliance summary for one market: one row per requirement, each `pass`, `fail` or `notChecked`, with the regulation and clause cited and what was simulated. It is in **Design > Design Steps > Compliance**. It reads the results you give it; only the EU harmonic row runs a simulation (`simulate: false` turns it off). Without `spec` and `autoRun` it reads this session's latest `design.auto` run on the circuit, else the spec stored with the circuit, so after `design.auto` the call `{"market": "eu"}` is enough. - **Efficiency** (with `eps: true`, for an external power supply on the mains): the average efficiency at 25, 50, 75 and 100 percent load against US DoE Level VI or EU Regulation 2019/1782. The no-load limit is shown but not checked, because no-load power is not simulated. - **Harmonics** (EU, a mains spec whose line range includes 230 V): the circuit runs at the standard's reference supply, 230 V and 50 Hz (IEC 61000-3-2:2018, clause 1 and Annex A.2), at full load until its DC link settles, then over one window of IEC 61000-4-7:2002+A1:2008: 10 line cycles, 200 ms (4.4.1). Each order 2 to 40 is its harmonic group (5.5.1). The row holds a table of every order with its measured current and its limit in amperes: Table 1 for Class A (the class assumed when the spec names none, clause 5.1), or Table 3 for Class D (milliamperes per watt of input power, capped by Table 1; above 600 W Class A holds). It also gives the partial odd harmonic current (POHC, the odd orders 21 to 39) and, for Class A, takes the 50 % allowance of clause 7 for those orders while the POHC stays within the POHC of the limits. At 75 W or below (clause 7.1) and above 16 A per phase (IEC 61000-3-12) it is not checked. The circuit has no EMI filter, so the switching ripple is in the current. The report text lists the table. With `verifyRun` (an AC `spec.verify` reply whose spec names `harmonics`), or `simulate: false` and a `design.auto` report as `autoRun`, the row reads that verification instead of simulating: it judges the most loaded corner at the 230 V test voltage, gives the order nearest its limit in percent of it, and lists every order (`orders`: measured A, limit A, percent, pass) with a per-order table under the summary. That current is read over the verification's window of whole line cycles, not the 10-cycle windows of IEC 61000-4-7. Without a 230 V corner or without `spec.harmonics`, the row is not checked and says what to run. - **Conducted EMC**: the verdict of `emi.conducted` (or of `design.auto`'s emi section) against CISPR 32 class `emcClass`; for the US, 47 CFR 15.107 has the same limits. - **Radiated EMC**: `emi.radiated`'s verdict for the EU. The US row is not checked. - **Safety**: `design.safety`'s IEC 62368-1 distances, not checked while its tables are empty (#374). ```sh powercraft-cli run --in work/pol.voltecx --cmd design.compliance \ --params '{"market": "eu", "emcClass": "B", "spec": {"vinAc": 230, "vout": {"nom": 12}, "iout": {"max": 2}}, "eps": true}' ``` Pass the earlier replies as `autoRun` (a `design.auto` report), `efficiencyRun`, `verifyRun`, `conducted`, `radiated` and `safety`. A result you do not give is `notChecked`, never `pass`. The summary is a list of what was simulated and what is left. It is not a certification, a declaration of conformity or a test report. ### design.review It runs the eight checks a hardware engineer does before trusting a power design, on any open circuit (not only one `design.auto` made), and returns one table: check, worst value, limit, margin, `pass`/`warn`/`fail`/`notChecked`, and how to fix it. It is in **Design > Design Steps > Review**; the form takes the data each check may need, and every field is optional. Each row runs the command that already does that check, on the circuit as it is (it simulates first when the result is missing or stale), and changes nothing. | Row | Check | From | |---|---|---| | R1 | Magnetics saturation: each inductor's simulated peak current, ripple included, as B = L·Ipk/(N·Ae) on its linked core against the material's Bsat, or against its `isat` scaled by `isatTemp`, at 25 °C and hot (`hotC`: 100 °C, or the spec's highest ambient plus `coreRiseK`) | `analysis.stress`, the magnetics catalogue | | R2 | Thermal: each junction against Tj max; each magnetic part's hotspot (`magneticsHotspotC`) against the hot temperature of R1 | `design.thermal` | | R3 | Device stress: peak voltage, the same plus the loop overshoot L·di/dt, RMS or average current and dv/dt, against the library device's derated ratings (NASA EEE-INST-002 S1 Table 4: switch 0.75 of the voltage and current, diode 0.70 and 0.50 of the average current; `derating`) | `analysis.stress`, `layout.hints` | | R4 | Parasitics and layout: each commutation loop's inductance (a routed board via `path`, else your `loopInductance`) against its budget, its ring, and the layout and sensor-placement hints | `layout.extract`, `layout.hints` | | R5 | Sensing: each sensed signal's worst-case error against the output tolerance (`currentTolPct` for a current), with the filter's bandwidth and delay | `design.senseNetwork` | | R6 | Protection: the trip and OVP checks, the trip against the switch rating, the trip's response against the fault's rise to that rating (a circuit with no hardware trip is firmware-only: two switching periods), `otpC` against Tj max, `desatResponse` against `tsc` for an IGBT or a switch rated 600 V or more | `design.protection` | | R7 | Tolerance: every corner of L ± `lTolPct`, C ± `cTolPct` (20 % each) and the spec's input range; the output's widest excursion against its tolerance, the ripple against `ripple.maxPp` | `analysis.worstCase` | | R8 | EMI and noise: the conducted level without a filter against the class limit; dv/dt pickup into the ADC through `couplingCap` against one LSB; gate-signal dv/dt against the isolation's CMTI | `emi.conducted`, `design.gateDrive` | A check without the data it needs is `notChecked`, and the row says what it needs (a data sheet's `tsc`, a board, a threshold). Nothing is guessed. A row is `warn` when its margin is under `warnPct` (10 %), `warnK` (10 K) or the EMI target margin, or when only part of it could be checked. With no spec given or stored with the circuit, the review reads the converter's own operating point with a 2 % output tolerance. ```sh powercraft-cli run --cmd file.openExample --params '{"name": "buck"}' \ --cmd design.review --params '{"loopInductance": "10n", "senseSupply": 5}' ``` The latest review is kept with the circuit: `report.export` adds it as a **Design review** chapter. The agent panel runs it through `analysis_run`. ### Small tools for assistants Three read-only commands save an assistant from reading thousands of samples or doing arithmetic by hand. `analysis.diagnoseWaveforms` runs rule-based detectors over the last result (`mode.crossing`, `inductor.saturation`, `oscillation.subharmonic`, `ringing.step`, `gate.overlap`, `diode.recovery`, `startup.inrush` and `device.overstress`) and lists each finding with its evidence, a likely cause and, where the fix is clear, edits you can apply with `circuit.apply`. It also reads a measurement: pass a scope export as `csv` (or `path` under the read root) and a `map` from the signal names the rules read (`i(L1)`, `v(sw)`, a gate signal; or the roles `inductorCurrent` and `outputVoltage`) to its columns, and `fsw` when the circuit has no switching source. The open circuit gives the context (inductance, ratings, the parts a proposal edits). A rule whose signals the capture lacks is skipped and listed under `skipped`, and the thresholds widen with the noise and the 8-bit step measured in each column, so a clean capture raises no finding. `device.overstress` also checks clamps against their own parameters, with no device file: a Zener's current against `izm`, a TVS's against `ipp` and the energy a varistor absorbs against `wmax`, over the whole run; those findings carry a Traditional Chinese `messageZh` too. `waveform.features` gives the mean, ripple, overshoot, settling time and frequency of a signal in one call. `calc.eval` evaluates an expression such as `Vin*D/(fsw*Lf)` exactly. ## After design.auto The run now covers the magnetics, the robust loop, the firmware, the EMI estimate, the layout hints, the bill of materials and the KiCad project. What is left for you: 1. Read the report, above all `openItems` and `notChecked`. 2. Read the `protection` section for the current sense, the trip point, the blanking, the over-voltage and under-voltage thresholds and the soft-start time. When it was skipped, run `design.protection` yourself where it applies. 3. Look at which device each switch received, before you trust the efficiency and the temperatures. 4. Open the KiCad project, assign any footprint the warnings list, and draw the board. 5. Run `powercraft-cli sim` on the saved circuit with limits of your own (chapter 13). ## A multiphase buck and an LLC with synchronous rectification For a high-current, low-voltage output, `topology.suggest` ranks the multiphase buck: N synchronous phases, 2 to 8, with their carriers 1/N of a period apart, so the phase ripples cancel in the output (TI SLYT449). The phase count starts at one phase per 25 A, and the ranking adds a phase while it raises the estimated efficiency by at least 0.2 points. The template holds a voltage PID with a duty feed-forward and a current-sharing PI per phase, which pulls each phase to the average current. Each phase current is sampled once a period at its own carrier's start, as a PWM-synchronized ADC reads it, and the average is the mean of those samples, so every phase is compared at the same point of its ripple: sampled at one instant instead, each phase's error carried a fixed part of its ripple, and the six-phase 12 V to 1.2 V, 60 A design split its current from 9.07 A to 10.93 A per phase where each should carry 10 A. The PID's derivative damps the output filter's resonance (Kd = 2ζ/(Vin·ω0), ζ = 0.5, ω0 = 1/√(L/N·C)), which the load alone damps only near full load, so the output holds at light load too: the four-phase 12 V to 1 V, 60 A design swung 0.39 V peak to peak at a 1 A load with the PI alone. The phases still draw pulsed current from the input, so the template draws `Cin`, a ceramic bank from the input to ground, sized for the input ripple (1 % of Vin) from the charge it supplies, Iout·(D − m/N)·((m + 1)/N − D)/fsw with m = ⌊N·D⌋, plus its ESR times the step of one phase current; it carries Iout·√((D − m/N)·((m + 1)/N − D)) RMS. ```sh powercraft-cli run --cmd circuit.template --params '{"topology": "multiphaseBuck", "vin": 12, "vout": 1, "iout": 60, "fsw": 300000, "phases": 4}' \ --cmd simulation.run ``` `design.auto` draws it with the ranked phase count when it ranks first (12 V to 1 V at 60 A does), keeps the template's loops (`design.voltageLoop` does not model the multiphase loops), and varies the first phase's inductor and the output capacitor in the worst case. With a load step (`stepAmps` and `maxDroopPct` in `circuit.template`; `design.auto` passes the spec's `loadStep`), the output capacitor is the largest of what the ripple needs, `ΔI/(ωc·ΔV·2·sin(PM/2))` for a loop crossing at ωc = 2π·fsw/20 (the closed-loop output impedance, Erickson and Maksimovic ch. 9), the inductor slew bound `(L/N)·ΔI²/(2·ΔV·(Vin·Dmax − Vout))`, and the capacitance that puts the LC resonance at or below the controller's zero. The voltage controller is then a PID with its double zero at ωc/4 and its derivative pole at 4·ωc (48° of phase margin), crossing above the resonance: a PI below the resonance cannot hold a VRM-sized step. The bank this asks for at a low switching frequency is large (12 V to 1.2 V, a 30 A step with 3 % dip at 100 kHz needs 32.7 mF), so a higher switching frequency is the lever that shrinks it. The phase-shifted full bridge does the same with a load step: its output inductor `Lf` stands for `L/N`, the slew headroom is `Vin,min/n·(Dmax − ΔD) − Vout` (the bridge cannot raise the effective duty past 0.95 less the duty-cycle loss), and the PID is designed on `(Vin/n)/(1 + s·(Lf/R + Rd·C) + s²·Lf·C)`, where the duty-cycle loss acts as a resistance `Rd = 4·Lr·fsw/n²` (Vlatković et al., IEEE Trans. Power Electronics, 1992). Without a load step it keeps its PI below the resonance. An LLC rectifies with diodes by default. `rectifier: "sync"`, in `circuit.template` with `llc` and in `design.auto`, draws four MOSFETs SR1 to SR4 instead. A pair turns on when the secondary voltage exceeds the output by `VsrOn` and off when the secondary current falls below `IsrOff`, before it reverses; a pair whose current runs backwards by more than `IsrOff` turns off at once, even inside its minimum on-time `TsrMin`. `design.parts` picks low-voltage MOSFETs for them. ```sh powercraft-cli run --new '{"name":"llc"}' --cmd design.auto --params '{"spec": {"vin": {"min": 380, "nom": 400, "max": 410}, "vout": 12, "iout": 25}, "topology": "llc", "rectifier": "sync"}' ``` On 380 to 410 V to 12 V at 25 A the full-load efficiency rises from 91.0 percent with diodes to 98.3 percent, with an ideal transformer and no core loss in Lr, so the real gain is smaller. Known limits: the template draws no input capacitor, so the EMI gate fails with diodes and with synchronous rectifiers alike: the sized input filter would meet class B (by 0.2 dB at 151 kHz with synchronous rectifiers), but it cannot go into the circuit, and the gate's next fix says to add an input capacitor or set `spec.emi.apply`. Below about 3 percent load the rectifier may hunt. ## An isolated design With `isolated: true` the flyback, the LLC and the phase-shifted full bridge are drawn isolated (`circuit.template` with `isolated`). The primary returns to ground `0`. The secondary returns to its own ground `sgnd`, which the schematic draws with its own symbol, an open triangle with the name under it. The two grounds meet only through the transformer, the parts made to cross a barrier, and one documented resistor, `Rtie`. `Rtie` is the simulation's tie: it gives the solver a DC path to the secondary, carries no current because nothing else joins the two sides, and is not fitted on the board (the bill of materials leaves it out). It is 10 kΩ. A bleed resistor's 10 MΩ does not work here: with a floating secondary the solver cannot factor its matrix at 1 MΩ and above, and below that the residual currents of the solution move `sgnd` by the tie's resistance times them (2 mV at 100 kΩ, 0.4 mV at 10 kΩ). The layout puts the primary left of the barrier and the secondary right of it, the crossing parts on it, and draws the barrier as a dashed line from the top of the drawing to its bottom. **Flyback.** The loop is closed the way an off-line supply closes it, all in the circuit as IC modules (`ic.place`): a UC3843-class peak-current-mode controller `U1` (the `pwmController` IC with the UCx843's numbers, TI SLUS223H) on the primary with the current-sense resistor `Rcs` in the switch's source, a TL431C `U2` and an optocoupler `U3` of the TCET1100 family on the secondary. The controller's FB is grounded, so its error amplifier sources its 0.8 mA limit into COMP, and the phototransistor pulls COMP down against that and the pull-up `Rpull` from the 5 V reference. The TL431's divider `Rup`/`Rlow` sets the output, and its type II network `Rz`/`Cz`, the LED resistor `Rled` (behind the filter `Rfl`/`Cled` when the fast lane alone cannot close the loop) and the bias `Rbias` are the ones the network design chose. It tries each CTR bin of the family in turn, unless `spec.feedback` names one, and takes the first that keeps 45 degrees and 6 dB at every operating corner, at the bin's highest CTR, its lowest CTR and its lowest after ageing (50 percent by default). `Rcs` puts the data sheet's lowest current-sense threshold (0.9 V) at 1.2 times the full-load peak at the lowest input; when no bin closes the loop there, 1.15, 1.1 and 1.05 are tried in turn, since a larger shunt lowers the plant's gain. `design.protection` reads that `Rcs` from the circuit and checks the trip it sets. The bias supply of the controller (`Vcc`, 12 V) and its 5 V reference (`Vvref`) are sources, since the bias winding is not modelled; `GateCmp` turns the switch on while the controller's OUT is high. The simulation runs the optocoupler at the middle of its bin (the geometric mean of the CTR range, a new part at 25 °C). Each corner of the verification starts at its own operating point: the COMP capacitor at the voltage the controller needs there, and the TL431's capacitors at what the LED current then leaves on them. There is no firmware, so digitalize, codegen and senseNetwork are skipped, and so is gateDrive: the UC3843's own output stage drives the switch. When no bin closes the loop, the closeLoop gate fails with each bin's reason and the run stops. The report's isolatedFeedback section is the network, with its parts named as in the circuit. **LLC and phase-shifted full bridge.** The controller sits on the primary with the bridge it drives, so its gate signals cross nothing. It reads the output across the barrier through an isolated amplifier, `Uiso` (the `isolatedVoltageSensor` IC, the TI AMC1311 of SBAS786C): a divider of E96 resistors puts 1.2 V of its 2 V linear input on it at the nominal output, the voltmeter `VMiso` reads its differential output on the primary, and the gain `Kiso` scales it back to volts. A synchronous rectifier's gate logic sits on the secondary with its MOSFETs and their current meter. The controlModules stage wraps each side's control into one module, `Ctrl` and `SrCtrl`. The isolatedFeedback stage reports the amplifier, and its divider becomes lines of the bill of materials. Not done: the bridge's gate drive (the high-side switches need a bootstrap or an isolated driver) and the protection; both are open items. **The report.** The Isolation section names the two grounds, the tie, the parts that cross the barrier and how the control crosses it. The safety stage runs `design.safety`, and the section lists each pair of nets across the barrier with its working voltage and the clearance and creepage, which stay open until the IEC 62368-1 tables are filled in (the cells it needs are listed and are an open item). Not done: slope compensation for the peak-current controller is in the model the network is designed on (QP = 1), but not in the simulated controller, which a duty cycle below 0.5 does not need. Without `isolated` a flyback keeps its common ground and its PI, and the isolatedFeedback stage designs the TL431 network for the bill of materials only. `file.openExample` with `flybackTl431` opens a hand-designed flyback that closes through both parts in simulation (chapter 10). ## A power-factor corrector from the mains A spec with `vinAc` instead of `vin` is an AC-input spec, for example `{"vinAc":{"min":90,"nom":230,"max":264},"fline":50,"vout":400,"pout":500,"pf":0.98,"thd":10}`. The run draws the boost PFC, sizes the inductor, the bulk capacitor and both loops for the whole line range, and verifies the power factor, the THD, the ripple at twice the line frequency and the hold-up time at the low, nominal and high line, at light and full load. The power factor and THD limits hold from half load up (`pqFromLoadPct`); lighter corners are reported for information. The hold-up default is 10 ms with the DC link above 0.75 of its voltage (300 V for 400 V). The bulk capacitor meets the ripple and the hold-up at the low end of its 20 percent tolerance: the larger need divided by 0.8, rounded up to E12 (270 µF for the example). In the Auto Design window, set Input type to AC mains input. The window then asks for the line voltage (minimum, nominal and maximum, rms), the line frequency, the output voltage, the output power and, if you want them checked, the power factor and the input current THD. It builds the same spec, so a spec file with `vinAc` loads into those rows. The worst case moves the choke L1 and the bulk capacitor C1 by 20 percent each, every corner, at the lowest and at the highest line. It reports the mean and the ripple of the DC link, the input current (rms) and the input power, each named with its line voltage (`outRipple@90V`). It is not a gate: compare the ripple with your spec yourself. The current loop is designed for the firmware that runs it: one switching period from the sample to the new duty and half a period of PWM, 1.5 periods in all. At a tenth of fsw that delay costs 54° and no PI keeps 45°, so the loop crosses at a twentieth (46° for the example). The digitalize stage runs `design.digitalize` on both loops, sampled at fsw in the format of `spec.digital.format`. Its gate is that neither loses more than 10° of phase margin, and it writes `pc_pfc_current` and `pc_pfc_voltage` C files. The report's `digital` is the current loop, with the voltage loop under `voltageLoop`. The codegen stage runs `codegen.verify` on the circuit. The continuous blocks (the voltage loop's integrator and pole, the feedforward filters, the multiplier and the sense pole) are not generated, and its note names them. The gateDrive stage runs `design.gateDrive` on the switch S1 as a boost from the rectified line's peaks (√2 times the lowest and the highest line) to the DC link at fsw, turning off the current of the low-line peak (√2·Pin divided by the lowest line voltage): a low-side driver, its gate resistors and the VDD bypass, which become lines of the bill of materials. The EMI stage is skipped: there is no input filter model yet. **The totem-pole PFC.** Name it in the call, `"topology":"totemPolePfc"` (the default is `pfcBoost`). The run sizes the same inductor, bulk capacitor and loops, then draws the bridgeless totem-pole instead of the diode bridge: a fast leg S1 over S2 switching at fsw and a slow leg S3 over S4 at the line frequency. A comparator on the line voltage gives the polarity: in the positive half cycle S4 ties the mains return to the DC negative rail and the PWM drives S2, in the negative half cycle S3 ties it to the DC link and the PWM drives S1; the other fast-leg switch rectifies through its body diode. The duty and the plants are the boost PFC's, so the loops are too. The design values drop the bridge's and add `Vleg` (every switch blocks the DC link), `IfastRms` and `IslowRms` (Ipk/2 each). In continuous conduction the fast leg needs GaN or SiC switches without body-diode recovery; the design notes say so. **Harmonic limits.** `"harmonics":"classA"` or `"classD"` checks each harmonic of the input current, 2 to 40, against IEC 61000-3-2:2018 (Table 1 for Class A in amperes; Table 3 for Class D in milliamperes per watt of input power, capped by Class A). The verification adds a `harmonics` row: the harmonic nearest its limit, in percent of the limit (100 is the limit), at the corners the power factor and THD limits hold at; each corner names that harmonic (`harmonicOrder`) and lists every limited order (`harmonics.orders`: `currentA`, `limitA`, `pctOfLimit`). Class D covers 75 W to 600 W of input power, and the row's note says when the design is outside it. The limits are written for the rated 230 V, 50 Hz input; equipment above 16 A per phase falls under IEC 61000-3-12. For a three-phase input of 16 to 75 A per phase, `"harmonics":"iec61000-3-12"` (written out as `{"standard":"iec61000-3-12","rsce":33}`; name a larger `rsce` for a stiffer supply) holds each phase to IEC 61000-3-12:2011 Table 3, the limits for balanced three-phase equipment: I5, I7, I11, I13, THC and PWHC, and 16/h % for each even order up to 12, in percent of the reference current (here the phase's rms input current at the corner). An Rsce between two rows of the table is interpolated linearly, as its note allows; Rsce 33 is the smallest row. Each corner lists every quantity on the phase nearest its limit (`harmonics.terms`: `term`, `phase`, `pctOfIref`, `limitPctOfIref`, `pctOfLimit`). Table 2 (single-phase equipment), Tables 4 and 5 (balanced three-phase equipment under specified conditions) and Table 6 (hybrid equipment) are not checked. **The schematic.** A PFC run hands the circuit over grouped into blocks (the `blocks` stage, `circuit.groupBlocks`): the power stage and the controller are separate subsystems joined by net labels. `"auto":{"blocks":false}` keeps it flat. ## A dual active bridge Name it in the call: `"topology":"dab"` with a DC spec, for example `{"spec":{"vin":[360,440],"vout":200,"iout":20,"ripple":2},"topology":"dab","fsw":"50k"}`. The ranking does not pick it on its own. The template draws two full bridges around the series inductance Lk and an ideal transformer with n = Vin/Vout at the nominal input. Lk gives the full power at a phase shift of 30 degrees from the lowest input (P = n·V1·V2·φ·(π − φ)/(2π²·fsw·L), De Doncker, Divan and Kheraluwala 1991), so the higher inputs need less. A PI on the output sets the single phase shift, added to the nominal shift as a feed-forward: the secondary current does not depend on the output voltage, so the plant is Gφ·R/(1 + s·R·C) with Gφ = n·Vin·(π − 2φ)/(2π²·fsw·L) (Kheraluwala et al. 1992), and the loop crosses at a twentieth of fsw with the PI's zero at a quarter of that. The loop reads the output once a switching period: read continuously, the output ripple moved the phase shift within each period and left a DC current in Lk that grew until the output collapsed. The PI may take the shift to ±90 degrees; a negative shift moves power back to the input. The spec's load is a resistor, so the verification checks the forward direction. The reverse stage then runs copies of the finished circuit backwards, at the lowest and the highest input: the load becomes a current source feeding the full-load current into the output, as a battery discharging into the bus. Its note gives each copy's output, phase shift and the power back to the input; the 200 V, 20 A example holds 199.9 V at −37° (360 V) and −29° (440 V), and about 98 % of the power reaches the input. A copy that misses the output tolerance is an open item, not a failed gate, since the spec asks for no reverse power; the reply's `reverse` has the numbers. The closeLoop and voltageLoop stages keep the template's PI (as for the phase-shifted full bridge); the magnetics stage designs Lk and the transformer, and the worst case moves Lk and the output capacitor by their tolerance. ## A non-isolated bidirectional converter Give `"bidirectional":true` beside the spec, for example `{"spec":{"vin":[36,60],"vout":12,"iout":10},"bidirectional":true}`. The ranking then drops every topology whose power flows one way only, so a step-down spec gets the synchronous buck and a step-up one the synchronous boost: their second switch is a MOSFET, so the inductor current may reverse and the same half bridge boosts from the output back to the input (TI SLVA390). The run designs and verifies the forward direction as usual. After the worst case the reverse stage runs copies of the finished circuit backwards as it does a dual active bridge: at the lowest and the highest input, a current source feeds the full-load current into the output. Each copy starts at the forward operating point, so its loop takes a step of twice the full-load current, and the copy runs 16 times the verification's length for the output to settle. The 36–60 V to 12 V, 10 A example holds 12.0 V at both inputs (within 0.13 %) with 94.7 % (36 V) and 95.8 % (60 V) of the power reaching the input. When the output lies inside the input range, the ranking keeps the four-switch buck-boost: both of its legs are synchronous half bridges (LTC3780 data sheet), so it gets the same reverse copies. The 9–16 V to 12 V, 2 A spec holds 12.0 V at both inputs with 95.9 % (9 V) and 97.9 % (16 V) of the power reaching the input. At a current one phase cannot carry, the ranking keeps the interleaved buck, drawn as the multiphase buck: each phase is a synchronous half bridge with its own high- and low-side gate (TI SLYT449), so it gets the reverse copy too. Its template's voltage loop is a PID whose derivative damps the output filter, which the load alone does only near full load, so the copy holds the output with the full-load current fed in: the 12 V to 1.2 V, 60 A spec holds 1.200 V (0.001 %) with 91.0 % of the power reaching the input. A copy that misses the output tolerance is an open item; the reply's `reverse` has the numbers, without a phase shift. ## A three-phase inverter A spec with `vdc` instead of `vin` is an inverter spec: `grid {vll|vln, f}` for a grid-tie inverter or `acOut {vll|vln, f, tolPct}` for a standalone AC output, with `pout`, `pf {min, capability}` (grid only), `thd` (a standard: `ieee1547`, the grid's default, is 5 % total rated-current distortion of IEEE Std 1547-2018 Table 26; `iec61727` is 5 % current THD at rated output of IEC 61727:2004 Table 1; `ieee519`, an AC output's default, is 8 % voltage THD of IEEE Std 519-2014 Table 1; or `{maxPct}`), `fswRange`, `ripple`, `filter` (`lcl` or `l` for the grid, `lc` for an output) and `rideThrough {residualPu, duration, maxCurrentPu}`, every value of it from the standard you cite. For example `{"vdc":[750,850],"grid":{"vll":400,"f":50},"pout":10000}`. The run draws a two-level bridge. The bridge inductor L1 = Vdc,max/(6·fsw·ΔI) with ΔI 20 % of the peak current; the LCL filter follows Liserre (2005) and Reznik (2014): the filter capacitor is 5 % of the base capacitance, the grid-side inductor gives the attenuation of the switching ripple, and the damping resistor is a third of the capacitor's impedance at the resonance. The control is a dq current PI with an SRF-PLL on the grid (a dq voltage loop for an AC output), its crossover searched for the margins over the damped plant, and it is wrapped in the subsystem `controller` (instance `Ctrl`), joined to the power stage by labels. Then magnetics, the verification, parts, efficiency, thermal, stress, the worst case, the gate drive, protection, layout, BOM and KiCad. `spec.verify` and the Test Bench take the same spec on the circuit the run drew (they need its variables `Vdc`, `Pref` and `Qref`). The corners are the link min and max by the power min and max at unity power factor, plus the capability corner; the rows are `thd` as the standard measures it, `powerFactor` (grid) or `regulation` (output), `ripple`, `efficiency` and, with `rideThrough`, the peak bridge current through the sag (chapter 18 lists the Test Bench cases). Like the rest of `design.auto` it runs on Voltecx Cloud. ## Auxiliary rails Real boards need more than the converter's output: 3.3 V for the MCU, a 15 V gate-drive bias, a quiet rail after the switcher. With `spec.auxRails`, `design.auto` adds them with linear regulators, after the EMI stage and before the layout: ```json "auxRails": { "rails": [{ "name": "V3P3", "vout": 3.3, "iout": 0.1, "from": "vin", "sourceRipplePp": 0.2 }], "postRegulator": { "vout": 3.3, "iout": 0.2 } } ``` - **The part.** Each rail takes the first LDO of the catalogue that passes every check, fixed outputs before adjustable ones: TI LP5907, TI TPS709, Microchip MCP1754S, TI TPS7A16, TI TLV767, TI uA78L05 and uA78L15. Every value (dropout, PSRR points, quiescent current, RθJA, the junction limit, the input and output capacitors) cites the data sheet's document number, revision, table and page. PSRR points read off a typical curve say so. - **The checks.** The lowest feed less the rail must cover the data sheet's dropout at the rail's load. The feed must stay within the recommended input range. The switching ripple on the feed, through the PSRR at the switching frequency, must stay within the rail's ripple limit; the PSRR is interpolated between the data sheet's points and never extrapolated, so a switching frequency past the last point, or a vin feed with no `sourceRipplePp`, is reported as information. The junction must stay within the recommended range at the highest feed, full load and the spec's hottest ambient (40 °C when the spec names none). Rails fed from the output add their load to the converter's, so `iout.max` must cover them. - **Refused early.** A rail at or above the lowest voltage it is fed from is refused before the run, with the rail named: no linear regulator can step up. - **Schematic first.** The LDOs go in as the `ldo` IC with the picked part's values, with their input and output capacitors and EN tied to IN, all in one subsystem `AUX_RAILS` (instance `XAUX`) below the power stage. Each rail is drawn as a net label at the subsystem's pin. Enter the subsystem to see the regulators. - **Bill of materials and report.** `U_` is the LDO with its data sheet, and `Cin_` and `Cout_` are catalogue capacitors that hold the data sheet's value at their DC bias. The report's "Auxiliary rails" section lists each rail with its part, dissipation, junction temperature and PSRR, every check, and the notes. - **What it does not do.** The rails are checked on paper; the converter's simulations do not include them. An adjustable part's feedback divider is not designed: its data sheet gives it. ## Limits - `design.auto` draws and designs a buck, a synchronous buck, a boost, a synchronous boost, a buck-boost, a SEPIC, a flyback, an LLC (with diodes or synchronous rectifiers), a phase-shifted full bridge, a dual active bridge (named in the call) and a multiphase buck, and a four-switch buck-boost (named in the call). It closes the loop of every one of them except the LLC; the phase-shifted full bridge and the dual active bridge bring their own loops. From an AC-input spec it designs a boost or totem-pole power-factor corrector, and from an inverter spec a three-phase inverter (the sections above). For anything else, the design is the template's starting point, and the open items say so. - The vendor device library is small. A passing design with generic devices shows that the structure works, not that a given part will. - A pass is a pass of the checks in your spec. It is not a safety or compliance result. Read the not-checked list every time. --- # 17. Python URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/17-python/ The `powercraft` Python package drives the same engine as the app, the command-line tool and the assistant. Every command you can run from a menu, `powercraft-cli run` or an assistant, you can run from Python, and a simulation's waveforms come back as numpy arrays with every sample. Use it from a script or from Jupyter. ## Install The package is a wheel for your platform (one wheel works with Python 3.9 and later). Install it with pip: ```sh pip install powercraft-0.9.0-cp39-abi3-macosx_11_0_arm64.whl # the file you were given pip install pandas matplotlib # optional: data frames and plots ``` To build the wheel from the source tree, install [maturin](https://www.maturin.rs) and run `cargo xtask python --wheel --release`; the wheel is written to `target/wheels/`. `cargo xtask python` builds a development copy and runs the package's tests. ## A first session ```python import powercraft s = powercraft.Session() s.execute("file.openExample", {"name": "buckIdeal"}) result = s.run(solver="fast") # simulation.run print(result["status"], result["samples"]) w = s.waveforms(["v(out)", "i(L1)"]) # numpy arrays, every sample print(w["time"][-1], w["v(out)"].max()) ``` - `Session.execute(command, params)` runs any engine command by its id and returns its result as Python dicts and lists. `Session.commands("analysis")` lists the commands whose id or label matches, with their parameters. - `Session.run(**params)` is `simulation.run`. - `Session.waveforms(signals, t0, t1)` returns a dict: `"time"` (float64 seconds) and one float32 array per signal, as the engine stores them. Without `signals` you get every signal; `t0` and `t1` limit the window. The arrays are read-only views; use `.copy()` to change one. `Session.signals()` lists the names. - `Session.dataframe(signals, t0, t1)` gives the same data as a pandas DataFrame indexed by time. `waveform.get`, which the CLI and the assistant use, returns a preview of at most 2000 points per signal unless you ask for more. `waveforms` returns the full result instead. The commands are the ones the app runs. Type the same lines in its console (**View > Console**, Cmd+Shift+Y) to try a call before you script it: ![The console running the first session's commands, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/python-console/01-console.png) 1. `file.openExample {"name": "buckIdeal"}`: what `s.execute("file.openExample", {"name": "buckIdeal"})` runs. 2. `simulation.run {"solver": "fast"}`: what `s.run(solver="fast")` runs. 3. `waveform.list`: the signals the run recorded. 4. Its reply: 80800 samples and the signal names. ## Errors A command the engine refuses or that fails raises `powercraft.CommandError`. Its message starts with the command id and says what is wrong, as in the app's Problems panel. Parameters that cannot be written as JSON raise `TypeError` or `ValueError` before anything runs. Nothing a Python caller sends can crash the engine. ## Files `Session.open(path)` and `Session.save(path)` read and write `.voltecx` files anywhere you point them, like the CLI's `--in` and `--out`. The `file.*` commands themselves (`file.open`, `file.saveAs`, `file.exportWaveforms` to a path, ...) reach files only inside a folder you grant when you create the session: ```python s = powercraft.Session(root="work") s.execute("file.saveAs", {"path": "buck.voltecx"}) # writes work/buck.voltecx ``` Paths that leave the folder (`../x.voltecx`) are refused. A session without `root` has no file access through commands, the same rule as `powercraft-cli run`. ## Sweeps `Session.sweep` sets one parameter to each value, runs the simulation, measures, and then undoes its changes, so the circuit is as it was: ```python rows = s.sweep("R1", "r", [1, 2, 4, 8], measure=("v(out)", "mean"), t0=2e-3, solver="fast") for row in rows: print(row["value"], row["result"], row["error"]) ``` `measure` is a signal and a statistic (`mean`, `rms`, `max`, `min`, `pp`, `last`) over `[t0, t1]`, or a function that takes the session and returns a value, for example `lambda s: s.waveforms("i(L1)")["i(L1)"].max()`. A point that fails keeps its error message and `None` as its result; the sweep goes on. For sweeps over circuit variables, with the work spread over threads, use the engine's own `analysis.paramSweep` and `analysis.paramSweep2d`. ## Field solver (Preview) The field solver is a Preview feature: start the session with `preview=True` (the same as `preview.set` in the CLI). A model is a `magnetics.design` result, drawn as its core's template (an E pair with its gap, or a ring core), or a `Sketch` you draw in millimetres: ```python s = powercraft.Session(preview=True) design = s.design_magnetics(l="100u", fsw="100k", idc=2, ripple=0.9, duty=0.25, top=1, shape="E 25/13/7", wire="Round 0.5 - Grade 1") solved = s.field_solve(design=design, field=True) # magnetics.fieldSolve print(solved.inductance() * 1e6, "µH", solved.model["nodes"], "nodes") nodes, triangles, regions = solved.mesh() # numpy: m, node indices, region per element b = solved.flux_density(current=2.0) # (Bx, By) per element, T core = (powercraft.Sketch(depth_mm=10) .rectangle((-40, -40), (40, 40)).rectangle((-12, -8), (12, 8)) .air("air", (0, 30)).core("core", (0, 6.5), mu_r=1e4)) ``` - `Sketch` has `point`, `segment`, `arc` (degrees), `polygon`, `rectangle` and `circle`, and labels each region with `air`, `core` (a linear material with its μr) or `coil` (a circuit's coil side and its turns, negative for the return side). `Sketch.from_drawing(s.execute("geometry.get"))` takes a drawing made with the `geometry.*` commands. A wrong number (NaN, a zero radius, a sweep of 360°) raises `ValueError` naming it; a drawing the engine cannot mesh raises `CommandError` naming the point, edge or region. - `Session.field_solve(design | sketch, field, element_mm, mu_r, component, apply)` returns a `FieldSolution`: `values` (`l1`, and with two windings `l2`, `m`, `k`, `lm`, `llk1`, `llk2`), `inductance(circuit)`, `model` (mesh size, iterations, residual, solver version and input hashes) and `notes` in English and Traditional Chinese. With `field=True` it also has `mesh()`, `regions()`, `potential(circuit)` and `flux_density(circuit, current)`. `apply=True` writes the values to `component` in one undo step. - Every field result carries its warnings (planar model, linear material, outside the material data, not converged, mesh too coarse, above saturation, older solver version). `FieldSolution.warnings` lists them as `{"code", "en", "zh-Hant", "data"}` and `FieldSolution.warning(code)` finds one; `powercraft.field_warnings(reply)` reads the same list from any other field command's reply, such as `field_core_loss`. - `Session.field_line_profile(start, end, ...)` gives B and H along a line as numpy arrays (`reply["arrays"]`), the flux across it and ∫H·dl along a path. `Session.field_region_table(...)` gives each region's energy, force and peak |B|. Both take `currents` per circuit and write a CSV with `csv_path` under the session's `root`. - `Session.field_core_loss(design | sketch, waveform=... | signals=[...])` is `magnetics.fieldCoreLoss`, with the loss-density map as an (n, 4) array in `reply["map_array"]`. - `Session.export_field_diagnostics(record, path)` checks a solve's diagnostics record and writes it for a bug report. `apps/powercraft-python/examples/field_solve.py` solves the E 25/13/7 design and sweeps the gap of a hand-drawn core. The numbers are the same as `powercraft-cli run --cmd magnetics.fieldSolve` gives for the same call. ## Jupyter `apps/powercraft-python/examples/design_simulate_plot.ipynb` designs a buck converter's output filter with `design.converter` (L, C and the duty cycle from the output spec), simulates the result and plots the output voltage and inductor current with matplotlib. ## Licence A session uses the licence stored by the desktop app (Help › Licence), like `powercraft-cli`. Pass `licensed=False` to run as Free. --- # 18. The Test Bench: run one test case and see it against its limits URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/18-test-bench/ `spec.verify` (chapter 16) checks every corner of a spec in one go and answers with a table. The **Test Bench** runs the same checks one case at a time and keeps each run's waveforms, so you can look at a failing row on the scope, with its limit drawn on it, fix the circuit, run the case again and compare the two runs. Choose **Simulation > Test Bench > Open Test Bench**. ![The Test Bench with a spec filled in, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/test-bench-manual/01-spec.png) 1. The **Spec** section, from its **Targets** rows down. 2. The Test Bench's own cases: tick **Start-up**, **Line step** or **Hold-up** to add them. 3. **List Cases**. ## The cases Fill in the **Spec** section at the top: the same rows as the Auto Design form (chapter 16), with the nominal input, the output voltage and the maximum load current under **Required**, the other targets below them and the temperature and loop-margin limits closed under **Limits**. **Use spec from Auto Design** fills it with the spec Auto Design opens with: its last run's, else the open converter's input, output and load current (marked *from circuit*). A spec you already have as JSON goes in through **Paste JSON** (at the end of the window's top row) and **Apply**, for example `{"vin":{"min":44,"nom":48,"max":52},"vout":{"nom":12,"tolPct":2},"iout":{"min":4,"max":5}}`. Then press **List Cases**. Listing simulates nothing, and the Spec section closes so the cases have the room; click it to open it again. Under the rows, **Test Bench cases** holds the cases only the Test Bench runs. Tick **Start-up** (maximum start-up time and overshoot), **Line step** (an input step with its deviation and settling limits) or **Hold-up** (how long the output holds after the input is cut, and the lowest input voltage) to add that case with its limits, each field with its unit (`6m` in a seconds field is 6 ms); untick it to remove the case. **Circuit binding** picks the input source, the load and the output net when the automatic choice is wrong. The automatic choice also covers the bridge converters: the `dab`, `psfb` and `llcHalfBridge` examples list and run their cases without a binding, and a DAB's output source is replaced by a load resistor in each case's copy (a note under the cases says so). **Edit as JSON** (beside it) shows the whole spec as JSON text in the same box as **Paste JSON**, to read or change any field; **Apply** writes it back. ![The cases of the spec, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/test-bench-manual/02-cases.png) 1. **List Cases**. 2. A case that has not run. 3. **Run All Cases**. 4. **Re-run Failed**. | Case | What it runs | Its limits | |---|---|---| | Corner (`corner-48V-5A`) | The circuit at one input and load, from its initial state until the output settles | Regulation (the band around the output), ripple | | Start-up | The nominal input at full load | Start-up time (a window up to `startup.maxTime`), overshoot (a line), regulation | | Load step (`loadStep-48V`) | The bench `spec.verify` uses: the load steps from `loadStep.from` to `loadStep.to` at the end of the first run (ramping at `loadStep.slew` A/µs when given) and back at the end of the second | The largest swing after the step and after the release (a line each; the note gives the undershoot and overshoot in mV and the settling time in µs), recovery (a window from the step) | | Pre-biased start-up (`preBias`) | The nominal input at full load, from the circuit's own initial state with the output capacitor already at half the output voltage | The peak output (a line at the spec's start-up overshoot, when it gives one) and the reverse inductor current a synchronous converter pulls out of the output (shown only) | | Hold-up | The input is cut at the end of the first run (`holdUp {time, vMin}` in the spec) | The time until the input falls to `vMin` | | OCP | Full load at the input `design.protection` names | The peak inductor current stays below the current trip | | OVP | Start-up at the highest input and the lightest load | The peak output stays below the over-voltage trip window | | UVLO | The lowest input at full load | The input stays above the under-voltage start window | | Inrush | Switch-on into the discharged input | The peak input current | The OCP, OVP, UVLO and inrush cases come from `design.testPlan` (chapter 16). A test-plan step that no simulation can show (efficiency, a release threshold, a part check, a hipot test) is not a case; the command reply lists it under `notSimulated` with the reason. ## A mains (AC-input) spec A converter fed from the mains, such as a PFC, takes the spec `spec.verify` takes for it (`vinAc`, `fline`, `vout`, `pout`, `pf`, `thd`, `holdUp`; chapter 16), for example `{"vinAc":[90,264],"vout":400,"pout":500,"pf":0.98,"thd":10}`. The circuit needs the same parts `spec.verify` finds: one sine voltage source for the mains, the load resistor on the DC link and the meter signals `vac` and `iac`. The cases then are: | Case | What it runs | Its limits | |---|---|---| | AC corner (`acCorner-230V-500W`) | One line voltage and one output power, read over two whole line cycles | Power factor and input-current THD (limits from `pqFromLoadPct` of full load up, shown only below it), with `harmonics` (`classA` or `classD`) the harmonic nearest its IEC 61000-3-2:2018 limit in percent of it, DC link ripple at twice the line frequency, regulation, efficiency at full load | | AC load step (`acLoadStep-230V`) | The load steps from the lightest to the full output power at the nominal line, at a zero crossing of the line | The largest DC link deviation (shown only), then regulation, power factor, THD and ripple once settled | | AC line step (`acLineStep-230to90V`) | The line voltage steps from the nominal to its lowest (and to its highest) value at full load | The same as the load step | | AC hold-up (`acHoldUp-90V`) | The mains is cut at full load into a constant-power load | The time the DC link stays above `holdUp.vMin` | | AC inrush (`acInrush-264V`) | The circuit switched on cold at the highest line and full load, at the line's peak: every capacitor, inductor and controller state starts at zero, so the bulk is empty and the NTC, its bypass relay and the soft start drawn in the circuit (`design.inputProtection` with `apply`) meet it | Each diode's peak current and largest ∫i²dt over 10 ms in percent of its data sheet IFSM and I²t (at most 100; a diode without a rating is named as not checked), the largest diode current, and the DC link's peak against 1.1·vout | | AC dip (`acDip-0pct-10ms-230V`, `acDip-70pct-500ms-230V`) | The dips of IEC 61000-4-11:2020 Table 1: the line to 0 % for half a cycle and to 70 % for 25 cycles (30 at 60 Hz), from a zero crossing at full load, at 230 V when the line range holds it, else at the nominal line | The DC link's lowest value against `holdUp.vMin`, and its largest deviation (shown only) | In these cases `vin` is the line voltage in volts rms and `iout` the output power in watts. The protection trips and the surge of IEC 61000-4-5 are not simulated. ## A three-phase inverter spec An inverter spec (`vdc` with `grid` or `acOut`, chapter 16) lists the corners `spec.verify` reads, on the circuit `design.auto` drew for it (the cases need its variables `Vdc`, `Pref` and `Qref`; another circuit is refused with the variable it lacks). The inverter verification runs on Voltecx Cloud, as `design.auto` does. | Case | What runs | Limits | |---|---|---| | Inverter corner (`inverterCorner-750V-10000W`) | One DC link and one output power at unity power factor, read over whole line cycles after the settling cycles; a grid-tie spec with `pf.capability` adds the lowest link at full power feeding reactive power (`…-var`) | The distortion as the spec's standard measures it (IEEE Std 1547-2018 Table 26 TRD at every corner, IEC 61727:2004 Table 1 current THD at rated output, or the IEEE Std 519-2014 Table 1 voltage THD of an AC output), the power factor (grid, unity corners) or the output voltage regulation (AC output), the DC link ripple, and the efficiency at full power (shown only) | | Ride-through (`inverterRideThrough-800V`) | With `rideThrough`, the grid sags to `residualPu` for `duration` at the nominal link and full power | The peak bridge current through the sag, per unit of the rated peak, against `maxCurrentPu` | In these cases `vin` is the DC link in volts and `iout` the output power in watts. The start-up, the grid synchronisation and the protection trips are not simulated. ## Run and read a case Click a case to run it. A case that has run shows its latest run instead; press **Run Case** to run it again. **Run All Cases** runs every case in parallel, and **Re-run Failed** runs only those that failed or could not be measured. Each run is a background job, so the status bar shows progress and **Cancel**. ![A case that has run, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/test-bench-manual/03-run.png) 1. The case, with its verdict. 2. The regulation band drawn on the plot of v(out). 3. The table of limits. Each case has a chip: **Pass**, **Fail**, **Not measured** (the run or a reading failed; hover over the limit for the reason) or **Not run**. A ⟳ after the title means the circuit changed after the run. The scope on the right shows one plot per signal of the case. Each limit is drawn on its signal: - a **band** is a shaded area between two levels (the regulation band, a trip window); - a **line** is a dashed level (the overshoot limit, the current trip); - a **window** is a pair of dashed vertical lines (the start-up time allowed, the recovery time after a step). Below the plots, the table gives each limit's measured value, what is required, the margin to the nearest bound (negative when outside) and the verdict. ## Compare two runs Pick another run in **Compare with:** (above the plots). Its traces are drawn dashed on the same plots, and the table adds its measured values and the difference. A typical use: run a case, change a part, run it again, overlay the first run. ## Check a bench measurement Pick a case, then press **Add bench measurement…** under the Cases table and choose the scope's export: a CSV (Tektronix, Keysight, Rigol or a time/value table), an LTspice or ngspice `.raw`, a MAT-file or a sigrok `.sr` session. Name the column of each of the case's signals (CH1, CH2, … to start with; leave one blank if the scope did not record it). Time 0 is the case's switch-on, so a load step happens at the same time as in the simulation. **Check Against Limits** reads every limit off the measured traces with the same readings the simulation uses (`testbench.measure`) and draws the measurement dashed over the simulated run; the table's **Bench** column gives its value and the difference. A column the file does not have is named in the panel, with the columns it does have. ## Export **Export CSV** writes one row per limit of every case with its latest run. **Copy JSON** puts the cases and every run (without the waveforms) on the clipboard. ## Make the test report The **test report** puts every case and the analyses that apply into one document you can hand over: run it when you are done, or whenever someone asks how the design stands. Choose **Simulation > Test Bench > Run All and Report**, or press **Make Report** in the Test Bench. Every case whose latest run is not of the circuit as it is now runs again; the others are reused. Then Voltecx measures the loop gain of each control loop, the efficiency over the load with its loss breakdown, the junction temperatures, the stress on every part against its rating, and the conducted EMI when the circuit has a LISN or an input filter. When **Run All Cases** ends, the window offers the report on its own. ![The report bar, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/test-bench-manual/04-report.png) 1. **Make Report** runs the cases again where needed and makes the report. 2. **Save Report** writes it as one HTML page. 3. **Copy for AI** puts it on the clipboard with a request to explain it. 4. **Open in Claude** opens a new conversation with the report. 5. **Open in ChatGPT** does the same in ChatGPT. The report has: - a cover with the circuit, the spec, the date, the Voltecx version and the verdict; - a summary with one row per case and per analysis, and a filter that shows only what does not pass; - what failed, each with the measured value, what is required and the next step to try; - one section per case: its readings and the plot of its signals with the limits drawn as in the Test Bench; - the Bode plot of each loop with the crossover marked, and the phase and gain margins; - efficiency against load, the loss of each part, the junction temperatures and the stress table; - the schematic, the open items (steps no simulation shows, analyses that do not apply) and every setting used. The same circuit and settings give the same numbers; only the date changes. **Save Report** writes the report as one HTML page that needs nothing else: open it in any browser, drag across a plot to zoom in, double-click to zoom out and hover to read the values. It follows the light or dark setting of the computer, and the browser's **Print** saves it as a PDF. A Markdown copy (`.md`) is saved beside it for AI tools. Not sure how to read it? **Copy for AI** puts the report on the clipboard with the request "Explain this power-electronics test report and tell me what to fix", ready to paste into any AI assistant. **Open in Claude** and **Open in ChatGPT** open a new chat with it filled in; a long report is cut in the link, and the whole report is on the clipboard to paste after it. The page itself has the same three buttons. In the AI assistant panel, ask "make a test report": the assistant runs the same command, and the report shows here. ## The commands Every button is a command, so a script, the CLI or an AI assistant can do the same: | Command | Does | |---|---| | `testbench.list {spec}` | Lists the cases and their limits; without `spec`, from the spec stored with the circuit (`specFrom` says which) | | `spec.set {spec}` | Stores the spec with the circuit (saved in the file); `testbench.list {}` then lists from it. `design.auto` stores its own | | `testbench.run {case}` | Runs one case id, `all` or `failed`; returns a run id and each limit's measured value and verdict | | `testbench.results {run, case, points}` | Every run, or one run with its waveforms | | `testbench.compare {a, b}` | Two runs side by side | | `testbench.measure {case, csv, map}` | Reads a bench measurement (scope CSV, or `bytes` of a `.raw`, MAT-file or sigrok session) against one case's limits with the same readings, and keeps it as a run with `source: "measured"` next to the simulated ones, so `testbench.compare` and the export show simulation, measurement and limit side by side | | `testbench.export {path, format}` | The cases and results as CSV or JSON | | `testbench.report {path, format, lang, spec, include, rerun}` | Runs every case (or reuses fresh runs) and the analyses, and writes the test report as one PDF or HTML page with a Markdown twin; without `path` the reply holds the page | --- # The command line URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/19-command-line/ `powercraft-cli` runs Voltecx without a window: in a terminal, a script or a CI job. Every subcommand dispatches the same engine commands as the menus, so a result from the command line matches the app's. Every subcommand explains itself: `powercraft-cli SUBCOMMAND --help`. `powercraft-cli --help` lists them all. ## Exit codes | Code | Meaning | |---|---| | 0 | It worked | | 1 | A command failed: a file could not be read or written, or an engine command refused | | 2 | Usage error: an unknown subcommand or option, a missing or malformed value | | 3 | `sim`, `batch`, `sweep`: an `--expect` did not hold | | 4 | `sim`, `batch`, `sweep`: the simulation or the analysis failed | | 5 | `sim`, `batch`, `sweep`: there were warnings and `--strict` was given | `batch` and `sweep` exit with the code of the first file or point that failed. ## Find a command ```sh powercraft-cli commands --filter export # every command whose id or label holds "export" (JSON) powercraft-cli commands describe analysis.loopGain ``` `commands describe ID` prints the command's menu path, its kind, each parameter with its type, default and whether it is required, and an example `run` line. Add `--json` for the same as JSON. ## Run commands ```sh powercraft-cli run --cmd file.openExample --param name=buck \ --cmd simulation.run --param solver=fast \ --cmd spec.verify --params '{"spec":{"vin":12,"vout":5,"iout":2}}' --format md ``` `--param KEY=VALUE` adds one parameter to the `--cmd` before it; the value is read as JSON when it is JSON (`5`, `true`, `[1,2]`) and as text otherwise (`2k`, `v(out)`). `--params JSON` gives several at once. `--format csv` or `md` prints a result that holds a table (the rows of `spec.verify`, a BOM, an AC sweep) as that table; other results stay one JSON line each. `--root DIR` gives the file commands (open, save and the exports) access to the files under DIR. A file opened with `--in` that lies under DIR is the circuit's own file, so `--cmd file.save` writes the changes back to it. When a command stops because the session lacks something (most often a simulation result: `bom.export`, the scope's measurements and `analysis.stress` read a run), the error says what to run first. A step that fails also prints one JSON line on stdout, after the lines of the steps before it, so a program reading the output can tell which step stopped the chain: `{"command":"bom.export","error":{"message":"...","problem":{...}}}`. `problem` is the engine's problem behind the error (its `code`, `hint` and fixes) and is left out when there is none. `powercraft-cli script FILE` prints the same line for the step that stopped the script, with its `"line"`; a script that does not parse runs nothing and names `script.run`. The exit code is still 1, and the `error:` text on stderr stays. Each `--cmd` is one line of the app's console (**View > Console**, Cmd+Shift+Y), so you can try a chain there before you script it: ![The console running the first two commands of the run above, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/command-line/01-console.png) 1. `file.openExample {"name": "buck"}`: what `--cmd file.openExample --param name=buck` runs. 2. `simulation.run {"solver": "fast"}`: what `--cmd simulation.run --param solver=fast` runs. 3. Its reply: the run's number, the time it simulated, how long it took and the solver, with Show run N in the scope. Each line of the console starts with its level: INFO for a reply, WARN for a warning a reply carried, ERROR for a line that failed. The bar above picks a level (**All**, **Errors**, **Warnings**, **Info**, each with its count), **Command lines** shows or hides the commands that ran, and the filter field keeps the lines that contain its text (any case). **Copy visible** copies the lines shown and **Clear** empties the console. An error about a part links to the part on the schematic and to **Problems**, and its copy icon copies the message. ## Simulate and check: `sim` ```sh powercraft-cli sim buck.voltecx --set Vin.v=24 --tend 5m \ --measure 'mean(v(out))' --measure 'power(v(out), i(R1), 4m, 5m)' \ --measure 'efficiency(v(in), i(S1), v(out), i(R1), 4m, 5m)' \ --expect 'mean(v(out)) in 5.7..6.3' --png buck.png ``` `buck.voltecx` is the example `buck` saved to a file (its load is `R1`). The run prints `v(out) mean = 6.043 V`, `v(out) power = 14.99 W` and `v(in) efficiency = 99.96 %`, then `PASS`. The input current of `efficiency` is the current into the circuit, here the switch's `i(S1)`: a source's own current `i(Vin)` is negative while it delivers power, and `efficiency` refuses a negative input power. Measure over a steady window inside the run (`--tend`), since the start-up charges the capacitors. The functions are `mean`, `rms`, `min`, `max`, `pp`, `last`, `thd` (percent), `freq` (Hz), `power(V, I)` (the mean of v·i, W) and `efficiency(VIN, IIN, VOUT, IOUT)` (percent). Each takes an optional window: `mean(v(out), 4m, 5m)`. `--model averaged` runs a buck, boost, buck-boost, SEPIC or flyback on its averaged model, and `--solver fast|ref` picks the solver. `--analysis NAME` runs an analysis and prints its table: | NAME | Command | Notes | |---|---|---| | `ac` | `analysis.acSweep` | needs `--analysis-param output=v(out)` | | `loopGain` | `analysis.loopGain` | prints the crossover and the margins | | `steadyState` | `simulation.steadyState` | in place of the transient run; measurements read its result | | `thermal` | `analysis.thermal` | after the transient run | | `emi` | `emi.conducted` | the bands of the conducted emission and their margins | `--analysis-param KEY=VALUE` passes any parameter of that command (`commands describe` lists them). `--format text|json|csv|md` sets how the table is printed. `ac`, `loopGain` and `emi` give no waveforms, so `--measure`, `--expect`, `--csv` and `--png` go only with `steadyState`, `thermal` or no analysis. `--watch` runs again every time the file is saved, until Ctrl-C. ## Many files, many values: `batch` and `sweep` ```sh powercraft-cli batch designs/ -- --tend 5m --expect 'mean(v(out)) > 4.9' --format md powercraft-cli sweep buck.voltecx --set L1.l=10u,22u,47u --set R1.r=1,5 --tend 5m --measure 'pp(v(out), 4m, 5m)' ``` `batch` takes folders, files and globs (`'designs/*.voltecx'`) before `--`, and `sim` options after it. It prints one row per file with its status (`ok`, `fail`, `error`), its exit code and each measurement. `sweep` runs every combination of the listed values (at most 1000) and prints one row per point. A comma inside parentheses does not split a value. A window must lie inside the run: the buck example ends at 4 ms, hence `--tend 5m`. ## Compare two designs: `compare` ```sh powercraft-cli compare buck_v1.voltecx buck_v2.voltecx powercraft-cli compare buck_v1.voltecx buck_v2.voltecx --tend 5m --measure 'pp(v(out), 4m, 5m)' --lang zh-Hant ``` It lists the parts added, removed and renamed, and the parameters, nets and variables that changed (`file.diff`). With `--measure` or `--expect` it also simulates both files the same way and shows each value for A and B with the change. ## Inside a Voltecx terminal: the open window In a terminal opened in Voltecx (View › Terminal), `run`, `sim` and `script` act on the open window instead of a separate session: the circuit they build or open appears there, each command is one step you can undo, and the version history records it as the command line's. After acting they print one state line on stderr, so you (or an agent working in that terminal) see what the window now shows: ```text window: 0 errors, 1 warnings, 0 notes (value.range (R1.r)); last run: v(out) mean 12.01, ripple 0.0412 pp, efficiency 96.4 % ``` The line names the first three problems (`powercraft-cli app problems` lists them all) and the last run's key figures, or `not run since the change` when the circuit changed after it. `--shot PATH` also writes a picture of the window. A simulation runs in the window as a job, with its progress bar and Cancel button. A `.voltecx` file that was written outside Voltecx (it has no version history next to it, as a file a script wrote by hand) is not opened in the window: build the circuit with commands instead (`run --new '{"name":"buck"}' --cmd circuit.apply ...`). Add `--headless` to any of the three to work in a separate session as before; it says that the result is not in the window. `--root` and `sim --watch` work only with `--headless`. In any other terminal nothing changes: the commands run without a window. ## Exports and the report ```sh powercraft-cli export buck.voltecx --out out --schematic pdf --kicad --bom csv powercraft-cli export buck-closed-loop.voltecx --out out --code stm32g474 powercraft-cli report buck.voltecx --out out --lang zh-Hant ``` `export` writes the schematic (`png`, `svg` or `pdf`), a KiCad 8 project, the BOM (`csv`, `json` or `md`; the file is simulated first, since parts are picked from the stresses) and the control's C code (`portable`, `stm32g474` or `f28379d`) into `out/FILE-code`. `--code` needs a circuit with a digital controller, such as the example `buckClosedLoop`; the open-loop `buck` has none. `report` writes the design report as PDF or HTML (`--format html`). ## Shell completion ```sh powercraft-cli completions bash > ~/.local/share/bash-completion/completions/powercraft-cli powercraft-cli completions zsh > "${fpath[1]}/_powercraft-cli" powercraft-cli completions fish > ~/.config/fish/completions/powercraft-cli.fish powercraft-cli completions powershell >> $PROFILE ``` The scripts complete the subcommands and the options of each. --- # 20. Troubleshoot: from a wrong reading on the bench to the faulty part URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/20-troubleshoot/ A board on the bench reads wrong: the output sits at 10 V where it should be 5 V. **Troubleshoot** compares what you measure with what the circuit predicts for every fault it can think of (each part open, shorted, of the wrong value, a switch stuck, a wrong variant), and tells you which point to measure next to tell the likely causes apart. It never changes the circuit. Choose **Analysis > Faults > Troubleshoot**. ## The symptom Type what reads wrong and what it reads: - **Symptom**: a node (`VOUT`) or any recorded signal (`i(L1)`); - **reads**: a number (SI prefixes and a unit are fine: `4.8`, `4.8 V`, `12m`), a range typed `low..high` (`4.7..4.9`), `open`, or what a scope shows: `no switching`, `switching`, `oscillates` or `steady`. A scope word makes every prediction a simulation of the circuit, read as a meter and a scope would read it over the end of the run: a node's mean (what a DC meter shows on a switching node), its peak to peak, whether it switches and whether it oscillates. So `SW` reading `no switching` on a buck ranks the switch stuck on or off and a missing load first, and the next checks can be a scope look (`switching(v(SW))`, `pp(v(VOUT))`) as well as a meter reading. **Bench test** says how the board is set up: **Board as it is**, or one of the named tests (**Static gate test**, **Double-pulse test**, **No-load start-up**, **Full load**). With a test, every prediction is a simulation of the board as it is on that bench, and what the healthy board does wrong there (a DESAT trip with no drain connection, an under-voltage lockout from a low bench supply, a missing fault pull-up) is ranked next to the part faults, in orange. Press **Start Troubleshooting**. ![The Troubleshoot window on the buck example, after its switch node SW read no switching, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/troubleshoot/01-session.png) 1. **Symptom**: the node that reads wrong, here `SW`. 2. **reads**: what it reads, here `no switching`, a scope word, so every prediction is a simulation. 3. **Start Troubleshooting** starts the session. 4. **Likely causes**: S1 stuck on, S1 stuck off and the missing load (R1 open) come first, at 33 % each. 5. **Next check**: measure the DC voltage of `SW`, which tells those three apart. ## The next check On the left, **Likely causes** ranks the causes with their probability, and **Readings** lists what you have measured so far, the symptom first. On the right, **Next check** names the point to measure (`v(fb)`, a part's marking, or `r(fb,0)`: a resistance with the power off, `0` being ground), how to measure it and why that check. A red warning means the check touches a hazardous voltage. **If it reads** lists each reading the check can give and the causes it would point to. Type the reading and press **Enter Reading** (or Enter), or click one of the expected readings. A resistance takes ohms or `open` (the meter's OL); a marking takes `differs` or `matches`. Live checks come first: a resistance check is asked for only when no live reading can split the causes left. ## The conclusion When one cause is likely enough, or no further check can split the rest, the card shows the **Conclusion**: the most likely cause, or the causes that read the same in every check, and their **Fixes**. Causes that read the same everywhere, live and with the power off, are told apart only by inspection. **End Session** ends the session. The session belongs to the circuit: closing the window keeps it, and the CLI and the assistant see the same one. ## Plan a bench test Pick a **Bench test** and press **Plan Test** before you power the board. The bench is simulated with the real IC models, and the window lists what will go wrong (for example "DESAT protection trips", with "short DESAT to COM for the static test" as the fix) and the preparation the test needs. ## The same from the CLI and agents The window runs the engine commands `debug.start`, `debug.answer`, `debug.end` and `debug.planTest`; see the `powercraft-lab` skill and the command reference. --- # 21. The field solver (Preview): inductance, loss, heat and force from the field URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/21-field-solver/ A circuit model of an inductor or transformer needs numbers: L, the coupling, where the core saturates, how much it loses and how hot it runs. The field solver finds them from the magnetic field of the part itself. It meshes a section of the core and windings into triangles (or the whole part into tetrahedra in 3D), solves Maxwell's equations on that mesh and reads the inductance, loss density, temperature and force from the solution. You can write the results into the part on the schematic, so the circuit simulation then runs on the solved values. This chapter covers turning the solver on, the ready-made examples, solving a part you designed, reading the field window, core loss, 3D, drawing a section of your own, the other analyses, exports, the limits and the accuracy report. Every command it names has a page in the [command reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/), under **Field solver commands**. ## Turn on Preview features The field solver is a **Preview** feature: it has not passed its release gate (the accuracy, hardware and performance rows described at the end of this chapter), so check its results before you rely on them. While Preview features are off, its items stay in **Design > Field Solver** but are greyed out, and hovering one says how to turn them on. ![Design > Field Solver with Preview features off: the solver's items are greyed out](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/field-solver/01-preview-off.png) Turn them on in **Edit > Preferences > Simulation** (**Preview features (field solver)**). From the CLI, Python or an agent, run `preview.set {"enabled":true}`; `preview.get` reads the setting. Development builds start with it on and release builds with it off. While it is on, every field-solver reply carries `preview: true` and a note in English and Traditional Chinese, so a report or export built from it says that it came from a Preview feature. ![The Field Solver submenu with Preview features on](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/field-solver/02-menu.png) The submenu holds: - **Design > Field Solver > Field Solve** (`magnetics.fieldSolve`): solve the selected part's field and read L. - **Design > Field Solver > Core Loss from Last Run** (`magnetics.fieldCoreLoss`): drive that model with the part's current from the last simulation and find the core loss. - Two exchange items (`magnetics.femmExport`, `magnetics.femmImport`) that write the same model for an independent open-source 2D solver and read its results back, so you can cross-check this one. - **Design > Field Solver > Open Field Example** (`field.openExample`): open one of the four checked examples. - **Design > Field Solver > New Field Drawing** (`geometry.new`): start a drawing of your own section. The other commands (line profile, region table, force, flux map, transient, winding capacitance, thermal and the exports) have no menu item yet. Run them from Quick Open (**Cmd+K**), the CLI, Python or an agent. ## Start with an example Choose **Design > Field Solver > Open Field Example** and pick one. Each opens solved in the field window, with a card on top that checks the result against its row of the accuracy report. ![The gapped E 25/13/7 example in the field window, its check card on top](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/field-solver/03-example-e25.png) | Example (`name`) | What it is | Check (accuracy-report row) | Result | |---|---|---|---| | `e25BuckInductor` | Gapped E 25/13/7 N87 inductor, 34 turns, 1 mm gap | L against the Richardson-extrapolated 91.83 µH (`mesher_independence`, ≤ 0.5 %) | 91.45 µH, 0.42 % | | `e25FlybackTransformer` | The same core wound as a 1:1 coupled inductor, 25 turns each | M12 against M21 (`reciprocity`, ≤ 0.5 %) | L1 48.97 µH, L2 50.37 µH, M 49.21 µH, k 0.991 | | `ringCoreChoke` | 30/20/5 mm ring core, 20 turns, μr 2208, as an axisymmetric (r, z) section | L against the closed form 358.1 µH (`analytic_toroid_axisym`, ≤ 1 %) | 358.1 µH | | `potCore` | P26/16 pot core, 1 mm centre-post gap, 34 turns, μr 2208, axisymmetric | L from flux linkage against L from stored energy (`energy_vs_flux_linkage`, ≤ 1e-6) | 173.7 µH, the two agree to 1e-13 | | `twoWireLine` | Two round wires, 1 mm radius, 20 mm apart, go and return, no core, inside an open boundary (60 mm, 4 shells) | L per metre against the closed form (μ0/π) arccosh(D/2a) + 2 μ0/(8π) (`open_boundary_two_wire`, ≤ 0.5 %) | 1.2924 µH/m against 1.2973 µH/m, 0.37 % | The ring core has no field view: its toroidal winding's B runs along φ, round the axis, which a 2D (r, z) section cannot draw. The card and the values still show. From the CLI: ```sh powercraft-cli run --cmd preview.set --params '{"enabled":true}' \ --cmd field.openExample --params '{"name":"e25BuckInductor","field":false}' ``` ## Solve a part you designed Select an inductor, coupled inductor or transformer on the schematic and choose **Design > Field Solver > Field Solve**. The solver works on the part's design from **Design > Automate > Design Magnetics** (`magnetics.design`, chapter 16). A part with no design yet is designed first, and the solve follows when the design arrives. With nothing selected it uses the part of the last Design Magnetics run. What it builds: the front section of an E pair or planar E set with the gap ground into the centre leg, or the top view of a ring core, with each winding in the window. The mesh is automatic, with three elements across every gap and graded out from there; `elementMm` sets the largest element in the core and windings instead. The 2D solve is magnetostatic with linear materials (the core at its catalogue initial permeability at the design temperature, or `muR`), with 1 A in each winding in turn. It returns: - L of each winding from the field energy, M and k, and, when the turns ratio allows, the magnetising inductance and the leakages (a split that falls below zero is left out with a note); - `model`: the mesh size, the smallest element angle, the solver's iterations and residual, the reciprocity `|M12 − M21|/|M|`, and `provenance`, a hash of each solve's input, so a stored result can be checked against a fresh solve (the same call gives the same hash). `apply: true` writes the result into the part in one undoable history step: `l` for an inductor; `l1`, `l2` and `k` for a coupled inductor; `lm`, `llk1` and `llk2` for a transformer. The solve runs as a job: its progress counts the windings solved, and cancelling stops it within one iteration. Before it starts, the solver estimates the memory it needs. Past 60 % of the memory available it refuses, says what to change (a larger `elementMm`, for example), and offers **Run Anyway**, as `simulation.run` does (`ignoreMemoryCheck` from the CLI). ## Read the field window The window (the example above is one) shows the values the solve reports, then the field view: - The quantity tabs: **Flux density |B|** (T) and **Field strength |H|** (A/m); a core-loss result adds **Core loss density** (W/m³), and a thermal result shows **Temperature** (°C) instead. - With two windings, **Winding A at 1 A** or **Winding B at 1 A** picks whose field is drawn. The materials are linear, so the field at any currents is the sum of the windings' 1 A fields times their currents. A core-loss result adds **At the peak |B|**: every winding at its current at the instant of the core's peak |B|. - Layers: **Flux lines** (contours of the vector potential A_z, or of ψ = r·A_φ in an axisymmetric section), **Mesh** and **Outlines** (region edges). - **Whole model** fits the air box as well as the core. - Click the map to place the probe, which reads the value under it. Scroll to zoom and drag to pan. - The colour scale runs from 0 to the core's 99th percentile of |B| by area, so a few crowded elements in a corner do not wash out the map; the legend's top reads ≥ when values lie above it. - **Export Image** saves the map as PNG or SVG at print resolution (`field.exportImage`, below). Look for flux that leaves the core through the gap and the window: that fringing field is what heats the winding next to the gap, and what a gap spacer moves. ## Core loss **Design > Field Solver > Core Loss from Last Run** takes the part's winding currents from the last simulation (`i(L1)`, or `i(T1.1)` and `i(T1.2)`), over the last switching period, and finds B(t) in every core element. When the core material has a data-sheet B-H curve (a data-sheet ferrite or alloy such as N87, or a powder grade from its DC-bias roll-off) each time point is a nonlinear Newton solve on that curve at the core temperature; otherwise the 1 A solves are scaled by the currents. The loss density of each element follows from the iGSE with the material's Steinmetz data, and the total is summed over the core's volume. ![Core loss from the last run: the loss-density map and the core's B(t)](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/field-solver/04-core-loss.png) The window adds the loss map and the core's mean B(t) over the period. The reply also gives: - `totalLossW`; for N87 and 3C90, a DC-bias correction from measured premagnetization data, with `totalLossIgseW` the plain iGSE total beside it and a `dcBiasNotCovered` warning outside the measured range; - `bP99`, the |B| below which 99 % of the core's area lies, checked against the material's saturation flux density at the temperature (the peak element is reported beside it; a peak on a corner of the drawing, where the linear field is singular, gets a `cornerPeak` warning); - a warning when the winding current peaks above the limit Design Magnetics held the design to: the core was designed for a smaller current, and saturates at this one. In an axisymmetric sketch each element stands for its whole ring (2π r̄ times its area), so the loss, the |B| 99th percentile and the mean B are weighted by volume, and `model.form` in the reply says `planar` or `axisymmetric`. Magnets are accepted (`direction: [r, z]`); only the `field` view is refused, because it is planar. From the CLI, give the waveform yourself (`waveform: {t, i}`) or name signals of the last run (`signals`, with `t0`, `t1` or `fsw` for the window). With `dimension: 3` the loss comes from the 3D model (see 3D below). Add `endTurns: true` for an E or planar E design with one or two round or litz windings on the centre leg: the core is then the wound one of Field Solve with `endTurns`, one eighth meshed. `totalLossW` and `coreVolume` are the whole core's, while the `map` rows are the eighth's and sum to an eighth of the loss; `model.construction` says `wound`. The end turns carry flux the straight extrusion leaves out, so the wound loss reads a few per cent above it (+4 % on the E 25/13/7 buck). `endTurns` is refused in 2D and with `sketch`, `layers` or `magnets`. ### Steel loss: hysteresis, classical and excess For a laminated steel, `magnetics.lossSeparation` splits the iron loss into Bertotti's three terms for sinusoidal flux: P = kh·f·B^Y + kc·F·(f·B)² + ke·(f·B)^1.5 (hysteresis, classical eddy current, excess). Read the loss points off the steel's data-sheet curves (`points: [{frequencyHz, bPeakT, loss}]`, in W/kg with `densityKgM3`, or in W/m³). With the sheet's `conductivitySm` and `thicknessMm` the classical coefficient is the thin sheet's π²σd²/6, so one 50 or 60 Hz curve is enough; without them it is fitted too, and the points need two or more frequencies. `muR` adds the sheet's skin factor F(d/δ) to the classical term, and `exponent` fixes Y (otherwise it is fitted). The reply gives kh, Y, kc and ke (per m³, and per kg with the density), the error at every point, and each term's loss and share at your working points (`at: [{frequencyHz, bPeakT}]`). A coefficient the fit wants below zero is held at zero and named in `heldAtZero`. The program holds no steel data: every coefficient comes from your points and sheet. ```sh powercraft-cli run --cmd magnetics.lossSeparation --params '{"densityKgM3":7650,"conductivitySm":2e6, "thicknessMm":0.35,"points":[{"frequencyHz":50,"bPeakT":0.5,"loss":0.4},{"frequencyHz":50,"bPeakT":1.0,"loss":1.2}, {"frequencyHz":50,"bPeakT":1.5,"loss":2.6}],"at":[{"frequencyHz":400,"bPeakT":1.0}]}' ``` The numbers above only show the format. Read yours from your steel's data sheet. ## Studies: 2D and 3D side by side Each circuit keeps its field analyses as **studies**, saved in its file: one 2D or 3D model each, with its drawing or design, the settings it was last solved with, its view and its results. The fast 2D section stays your design loop while a 3D study of the same part checks the final design, and neither overwrites the other. The row at the top of the field, 3D and drawing windows picks the study and holds four icons (each names itself on hover): - **New 2D study** starts an empty 2D study; the one you were in keeps its drawing and results. - **Open in 3D** (**Open in 2D** in a 3D study) starts a study of the same part in the other dimension with the same design (core, gap and winding) and settings, so nothing is drawn twice. Solve it as before and compare L. - **Rename study** and **Delete study** (not undoable; a circuit keeps at least one). Each study remembers its own zoom, camera, section and the 3D views saved for the report. A file saved before studies opens with one study, **Field 2D**, holding what you had. With **View › Studio Layout (Preview)**, the **Field 2D** and **Field 3D** documents list the studies of each kind with their part and saved L; click one to open it. From the command line, `field.studies` lists them and `field.newStudy {"dimension":3,"from":0}` opens the 3D study from the first one: ```sh powercraft-cli run --in choke.pcraft --cmd field.newStudy --params '{"dimension":3,"from":0}' --cmd field.studies ``` A save keeps each study's drawing, settings, view and the values of its last solve, not the field itself: open the file and solve again to draw it. ## 3D `dimension: 3` builds the model in 3D and solves it with the 3D solver. An E-core design or a sketch is its section extruded straight through the depth (`layers` element layers, 8 by default), so its L checks the 2D solve; a ring core is its section revolved about the axis. `endTurns: true` winds round or litz windings on the centre leg as a bobbin with its end turns and solves one eighth of the part. A design whose core material has a catalogue B-H curve is solved on that curve at each of `currents` (L(I), secant and incremental); `linear: true` keeps it linear. `adaptive: true` refines the mesh where the error estimate is largest and solves again until L settles, on the curve too: there every point of L(I) must settle, and each pass lists its `secant` at the largest current. `import` reads closed bodies from an STL file or the solids of a STEP file, with your μr for each and your windings. A `helix` winding is a stack of rings by default; `pitched: true` makes it a true helix with its axial current and a straight return lead back down through its turns at `startAngleDeg` (its corner radius at least its thickness). `field.exportModelStl` (Preview) takes the same model keys and returns the meshed 3D model as ASCII STL, one solid per region named after it, with the symmetric part the solve meshes reflected into the whole (`whole: false` writes the part). Save its `stl` text as a .stl file to check the mesh in a CAD or mesh viewer. `field.exportModelStep` (Preview) takes the same keys and writes the meshed solid regions as a STEP file (ISO 10303-21, AP214, in metres), one faceted solid per closed piece of each region (a region in several pieces gives `primary 2` and so on). A piece that encloses other regions, such as the air box around a wound core, is written as a solid with voids (`BREP_WITH_VOIDS`), so every region comes out and its volume is the material between its outer shell and its voids. The 3D import reads such a solid back. Save its `step` text as a .step file to open the core, windings and magnets in a mechanical CAD tool. ![The E 25/13/7 solved in 3D, |B| on a section plane across the core](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/field-solver/05-field3d.png) With `field: true` the 3D window shows each body, a section plane, smooth shading and flux tubes (each tube carries the same share of the flux through the section). The reply gives L two ways (from the field energy and from the flux linkage) and the largest difference between them, and the peak and 99th-percentile |B| of the core. The window opens with the whole model filling about 70 % of the view, seen from the front-right and above (yaw −45°, pitch 30°). Drag to orbit, right-drag to pan and scroll to zoom; the triad in the bottom-right corner shows where the model's x, y and z point. The bodies are lit by a key and a fill light with a soft highlight, and their outlines and the section's edge are drawn as thin dark lines, so the core keeps its shape against the colours. The controls above the view: - **Section plane**: none, or across x, y or z, with a slider for its position. The cut face is filled with the field's colours, unlit, so they match the legend. - **Smooth shading**: each body's values averaged at its corners and blended across each face; off, every element shows its own value. - **Colour map**: Viridis (the default), Inferno or Turbo. Viridis and Inferno grow lighter from bottom to top, so they still read in grey; Turbo tells more levels apart. The report's pictures stay on Viridis. - **Flux tubes** (not in a thermal result). While they are on, the magnetic parts turn see-through so the tubes inside the core show at full strength. - **Colour range**, when the result has more than one body: Automatic, or one body, whose own values then set the scale (a core a few kelvin apart shows its gradient beside a much hotter winding). The other bodies take the end colours and turn see-through, so they do not hide it. - **Bodies**: an opacity slider for each body. An opacity you set yourself is kept when the tubes or the colour range change, and so is a hidden body. |B| and the temperature use a linear scale. A core loss's loss density spans decades, so it uses a logarithmic scale from the 1st to the 99th percentile by volume; the legend's bottom reads `≤`, since lower values take the bottom colour. On the desktop the view is drawn by the graphics card, with a depth buffer and 4× anti-aliasing, so faces that cross meet in the right place and the edges are smooth. In the browser, without a usable graphics card, and in pictures made without a window (the report, snapshots) the same view is drawn by the processor instead; the colours, picks, legend and saved cameras are the same either way. A 3D solve takes a while, so `field.tables3d` solves the 3D model once and returns tables to reuse: the L/M matrix, the flux-linkage table on the B-H curve over `currents` (the same `psiCurve` or `coupledCurve` the flux map writes, which both circuit solvers follow), and with `loss` a grid of core loss against peak current and frequency. `field.tableLookup` then reads L, M and the loss from that reply at any current and frequency inside the grid, without solving again. ### Thermal in 3D `field.thermalSolve` with `dimension: 3` solves the steady temperature on the same tetrahedra as the 3D field solve. The regions, the convection and the copper coupling are given as in 2D, and `lossW` is the whole heat of a region. Every outer face of the solids convects; `ends: "insulated"` stops the two end faces of an extruded model from convecting, so no heat flows along the depth and the result is the planar solve's, which makes it a check against 2D. `layers` sets the element layers through the depth, and `ignoreMemoryCheck` runs past the memory guard. This example is a rod 10 mm across and 1 m deep with 100 kW/m³ in it, k = 4 W/(m·K) and h = 10 W/(m²·K): ```json { "sketch": { "depthMm": 1000, "points": [[5, 0], [-5, 0], [-20, -20], [20, -20], [20, 20], [-20, 20]], "edges": [[0, 1, 3.141592653589793], [1, 0, 3.141592653589793], [2, 3], [3, 4], [4, 5], [5, 2]], "labels": [{"name": "rod", "at": [0, 0], "muR": 1}, {"name": "air", "at": [15, 15]}] }, "elementMm": 0.5, "regions": [{"name": "rod", "k": 4, "heatWm3": 100000}], "convection": {"hWm2K": 10, "ambientC": 25}, "dimension": 3, "layers": 2, "ends": "insulated" } ``` The surface settles at 49.97 °C and the hot spot on the axis at 50.13 °C; the closed form for a long cylinder gives 50.0 °C and 50.16 °C. With `ends: "convecting"` the end faces cool the rod as well, and it runs a little cooler. The heat can come from the same sources as in 2D: - `core` heats the core with the 3D core loss on the same tetrahedra, recomputed at the core's mean temperature until it settles. `permeability: "followsTemperature"` solves every winding again at the core's permeability at that temperature, and `drive: "curve"` puts the core on its catalogue B-H curve. - `ac` heats the conductors with the planar section's AC loss, the same along the depth. It has no end turns. With `core` as well, both losses are iterated in one loop. - `line` reads the temperature along a line given as `[x, y, z]` in mm (or `[x, y]` on the middle plane), and `lumped` reduces the result to a thermal network with one 3D solve per region. - `plane: {axis, atMm, points?}` reads the temperature on an axis-aligned cut (`axis` "x", "y" or "z", z = 0 at mid-depth) on a grid over the solids, up to 1001 points a side: the reply gives the grid, the range, the mean of the points inside the solids and the cut's hot spot with its region. Points in the air are null. A ring-core design is its section revolved a full turn. The core is the only solid, since the windings are current sheets on it, unless you name a region `A` or `B`: that winding is then drawn as a solid copper frame around the core, as thick as its turns fill the hole and carried over the faces and the outside. The frame holds more copper than the turns do, so give its effective `k` yourself. `layers`, `ends` and `ac` do not apply to a ring. On a ring, `eddy: {"frequencyHz": …, "currentsA": [...]}` heats the regions given `sigmaSm` with their 3D eddy-current loss, ½∫σ|E|², from a time-harmonic solve of the revolved ring in which each winding is a toroidal current sheet at its peak current, all in phase. A whole turn has no end faces, so the induced current closes inside the ring, end effects and all. A copper region's conductivity follows its mean temperature (IEC 60028), `sigmaSm` being its value at `lossAtC`, and is iterated with the thermal solve; any other conductor keeps the value given. `eddy` is refused on an extruded model, whose conductors run to its end faces (the planar `ac` is the loss there), together with `ac`, `core` or `lumped`, and on a winding's copper frame, which would be one shorted turn. The winding's own loss is not in this solve. ### Force in 3D `field.force` with `dimension: 3` gives the force and torque on a body of the 3D model: a sketch or an E-type design extruded through its depth, `layers` element layers as in Field Solve. The force is the weighted Maxwell stress tensor over the air around the body, as in 2D, and `forceN` and `torqueNm` are `[x, y, z]` for the whole model, with z along the extrusion and z = 0 its middle plane. `centreMm` may then be `[x, y, z]`. The solver meshes only the half through the depth (even `layers`) or the quarter (a body that is its own mirror across x = 0, and no magnets), and unfolds the part's force into the whole body's; `mirrorPlanes` names the planes it unfolded across. `lorentzN` checks it on a coil in air, and `nonlinear: true` puts the core on its B-H curve. `virtualWork: true` checks it a third way, by the derivative of the co-energy with the body moved by ±1e-3 of its size along x and y and turned by ±1e-4 rad: six more solves, two on the quarter. It gives F_x, F_y and τ_z; F_z, τ_x and τ_y are null, because the extrusion's ends hold the body along z. A winding's current moves with the body, and a magnet in the body turns its magnetization with it. A magnet given its grade's `demagCurve` (as in `magnetics.fieldSolve {dimension: 3}`) is solved on that curve by Newton's method at the currents given, and the force and the knee check read that field (`model.magnets: "demagCurve"`), so a magnet driven past its knee pulls less. `virtualWork` is refused with a `demagCurve`, because the co-energy on the curve is not computed yet. `magnets` works as in 2D: each magnet is its region through the depth, magnetized in the drawing's plane, and a drawing of magnets alone, with no coil, is extruded with no winding. The reply then has a row for each magnet with its volume and where it is worst, and the demagnetization warnings. This example is the two conductors of "Draw a section of your own" below, 2 A in 10 turns each, out and back, extruded 100 mm with two layers and 0.5 mm elements: ```json { "sketch": { "depthMm": 100, "points": [[-50, -50], [50, -50], [50, 50], [-50, 50], [-12, -2], [-8, -2], [-8, 2], [-12, 2], [8, -2], [12, -2], [12, 2], [8, 2]], "edges": [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 4], [8, 9], [9, 10], [10, 11], [11, 8]], "labels": [ {"name": "air", "at": [0, 30]}, {"name": "go", "at": [-10, 0], "circuit": "A", "turns": 10}, {"name": "return", "at": [10, 0], "circuit": "A", "turns": -10} ] }, "elementMm": 0.5, "regions": ["go"], "currents": {"A": 2}, "dimension": 3, "layers": 2, "virtualWork": true } ``` The stress tensor gives −0.342 mN along x: the conductor on the left is pushed away from the other. Virtual work and the Lorentz force agree with it within 1 %, and so does the planar `field.force` of the same section through the depth, since the extrusion's ends carry the planar field. F_z is close to zero. The box's edge pulls the value below the thin-wire 0.40 mN, as in 2D. Give `elementMm` when you want the Lorentz check. The 3D mesh is coarse by default, and the Lorentz force needs the field resolved inside the conductor: on the default mesh of this example it is 38 % low, while the stress tensor is within 1 % of the planar force on that mesh too. When `lorentzN` and `forceN` are more than 1 % apart, the reply says so in a note, with the number of tetrahedra in the body. ## Draw a section of your own **Design > Field Solver > New Field Drawing** asks for planar or axisymmetric and, for planar, the depth in mm, then opens the drawing canvas. Pick a tool along its top: | Tool | What it does | |---|---| | Pan | Drag a point or region label to move it onto the grid, or drag the canvas to pan; scroll to zoom | | Point | Click to place a point | | Segment | Click where the segment starts, then where it ends | | Rectangle | Click one corner, then the opposite one | | Circle | Click the centre, then a point on the circle | | Arc | Click the start, the end, then a point the arc passes through | | Region | Click inside a closed region to say what it is: air, a magnetic material with its μr, or a coil with its circuit and turns (negative for the return side) | | Dimension | Click two points to show their distance (`geometry.setDimension` then sets it, moving the second point) | | Delete | Click a point, edge or region label to delete it | **Grid (mm)** sets the snap grid. Esc cancels an unfinished edit; **Undo** and **Redo** step through the drawing's own history. The line under the canvas says **Ready to mesh.** once every region is closed and labelled, or names the first problem (the point, edge, region or label). Each tool is a `geometry.*` command, so the CLI, the assistant and Python draw the same way, in metres: `geometry.addRectangle {"min":[0,0],"max":[0.01,0.02]}`. `geometry.get` returns the whole drawing. The canvas has no Solve button in this version. To solve a section of your own, give it to a command as `sketch`, in millimetres: points, edges between them (`[a, b]`, or `[a, b, sweepRad]` for an arc) and labels. A label with `muR` is a linear core, one with `circuit` and `turns` a coil, one with neither air. The outer boundary holds A = 0, unless you give the sketch an open boundary (next section). For example, two conductors 20 mm apart carrying 10 turns each, out and back, in a 100 mm box 100 mm deep: ```json {"depthMm":100, "points":[[-50,-50],[50,-50],[50,50],[-50,50],[-12,-2],[-8,-2],[-8,2],[-12,2],[8,-2],[12,-2],[12,2],[8,2]], "edges":[[0,1],[1,2],[2,3],[3,0],[4,5],[5,6],[6,7],[7,4],[8,9],[9,10],[10,11],[11,8]], "labels":[{"name":"air","at":[0,30]}, {"name":"go","at":[-10,0],"circuit":"A","turns":10}, {"name":"return","at":[10,0],"circuit":"A","turns":-10}]} ``` `magnetics.fieldSolve {"sketch": …}` gives L = 9.23 µH. `field.force {"sketch": …, "regions": ["go"], "currents": {"A": 2}}` gives a force of −0.341 mN along x: the conductors repel. Two thin wires 20 mm apart with 20 A·turns each repel with μ0·I²/(2π·d) × depth = 0.40 mN; the box's edge, where A = 0, is close and pulls the value down. With the box grown to ±200 mm the same call gives −0.392 mN. Make the air box several times larger than the part, and check that L or the force no longer moves when you grow it again (the accuracy report's `boundary_distance` row does exactly this for the E25). An open boundary, next, does without the box. ## Open boundaries The A = 0 edge round a drawing holds the whole field inside it, as if the part sat in a closed iron box. A closed core keeps nearly all its flux inside, so the box hardly matters. For an air-core part, a busbar, a line or the stray field of a gap, it pulls L and the forces down, as the example above shows. Instead of growing the box, put the drawing inside an open boundary. This is a circle of air with graded-permeability shells outside it, Meeker's improvised asymptotic boundary conditions (femm.info, "Improvised Asymptotic Boundary Conditions"). The shells make the circle's edge behave like the free space beyond it: each layer matches one more harmonic of the field outside exactly. For a sketch, add `openBoundary` inside the sketch: `{"radiusMm": …, "centreMm": [x, y], "layers": 4}`. - `centreMm` defaults to [0, 0]. In an axisymmetric sketch the centre is on the axis. - `layers` defaults to 4 and runs from 1 to 10. Each layer meshes into many more nodes: a small ring takes about 29,000 nodes at 4 layers and 135,000 at 10. Four is the fewest that holds a circle drawn tight round the part, 10 % past it: L then moves less than 0.2 % from a far circle, and 0.6 % at 3 layers. With the circle at three times the part's size, 1 layer already gives the same L, so fewer layers there only save nodes. - The circle must hold the whole drawing, which then needs no outer edge of its own. - The air between the drawing and the circle is labelled `open boundary air` unless your drawing labels it. The shells are the regions `open boundary shell 1` to `N`, so don't use those names in the drawing. The same two conductors as above, without the box: ```json {"depthMm":100, "points":[[-12,-2],[-8,-2],[-8,2],[-12,2],[8,-2],[12,-2],[12,2],[8,2]], "edges":[[0,1],[1,2],[2,3],[3,0],[4,5],[5,6],[6,7],[7,4]], "labels":[{"name":"go","at":[-10,0],"circuit":"A","turns":10}, {"name":"return","at":[10,0],"circuit":"A","turns":-10}], "openBoundary":{"radiusMm":60}} ``` - `magnetics.fieldSolve` gives L = 9.51 µH, against 9.23 µH in the 100 mm box. - `field.force` with the same `regions` and `currents` gives −0.397 mN, within 1 % of the thin-wire 0.40 mN. The box only came close at ±200 mm. - With `radiusMm` doubled to 120, L moves by 0.07 % and the force by 0.3 %, so the boundary no longer limits the answer. - The mesh still does. With `elementMm: 0.5`, L rises to 9.61 µH. The closed form is 9.66 µH: (μ0/π)·ln(D/g)·N² × depth, with g = 0.447 × the side of a square conductor, its geometric mean distance (F. W. Grover, *Inductance Calculations*, 1946). The reply's `model.openBoundary` gives the centre, radius and layers, and a note says what the boundary does. For a design, give `openBoundary` beside it: `magnetics.fieldSolve {"design": …, "openBoundary": {"radiusMm": …}}`. - The design's drawing goes inside the circle, and its A = 0 box becomes an inner edge. - `centreMm` defaults to the middle of the drawing. The circle must hold the box, so start at about 1.2 times the box's half-diagonal. - A closed core keeps its L: the gapped E25 moves by 0.0025 %. - The other commands refuse a design's `openBoundary`. Draw the part as a sketch to use one there. Where it works: - A sketch's open boundary works in every 2D magnetic command that takes a sketch: Field Solve, core loss, flux map, line profile, region table and force. - In `field.windingCapacitance` the shells are graded in permittivity instead, and only the outermost shell is held at 0 V. A planar drawing gets a note there: each conductor's capacitance to ground depends on the radius, because a net charge per metre has no free-space reference in 2D. The capacitance between conductors does not depend on it. - 3D solves and the thermal solve refuse an open boundary. `field.openExample` `twoWireLine` is a line inside an open boundary, checked against the `open_boundary_two_wire` row of the accuracy report. ### Symmetry planes: solve a half or a quarter A device symmetric about a line can be drawn as its half (or, symmetric about two lines, its quarter) and solved as the whole: `magnetics.fieldSolve {"sketch": …, "symmetryPlanes": [{"axis": "y", "atMm": 0, "kind": "fluxNormal"}]}`. - Each plane is `x = atMm` or `y = atMm`, at most one per axis. It must be a straight outer edge of the drawing, with the whole drawing on one side. - `fluxTangential`: the field is odd about the plane, as when the go side of a winding is mirrored by its return side. No flux crosses the plane, so it is held at A = 0 like the rest of the outer edge. - `fluxNormal`: the field is even about the plane, as when the plane cuts a core and its windings through their middles. The flux crosses the plane at right angles, so its nodes are left free. - L and M are multiplied by 2 per plane. The turns stay the drawn ones: a winding cut in half by a plane is drawn with half its turns. - The reply's `model.symmetry` gives the multiplier, `model.symmetryPlanes` the planes, and a note says what they did. On the two-window transformer the half on either side and the quarter give the whole drawing's L and M within 0.02 %. - The 2D AC solve (`mode: "harmonic"`) takes the same planes: Z, R, L and every loss are multiplied by 2 per plane. A conductor may be cut by a `fluxNormal` plane (its eddy current is even about it), but not by a `fluxTangential` one: its eddy current is odd about that plane, so draw it whole. `adaptive` refines the drawn part and cuts each refined mesh the same way, and its passes report the whole device. `dcBias` solves the DC state on the drawn part, whose field has the same symmetry as the AC field. - Only the 2D Field Solve of a sketch takes planes. A design, a 3D solve and an open boundary refuse them. ### Periodic sectors: solve one pole or one coil of a ring A device that repeats n times around a centre (the poles of a winding, n identical coils on a ring) can be drawn as one sector and solved as the whole: `magnetics.fieldSolve {"sketch": …, "periodicSector": {"angleDeg": 90, "kind": "antiPeriodic"}}`. - The sector lies between two straight outer edges on the rays from `centreMm` (default the origin) at `startDeg` (default 0) and at `startDeg + angleDeg`. `angleDeg` must be 360/n, for 2 to 360 sectors. The rest of the outer edge, usually an arc, is held at A = 0. - `periodic`: every sector's currents are alike, so A on one side equals A at the same radius on the other. - `antiPeriodic`: alternate sectors' currents are reversed, as a winding's poles are, so A on one side is minus A on the other. A centre that the sector reaches is then held at A = 0. - The two sides are meshed with nodes at the same radii: where one side has a node the other lacks, a point is added to the drawing and the sector is meshed again. - L and M are n times the drawn sector's. The turns stay the drawn ones: the winding is the drawn coil once in each sector, in series. The reply's `model.symmetry` gives n and `model.periodicSector` the sector. - Checked against the exact solution: four annular coils (20 to 30 mm, 40° wide) in a grounded 50 mm cylinder, solved from one 90° sector with 1 mm elements, against the cylindrical-harmonic L: - alternating coils (anti-periodic): 0.10 % off, and within 1.3e-5 of the whole ring drawn and meshed alike; - like coils (periodic): 0.03 % off; - the same sector with its sides held at A = 0 is 10 % and 59 % off. - Only the 2D magnetostatic Field Solve of a sketch takes a sector, with linear triangles. `mode: "harmonic"`, `symmetryPlanes`, `elementOrder: 2`, `laminations`, a design and a 3D solve refuse it. ### Quadratic elements `magnetics.fieldSolve {sketch or design, elementOrder: 2}` solves the 2D magnetostatic model on quadratic (six-node) triangles: the same mesh with a node added at the middle of every edge. For a smooth field the inductance error falls as h⁴ instead of h², so a coarse mesh gives what the linear elements need a much finer one for. On the two-window transformer with 4 mm elements, L is 0.03 % from its converged value, where the linear elements are 0.4 % off. The solve has about four times the unknowns. `model.elementOrder` says which was used. The field view shows the potential at the triangle corners. Magnets, `dimension: 3` and `mode: "harmonic"` refuse it. ### Laminated cores `magnetics.fieldSolve {sketch or design, laminations: {"core": {"stackingFactor": 0.95, "normal": "y"}}}` solves a magnetic region as a stack of steel sheets with non-magnetic coats, drawn as one region. The region's `muR` is the sheet's; `stackingFactor` is the sheets' share of the stack (above 0, at most 1); `normal` is the drawing's axis the sheets are normal to (`x` or `y`, which are r and z in an axisymmetric drawing). Along the sheets the stack has μ = F·μr + (1 − F), across them μ = 1/(F/μr + 1 − F): with F = 0.95 and μr 10,000 that is about 9,500 along and only 20 across, so the direction matters as much as the material. The homogenized region is the limit of the stack as its sheets thin: against a stack drawn sheet by sheet, the field along the sheets gives the same energy for any sheet count, and the field across them comes within 0.4 % at eight sheets. `model.laminations` lists each stack with its two permeabilities, and a field view gets `muAxes` for its region. It is linear, in the magnetostatic solve and in the 2D AC solve (`mode: "harmonic"`), where each triangle of the stack takes its permeability along and across the sheets; at low frequency the AC inductance is the magnetostatic one to seven digits. The sheets' own eddy currents are in the 3D AC solve (`conductivityStack`), so in the 2D AC solve a stack takes no `conductivity` or `muRLoss`, and `laminations` takes no `dcBias` or `adaptive`. `dimension: 3` and `elementOrder: 2` refuse it. `magnetics.fieldFluxMap` takes the same `laminations` on a linear core: every Newton solve of the sweep keeps the stack at its two permeabilities, so λ(i) is a straight line whose slope is `magnetics.fieldSolve`'s L for the same stack. `magnetics.fieldTransient` (2D) takes it too: every time step keeps the stack at its two permeabilities, so with no conductor each step's λ/i is `magnetics.fieldSolve`'s L. When the core sits on a B-H curve (a design whose material has one, or a transient sketch given `material`), both commands put each sheet on that curve and the stack on its own curve along the sheets (H shared by sheet and coat) and across them (B shared), so the stack saturates; on the curve's first segment it is the linear stack at the curve's initial μr, and `model.laminations` names the curve (`bhCurve`). A stack takes no `conductivity` there (its sheets' eddy currents need the 3D transient's `conductivityStack`) and no `jilesAtherton` loop. ## More analyses Each of these takes a `design` or a `sketch`, as Field Solve does, and changes nothing in the circuit unless it says so. - **Line profile** (`field.lineProfile`): B and H at evenly spaced points along a line, the flux across it, and ∫H·dl along a path; a closed path gives the ampere-turns it encloses (Ampère's law), a good check of a model. `csvPath` writes the points. - **Region table** (`field.regionTable`): per region, its area, current, stored energy and co-energy, Lorentz force, peak and 99th-percentile |B|, and whether the peak sits on a corner of the drawing (a singularity that grows as the mesh is refined, not a real hot spot). - **Field calculator** (`field.calculator`): your own quantities, written as expressions of the solved field (`Bx`, `By`, `B`, `Hx`, `Hy`, `H`, `A`, `J`, `muR`, `mu0` and the position; `r`, `z`, `Br`, `Bz`, `Hr`, `Hz` on an axisymmetric sketch; the normal `nx`, `ny` and tangent `tx`, `ty` on a path), up to 16 in one solve. Each is integrated over the regions you name (a volume integral, with the volume and the mean), over the surface a polyline sweeps through the depth or round the axis (`Bx*nx+By*ny` is the flux through it), or read at a point. The integrals are exact for the solver's element field, so `B*H/2` over every region is the region table's energy. With `dimension: 3` it works on the 3D extrusion of a sketch or an E-type design (meshed whole): volume integrals and point values `[x, y, z]` of `Bx`, `By`, `Bz`, `B`, `Hx`, `Hy`, `Hz`, `H`, `muR`, `mu0` and `x`, `y`, `z`, and surface integrals over a flat parallelogram `surface {corner, u, v}` (mm) with its unit normal `nx`, `ny`, `nz` (`Bx*nx+By*ny+Bz*nz` is the flux through it; `areaMm2` is the part inside the mesh). It takes `magnets` too: in a magnet H is on the recoil line, (B − Br)/(μ0 μrec), so `mu0*muR*H^2/2` over every region is the energy, and the reply carries each magnet's demagnetization check; a drawing of magnets alone needs no coil. A ring design is revolved a whole turn about the z axis (`stepDeg` sets the step), each winding a current sheet on the core: the flux through the core is the surface `y = 0, x > 0` across its section, and `H*sqrt(x^2+y^2)` over the core is N·I/(2π). A ring takes no `magnets` or `layers`. - **Force and torque** (`field.force`): the force and torque on a body by the weighted Maxwell stress tensor, checked by virtual work (`virtualWork: true`, six more solves) and, for a coil in air, by the Lorentz force. `nonlinear: true` solves the core on its B-H curve. An axisymmetric sketch gives the axial force. Permanent magnets (`magnets`, direction `[r, z]`) work there too, in the body or outside it, with or without `nonlinear`; `lorentzN` is null on a magnet body, and a body touching a magnet of recoil μr 1, or a path through it, is refused by name. - **A body that slides** (`field.slide`): the same model and `regions` as `field.force`, the body on a spring (`massKg`, `springNPerM`, `dampingNsPerM`, `loadN`) moved along `axis` (planar: `"x"`, `"y"` or `[x, y]`; axisymmetric: `"z"`) by the field's own force, one magnetostatic solve per time step (`timeStepS`, `steps`). The body moves rigidly and the air round it stretches, so the travel must stay inside the air drawn round it; a move past it stops the run at that position. `smallSwing` gives the force where the body is drawn, the field's stiffness −dF/dx there and the small-swing period about it; pick `timeStepS` about a fortieth of it and quote `energy.errorPct`. Eddy currents are not modelled. - **Flux map** (`magnetics.fieldFluxMap`): sweeps one winding's current up to `maxCurrent` with the core on its B-H curve and records the flux linkage of every winding: the saturating inductor's λ(i) table. `apply: true` writes it into the part (`psiCurve` for an inductor, `coupledCurve` for a coupled inductor or transformer), and both circuit solvers then follow the table's incremental inductance, so the simulation saturates where the core does. With a magnet bias on a two-winding sweep the `coupledCurve` is two-sided: its rows run from a negative current through the bias row at 0 A to a positive one, are read at the signed magnetising current, and hold their end rows beyond either end. `apply` writes it into a coupled inductor or a transformer, and `field.tableLookup` reads it at the signed current. A magnet can also sit in a design's gap: on a gapped E-type design, `magnets[].region: "centre-leg gap"` draws the centre leg's gap as its own region and fills it with the magnet (a ring or a gapless design is refused by name). Permanent magnets (`magnets`) take a built-in grade by name (`Arnold N35`, `Arnold N42`, `Arnold N42H` or `Arnold N42UH`, sintered NdFeB, each read from its Arnold Magnetic Technologies data sheet) or your grade's data-sheet values, cited. In `field.lineProfile`, `field.regionTable` and `magnetics.fieldFluxMap` a magnet can also take its grade's normal demagnetization curve at the temperature, `demagCurve: [[H, B], …]` from the same sheet (from `[0, Br]` through the knee). It is then solved on that curve by Newton's method: a reverse field along the magnetization follows the curve, a forward or crosswise one the recoil line, and B, H, the energies and the knee check read the curve. The curve is reversible, so a loss of magnetization past the knee is not kept after the field goes away. In the flux map every swept current is solved on the curve, so a current that drives the magnet past its knee shows in λ(i) and in the incremental inductance. `magnetics.fieldTorque` takes the same curve for its machine's magnets as `magnetDemagCurve` (its B_r within 1 % of `magnetBrT`): each rotor angle is then solved on the curve, so a load current or a temperature that drives the magnets past the knee shows as lower flux linkage, back-EMF and torque. Each angle also reports the largest reverse field in the magnets and the share of their area past the curve's knee (where `J = B − μ0H` falls to 0.9 Br), with a "demagnetization" warning naming the worst angle when any angle passes it. With `magnetIrreversible: true` the loss is kept: the angles are solved in the order swept, and each magnet cell of the rotor recoils at every later angle from the lowest point it has reached on the curve, along a line of slope μ0·`magnetMuR`, its remanence lowered to Br' = B − μ0·`magnetMuR`·H there (the recoil-line model: Furlani 2001 §2.6; Ruoho, Dlala and Arkkio, IEEE Trans. Magn. 43(11), 2007). Each point then gives the magnets' mean and largest remanence lost (`magnetBrLossPct`, `magnetMaxBrLossPct`), and `demagnetization` adds `finalBrLossPct`, `maxBrLossPct` and `areaWithLossPct` after the last angle. `eccentricity: {kind, offsetMm, angleDeg}` puts the rotor's axis off the stator's: `static` keeps the offset while the rotor turns about its own axis, `dynamic` turns it with the rotor. The whole cross-section is solved, the air-gap band takes up the offset (up to about 30 % of the gap; the error names the mesh's limit), and each angle gives the unbalanced magnetic pull on the rotor (`pullN`), by the Maxwell stress tensor over the stator's ring of the gap, with the torque taken about the rotor's axis. Shaft and bearings are not modelled. - **Transient** (`magnetics.fieldTransient`): eddy currents in conducting regions over time, with windings driven by a current or a voltage step, sine or table, and solid conductors whose skin and proximity effect follow. A table with `stepMean: true` drives each step with the table's mean over it, so a switched (PWM) voltage keeps its volt-seconds instead of moving each edge to the next step end. `skinLayers` lines a thick conductor's surface with mesh layers, as in the 2D AC solve below, two skin depths deep at `skinFrequencyHz` (by default the highest frequency of a sine drive). Every row gives each winding's apparent inductance λ/i and its incremental inductance Δλ/Δi over the time step, which falls below λ/i once a core passes its knee. For a periodic drive (sines of one frequency, or `periodS`, such as a PWM table's switching period) `steadyState` compares each period with the one before: `reached` says the last one repeats it within `steadyTolerance` (1e-3 by default), and `lastPeriod` gives the eddy and copper loss and rms currents averaged over it, the numbers a circuit simulation takes. A core on its catalogue B-H curve also gets `lastPeriod.coreLoss`: the iGSE of its material's Steinmetz data on each core element's own B(t) over the last period, eddy currents and saturation included. A core kept linear at its muR (a material with no B-H curve, or a design with `linear` or `muR`) gets it too, without saturation (null, with a note, when the period is not a whole number of steps, the run is not longer than one period, the material has no Steinmetz data, or a sketch names no material). When `reached` is false, run more periods; an L/R transient's residual shrinks by e^(−T/τ) each period. Permanent magnets (`magnets`, as `field.regionTable` takes them) step on their recoil line or, with `demagCurve`, by Newton's method on their demagnetization curve, so a winding current driven against the magnetization shows the flux the magnet loses past the knee; `magnets` in the reply gives the knee check on the last step's field. A magnet takes no core curve, Jiles–Atherton loop or lamination, and the curve is reversible: no irreversible loss is kept. - **Transient in 3D** (`magnetics.fieldTransient` with `dimension: 3`, Preview): the same time steps on the 3D model the 3D eddy-current solve below builds (a ring-core design, the wound E core with `endTurns: true`, or imported bodies), with eddy currents in the bodies given a conductivity (and laminated stacks). Each winding is stranded and driven by its current (a step, sine or table), so its voltage is dλ/dt; materials are linear. Every row gives each winding's flux linkage and voltage, each conductor's loss at that instant and the field energy, for the whole model. A conductor in an extrusion is refused for now, since its ends cannot yet be held at zero net current: solve that section with the 2D transient. - **Eddy currents in 3D** (`magnetics.fieldSolve` with `dimension: 3`, `mode: "harmonic"`, Preview): the loss in a shield, clamp or plate at one frequency, and each winding's impedance, with the bodies' conductivities given. With `field: true` it also returns the loss density and the current density of every tetrahedron, so you can see where in a body the loss sits. - **AC impedance in 2D** (`magnetics.fieldSolve` with `mode: "harmonic"`, no `dimension`): the same eddy-current solve on the planar drawing, giving the full impedance matrix of every drawn circuit with the mutual resistance. A ferrite or powder core's own loss comes from its complex permeability μ′ − jμ″: give the data sheet's μ″ at the frequency with `muRLoss` (μ′ is the region's `muR`), and its magnetic loss is in the resistance and the loss. A conductor many skin depths thick needs no fine mesh inside: `skinLayers` (for example `{"plate": 3}`) puts that many mesh layers under its surface, together two skin depths deep at the frequency, each twice as thick as the one outside it. Five skin depths thick or more (a shield, a tank wall), `surfaceImpedance` (for example `["shield"]`) leaves the conductor's inside out of the solve and gives its boundary the surface impedance of a good conductor, so its mesh can be as coarse as its shape; its loss is the power flowing into its surface. A `surfaceImpedanceThin` warning says when a conductor is too thin for it. With `adaptive`, the mesh is refined beside such a conductor, where the field at its surface sets its loss. A conducting layer much thinner than the skin depth (a foil or plated screen, a thin can wall) need not be meshed at all: draw it as the line between two regions and give `sheets` (for example `[{"between": ["inside", "outside"], "conductivity": 5.8e7, "thicknessMm": 0.01}]`). The sheet carries the eddy current that screens the field, with no net current, and its loss is listed under each winding's `sheets`. A `sheetThick` warning says when a sheet is a skin depth thick or more and should be drawn as a conducting region. For a converter current that is not a sine, give `current` instead of `frequency`: one period as points, or a branch current of the last run (`signal` with `periodS`). The drawing is solved at each of its harmonics and the eddy and core loss summed over them, harmonic by harmonic, with each region's share. For a choke that carries DC, give `dcBias` (for example `{"P": 3}`, the DC current of each circuit; a sketch also names its core `material`): the drawing is first solved at that DC current with the core on its B-H curve, and the AC solve then uses the core's incremental permeability there. The inductance is then the ripple inductance on the bias, which falls as the core nears saturation, and the losses are the ripple's. For the forces on the windings (a transformer's short-circuit forces, a busbar's pull), give `forceCurrents` with each circuit's peak current (for example `{"P": 1000, "S": -2000}`, or `{"peakA": 2000, "phaseDeg": 180}`): `forces` gives the Lorentz force on each winding side and each conductor, as its average and its part at twice the frequency, with the peak over the cycle. A core's own magnetic force is not in it; `field.force` gives that one. Paralleled layers and split windings drawn as separate circuits are joined into the part's ports with `connections`, as for the DC inductance; at frequency a parallel port's current divides by the layers' impedances, their eddy loss included, and `connection` gives each layer's share in magnitude and phase. Instead of refining by hand, `adaptive: true` refines the mesh pass after pass where the field's error is largest, the conductors given their own share, until each winding's resistance and reactance settle; `adaptive.stopOn: "resistance"` stops on the loss alone, and `minConvergedPasses: 2` waits for two settled passes in a row. With `current` the loop refines at the highest harmonic and solves the others on its last mesh; not with `dcBias`. - **DC conduction** (`field.dcConduction`, Preview): the resistance of a copper pour, busbar or trace between its pads. Label each conductor with its `conductivity` (S/m, from the material's data sheet) and each pad or via with an `electrode` name; a planar drawing is a sheet `depthMm` thick seen from above (1 oz copper is 0.035), an axisymmetric one a revolved part. It gives the conductance matrix and the resistance between every pair of electrodes (the others floating), and with `voltagesV` each electrode's current, the loss per region and where the current density peaks. DC only: no skin or proximity effect. - **Winding capacitance** (`field.windingCapacitance`): an electrostatic solve of a drawing of the turns gives the capacitance matrix, each winding's self-capacitance and the interwinding capacitance. With `component`, the capacitors are proposed for the part on the schematic (or added with `apply`), so the circuit sees the winding's self-resonance. - **Capacitance in 3D** (`field.electrostatic3d`, Preview): the solids of an STL or STEP file, each a conductor or a dielectric with its relative permittivity, in a box of air whose sides are the ground. It gives the capacitance matrix of the conductors and, at the voltages you give, the largest electric field in each dielectric and where it is. Give each material's dielectric strength from its data sheet (`strengthKVPerMm`) and each dielectric gets its margin, strength over peak field, and the hot spot is the one with the least margin; below 1 the insulation breaks down there. The design report shows the latest one: the matrix, the capacitance between each pair of conductors and from each to the ground (the values a circuit model takes), and the field stress with the hot spot. Name the conductors that are a transformer's windings (`windings`) and the part (`component`), and the interwinding capacitance is proposed as a capacitor between its winding starts (or added with `apply`), so the EMI analysis sees the common-mode path. - **Winding AC loss** (`field.windingAc`): each winding's AC resistance, its proximity share and the leakage inductance against frequency for interleaved layers of foil, planar copper, round wire, litz or traces, with Dowell's result beside each number. `dimension: 3` solves a foil, round-wire or litz window extruded in 3D and puts the planar result beside each row. With a `design`, `endTurns: true` and `dimension: 3` it winds the design's E core with its end turns in 3D, round wire, litz or foil (one foil per turn, Dowell's foil model: exact in the window, a lower estimate in the end turns), and gives each winding's end-turn share of the loss. For foil or planar layers, `secondaryThicknessMm` gives the secondary its own copper thickness, and `parallel` joins layers of one winding at their terminals (e.g. `[[1, 5]]`, the outer primaries): the solve splits the current between them and each row gives every layer's share, so circulating current in paralleled layers shows as extra loss (Ouyang, Thomsen and Andersen, IPEC 2010). `coreDepthMm`, the core's depth along its legs, adds the end turns of foil or planar layers, in series or in parallel groups: the core covers twice that depth of each turn, and the rest of the mean turn is solved in air by PEEC. Each row then gives the end turns alone and the whole turn (`endTurns.total`), whose Rac and leakage sit below the window's over the whole mean turn, since outside the core the field spreads round the copper's edges. Parallel layers split their group's current by the whole turn's impedances, the window's over the core's share and the end turns', and carry that split in both (`endTurns.layers`). - **Thermal** (`field.thermalSolve`): the steady temperature of the core and windings from their losses, with conduction inside and convection from the outer surfaces. The losses can be given, come from the AC winding solve (`ac`), or come from the core loss (`core`), iterated with the temperature until they settle. `lumped` reduces the result to a thermal network for fast sweeps. Give the heat-transfer coefficient and every conductivity except copper, aluminium, air, ferrite, Kapton HN film, Nomex 410 paper and MG 832TC potting from a data sheet or a measurement: none is built in (no core grade is, either). With `dimension: 3` it solves the 3D model on the field solve's tetrahedra; with `field: true` as well, the 3D window opens on the temperature map (each element the mean of its corners' temperatures), with the hot spot and each region's loss, mean and highest temperature above it, and the same section plane, see-through bodies and smooth shading as a magnetic field. - **Sweep and optimise** (`field.sweep`): runs Field Solve, Core Loss, the AC winding solve, Thermal or PEEC over up to four parameters (the gap, the turns, the core, the element size, a frequency), each a list of values or a range: linear or log, by a step with both ends included, or so many points per decade or octave. The grid is every combination, or with `combine: "synchronised"` the values taken pairwise; at most 256 points. One parameter may go to several places, each scaled (`paths` with `times` and `plus`), so a laminated busbar's spacing moves every point of its upper layer. `design` draws the points from the ranges instead of a grid: a Latin hypercube (`latinHypercube`, `runs` and `seed`, one run in each of `runs` equal strata of every range) or a two-level fractional factorial (`fractionalFactorial`, at the range ends, the standard generators or your own), the plans of `analysis.doe`. `surface` fits a quadratic response surface to a grid's or a design's rows (in coded units, as `analysis.doe` does), finds its exact least or greatest value on the ranges, and runs the command once more there to confirm it, with the difference between the surface and that run. With `surface.goals` it weighs several outputs at once (Derringer and Suich's desirability): each goal is a column with `min`, `max` or `target` and the range it is acceptable over (`low`, `high`), each column gets its own surface, and the point where the weighted geometric mean D of the goals' desirabilities is greatest is run to confirm it; D is 0 when no point meets every range. `optimize` searches the parameters for a goal instead: a target value (such as the inductance), the least or the most of an output, by golden-section search for one parameter and Nelder–Mead for more. Each row is that single solve's result. The Field Sweep window shows the best point, a plot of the output you pick against the first numeric parameter (one line for each value of the others) and the table of every point; a point that failed keeps its reason in the table. ## PCB and busbar parasitics (PEEC) `field.peec` (Preview) gives the resistance and inductance matrix `R(f) + jωL(f)` between ports of straight conductors in air: tracks, busbars, wires and ground planes. It is the partial-element method (Ruehli 1972; Kamon, Tsuk and White 1994): each conductor is split into filaments across its section, finer near the surface than the skin depth at the highest frequency you ask for; the self and mutual partial inductances of parallel rectangular filaments come from Hoer and Love's exact equations (NBS J. Res. 69C, 1965), those of filaments at an angle from Neumann's integral, round sections are coaxial shells, and every mutual term is kept. It changes nothing in the circuit. A model of up to 2000 filaments is solved by a dense LU; past that, up to 5000, by GMRES (Saad and Schultz 1986) with a preconditioner made of each segment's own filaments, to a relative residual of 1e-11, so a fine plane under a routed loop still solves. Filling the partial inductances grows with the square of the filaments, so a 5000-filament model takes about a minute. You describe the copper in one of three ways, and may mix them: - **Segments** between named **nodes** (`nodes`, `segments`): each a straight piece with a rectangular section (`width`, `height`, `widthAxis`) or a round one (`radius`), in any direction, as FastHenry's input file describes them. - **Busbars** (`busbars`): a centre-line `path` of straight legs with one `width` and `thickness`; the path's points are nodes named `.1`, `.2`, … A laminated busbar is one busbar per layer. - **Planes** (`planes`): a rectangle given by three corners, meshed into a grid of segments (`seg1` × `seg2`), with `holes` (point, rectangle or circle) cut out as FastHenry cuts them, and `nodes` that name the grid points you connect to. `shorts` join nodes with no impedance (a track's end tied to the plane below it), and each port names the node the current goes in at (`plus`) and the one it leaves at (`minus`). Copper is annealed copper at `temperatureC` (20 °C by default, IEC 60028); give `resistivity` for another metal. Frequency 0 gives the DC limit. A 100 mm copper bar, 10 mm wide and 2 mm thick, at DC and at 100 kHz: ```json {"busbars": [{"name": "bar", "path": [[0, 0, 0], [0.1, 0, 0]], "width": 0.01, "thickness": 0.002}], "ports": [{"name": "P1", "plus": "bar.1", "minus": "bar.2"}], "frequencies": [0, 100000]} ``` At DC it gives 0.0862 mΩ, which is ρl/(wt), and 66.91 nH, Hoer and Love's self partial inductance of the bar. At 100 kHz the skin depth (0.21 mm) is a tenth of the thickness, so the current crowds to the surface: 0.4607 mΩ and 63.44 nH. This is a partial inductance: a loop's inductance is that of the whole path, so put the return conductor in the same model and the port across the loop's opening. To know the filaments are fine enough, add `converge: {targetPercent, maxPasses}` (1 % and 4 passes by default): the model is solved as given, then again with every split twice as fine (`nw`, `nh` and `shells` of each segment and busbar, `seg1`, `seg2` and `nh` of each plane), until R and L change by less than the target between two passes. The reply is the finest pass, and `convergence` lists each pass's filaments, unknowns, solver (`denseLu` or `gmres`) and change; `converged: false` with `stop` `maxPasses` or `filamentLimit` (the next pass would pass 5000 filaments) means the answer is no better than the last change. In the result window, **Filament convergence** under the ports gives the verdict with a tick or a cross: the last pass's change against the target, and why the study stopped when it did not converge. A second table has one row per pass (its split refinement, filaments, change in R and in L, unknowns and solver), and a plot shows the two changes against the filament count on a log axis, so you can see whether they still fall. With `meshStatistics: true` the result window also shows the solve's profile: **Solver** (Dense LU, or Iterative (GMRES) past the dense solver's size) and **Unknowns** under the ports, and a table with one row per drawn segment, busbar and ground plane giving its segments and filaments and the least and most segment length, filament side and filament cross-section (in mm²), with a plane's recovered area and its repair class. Look there for the object whose filaments are much thicker than the skin depth, or whose segments are much longer than its neighbours': refine it first. Wall time is not shown, so the same model always gives the same result. For an RF tool or a network-analyser comparison, add `sParameters: {z0Ohm}` (50 Ω by default, the reference a Touchstone file takes when it names none). The reply's `sParameters` gives, at each frequency, the scattering matrix `S = (Z + Z0·U)⁻¹(Z − Z0·U)` of the port impedance matrix `Z = R + jωL` (Pozar, *Microwave Engineering*, 4th ed., §4.3): its real and imaginary parts and `|S|` in dB, row k and column l being the wave out of port k for a wave into port l. With `export: ["touchstone"]` the file then holds S (`# Hz S RI R 50`) instead of Z. Each port end is a terminal. By default it is a Constant Voltage terminal: every filament of the conductor joins at one potential there, so the current may crowd to the surface. `uniformCurrent: "all"` makes every port end a Uniform Current terminal, and a list of node names makes only those ends one: the port's current goes into each filament in proportion to its cross-section, a uniform density that approximates a point feed, and the terminal's voltage is the filament ends' potentials averaged the same way, which keeps the matrix reciprocal. A uniform terminal must be the end of exactly one segment and joined by no short. Its self-inductance usually comes out higher than a Constant Voltage terminal's; on a lone bar, with the current held uniform, R stays at its DC value. The reply's `terminals` lists every port end with its `excitation`. A plane much wider than it is thick (a ground plane, a pour, a busbar sheet) can be a thin sheet: `sheet: true` on the plane gives it one filament across its thickness, and gives each of its segments the internal impedance of a slab with the same field on both faces, ρl/(wt)·x coth x with x = (1 + j)t/(2δ) (Ramo, Whinnery and Van Duzer, *Fields and Waves in Communication Electronics*). That is ρl/(wt) at DC and half the surface impedance once the skin depth δ is small against the thickness t, so the skin effect through the thickness costs no filaments. The partial inductance keeps the thickness. A 30 × 10 mm plane of 35 µm copper at 228 MHz (δ = t/8) comes within 3.1 % of the same plane split into 21 even filaments, whose own error at that depth is 2 %, with a twenty-first of the filaments. A sheet suits a plane whose current runs on both faces. Over a close return the current runs on the facing side only, where a sheet gives about half the loss: there give the plane `sheet: "oneSided"` (`"twoSided"` is the same as `true`). Each segment then gets the internal impedance of a slab driven from one face, ρl/(wt)·y coth y with y = (1 + j)t/δ (Dowell's factor for one layer): ρl/(wt) at DC and the full surface impedance once δ is small against t. Two such planes 10 µm apart come within 0.05 % of the parallel-plate line's resistance and about 2 % from the same planes split into 21 filaments through their thickness, where a two-sided sheet gives half; the gap is the field fringing round the edges, 5 % at a gap of a hundredth of the width, and the sheets' inductance is up to 2 % below the split's. A one-sided sheet far from its return is wrong the other way. `nh` above 1 and a perfect conductor are refused, and the reply's `planes[].sheet` and `sheetSides` say which planes are sheets and of which kind. A ferrite plate under a coil or a track, or a core face beside a busbar, is `magneticHalfSpace: {axis, at, muR}`: a non-conducting material of relative permeability `muR` (above 0, at most 1e6) filling everything beyond the plane `axis = at` from the conductors, which must all lie on one side of it (they may touch it). Its field where the conductors are is that of their mirror images with strength k = (μr − 1)/(μr + 1), the image of a current along the interface running the same way and of one across it the other way (Jackson, *Classical Electrodynamics*, 3rd ed., Problem 5.17), so each partial inductance gains k times its mutual with the other conductor's image. A two-wire line 10 mm apart, 5 mm over ferrite of μr 1000, gains 0.138 µH/m, within 1e-5 of the 2D image solution; a 2 mm loop 50 mm over it gains the dipole image to 4e-4, twice as much lying flat as standing up. The material is taken as infinite and non-conducting: a plate thick and wide against the conductors' distance from it is close to that, and a steel part only while its skin depth is large against its thickness. It changes no capacitance. The reply's `magneticHalfSpace` gives `imageCoefficient` k; `muR` 1 is free space. A plate of finite thickness, a ferrite sheet under a wireless-charging coil or a thin core face, adds `thickness` (m): `magneticHalfSpace: {axis, at, muR, thickness}` fills only the slab from the interface to `thickness` beyond it, with free space past it. Each plane-wave part of the field reflects from the plate with k(1 − e^(−2κt))/(1 − k² e^(−2κt)) (tangential H and normal B continuous at both faces, Jackson §5.9), which expands into the plate's image series: the mirror image of strength k, then images mirrored n·thickness farther of strength −(1 − k²)k^(2n−1). Their strengths sum to zero, so a thin plate adds little and a thick one is the half-space. The series stops when the images left out are bounded below 1e-9 of the first image's scale, or at 512 images; the reply gives `imageTerms` and `seriesBound` (0 unless the cap stopped it, which a thin plate of very high μr can need, and then it is close to the half-space anyway). A two-wire line 10 mm apart, 5 mm over a 1 mm plate of μr 20, gains its plate's share within 1e-6 of the plane-wave integral, and a 2 mm loop 50 mm over a 2 mm plate of μr 100 within 5e-4 of the dipole's. `meshStatistics: true` adds the solve's profile and mesh statistics. `solver` names how the network was solved (`denseLu` up to 2000 filaments, `gmres` past them), `unknowns` counts its unknowns (one current per filament and contact, one potential per node that is not a reference), and `objects` has one row per segment, busbar and plane, in the order given: its segments and filaments, and the least and most of its segment lengths (`lengthM`), its filament sides across the section (`filamentSideM`: a rectangle's smaller or larger side, a shell's radial thickness) and its filament cross-sections (`filamentAreaM2`). Refine first where a filament side is far above the skin depth at the highest frequency, or where one object's segments are much longer than its neighbours'. A uniform plane's row also has `area`: its true area (`geometricM2`: the rectangle less its holes, inside its outline) and its mesh area (`meshM2`: the cell of each grid node left with a segment, clipped to the rectangle), `recoveredAreaPercent` (mesh over true) and `mismatchPercent`, and `repair`, the class of the difference: `strict` (none), `minorRepair` (5 % or less), `majorRepair` (above 5 %) or `meshLeak` (above 10 %, or no mesh left). The last two also add a warning with that code. A hole or outline edge that falls between the grid's nodes moves the copper solved away from the copper drawn; refine the plane (`seg1`, `seg2`) until it is a minor repair. A nonuniform plane's row has the same `area`: its true area is the rectangle less its hole cells, and its mesh area is the copper its segments cover (length times width, along x and along y; the direction further from the true area is given). `meshOperations: [{kind: "length", objects?, maxLengthM, maxAdded?}]` seeds the uniform planes by length, as a 3D extractor's length-based mesh operation does. Each plane it names (every uniform plane when `objects` is left out) gets the fewest `seg1` and `seg2` that keep every segment along that edge at most `maxLengthM` long; the counts the plane gives are never lowered. `maxAdded` caps the plane segments the operation may add (counted before holes): both counts then move together toward the target only as far as the cap allows. Where several operations name a plane, the finer count wins along each edge. The reply's `meshOperations.planes` lists each plane's `given` and `used` counts, its `addedSegments` and whether a cap stopped it short (`capped`); a convergence study starts from the used counts. Straight segments and busbar legs are not cut along their length (with every mutual kept, the pieces add up to the same R and L), and a nonuniform plane takes its own `refinements`, so naming either is refused. `meshOperations: [{kind: "resolution", objects?, lengthM}]` sets a model resolution, as a 3D extractor's model-resolution operation does: each uniform plane it names drops the holes whose drawn size is under `lengthM` (a circle's diameter, a rectangle's smaller side along the plane's edges, and 0 for a point hole, which has no drawn size), and keeps its copper there. Where several resolution operations name a plane, the smallest length wins. The reply's `meshOperations.droppedHoles` lists each dropped hole: its `plane`, its place in the plane's `holes` (from 1), its `kind`, its `sizeM` and the `lengthM` that dropped it. A segment's or busbar's small features are `modelCheck`'s (`smallEdgeM`, `sliverM`), and a nonuniform plane has no holes of its own, so naming either is refused. `setups: [{name?, duplicate?, enabled?, frequency?, unit?, cg?, dc?, ac?}]` gives named solution setups in place of `frequencies`, as a 3D extractor's solution setups do. Each setup has a name, an enabled flag, a solution frequency in Hz, kHz, MHz or GHz, and a switch for each matrix family: C/G, DC (`true` for R and L, `"r"` for R only, or `false`) and AC R/L. All three are on by default. A setup given no name, or one that copies an earlier setup with `duplicate` (its other keys override the copy), is named Setup followed by the smallest free number, so duplicating Setup1 gives Setup2. AC R/L needs a frequency, since no default is documented. The model is solved once at 0 Hz and at each AC frequency the enabled setups need, and the reply's `setups` gives each setup its own `dc` and `ac` matrices (the same as the `frequencies` row at that frequency; R only leaves out L) and `cg`: `solved` when the model has `capacitance`, `notModelled` otherwise, with a note. A disabled setup is listed and solves nothing, and only the families a setup turns on appear in its reply. `capacitance` adds the Maxwell capacitance matrix between the nets of the drawn conductors, as a 3D extractor's C solve does: a switch node to a heat sink, DC+ to DC− across a laminated busbar. Every conductor surface is cut into rectangular panels of uniform charge, graded towards the edges, and the potential is matched at each panel's centre (the moment method of Ruehli and Brennan, 1973); the zero of potential is at infinity, so no ground is assumed. Give `capacitance: true` to make each connected piece of the model one net (named after its first object), or `capacitance: {nets: [{name, objects}], epsR?, maxPanelM?, panelsPerEdge?}` to name them: objects in no net, such as the strap that closes a laminated pair's loop, are left out and listed in `leftOut`. `epsR` is the dielectric round the conductors (1 by default); a film or a laminate of its own εr goes in `dielectrics` (below). The reply's `capacitance.maxwellF` is the matrix (net i's charge with net j at 1 V and the rest at 0 V), `toInfinityF` each row's sum, and `pairs` each pair's mutual capacitance and the capacitance between the two with every other net floating. Rectangular segments, busbars and planes (their holes cut) have panels. A round section (and a via's tube) is a prism of `roundFacets` flat facets (default 16, 4 to 64), its corners placed so the polygon has the circle's own capacity, so a long wire comes out as a round one does: two round wires of 1 mm radius 5 mm apart give the two-wire line's π ε0 / acosh(d / 2a) per length within 0.3 %. A nonuniform plane is its conductor cells, top and bottom, with walls on its outline and round its hole cells: a 1 m plate 1 mm thick, its cells refined to 1/64 m along its edges, comes within +0.15 % of the unit square's 0.3667874 · 4π ε0 m (Read 1997). A 1 m cube comes within 0.05 % of the unit cube's published 0.6606785 · 4π ε0 m (Read 1997). The capacitance stands beside the port matrices; it does not enter them, so `noCapacitance` still holds for R and L. Each named net may take a `type`. A `"signal"` net, the default, is a row of the matrix. A `"ground"` net, such as a heat sink or a baseplate tied to protective earth, is held at 0 V in the solve and then leaves the matrix (its row and column deleted). A `"floating"` net, such as an isolated heat sink, carries no net charge and leaves the matrix by the Schur complement, which lowers the other nets' own capacitance and raises their coupling. At least one net must stay a signal net. With `nets`, `unnetted: "ground"` puts every conductor named in no net into the field at 0 V, as one ground net called `(unnetted)`, instead of leaving it out (`"omit"`, the default); a conductor joined to a net's conductor cannot be grounded apart and is refused. `priority: ["ground", "signal", "floating"]`, highest first, settles an object named in nets of two types, and `resolved` in the reply says which net kept it. The reply's `groundedNets`, `floatingNets` and `groundedObjects` say what left the matrix. A unit cube with a grounded or a floating unit cube 5 m away matches the potential-coefficient limit (Jackson 1999, §1.13) within 0.2 %. A lossy dielectric gives a conductance matrix G beside C. Add `lossTangent` (tanδ) and, for a leaky insulator, `conductivitySPerM` (σ) to `capacitance`, and `capacitance.frequencies` lists, at every solved frequency, the permittivity `epsR` (ε′) and `epsRImag` (ε″), the loss tangent, the Maxwell matrices `maxwellF` and `conductanceS`, their row sums and each pair's `betweenF` and `betweenS`. In one dielectric the admittance between the nets is jω ε0 ε*(ω) times their vacuum matrix, so G is ω ε0 ε″ + σ over ε0 εr times the solved C (Cheng 1989, §5-6). A loss tangent that is the same at every frequency is not causal. `causal: {atHz, upperCornerRadS, lowerCornerRadS?}` turns it into the wide-band model of Djordjevic, Biljić, Likar-Smiljanić and Sarkar (2001): εr and tanδ are the values at `atHz`, the permittivity falls slowly with frequency, and the loss tangent stays nearly flat between the two corners. The lower corner is 10 krad/s unless given; the upper corner has no default. Given the material's DC permittivity instead, `epsStatic` (above εr), the lower corner is solved so that ε(0) equals it. A lossless material is left as it is. A 1 m cube in a dielectric of εr 4.3 and tanδ 0.02 comes within 0.1 % of the published unit-cube C and of ω tanδ C, and the wide-band model's ε′ matches the Kramers–Kronig transform of its own ε″ (Jackson 1999, §7.10). A non-homogeneous dielectric, such as a laminated busbar's film between two plates in air or a board's laminate under its copper, is `dielectrics: [{name, min, max, epsR}]` in `capacitance`: axis-aligned blocks (corners in metres) of their own εr in the background `epsR`, 1 to 16 of them. Blocks of one material (the same εr and the same loss) may overlap: the smaller one wins and the larger is cut around it into touching pieces, so the solve is that of their union (the material override; the reply lists each overlap in `dielectrics.materialOverride` and a cut block's `pieces`). Blocks of two materials must not overlap. Blocks may touch face to face, so a stack of laminates of different εr (a board's core and prepreg, a film on a carrier) is one block per layer with no gap; the part of a face two blocks share is one interface between their two εr, and none where they are equal. A conductor face that a block's edge crosses, such as a plate under a film smaller than itself, is cut there so each panel faces one medium. Every charge is then a total (free plus bound) charge in vacuum: the block faces are cut into panels of bound charge on which the normal D is continuous, and each conductor panel's free charge is its total charge times the εr of the medium it faces (the equivalent-charge formulation of Rao, Sarkar and Harrington, 1984). Block faces that lie on a conductor, such as a film's faces pressed on the plates, or inside one, such as a laminate's face inside a via, are not interfaces and are left out; the reply's `capacitance.dielectrics` counts the interface panels (they count towards the 2500) and the faces left out. Two plates with a film filling the gap, and with a film filling half of it, follow the series-layer law ε0 / Σ dᵢ/εᵢ per area within 0.3 % once the fringe is taken out (Jackson 1999, §4.4), and so do two touching films of εr 2 and 6 stacked across the gap; side by side across the plates they follow the parallel law ε0 (ε₁A₁ + ε₂A₂) / d within 0.3 %. A block can be lossy too: give it the same `lossTangent`, `conductivitySPerM` or `causal` as the background (a block without them is lossless), and the background may be lossy beside blocks. `capacitance.frequencies` then gives C and G at each solved frequency, in the same keys as one lossy dielectric, so **Insert into Circuit…** and the SPICE export take them. Each frequency is solved again with every medium's complex permittivity ε′ − j(ε″ + σ/(ω ε0)), whose normal ε*E is continuous across each face (the free and displacement current together; Cheng 1989, §7-3), and the complex matrix K gives C = Re K and G = −ω Im K. A lossy core under a low-loss film therefore gives the series layer's Maxwell–Wagner loss, not a scaled copy of one film's. Two lossy films stacked across the gap follow the complex series law ε0 / Σ dᵢ/εᵢ* within 0.2 % of |ε*|, and side by side the parallel law within 0.3 %. One solve is taken per distinct set of permittivities, at most 64 (a constant tanδ without σ is one solve at every frequency); a conductivity at 0 Hz is refused, as its conduction term is infinite there. A body drawn in a CAD tool, such as a heatsink or a baseplate under the switch node, goes in as `bodies: [{name, path, unitMm?}]` in `capacitance`: each entry reads an STL, STEP or IGES file through the same readers as the magnetic field solve's import, and every closed solid of the file is part of one conductor of that name, which `nets` names like a drawn object (without `nets`, each body is a net of its own; with `type: "ground"` the heatsink is held at 0 V). Its facets are cut into flat triangular panels of uniform charge, each side at most `maxPanelM`, and the potential of each uniformly charged triangle is in closed form (Wilton, Rao, Glisson, Schaubert, Al-Bundak and Butler, 1984). A curved body is the polyhedron its file draws, so a coarse sphere has a little less capacitance than the true one: 1280 facets give −0.34 % of 4π ε0 a. A 1 m cube read from an STL file is within 0.35 % of the unit cube's 0.6606785 · 4π ε0 m with 1200 triangles, and next to a drawn cube 10 m away the matrix follows the potential-coefficient limit within 0.01 %. The reply's `capacitance.bodies` gives each body's file, solids, facets, panels (they count towards the 2500) and area. A body is in the capacitance only and carries no current in the R/L network. Bodies go with `dielectrics` (a heatsink on a thermal pad, a baseplate over a laminate): each facet panel is cut where a block's face plane crosses it and faces the medium it touches, a block face lying on a body or inside it is no interface and is left out, and the field of each triangle at the block faces is the gradient of its closed-form potential (Wilton et al. 1984). An STL plate over a drawn plate with a pad of εr 4 filling the gap gives the same ratio to air as the plate drawn within 0.15 %, and with a pad filling half the gap within 0.01 %; with both plates' second difference taken over their size, the pad follows the series-layer law within 0.24 %. A body with a lossy block or a lossy background (`lossTangent`, `conductivitySPerM`, `causal`) is refused. To take the capacitance into a SPICE model with the R and L, add `"spice"` to `export` and name one signal net per port, in port order, with `spice: {nets: ["DCP", "DCN"], cells?}` (null for a port with none). With 1 cell (the default) the subcircuit is a T model: half of each port's R and L, a shunt block, then the other half. The shunt block has a capacitor from each port's node to node 0, the net's capacitance to infinity and any grounded nets (the Maxwell row sum), and one between each pair of ports' nodes (minus the Maxwell entry). More cells make a ladder: each shunt block holds C / cells, the two end series blocks R and L / (2 cells) and the others R and L / cells, so the totals are unchanged. A signal net no port names is held at 0 V and listed in `heldAtZero`. A 200-cell ladder matches the input impedance of the uniform line (Pozar 2012, §2.3) within 2e-7 near a quarter wave, and the shunt capacitors of two unit cubes match the potential-coefficient limit within 0.2 %. Solved in a lossy dielectric, the shunt block takes the export frequency's C and G and puts each conductance beside its capacitor as a resistor of 1/G (`RG` to node 0, `RM` between ports), the shunt G + jωC of the telegrapher's line (Pozar 2012, §2.1); the reply's `conductance` says so. A 200-cell ladder with G matches the lossy line within 2e-7. The SPICE export above is lumped at one frequency. For one model that holds across the band, a transient run whose switching edges reach from DC to many megahertz, add `"broadband"` to `export` and solve a sweep in increasing order with at least two frequencies above 0 Hz, for example `[0, {"kind": "perDecade", "start": 10, "stop": 1e6, "points": 5}]`. The export fits the port impedance matrix Z = R + jωL at every solved frequency with one set of poles shared by every entry, Z(s) ≈ D + sE + Σ R_k/(s − a_k), by vector fitting (Gustavsen and Semlyen 1999, with the relaxed condition of Gustavsen 2006 and the per-entry QR of Deschrijver et al. 2008). It fits Z itself rather than S referred to 50 Ω, which would multiply the error of milliohm R and nanohenry L. Unstable poles are flipped into the left half plane. The subcircuit draws the fitted state-space model with controlled sources: each port's current drives one 1 F state node per real pole and two per complex pair, and each port's voltage is a chain of sources for D, E and the residues (Neumayer et al. 2002), with pins as in the SPICE export. `broadband: {poles, initialPoles, iterations, name}` sets the order (default 2 poles per decade of the band, 4 to 30), complex or real starting poles, the relocation passes (default 10) and the model name. The reply gives the poles, D, E and the fit error `worstError`, the largest entry error over the largest entry at the worst frequency. A fit need not be passive: between or beyond its samples Re Z can dip below zero, and a circuit made from it then makes energy in a transient run. So the export makes it passive by default (`broadband: {passivity: "enforce", passes}`, 30 passes by default): where Re Z(jω) has a negative eigenvalue, on a dense grid, at the frequencies where the Hamiltonian of the model says an eigenvalue crosses zero, and at ω → ∞ (D), the deepest point of each dip is lifted just above zero by the least change to the residues and D, the poles kept, and the passes repeat until none is left (the iterated fitting of passivity violations: Gustavsen and Semlyen 2001; Grivet-Talocia and Ubolli 2008; the Hamiltonian test of Boyd, Balakrishnan and Kabamba 1989 and Grivet-Talocia 2004). A negative eigenvalue of E is set to zero. The reply's `passivity.enforcement` gives the passes, `largestChange` (the largest change at the solved frequencies over the largest entry) and the fit's passivity and error before; `worstError` is then the enforced model's. If `largestChange` is much larger than the fit's own error, the fit itself is poor: solve more frequencies or change `poles`. The model is then checked on a grid from 0 Hz to a decade past the band, and `fitNotPassive` warns if Re Z or E still has a negative eigenvalue. `passivity: "check"` leaves the fit as it is and only checks it. A model built to make energy, Re Z(0) = −0.2 Ω, comes out with its residue alone moved, Re Z(0) = 2e-7 Ω, passive on 2000 points per decade; a coupled pair of wires whose difference mode is 1e-4 of the common mode, fitted with 8 poles from DC to 100 MHz, goes from a negative D and a dip at 45 MHz to passive in 2 passes, moved by 2.2e-3 of the largest entry against a fit error of 2.3e-3, and no further from the exact Bessel impedance. Fitted to a round wire's exact Bessel internal impedance (Ramo, Whinnery and Van Duzer 1994, §5.12) from DC to 1 MHz, 10 real poles are within 5e-11 between the fitted points. The written netlist, solved on its own nodal equations, matches separate `field.peec` solves between the fitted points within 2e-11 for a skin-effect wire and within 1e-12 for two coupled tracks. To put the result into the circuit, click **Insert into Circuit…** in the result window of **Design > Field Solver > Extract Conductor Impedance (PEEC)**. It opens the form of `field.peecInsert` on the solve shown, at its highest solved frequency, with the first two ports in series with the parts you picked on the schematic (in pick order, each at its first terminal); change the parts, terminals or frequency there and click Run. One port goes in as an inductor with its L and R, two as one coupled inductor with k = M/√(L1 L2), and one undo takes it out again. The button is greyed while no circuit is open. A solve with `capacitance` can put its capacitance in too: give `field.peecInsert` a `capacitance` list of `{net, circuitNet}`, one entry per solved net, with or without `at`. Each net gets a capacitor `Cpeec_` to the circuit's ground, its Maxwell row sum over the nets listed, and each pair a capacitor `Cpeec__` of minus the Maxwell entry, so the capacitors' nodal matrix is the solved one. A solved net you leave out is held at 0 V, and its coupling goes into the others' capacitors to ground. The circuit's ground stands for the solve's zero at infinity. Solved in a lossy dielectric, the C and G are those of `frequencyHz` (required when several frequencies were solved), and each capacitor gets a resistor `Rpeec_…` of 1/G in parallel, so the pair's nodal admittance is the solved G + jωC. A loss tangent's G grows with frequency, so the resistor is right near that frequency only; in a leaky insulator R·C is the relaxation time ε/σ at every frequency. From the result window, **Insert into Circuit…** on a solve with `capacitance` fills this in: the form carries the solved C (and G) and lists every solved net, each already on the circuit's net of the same name when there is one (never a ground net), the others empty for you to fill in. Delete the `at` rows to put in the capacitance alone. `field.peecReduce` turns a solved port matrix into another without solving again, as a Q3D-class extractor's matrix reductions do (`docs/specs/q3d-matrices/SPEC.md`): pass the `field.peec` reply as `peec` and a list of `ops`. A return path (`{op: "returnPath", port}`) gives the loop inductance from partials, `L11 + L22 − 2 L12`; joining in series or in parallel (`joinSeries`, `joinParallel`) gives two bars or two dies as one terminal; `reverse`, `float` (left open), `ground` (shorted), `moveSink` and `addSink` follow the SPEC. Each row also gives the coupling coefficients `couplingL` and `couplingR`, `|Xij| / √(Xii Xjj)`. Because the other ports of a `field.peec` matrix are open, each reduction is exact for the structure it describes, and the reply goes on to `field.peecInsert`. For a routed board, `layout.extract` with `peecHz` runs the same solver on each power loop's copper path (chapter 16, "layout.extract"), and `field.sweep` runs `field.peec` over a parameter. Three warnings say where the model stops: `noMagneticMaterial` (no core, steel or heat sink is in it), `noCapacitance` (R and L only, well below the first self-resonance) and `aboveQuasiStaticLimit` (a frequency above `c0 / (10 · extent)`, where the structure is a tenth of a wavelength). Its tests check it against Hoer and Love's table 1, the round-wire Bessel impedance (Ramo, Whinnery and Van Duzer) and FastHenry's own examples, ground planes included. ## Export the results - **Export Image** in the field window, or `field.exportImage`: the map as PNG or SVG at print resolution, in the light, dark or print palette, with flux lines or isotherms, outlines and a scale bar. `range` fixes the colour scale so several images share one; `currents` or `at: "peak"` draw the windings at their currents. - `field.exportCsv`: one line per mesh element (region, centroid, area, B and H per winding, and the loss density or temperature when the result has them), or the line profile, region table or thermal line, as RFC 4180 CSV with SI units in the header. - `report.export`: the report's Field solver section draws a 3D result as two views, from outside and cut at the mid-plane across the depth: a field solve's |B| on the magnetic parts (with flux tubes from outside) and a core loss's loss density (on the window's log scale), both scaled to the core's 99th percentile by volume as the 3D window scales them (the caption says so when hotter tetrahedra lie above the top), and a 3D thermal solve's temperature on every solid over its whole range. The pictures draw the window's outlines, in Viridis. **Save View for Report** in the 3D window keeps the view on the screen (camera, section, opacity, shading and the colour range; up to eight), and Export Design Report adds one picture of each 3D result per saved view (`field3dViews`); a view saved with one body's colour range scales on that body and its caption says so. `field.exportImage` and `field.exportCsv` read 2D fields only. - `field.exportDiagnostics`: the solve's diagnostics (mesh size and quality, iterations, residual, Newton steps, time, memory, solver version and input hash) as one JSON file to attach to a bug report. It holds no coordinates, names or materials. ## Warnings Every field result carries a `warnings` list, shown next to its numbers in the app and returned by the command, the CLI and Python. Each warning is `{code, message, messageZh, data}`: the `code` is stable for programs and never changes once released, `message` and `messageZh` say it in English and Traditional Chinese, and `data` holds its numbers (the region, the element, the values compared). A sweep (`field.sweep`) keeps each point's warnings on its row and lists every distinct code once, with the rows that raised it. The codes: | Code | What it means | |---|---| | `planarModel` | A planar section of a given depth with no end effects: end turns and the field outside the section are not in the result (for an electrostatic model, the capacitance is that of the slice alone). | | `linearMaterial` | A magnetic region solved with a constant permeability: it does not saturate in this result. Give it a B-H curve to model saturation. | | `freeFormPreview` | Free-form 3D from imported bodies (Preview): near a curved or slanted face the field is less accurate; solve again with a smaller `elementMm` to check. | | `outsideMaterialData` | The temperature is outside the material's or the magnet grade's data (the nearest point is used), the peak B is past the last point of the B-H curve, or the DC bias is above the material's DC-bias data. | | `dcBiasNotCovered` | The core flux has a DC level the material's loss data do not cover, or the most biased element is outside the measured box: the core loss reads low. | | `notConverged` | Adaptive refinement stopped at its pass limit, or ended early, without meeting its change criterion. | | `meshTooCoarse` | The estimated inductance error is above the target (0.5 % by default). Refine the mesh or raise the pass limit. | | `aboveSaturation` | The core's flux density (its 99th percentile by area or volume where the result has one, else the peak) is above the material's saturation flux density at the core temperature. | | `cornerPeak` | A region's peak \|B\| is on a corner of the drawing, a singularity that grows as the mesh is refined: read the 99th percentile `bP99` instead. | | `noSaturationData` | The material data give no saturation flux density, so the peak was not checked. | | `coldRestart` | In a waveform solve, the Newton iteration from the previous step failed and that step was solved again from zero. | | `olderSolverVersion` | The result was computed by another solver version. Solve again to update it. | | `incrementalError` | The DC-plus-ripple core loss is off the full solve at the ripple's extremes by more than its limit: solve every time point instead. | | `demagnetization` | Part of a magnet is past the knee at its temperature and loses magnetization irreversibly; `data` gives the share and the worst element. | | `oneDimensionalModel` | A winding AC loss on Dowell's one-dimensional window: every layer fills the window breadth, so the field at layer edges, at an air gap and around the end turns is not included. | | `idealCore` | A winding AC loss whose window faces are an ideal core (infinite permeability, no gap): a gap's fringing field is not in the result. | | `outsideCheckedRange` | Round wire or litz homogenized past the strand diameter, in skin depths, it was checked to (within 1 %); `data.fromHz` is the frequency where that starts. | | `noMagneticMaterial` | A PEEC result has no magnetic material: a core, a steel enclosure or a heatsink near the conductors is not in it. | | `noCapacitance` | A PEEC result has resistance and inductance only, which holds well below the structure's first self-resonance. | | `aboveQuasiStaticLimit` | A PEEC solve is quasi-static (no retardation, no radiation) and the highest frequency asked is above `c0 / (10 · extent · √εr)`, with the extent the diagonal of the nodes' bounding box and εr = 1 (air). `data` gives `extentM`, `epsilonR`, `limitHz` and `highestHz`. Read rows above `limitHz` as outside the model; a full-wave solver is needed there. | | `notPassive` | A PEEC result's R or L matrix fails the passivity check at one or more frequencies: its symmetric part has an eigenvalue below `-tolerance` times its largest, or it is asymmetric by more than the tolerance (`passivityTolerance`, default 1e-6). A network of conductors can't give out energy, so the result has lost accuracy. `data` gives `matrix`, `failing`, `frequencyHz` (the worst), `relativeMinEigen`, `asymmetry` and `tolerance`. Refine the split (`converge`) and solve again before making a circuit model from it. | | `majorRepair`, `meshLeak` | With `meshStatistics: true`, a `field.peec` plane's mesh area differs from its true area by more than 5 % (`majorRepair`) or 10 % (`meshLeak`, also a plane with no mesh left). `data` gives `plane`, `repair`, `mismatchPercent` and `recoveredAreaPercent`. Give the plane more segments until its row says `minorRepair`. | | `fitNotPassive` | The broadband export's rational fit (`field.peec` with `"broadband"` in `export`) is checked on a grid from 0 Hz to a decade above the band, and Re Z or its term in s (E) still has a negative eigenvalue after passivity enforcement, or with `passivity: "check"`. Vector fitting does not enforce passivity on its own (Gustavsen and Semlyen 1999), and a circuit made from such a model can make energy in a transient run. `data` gives `relativeMinEigen` (the smallest eigenvalue of Re Z over its largest, at the worst frequency), `frequencyHz` and `eRelativeMinEigen` (the same ratio for E). Fit again with fewer `poles`, solve more frequencies across the band, or give the enforcement more `passes`. | ## Limits - 2D is planar or axisymmetric: a planar section has no end turns, so its L is per unit depth times the depth. Use 3D with `endTurns` when the end turns matter. - Field Solve in 2D is magnetostatic and linear. It gives no AC resistance: use the AC thermal solve, the transient, or the exchange items to cross-check in another solver. - At most two circuits per model. B-H tables and other core families than E, planar E and ring are refused for a design; draw them as a sketch. - B-H curves come from data sheets (ferrites such as N87 and 3C95, amorphous alloys) and, for powder grades (High Flux, Kool Mµ, XFlux, MPP, Edge), from the catalogue DC-bias roll-off as B = μ0·μi·%μ(H)·H. Any other material stays linear, and the reply says so. - A peak |B| on a corner of the drawing is a singularity of the linear field: read `bP99`, not the peak. - Read the `warnings` and `notes` of a reply (planar model, linear material, outside the material data, a corner peak, a current above the design's): they say where a number stops meaning what it seems to. ## The accuracy report Every field-solver claim is checked by a row of the accuracy report, `docs/accuracy.md`, section **Field solver (magnetics FEM)**, regenerated by `cargo xtask accuracy`. Rows fall in four groups: verification (is the math right: analytic cases, convergence order, reciprocity, energy against flux linkage), validation (does it match references), hardware (does it match the bench) and performance. At the time of writing, 30 of 30 measured rows pass and 18 are pending; a pending row names the task that will fill it. A few of them: | Row | Our value | Reference | Error | Target | |---|---|---|---|---| | `analytic_coax_2d`: B and L per metre of a coaxial line | 3.184e-5 | 3.195e-5 | 0.36 % | ≤ 1 % | | `analytic_toroid_axisym`: L and B of a toroid | 1.622e-7 | 1.622e-7 | 2e-7 % | ≤ 1 % | | `convergence_order_smooth`: observed order of the energy error | 2.005 | 2 | 0.005 | 2 ± 0.3 | | `mesher_independence`: E25 drawn as a sketch, automatic mesh, L (µH) | 91.45 | 91.83 | 0.42 % | ≤ 0.5 % | | `extrusion_3d_vs_2d`: 3D extrusion against 2D, L (µH) | 91.53 | 91.49 | 0.04 % | ≤ 1 % | | `force_parallel_wires_2d`: force between two wires | −1.398e-7 | −1.4e-7 | 0.17 % | ≤ 0.5 % | | `ac_resistance_dowell`: AC resistance where Dowell's assumptions hold | 18.18 | 18.14 | 0.20 % | ≤ 5 % | The field solver leaves Preview when the release rows (the hardware rows for saturation knee, ripple, core loss and temperature rise among them) pass. Until then, check a result that matters against a measurement or a second solver. --- # 22. The board: stack-up, placement, routing and fabrication files URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/22-board/ Voltecx keeps the printed circuit board next to the circuit. The board is one text file, `.vxpcb`, inside a project, and every board step is a command: you run it from the command line, from Python, from the chat or from a script, and each one that changes the board writes the file at once. The circuit is never changed by a board command, and a board nobody has drawn or routed has no loop inductance yet: the numbers come from the circuit and the simulation, never from a guess. This chapter takes a simulated converter to a board and a set of fabrication files. Lengths are in metres and copper weight in ounces, like everywhere else in Voltecx. Commands that need a board take `path` (a `.vxpcb` file); without it they use the open project's board. ## 1. Keep the design as a project A project is one `.vxproj` file that lists the `.vxsch` sheets, the `.vxsim` setups and the `.vxpcb` board. All are diff-friendly text, and parts keep their ids in every file. 1. `project.saveAs {"path":"w/buck.vxproj"}` splits the open circuit into its files with nothing lost. 2. `project.addBoard {}` adds the board. (`project.new {path}` starts an empty project, `project.open {path}` opens one and names a missing file, `project.save {}` writes it; `file.save` does the same.) 3. `project.show {}` lists the documents. ### Assembly variants One project can keep several ways to build the same circuit, for example a Debug build with test links and snubber footprints, and a Production build without them. A variant is a name and the list of parts it leaves unfitted (DNP). Variants live in the `.vxproj`, so they need a project (`project.saveAs` first; on a plain file the commands say so). 1. `project.setVariant {"name":"Production","dnp":["Rsnub","TP1"],"description":"no bring-up parts"}` creates or replaces a variant and writes the project file at once. Every part named must exist in the circuit. It does not change the circuit yet. 2. `project.activateVariant {"name":"Production"}` marks exactly those parts DNP and every other part fitted, as one history step, so **Edit > Undo** brings back the marks. The simulation, the bill of materials (`bom.list`, `bom.export`) and the board follow the marks: a DNP part stays out of the simulation but stays on the board and in the BOM's DNP list. The reply lists `dnp`, `fitted` and any `unknown` part the variant names that is no longer in the circuit. 3. `project.variants {}` shows every variant with the `active` one. A part named by a variant but missing from the circuit is listed under `unknown`; fix it with `project.setVariant`. 4. `project.removeVariant {"name":"Debug"}` deletes a variant. The parts keep their DNP marks. 5. `board.exportFab {"variant":"Production","folder":"fab-production"}` writes the fabrication set as that variant builds the board, without activating it: its DNP parts get no paste and no line in the position files or the assembly BOM, and every other part is fitted. The copper is the same for every variant. The reply's `assembly` lists the parts `notFitted`, the parts kept out of the BOM (`notBought`: on the board but neither bought nor placed, such as a test point on a bare pad, whose KiCad footprint says `exclude_from_bom` and `exclude_from_pos_files`), the board-only parts the BOM buys but the machine does not place (`notPlaced`, such as standoffs) and the placed parts whose footprint says `exclude_from_bom` alone (`notListed`). Without `variant`, the parts marked DNP now are left out, even when the board was not synced since. Say which variant is active before you quote a bill of materials or a simulation result, because they differ between variants. A variant is not a saved version of the circuit: for an A and a B design of the whole circuit use the variants of the history (chapter 14). ## 2. The stack-up `board.stackup {}` lists the layers from top to bottom (copper layers are signal, plane or mixed; the rest are core or prepreg), the copper count and the total thickness. Pass the board's nominal `thickness` (and a `tolerance` fraction) and it warns when the layers do not add up to it. A layer with no thickness leaves the total empty: Voltecx does not fill one in from memory, so take the value from your fabricator's stack-up. | Command | What it does | |---|---| | `board.setStackup {"copper":4}` | A standard stack of 1 to 32 copper layers; or pass `layers` with `name`, `kind`, `thickness`, `copperOz`, `dk`, `lossTangent` and `material` for each | | `board.setLayer {layer, ...}` | Change one layer's values; `null` clears a value | | `board.addLayer {above}` | Insert a layer | | `board.removeLayer {layer}` | Remove a layer; refused while an item is on it | Layers keep their ids, so the items on them stay put. An odd copper count is allowed: the reply warns once, and its `offer` is the `board.addLayer` call that makes the count even. Vias may be through, blind or buried over any two copper layers. ### Trace impedance `board.impedance {layer, width}` gives a trace's `z0` and, with `spacing` (edge to edge), the pair's `zdiff`. Going the other way, `{layer, targetZ0}` or `{layer, targetZdiff, spacing}` gives the `width`. An outer layer is a microstrip, an inner layer a stripline between its neighbours. With no board, pass `structure` (`microstrip` or `stripline`), `height`, `thickness` and `dk`. A value the stack-up lacks comes back as an error that names it: Voltecx does not guess a dielectric constant. The formulas are empirical (about ±10 %), so the reply carries `warnings`; for a controlled-impedance order, quote the fabricator's field-solver figure. ## 3. Placement Run `simulation.run {}` first, at full load and the highest input, so the hot loops are the simulated ones. Then `board.autoPlace {}` places the footprints already on the board: the hot-loop parts side by side in loop order, the power path below them, each gate net's parts next to their switch, every other part away from the switching node. It is a starting point. A locked footprint is never moved (`locked` lists them), and `unplaced` lists the parts that have no footprint yet. The circuit is unchanged. ### Put a footprint on the board, or swap one `board.placePart {part, footprint, at}` gives a circuit part that has no footprint one: `footprint` is a KiCad `.kicad_mod` file (or `like` names a copy already on the board), `at` is the position in metres, with `rotation` (degrees, counter-clockwise), `side` (`top` or `bottom`) and `locked`. The pads join the part's ports by the data-sheet pinout of the library footprint (`library`, or the file's `Lib.pretty` folder), otherwise pad n to the part's n-th port; `pins {pad: port}` overrides any pad (null leaves it unconnected). Each pad takes its port's net. Read `unassigned` (ports no pad joins), `pins` (what was joined) and `drc` (the rule check on the new footprint). `board.swapFootprint {ref, footprint}` gives a placed part another footprint and keeps its position, rotation, side and part; tracks to the old pads stay, and a locked footprint is refused. Both are one undo step. `board.get {}`, `board.nets {}` and `board.part {ref}` read the board (`unplaced` lists the parts with no footprint) without changing it. ### Outline, cut-outs and milled slots `board.setOutline {rect: {x, y, w, h, cornerRadius?}}` or `{polygon: [[x,y], {"arc":[x,y]}, ...]}` sets the board's edge (metres; arcs are drawn as in a zone's outline, within `maxError`). It replaces the outline and keeps the cut-outs. `board.addCutout {slot: {from, to, width}}` mills a slot (the stadium a router bit of `width` cuts between the two centres; `from` equal to `to` is a round hole), for example across an isolation barrier to gain creepage; `{polygon: [...]}` cuts any other shape inside the edge. `board.removeCutout {index}` removes one (`index` from `board.get`'s `outline.cutouts`). The reply's `notes` compare a slot's width with the cited slot-width rules; the pollution degree is the engineer's call. A ring that crosses itself, a cut-out not wholly inside the outline, and copper, holes or footprints that would fall outside the new outline or inside a cut-out are refused by name: move them first. The shape is yours to give; Voltecx has no default. Each edit is one `board.undo` step; run `board.drcRun` afterwards. ### Reference designators and silk `board.placeReferences {}` moves each part's reference designator (its footprint's `${REFERENCE}` text from `board.addReferenceTexts`, added when missing, so it still moves with the part) beside its courtyard on the silk of its face, at 0° or 90° (reading from the bottom or the right), clear of every courtyard, pad, mask opening, via, other silk (a part's shown fields, such as a KiCad Value, included) and the board edge: closest to the part first, then lined up with its neighbours. Bottom parts get mirrored references on the bottom silk. `refs` or `side` limits it. A part with no free spot is listed in `unplaced` and its reference stays where it was; references are never stacked. `board.clipSilk {}` cuts the silk, the board's and the footprints' on the board (the library is not changed), so its ink stays clear of every solder mask opening by the silk-to-mask gap. Voltecx assumes no text height, stroke width or gap: pass `height`, `strokeWidth` and `clearance`, or set them once from the fab's rules with `board.setSilkRules {silkToMask, textHeight, textWidth}`; a missing one is reported. Neither command changes copper or nets, and each is one undo step. ### Fiducials and mounting holes `board.addFiducials {global: {count, inset}, local: {parts, pitchBelow}, pad, maskOpening, keepout}` puts fiducials on the board: `global` at `count` corners of the outline's box, `inset` in from both edges (three are never on one line), on `side`; `local` at two opposite corners of each listed part and of each part whose closest pads are nearer than `pitchBelow`, just outside its courtyard. `board.addMountingHoles {positions | corners: {inset}, drill, plated, pad, net, headKeepout, layers}` puts mounting holes at the given points or the four corners: unplated holes go in the NPTH drill file, plated ones need their `pad`, and a hole on a `net` (a chassis net, say) is checked by the DRC like any pad on that net. The screw head's `headKeepout` is a courtyard on both faces and a copper keep-out the router walks round. Both are footprints with no circuit part (FID1, MH1 …), locked and not fitted, so they have no BOM line. A fiducial remembers whether it is global or local, and `board.exportFab` writes its pad on the copper Gerber as `FiducialPad,Global` or `FiducialPad,Local` (Gerber 2024.05 §5.6.10), so the fab and the assembler see it as a fiducial, not a pad to solder. A local fiducial also remembers the part it locates, and the Gerber X3 component layer lists it with that part as a zero-size `FiducialPad,Local` flash (Gerber 2024.05 §6.9.2); fiducials placed before this have no part and are left off. Every size is yours: Voltecx has none built in and refuses a call that leaves one out. A spot that would reach the board edge, a part or copper is listed in `skipped` and left empty. Each call is one undo step. ## 4. Routing `board.autoRoute {"via":{"diameter":...,"drill":...,"plating":...}}` routes the board: each switch's gate drive first, so it takes the short way beside its switch, then the hot-loop nets (`order` shows each net's role) and the rest by RMS current. - **Width** comes from each net's simulated RMS current (IPC-2221 section 6.2 on the layer's copper thickness), so set the thicknesses with `board.setLayer` first. - **Clearance** comes from each net's peak voltage (IPC-2221B table 6-1, column B2), written as `IPC-2221 B2 V` net classes unless you pass `"classes":false`. - **Vias** are an array sized for the current through the barrel `plating`. Pass `currents` and `voltages` for nets the simulation does not give. Never guess a via size or a plating thickness: use the fabricator's numbers. - **Layers** follow the ground plan of `board.groundPlan` unless you pass `"ground":false`: each net goes on its assigned layers, the ground nets reach their plane through via arrays (`toPlane`), gate and sense nets run only over an unbroken plane on the next layer (`referenced`), and the other nets keep off an inner plane. A board with no zones gets the plan's ground planes first (the power pours stay `board.groundPlan`'s to add). - **Thermal vias** go under the largest pads of the hot loops' switches and diodes before routing (`thermal` lists each pad's vias). Drill, pitch and the fewest vias per pad come from the design rule set; `thermalVias` overrides them or turns them off with `false`. Read the reply before you call the board routed. `unrouted` names each net left, with a `reason` (`noWidth`, `widthAboveMax`, `noClearance`, `noReference` or `noPath`) and the pads still open; `drc` is the design rule check of the result; `skipped` nets had one pad or copper already (nothing is ripped up). Then fill the zones (`board.fillZones`), run `board.drcRun` and `board.layoutReview`, and export with `board.exportFab`. Gate-loop pairing and ground stitching are not routed specially yet. ### Stitching vias in a zone `board.stitchZone {zone, pitch}` drops a grid of vias of the zone's net into its filled copper, tying the zone to the layers under it. The grid has `pitch` (and `pitchY`; `stagger` shifts every other row by half a pitch) and starts at the outline's lowest corner or at `origin`. A via is kept only where its whole pad fits `edgeMargin` inside the fill and the design rule check names no fault on it, so vias near other nets' copper on any layer they cross are dropped (`dropped`). The via size comes from the net class (or `diameter` and `drill`); `from` and `to` default to the outer layers. There is no default pitch: it is the engineer's choice. Without `commit` the board is unchanged and the reply lists the vias; `commit: true` adds them as one undo step. Refill the zones afterwards. `board.addViaFence {zone, edge: "board", pitch}` runs a fence of the zone's net round the board outline (cut-outs included), or with `edge: "zone"` round the zone's own outline, `offset` inside it (by default the board's edge clearance plus the via radius). The vias are spread evenly round the edge itself, so the pitch holds round corners as on the straight. A fence along tracks takes `tracks` instead. Each grid or fence committed for a zone is recorded on the zone with its settings and the vias it placed. `board.restitch` takes those vias away and places them again on the board as it now is, so after moving parts, rerouting or reshaping a zone the stitching follows; one undo step. `board.editZone` does this for the zone it edits, and `board.removeZone` removes the zone's recorded vias with it. A group that can no longer be placed (its tracks were deleted) keeps its old vias, and the reply says why. ### Copper thieving and copper balance `board.copperBalance` lists each copper layer's copper share (its copper area, zone fills, pads, tracks and vias with overlaps counted once, over the board outline's area) and the difference from the layer it mirrors in the stack-up (top against bottom, and so inwards). A layer with much less copper than its mirror plates and etches unevenly and can bow the board. `board.addThieving {layer, size}` adds copper of no net to a sparse layer: a zone over the board outline (or `outline`) whose fill is cut into square dots of side `size` (`pattern: "dots"`, the default) or a hatch of lines `size` wide around square openings (`pattern: "hatch"`). The zone fills after every other zone and keeps `keepout` (default the board's minimum clearance) from all copper, so it never touches a net; only whole dots and whole openings are made. Without `pitch`, the pitch is sized so the layer's share comes to `target`, by default the share of the mirrored layer, and never closer than `gap` (default the board's minimum clearance) between dots or across an opening. `limited` says the target is out of the pattern's reach: a hatch keeps a solid border at least its line width wide, so it cannot go as low as dots. A layer already at the target gets nothing. The dot size or line width has no default (ask the fab), nor has the target of a layer that mirrors no other. Without `commit` the board is unchanged and the reply shows the share before and after, the pitch and the number of dots or openings; `commit: true` adds the zone as one undo step. The pattern is not stored: every refill (`board.fillZones`, the fabrication outputs) makes it again around the copper as it then is. Remove it with `board.removeZone`. ### From the menu: Board › Stitching and Thieving The Board menu's Stitching and Thieving submenu holds the same five commands. Stitching Vias in Zone, Add Via Fence and Add Copper Thieving open their form already filled from the board window: the one zone selected, the tracks selected (a fence along them; with no track selected, a fence round the board edge carrying the zone's net), the active copper layer, and `commit: true`. The pitch, the via size where the net class has none and the thieving size are left for you to type. Restitch Zones and Copper Balance run at once. The status bar says what each did (vias added and dropped, the copper share before and after, each layer's share and its difference from the layer it mirrors, such as `Top 50 % (+37.5 % against Bottom)`), and the board is drawn again. ### Route one track by hand `board.routeStep {layer, from, to, width}` is one step of interactive routing. It returns the centre line (`points`, metres) of a track on the copper layer `layer` from `from` (a pad or a track end) towards the cursor `to`. The line walks round every other net's copper with the clearance (the board minimum, the fab `minSpace`, both nets' classes, `clearance`, `barriers`), stays inside the outline and keeps out of track keep-outs, so `board.drcRun` finds no short or clearance fault once it is drawn. `net` defaults to the net of the copper at `from`; `width` defaults to the track width of that net's class, and with no class it must be given. `corners` is `"45"` (default: horizontal, vertical and 45° segments), `"any"`, or `"arc"`: the 45° route with each corner rounded by a tangent arc, the largest that fits (half of a leg between two corners, all of an end leg) or at most `radius`, halved until the arc keeps the clearance as the DRC measures an arc track; a corner no arc clears stays sharp. In arc mode `radii` gives each inner corner's radius (0 sharp), `path` the centre line with each arc as its chords, and `addTrack` carries the radii: `board.addTrack {..., radius}` (one length for every corner, or one per inner corner) draws the corners as arc tracks in the same undo step. `board.routeShove` takes the same params and is the push-and-shove step: the track goes straight through other nets' tracks and vias, which are pushed aside by the clearance. A pushed track bends round the new one with horizontal, vertical and 45° sides; a pushed via moves away and the ends of its tracks follow; pushed copper pushes its own neighbours in turn. Pads, arcs, zones and footprints, locked or not, never move. The step never leaves a fault `board.drcRun` did not find before: when no push comes clean it falls back to the walk-around track and `walkedAround` is true. Each step starts from the board as it is, so items pushed for an earlier cursor position spring back. Without `commit` nothing changes and the reply lists the `moved`, `added` and `removed` items; with `commit: true` the track and every push are written as one `board.undo` step. `board.routeHighlight` takes the same params (without `radius` and `commit`) and is the highlight-collisions step: the track goes straight from `from` to `to` through whatever is in the way (a 45° leg then a horizontal or vertical one, or one segment with `corners: "any"`), and the reply lists in `collisions` the items it would short or come too close to (other nets' copper, barrier copper, holes, the board edge) and in `rules` the rules broken, as `board.drcRun` finds them with the same `fab` and `barriers`. Faults the board had before are not listed. It changes nothing; its `addTrack` params draw the track anyway. To change layer, `board.routeVia {at, from, to}` gives the via at the end of the track so far: the net's class via (or `diameter` and `drill`) from the copper layer `from` to `to`, at `at` when the design rule check names no fault on it there, else at the nearest such spot within `reach` (three diameters by default). When it moved, `routeTo` holds the `board.routeStep` params that bring the track to it. A fault the via has wherever it goes (a drill or annular ring below the rules) stops the search, and `placed` is `false` with the `faults`. The command only reads the board; `addVia` holds the `board.addVia` params. Check `reached`. When the cursor cannot be reached the track ends at the clean point nearest it, `reached` is `false` and `blockedBy` lists the items in the way. The command only reads the board: `addTrack` holds the exact parameters of `board.addTrack` that draw the track, so run that to keep it. In the app, the Board tab's Track tool does these steps for you. Click where the track starts; as the pointer moves, the route to it is drawn at its width with the clearance around it (a faint band), round every other net's copper, and the line under the toolbar gives the clearance kept and the length. Where the pointer cannot be reached, the route stops at the nearest clean point, turns amber, and the copper in the way is outlined in red. A click, or letting go after a drag, keeps the route up to there; ending on a pad or track of the same net draws the track (`board.addTrack`), and Enter or a double click draws it where it is. V keeps the route, drops the via `board.routeVia` finds at its end (`board.addTrack`, then `board.addVia`, the Via tool's sizes or the class's) and goes on from the via on the next copper layer. The Corners switch picks 45°, any angle or arc corners; with arc corners each corner of the route is rounded by the largest arc that keeps the clearance (Arc radius caps it; 0 takes the largest that fits), the preview draws the arcs, and the track is drawn with them. Shove mode routes arc corners as 45° ones. The Mode switch picks Walk around or Shove: in Shove mode the route goes straight through other nets' tracks and vias, which are drawn (amber) where `board.routeShove` pushes them, and a click writes the track so far, then the step and its pushes as one undo step, and goes on from its end. A push that would break a rule is not made: the route walks round instead and the line under the toolbar says so. In Highlight mode (`board.routeHighlight`) the route goes straight to the pointer through whatever is in the way, turns amber where it collides, the copper it collides with is outlined in red and the line under the toolbar names it; a click places the track anyway, and **Run DRC** lists the faults to clear. Highlight mode also routes arc corners as 45° ones. Esc cancels. ### Differential pairs, length and skew tuning, teardrops Name a pair with `board.setDiffPair {positive, negative}` and give the positive net's class a `trackWidth`, a `pairGap` (edge to edge, no less than the clearance between the two nets) and, if the interface limits it, a `maxSkew` (`board.setNetClass`). `board.routeDiffPair {net, layer, from, to}` then routes both tracks side by side at the gap, from the pair's centre between its pads at one end to the centre at the other, round every other net's copper; the pair leaves its pads square and `fanout` joins each track to its pad. `preview: true` shows the tracks without writing them. In the app, the Board tab's Diff Pair tool (key 6, as in KiCad; Route › Route Differential Pairs in the studio) does it with two clicks: click between a pad of each net where the pair starts, then between the pads where it ends. A click near the pads lands midway between them and takes the nearer pad's net (or the Net field's), and the pair goes on the active layer as one undo step. Esc drops the start. `board.lengths {}` lists each routed net's length against its class's `minLength`..`maxLength` window, and each pair's skew and how far it runs coupled at the gap; the DRC flags a net outside the window, a pair over its `maxSkew` and pair tracks closer than the gap. `board.tuneLength {net, target}` puts rectangular meanders into the net's longest straight track until it reaches the target (default: the middle of the window); `amplitude` caps the bump height and `spacing` sets the gap between bump legs (default: the net's clearance). `board.tuneSkew {net}` lengthens the shorter net of a pair into its `maxSkew`. Meanders only add length: a net that is already too long has to be rerouted. `board.addTeardrops {lengthRatio, widthRatio}` flares the copper where each track ends on a pad or via of its net, in proportion to the pad's smaller side or the via's diameter; the ratios are saved in the board's rules, a second call redraws, and `board.removeTeardrops {}` takes them off. A joint where the teardrop would come too close to another net is skipped and listed. Voltecx fills in none of these values: take them from the data sheets, the impedance calculation and your fab. ## 5. Copper zones `board.fillZones {path, layer, polygons}` fills every zone (no `layer`: every copper layer that has one) and reports each zone's copper `area` in m², its `pieces`, the `removedIslands` and the `starvedPads`. A starved pad is a thermal pad no spoke reached, so it is not joined to the zone; the `notes` say so in English and Traditional Chinese. A zone that came out in more pieces than you expected deserves a look too. The command changes nothing in the board. ### Draw, edit and remove a zone `board.addZone {net, layers, outline}` draws a copper zone on the copper layers `layers` (by name), inside `outline`: corners `[x,y]` in metres, or `{"arc":[x,y]}`, a point the arc passes through between the corner before and the corner after it. `holes` are cut-outs drawn the same way. `net` is the circuit net it fills for (none: unconnected copper). `clearance` and `minWidth` override the net class's, a higher `priority` fills first where zones overlap, `padConnection` is `solid`, `none` or `{"kind":"thermal","gap":...,"spokeWidth":...}`, and `removeIslands` drops pieces joined to nothing. The reply gives the new `zone` id and the refill of its layers. `board.editZone {id, ...}` replaces only the keys you give (`outline` without `holes` keeps the cut-outs, `holes: []` removes them, null clears `net`, `clearance` or `minWidth`), and `board.removeZone {id}` deletes the zone. Each one writes the board file. ### Pad connections to a zone: solid, relief or none How a pad meets a zone of its own net is set at four levels, and the first that sets one wins: pad, then footprint, then net class, then zone. `board.setPadConnection {part, pad?, connection}` sets it on a pad (without `pad`, on every pad of the footprint; `connection: null` clears it). A connection is `"solid"`, `"none"`, or `{"kind":"thermal","gap":...,"spokeWidth":...,"spokes":4,"angle":0,"minSpokes":...}`. `board.padConnections {part?}` lists every override and, with `part`, what each pad gets and from where (`source`). `minSpokes` is the fewest spokes that must reach the zone: `board.drcRun` reports a pad with fewer as `starvedThermal`, and `board.fillZones` lists each relief pad's `spokes` and `landed`. The gap, spoke width and minimum come from you or the fabricator; Voltecx fills in none. Each change is one `board.undo` step. ### Keep-outs and isolation-barrier keep-outs `board.addKeepout {polygon, layers}` draws a keep-out inside `polygon` (drawn like a zone's outline) on the copper `layers` (by name, or `"all"`): no tracks, vias or zone fill by default (`noTracks`, `noVias`, `noZones`), and no part pads with `noParts: true`. The router and the zone fill keep out of it. `board.editKeepout {id, ...}` replaces only the keys you give and `board.removeKeepout {id}` deletes it. `board.barrierKeepout {barrier, part}` draws the keep-out an isolator needs: the gap between its primary and secondary pad rows on every copper layer, at least the barrier's clearance and creepage wide (from `design.safety` or the engineer; without either it refuses). `board.drcRun` with the same barrier reports `barrierOverlap` for copper of the two sides overlapping on different layers and for tracks, vias or pads inside the barrier keep-out. Each one writes the board file and is one `board.undo` step. ### Net classes and board rules `board.setNetClass {class, values, nets}` writes a net class into the board's rules: `values` holds `clearance`, `trackWidth`, `viaDiameter`, `viaDrill`, `minTrackWidth`, `maxTrackWidth`, `maxLength` (metres) and `current` (RMS amperes for the width-for-current check). A key you give sets the value, null clears it, a key you leave out stays. `nets` puts those nets in the class (in `Default`, they leave their own class), and `remove: true` deletes the class and sends its nets back to `Default`. `board.setRule {...}` sets the board-wide limits: `minClearance`, `minTrackWidth`, `minDrill`, `minAnnularRing`, `edgeClearance`, `maxDrill`, `holeToHole` (metres), `maxAspectRatio` and `temperatureRise` (K). Voltecx fills in no value: take them from your fab's capability sheet or a cited standard. Each reply carries the DRC findings on the copper the change reaches, and each call is one undo step. `board.rules {}` shows every rule at once: the board-wide limits, each class with its values and the nets it reaches, the patterns and the rule areas. `board.setClassPattern {pattern, class, at}` puts the nets whose names match a glob (`GATE_*`, `V??`) in a class; patterns are tried in order and the first match wins, and a net named with `board.setNetClass` keeps its class. `remove: true` deletes a pattern. `board.setRuleArea {name, polygon, layers, priority, class, overrides}` draws a rule area: inside the polygon, on those copper layers and for that class's nets, the `overrides` (`clearance`, `trackWidth`, `viaDiameter`, `viaDrill`) replace the class values, and where areas overlap the higher priority wins. Call it again with the same `name` to change part of it (`rename`, null clears an override) or with `remove: true` to delete it. In the board window, Board › Rules… (or the Rules… button beside Stack-up…) opens the rule editor beside the board, in five tabs: the board limits (with the minimum mask web and the silk-to-mask gap), the net classes with their values and how many nets each reaches (Add Class, Remove), the class patterns in the order they are tried (▲ and ▼ move one, Add Pattern), and the rule areas highest priority first (▲ and ▼ raise or lower the priority by one, the overrides typed in place), and the board-wide solder mask and paste rules (mask expansion and paste expansion in mm, which may be negative, and the paste ratio from 0 to 1, all `board.setRule`; a footprint's or pad's own rule still wins). Add Layer Rule draws an area over the board outline on one copper layer, or all of them: a rule by layer. Lengths are typed in mm; Enter applies a field and an empty field clears it. A value the editor refuses keeps its reason under the page until a value is accepted there. Each edit is one undo step, and the DRC overlay reads the rules again. `board.citedRules {kind}` lists the cited rule set of the PCB design guide with each rule's bound, condition and source page, and `board.applyCitedRule {id, field, class}` writes one of its lengths into a class value or a board-wide limit; check the rule's condition against your board first. ## 6. Check the board `board.drcRun {}` runs the design rule check. Each net's RMS current from the last simulation sets the width it needs (IPC-2221 section 6.2, 10 K rise unless the rules' `temperatureRise` says otherwise); `"stale": true` in the reply means the board changed since that run, so simulate again. Useful parameters: - `currents {net: amps}` adds nets the simulation does not cover. - `barriers [{name, sideA, sideB, clearance, creepage, source}]` checks the copper across an isolation barrier, with the distances `design.safety` gives, in metres. - `fab {minTrace, minSpace, minDrill, ...}` takes numbers from your fabricator's capability page. A rule with no value is not checked, and the reply says so; do not call a board clean on a rule it did not check. - `fab` also takes a built-in profile by id (`jlcpcb-2layer`, `jlcpcb-multilayer`, `pcbway-standard`, `oshpark-2layer`, `oshpark-4layer`); `board.fabProfiles {}` lists them with each limit and the capability page it is cited from. In the Board window, pick one under **Fab** on the step bar: Run DRC (and the check after each edit), Check Board, and Board › Design Rule Check and Auto Route then use it, and hovering the picker shows its source. **Board rules only** checks the board's own rules. Rule areas count in the check: inside an area on its layers its `clearance` replaces the net class's, even when lower, and its `trackWidth` is the minimum for a track lying wholly inside it; the board's and the fab's minimums still hold. Off the copper the check finds silk closer to a solder mask opening than the `silkToMask` gap (`silkToPad`; the openings as the fabrication files draw them, pads grown by their mask expansion), two mask openings closer than `minMaskWeb`, which the fabrication files would merge (`maskSliver`), and the courtyards of two fitted parts on one face overlapping (`courtyardOverlap`, IPC-7351B; touching is allowed, DNP parts are skipped and a part with no courtyard is named in `notes`). Drill to drill is the `holeToHole` rule. Silk and sliver checks run only when their rule is set. `violations` lists each `rule`, the `items` and `at` position, and `measured` against `required` in metres, with `message` and `messageZh`. `widths` lists the width needed beside the width drawn, per net and layer, and `notes` says what was not checked and why (a layer with no copper thickness, for one). The IPC-2221B clearances are a board rule, not a safety creepage: an isolation barrier needs the distances `design.safety` gives. In the studio the list under **Run DRC** has three tabs, each with its count: **Violations** (every copper, hole, mask and current rule), **Unconnected** (nets whose pads the copper does not join yet, rule `unconnected`) and **Schematic parity** (circuit parts that belong on the board and have no footprint on it, rule `missingFootprint`). A click on a row selects the items it names and zooms onto it, in any tab. Outside the studio the list is one list. ### Board-only parts on the schematic Mounting holes, fiducials, standoffs and logos can sit on the schematic as board-only parts (in the library panel's Sources group: Mounting Hole, Fiducial, Standoff, Logo; kind `boardPart`). They are never simulated and never written to the netlist, whatever their simulate switch says, and the circuit checks skip them. They start out of the BOM and on the board, and the schematic tags them *board only*; turn the BOM switch on for a standoff you buy with the board, and its BOM line buys the part number in its `part` parameter (a line that says so when it names none; nothing is picked for it). The KiCad schematic export leaves board-only parts out, as they have no symbol, and its warnings name them. A mounting hole has one pin, `mh`: leave it open for a bare hole, or put it on a chassis or PGND net for a plated hole that grounds through its screw. The hole, pad and keep-out sizes are yours: give them to `board.addMountingHoles` and `board.addFiducials`. ### Test points `board.testPoints {}` places and reviews the circuit's test points on the board. Each test point is moved beside the nearest pad of another part on its key net (rails, switch nodes, gates, PWM, feedback, sense), with its ground point right beside it, clear of every other footprint and inside the outline; locked points stay. Without `"apply": true` the `moves` are a proposal and nothing is written; with it the board file is written in place. `"place": false` only checks. `findings` is the layout review, each with English and Traditional Chinese text: `noTestPoint` (a key net has none: add one on the schematic with `design.debugAids {"include":["testPoints"]}` and sync the board, because the schematic comes first), `noGroundPoint`, `groundTooFar`, `padTooSmall`, `probeBlocked` (another part on the test point's side sits where the probe's barrel goes: within half the probe kind's `bodyMm` of the pad), `bothSides`, and `unknownProbe`, `unknownGroundDistance` or `unknownProbeAccess` when no probe kind with a cited `source` gives that size, so it is not checked. The switch node and the gates are measured through the Tektronix 3.5 mm probe's circuit-board adapter (131-5031-00): their ground point must be within its 0.205 in (5.207 mm) hole spacing and the 3.429 mm barrel needs room round the pad. Placing keeps that room clear. Pass your own roles and probe kinds in `rules` (each probe kind with its `source`); never invent a probe's pad size or ground distance. In `board.layoutReview` with an `enclosure` whose `areas` come off the mechanical drawing, a test point or its ground point whose pad lies under a height-limited area of its face is `probeCovered`: the probe cannot reach it with the board in its case, so it fails `serviceReady`. ### Service access and silkscreen `board.serviceCheck {"labelHeight": 1e-3}` puts every reference designator, and every test point's net name, beside its part on the silkscreen: above, below, right or left of it, clear of every part, a word space (the stroke font's own space) clear of every other silk text, designators included, and inside the outline. When a label has no other room, its part's designator moves to another free spot beside its part. Without `"apply": true` the `labels` are a proposal; with it the board file is written in place. Without a `labelHeight` (or a cited `rules.minTextHeight`) no label is placed, because no text height is built in. `findings`, in English and Traditional Chinese: `noLabel`, `labelHidden` (the text lies over a part), `labelAstray` (nearer another part), `labelCrowded` (closer than a word space to another silk text, so the two read as one word), `textTooSmall`, `noPolarityMark` (a diode, electrolytic or battery whose silkscreen does not tell its ends apart), `noVoltageWarning` (a high-voltage net from `highVoltageNets`, or a DC source at or above `highVoltage {"volts", "source"}`, with no warning beside it), `noBoardName`, `noRevision`, `headerNotKeyed` and `headerFarFromEdge` for the debug and programming headers (found by their SWD, JTAG, UART, enable and reset nets, or named in `debugHeaders`), and `wearNoAccess` for a fan, electrolytic, fuse or battery that cannot come out without removing another part. Keying and tool clearance come from the part's data sheet in `fit`; a finding named `unknown...` means that number was not given and is not checked. ### Review the power layout `board.layoutReview {}` reads the board only; it changes nothing. Name each hot (commutation) or gate loop by its pads in order, `loops [{name, kind:"hot"|"gate", pads:["Q1.D",...], maxArea, maxLength, kelvin, source}]`, and it measures the loop's area (m²) and length (m) along the routed copper against your limits. A limit with no `source` is not invented: the loop is reported by its measured area instead. A gate loop must pass the switch's `kelvin` source pad. The same call checks the distance of `sense` nets from switch-node `aggressors`, the Kelvin routing of `shunts`, clearance by working voltage (`voltages`, IPC-2221B table 6-1 column B2), isolation `barriers`, track width for current and zone necks, thermal vias in each power pad against the data sheet's `minVias`, each `ties` ground pair joined at exactly one part, and return-path breaks over a gap in a `returnNets` plane. `passed` is true only when there are no findings. Each finding has its `rule`, `at`, `layer`, `value` against `limit` and `unit`, the limit's `source`, and `message` with `messageZh`. Fix the findings on the schematic or board, run it again, and read `notes` for what was not checked. ### Compare the circuit before and after layout Board › Compare Before and After Layout (`layout.compare {}`) runs the circuit twice: first without the routed board's stray inductances and capacitances, then with them put in (one undo step). The result window shows one table: each measure (efficiency at full and at half load, the loss in each part, each power loop's switch peak, overshoot and ring frequency, conducted and radiated EMI margin, the hottest case and junction, each board net's DC drop and the copper loss, each switch's gate overshoot, the spec) before and after layout, the difference, the limit it is held to and its verdict after layout. Above the table are the pass, fail and not-checked counts of each side and the measures that passed before and fail after. The efficiency limits (the half-load row only from a spec efficiency point at half the full-load current; every other spec efficiency point, at another load or input voltage, gets a row of its own, measured at that load and line on each side), the junction limit and the spec check come from the design spec stored with the circuit (`spec.set`, or the one Auto Design stored); with no stored spec those rows are not checked. Each part with a junction temperature on the board also gets its own row, held to its own rated junction limit (the part's `tjMax`, else its library device's data-sheet value), with or without a spec. The board's temperatures are solved at the spec's hottest ambient (its `ambient`, or the top of its range), where the spec check reads its junction row; with no ambient in the spec, at `board.thermal`'s default 40 °C. A measure with no limit is not checked, never a pass; Details says why. Copy gives the whole reply. The DC drop rows (a `.vxpcb` board only) are each current-carrying net's largest drop at a load after layout, held to its net class's `maxDrop`, and `copperLoss`, the board's I²R, which the simulated efficiency leaves out; before reads 0 (ideal wires). The gate rows are for a MOSFET at `level` dynamic: the peak gate-source voltage less `von`, held to the part's `vgsMax` less `von`: its own `vgsMax` param, else its library device's data-sheet `vgsMax` (without either the row is notChecked and says so). A second row per switch, `gateUndershoot.`, is the lowest gate-source voltage (the ring below the off level `voff`), held to the part's `vgsMin`, its own param, else its library device's data-sheet value. After is run on a scratch copy that adds the board's common-source inductance to the switch's `lcs` and the rest of its gate loop's inductance to its `lg` (the gate loop inductance, in series with the driver), so a fast gate drive that rings over `von` on the board shows here; the open circuit keeps its own `lcs` and `lg`. The radiated rows split the estimate. Before layout it assumes a 1 cm² hot loop and 10 pF from the switch node to the chassis; after layout it reads the board: each complete power loop at its own current, and each switch node's copper over a chassis or heat-sink fill. The differential-mode (loops) and common-mode (cable) margins are held to the limit line like the total. After layout, each loop's own field and each switch node's common-mode share get a row of their own, with no limit: they add up to the total, so the largest one is the place to shrink the loop or move the fill. The EMI rows follow the spec's `emi` block (`spec.set` or the `spec` you pass; emissions are not part of `spec.verify` itself): its `limit`, or `class` A or B as CISPR 32, is the conducted line, and a CISPR 32 class is also the radiated line (the radiated estimate has CISPR 32's lines only, so a CISPR 11 or CISPR 25 spec keeps it on class B and its Details say so). With `targetMarginDb` (or `marginDb`) the conducted row must reach that margin, shown as its limit; without one it passes at the line. To keep or send the comparison, pass its reply to `layout.compareReport {compare, path?, format?, lang?}`: it writes the same table, with the pass, fail and not-checked counts, the regressions, each row's reason, the warnings and notes and the schematic after layout, as one HTML page, Markdown or a PDF, in English or Traditional Chinese (`lang: "zh-Hant"`). It runs nothing again and adds no undo step, so the same reply gives the same report. In the app, **Export report…** above the result table does this: pick a file name, and its extension (`.html`, `.md` or `.pdf`) sets the format; the report is in the app's language. ### Plan the grounds and copper pours `board.groundPlan {}` proposes the ground strategy, the copper pours and the layer of each net from the circuit, and checks the plan with numbers. Run `board.autoPlace` first and, when the circuit has control parts, `schematic.splitGrounds`, so PGND and AGND exist. With one ground it plans a solid plane; with PGND and AGND it plans a PGND plane with an AGND island over the control parts, joined at one net tie (`strategy.kind` is `singlePlane` or `star`). The plane goes on the first inner layer, else the bottom. Power nets and the switching node pour on top, sized for each net's RMS current from the last simulation (IPC-2221 section 6.2, 10 K rise unless the rules say otherwise; `currents {net: amps}` adds or overrides nets), and sensed nets go on the far side of the plane. Without `"apply": true` nothing is written: the `checks` run on a copy with the plan added, so the numbers are there before you accept it. They report `planeSplit`, `returnPath`, `noTie` and `extraTie` (PGND and AGND must meet at exactly one footprint) and `pourCapacity` (the narrowest width of each pour's fill and the current it carries). With `"apply": true` the zones and the `PWR_A` net classes are added and the board file is written; applying twice adds nothing. Through-hole pads on a pour are listed in `reliefPads` for a thermal relief you set; no gap or spoke value is invented. IPC-2152 charts are not shipped, and `widthSource` says so. ### Board temperatures `board.thermal {}` turns the board's copper, vias, stack-up and outline into a grid of square cells (`cellSize`, default 10 mm) and solves the steady temperatures. Run `simulation.run {}` first: each part's loss of that run (`t0`, `t1` pick the window, default its second half) enters at the cell of the part's largest pad, or pass `losses [{part, lossW, rjc?, toAmbient?}]` to try a number without a run. Copper on each layer joins neighbouring cells (400 W/mK, the layer's thickness, else 35 µm per oz), the dielectric (`lambdaD`) and the vias (`viaPlatingOz`, `filledVias`) join the layers, and each cooled face (`cooled`: `both`, `top` or `bottom`) reaches `ambient` through `h`. A part's junction-to-case resistance is its library device's, and a heatsink on its thermal net is in parallel with the board. Read `parts` (`caseC` and `junctionC` for each part, `onBoard` false for one with no footprint, which keeps the circuit's own thermal path), `hottest`, `maxC` and `rises` (the temperature rise of every cell, per layer). The command changes nothing: edit copper, vias or a pour, then call it again to see the change. A layer with neither a thickness nor an oz weight, a dielectric with no thickness, or more than 250000 cells per layer is refused by name; Voltecx fills in no value. These are steady temperatures; for a startup or a pulse add `transient` (below). Add `transient: {tEnd, steps?, profile?, dielectricCv?}` to step the same grid in time from the ambient: the copper stores its heat (the planes and traces, and each via's barrel, half to each layer it joins), each loss is scaled by `profile` (`[[s, factor]]`, default 1), and `transient.parts` gives each part's `caseC` and `junctionC` at every time in `transient.times`, with `transient.peak` saying how hot and when. No laminate heat capacity is built in: pass `dielectricCv` from the laminate's data sheet, or the board warms faster than it would. To heat the board as the run itself did, set `transient.followRun: true` instead of a profile: each part's loss then follows its own loss waveform over the run's window (`t0`, `t1`; pass `t0: 0` for the startup), the mean over each step, the window repeating past its end, and `tEnd` defaults to one window. `transient.followRun.held` names any part whose loss has no waveform in the run; it is held at its mean. A part whose library device carries a junction-to-case Foster chain (its data sheet's transient thermal impedance Zth,jc), or a `losses` entry with `zthJc: [{r, tau}]` (then `rjc` defaults to the sum of `r`), has its junction follow that chain above its case, so a pulse shorter than the package's time constants no longer lifts the junction by the whole loss × Rjc at once; `transient.parts[].zthStages` says how many stages it followed. A part without a chain, or whose chain the CSV import made up from Rth,jc alone with an assumed 1 ms time constant (named in `transient.notes`), sits loss × Rjc above its case. The chain sits on top of the case node, which takes the whole loss at once. A track or plane neck that carries a large current heats the board by itself. Add `copperHeat: {nets: [...]}`, naming the nets as `board.irDrop` takes them (below), and each net's DC current is solved over its copper and every small cell's I²R loss goes in as heat on its own layer beside the parts' losses. Read `copperHeat.heatW`, the heat that goes in (the total, and per net in `copperHeat.nets`): it is the `heatW` `board.irDrop` gives for the same nets. A `{net}` whose loads come from the last run heats with their RMS current over the run's window, so an inductor's ripple counts; its loss at the mean current stays in `lossW`. A net whose loads you give heats at that DC loss. The copper's resistance is taken at `copperHeat.temperatureC`, the ambient unless you give a hotter one; it is not recomputed from the temperature found unless you add `copperHeat.coupled: true`. Then each cell's heat follows its own temperature, 1 + 0.393 % per kelvin at 20 °C (IEC 60028): the steady map is solved with the heat at the temperatures it finds, `copperHeat.coupledHeatW` gives that heat, and in a transient each step's heat is taken at the temperature the step starts from. The currents stay where the IR solve put them, so a hot cell sheds no current to cooler parallel copper (`board.irDrop`'s `thermal` re-solves the currents). If the copper makes heat faster with temperature than the board sheds it, the call is refused as thermal runaway: there is no steady temperature, and the transient stops when the copper passes 1000 °C, naming the time. With `transient.followRun`, each net named by `net` (its loads from the run) also follows the run: its copper heat in each step is its DC loss times the step's mean of the square of its loads' total current over the DC current squared, so a startup or an overload pulse heats the copper as it heats the parts, and the ripple counts by its RMS. `transient.followRun.copper` gives each net's `meanFactor`; a net whose loads you gave is held at its DC loss and says why. The same call then reports how hot each conductor of those nets runs, in `copperHeat.traces` and `copperHeat.vias`. Each track, arc and via shows its DC current (`currentA`) and two rises side by side. `ipc2221RiseK` is the IPC-2221 §6.2 conductor formula solved for that current, using the outer or inner constant for a track and treating a via as its plated barrel. It is flagged as IPC-2221 because IPC-2152's charts are not shipped. `offChart` marks a rise outside the formula's 10–100 K range. `boardRiseK` is the hottest board cell along the conductor on its own layer, so the parts' heat and the board's cooling are in it. `worstConductor` names the highest IPC-2221 rise. With `transient` in the same call, each conductor also gets `transientPeakRiseK` (and `transientPeakC`), the hottest its board cells get at any time of the transient, and `transientPeakAtS`, when that is first reached, so an overload pulse shows how hot a track ran even after it cooled. Add `transient.conductorRises: true` to get each conductor's whole curve too: `transientRiseK` holds its board rise at every time of `transient.times`, ready to plot a track's warm-up during a startup. A track shorter than one IR cell has no current; a smaller `copperHeat.cellSize` reads it. Leave `nets` out after a run, `copperHeat: {}`, and every board net the run puts current through heats the copper, chosen as `board.irDrop {}` chooses them; `copperHeat.skipped` lists the nets left out and why. In the Board window, **Board temperature** draws this map for the active layer with the copper's own heat in it: the nets the **Current density** overlay last solved (its `board.irDrop` request, grid and window), else every net the run puts current through. Under the scale it says how many watts of copper I²R heat went in and from how many nets, and the conductor with the worst IPC-2221 rise is outlined in red on the map. When no copper carries the run's current (nothing routed yet), the map shows the parts' heat alone and the line under the toolbar says why the copper's heat was left out. ### DC IR drop and current density `board.irDrop {nets: [...]}` solves the DC current of each power net you name over the board's copper and gives the voltage drop at every load pin, the current of every via and the current density of every cell. Name each net by its pins: `sources` (the pins that feed it, such as a regulator's output pad) and `loads`, each with the `currentA` it draws (from the design's operating point or the average current of a run). A net's tracks, arcs, pads, pours and vias become a grid of square cells (`cellSize`, default 0.5 mm); copper of other nets never joins it. Copper thickness comes from the stack-up (its finished thickness, else 35 µm per oz) and resistivity from IEC 60028 annealed copper at `temperatureC` (default 20 °C, rising 0.393 % per kelvin). Each pin is an equipotential terminal over its pad, and a through-hole pin joins all its layers. A via's barrel meets each layer's copper all round its hole, so the cells inside the hole are one node: with cells finer than the drill, a plane fed by a via spreads from the hole wall, as ρ/(2π t)·ln(r/r_hole) says. A pad on a thermal relief meets its pour only through the spokes that land, each a strip of the spoke's width across the gap, so a relief's drop reads true even with cells wider than its gap; keep `cellSize` at or under the spoke width for a drop within a cell over the length. After a simulation run, name a net by `net` instead: `board.irDrop {nets: [{net: "VOUT"}]}` takes its loads from the run. Every pad of a circuit part on the net draws that pin's mean current over the run's second half (`t0`/`t1` choose another window, given back as `window`), and a pin's current is split evenly over its pads on the net. The source is the pad that puts the most current in. When the current enters from a part with no footprint (a bench supply, a connector the circuit does not have), name that pad in `sources`. Each net says where its loads came from in `loadsFrom`. A load sees its supply's drop and the rise of its own ground. Add `returnNet` to a net (`{net: "VOUT", returnNet: "GND"}`, or with `sources` and `loads`) and the return is solved too, as one more entry of `nets` that names its supply in `returnOf`. Its reference is `returnSources`, else every pad on the return of the supply's source parts (a regulator's or connector's ground pad); a source with no pad there, an inductor say, needs `returnSources`. A net from the run takes the return's currents from the run as well, every part's return current included; with given `loads`, each load's current comes back through its part's pads on the return. Each load then gives `returnRiseV`, how far its ground pad sits above the reference, and `loopDropV`, the supply drop plus that rise: the load gets the source's voltage less `loopDropV`. `loopWorst` names the worst load, and `maxLoopDropV` sets `loopPass`. In the return's entry, `dropV` is that rise, positive where the current comes back. To check the whole board at once, leave `nets` out: `board.irDrop {}` solves every board net the last run puts current through, each the way `{net}` does, in name order (at most 64). A net with no pad that feeds it, nothing that draws from it, a pin the run did not record, or a load no copper reaches is left out and listed in `skipped` with why (`noFeeder`, `noLoad`, `noCurrent`, `solve`) in English and Traditional Chinese, instead of failing the call. Name such a net in `nets` with its `sources` to solve it. Copper that runs hot drops more. Add `thermal: {...}` (board.thermal's settings: `losses`, `ambient`, `h`, `cooled`, `cellSize`, `lambdaD`; leave `losses` out after a run to take the run's) and `board.irDrop` first solves the board's steady temperature with the parts' losses and these nets' own I²R heat, then solves the drop again with each cell's copper at the temperature found: a link takes the resistivity at the mean of its two cells' temperatures, a via at the mean of its two layers'. `temperatureC` then defaults to the ambient, and `temperatureFrom` says `thermal`. The reply's `thermal` lists in `nets` each net's worst drop and loss at the board's temperature beside the uniform `temperatureC` ones (`uniformDropV`, `uniformLossW`), and in `maxC` the hottest point. By default it is one pass: the heat is found with the copper at `temperatureC`, so a net whose copper runs much hotter than the ambient reads a little low. Set `thermal.passes` (1 to 20) to iterate: each further pass heats the copper at the temperature the pass before found, and the passes stop once the copper moves less than `thermal.tolK` (default 0.01 K). `thermal` then gives `passes`, each pass's largest temperature change in `changesK`, and `converged`. Each change is about the first pass's drop rise x₁ (drop over the ambient's, minus 1) times the one before, so the drop settles at the ambient's drop divided by 1 − x₁. When the change stops shrinking, the copper heats itself faster than the board sheds the heat: the passes stop, `runaway` is true and a note says so. Widen the copper or cool the board. To keep a limit with the board, set `maxDrop` (V) on the net class (`board.setNetClass {class: "Power", values: {maxDrop: 0.05}, nets: ["VOUT"]}`). `board.irDrop` uses it for a net that gives no `maxDropV` and says so in `maxDropFrom`. The design rule check then solves every net of such a class with the last run's currents, the same way, and reports a load pin past the limit as `irDrop` at its pad, with the drop and the limit in volts; `drops` lists each net it checked. Without a run, or for a net it cannot solve (nothing on the board feeds it), a note says IR drop was not checked. To hold the loop to a limit too, name the class's return and set `maxLoopDrop` (V): `board.setNetClass {class: "Power", values: {returnNet: "GND", maxLoopDrop: 0.08}}`. The design rule check then solves each net of the class with that return, as `returnNet` does above, and reports a load whose loop drop (its supply drop plus its ground pad's rise) is past the limit as `irLoopDrop` at its pad, in volts; `loops` lists each net it checked with its worst load and the return's reference. The reference is the supply's source parts' pads on the return, and when the source has none (an inductor feeding the output), the return pad that takes the most current out of it in the run, where its current goes home (`returnFrom: "run"`). `maxLoopDrop` needs a `returnNet`, and the return cannot be a net of the class. A class with no return, a load with no pad on the return, or a return that cannot be solved gets a note, not a pass. In the Board window, **Rules…** › **Net classes** shows both on each class's row: type the net in **Return net** and the limit in **Max loop drop (V)**, then press Enter. The limit needs the return net first, and the return net cannot be cleared while a limit is set. Read each net's `loads` (`dropV`, `dropMv`), `worst`, `pass` against the net's `maxDropV`, `vias` (busiest first; `rmsCurrentA` beside the mean `currentA`) and `maxDensityAPerMm2`. A net whose loads come from the last run also gives its RMS density over the run's window, ripple included: `maxRmsDensityAPerMm2` and `map[].rmsAPerMm2`. With `limitAPerMm2`, `hotSpots` lists the cells whose RMS density is over it, densest first, since a current-density limit is a heating limit; for loads you give, the RMS density is the mean one. No limit is built in, so take one from your design rule. The Board window's **Current density** button draws the last call's map on the active layer as RMS density in A/mm² (`rmsAPerMm2`, so a rippled net shows the density `hotSpots` judge), the cells over the limit outlined, and runs the same request again after each board edit. Over the copper it labels the vias that carry the most with their RMS current (up to 24, each carrying at least a tenth of the busiest one), and the scale names the busiest via's current, so a via array that shares its current unevenly shows at once. Beside it, **Voltage drop** draws the same map's `dropV` instead: how far each cell's copper is below its net's source, in mV, so the copper where the drop builds up shows at a glance. A copper layer with no thickness, a via through a dielectric with no thickness, or a load no copper reaches is refused by name. The per-cell losses (`map[].lossW`) are the copper's I²R heat. DC only. ### Near field The Board window's **Near field** button draws the magnetic near field of the board's hot loops under the copper: `emi.nearField` (chapter 6, *Near-field map of the board*) on the open project's board, at the first switching harmonic at or above 30 MHz (or the strongest of its lobe when that one is in a null of the spectrum) and 10 mm above the top copper unless the last request you ran says otherwise. The hot spots are ringed and numbered over the copper, strongest first, and the scale beside the board gives the frequency, the height, the strongest cell in dB(µA/m) and the loop that makes hot spot 1. Each cable connector of the board (the `cables[]` rows of `emi.nearField`, read from connector and terminal-block footprints) gets a square on its position and a label with its reference and the field over it in dB(µA/m), placed off the board where there is room; the scale names the connector with the strongest field and how far that is under the strongest cell, since a cable plugged in where the field is strong carries it off the board. Cells more than 40 dB under the strongest are left out, so the board stays readable where the field is low; that is a display choice, not a limit. The map is read again after each board edit, so moving a part or a track shows at once. Only one map of cells shows at a time: turning on **Near field** turns off the temperature and current-density maps, and the other way round. When the command cannot map the board (no routed board, or no complete hot loop with a known current), the window shows its reason instead of a map. It is an estimate to find which loop to fix, not a scan. ### Power devices on a shared heatsink `board.alignToHeatsink {heatsink, parts, pitch?, edge?, order?, holes?}` lines up TO-220 and TO-247 parts that share one heatsink: their tab holes go on the heatsink footprint's hole line at its hole pitch, in power-path order, with the leads pointing away from it. Place the heatsink's footprint first. The pitch is read off the footprint when it has evenly spaced holes; otherwise pass `pitch` from its data sheet, or the command refuses and says what is missing. `placed` gives each hole and rotation, and `misfits` lists the parts left where they were (locked, no tab hole, off the outline) with the reason. One undo step. Check the result with `board.layoutReview {heatsinks: [...]}`, which needs the heatsink's `potential` and the clearance under its body from the data sheet. ### Review comments `board.addComment {item, text}` (or `at: [x, y]`) pins a design-review comment to a board item (its id from `board.items`); `board.comments {open?, item?}` lists them and marks `orphaned` the ones whose item was deleted; `board.editComment {id, text?, resolved?}` and `board.removeComment {id}` change them. They are kept in a `.vxreview` file beside the board, so the board itself does not change. In the board window, the **Review comments** switch at the end of the side panel shows a numbered pin for each comment and their list. Write a comment, then press **Add Comment** to pin it to the one selected item, or **Pin to a Point** and click the board where it goes. ### Lock footprints `board.setLocked {refs, locked}` (or `ids`) locks or unlocks footprints. A locked footprint is not moved, turned, flipped or deleted, by the board commands or by `board.autoPlace`, so lock the connector or the part a mechanical drawing fixed before you place the rest. It is one undo step. ## 7. Compare two versions `board.diff {a, b}` compares two boards (each a path, `{path}` or `{text}`; with only `a`, it compares that file with the open project's board). Footprints are matched by their circuit part and everything else by its stable id, so a part placed again is one change, not a removal and an addition. Each row of `items` is `added`, `removed`, `moved` (with `delta` in metres, or a turn or flip) or `changed` (with the `.vxpcb` `fields` that differ), and names its `nets`. `board` lists stack-up, outline, rule and name changes. `nets.touched` are the nets whose copper changed: the ones to check again after a review. The `lines` are ready-made sentences in English and Traditional Chinese. The command changes nothing. `highlight.removedBoxes` gives where each removed item was on the old board (`bbox` in metres), so a view of the new board can mark the spot. In the board window, **Compare with a saved board** near the end of the side panel takes the path of another version of the board (a copy kept in git or a fab release). **Compare** boxes every change on the open board: green added, amber changed, blue moved, and a dashed red box where each removed item was. The changes are listed below it; click one to select its item and zoom onto it. **Hide** clears the boxes. ## 8. Fabrication files `board.exportFab {path, folder, maxError}` fills the zones and writes the fabrication set into `folder` (by default `fab` next to the board): - one Gerber X2 file per copper layer, and for both faces the solder mask, the paste and the legend. Every Gerber says it describes a single board (`.Part,Single`), that it shares the board's origin with the others (`.SameCoordinates,board`), and ends with its `.MD5` signature (Ucamco Gerber 2024.05, §5.6.2, §5.6.5, §5.6.9), so a file damaged on its way to the fab is found; the panel's files say `.Part,Array` and `.SameCoordinates,panel`, because their origin is the panel's. The pads of the circuit's test points (`testPoint` parts, open the circuit first) are marked `TestPad` on the outer copper (§5.6.10), so the fab's bare-board tester knows where to probe; inside the board a drilled test point's ring stays a component pad. An exposed (thermal) pad is marked `HeatsinkPad` instead of `SMDPad` (§5.6.10: thermal pads have their own function), while its thermal vias stay component pads: the exposed pads of `ic.place` packages and of `footprint.ipc7351` (a quad's `exposed` pad, the TI RGT0016C's pad 17) are marked for you, and in the footprint editor any surface pad takes `"heatsink": true`. A KiCad footprint or board whose pad carries KiCad's own mark, `(property pad_prop_heatsink)`, is read the same way, and the KiCad export writes the mark back. Nothing is guessed from a pad's size, so an older placed footprint stays `SMDPad` until it is placed again; - for each face whose fab layer has anything on it, the assembly drawing `-fab-top.gbr` or `-fab-bottom.gbr` (Gerber X2 file function `AssemblyDrawing`): the part outlines, texts and shown footprint fields on the fab layer, such as a KiCad part's Value. It is for the assembler and reviewer; nothing on it is printed on the board; - for each face with drawings on its adhesive layer (`F.Adhes`, `B.Adhes`, the glue dots of a KiCad board), the glue file `-glue-top.gbr` or `-glue-bottom.gbr` (Gerber X2 file function `Glue`, Gerber Layer Format Specification 2024.05 §5.6.3), for dispensing glue before soldering; - the board profile; - one Excellon drill file for each span and plating. The plated holes of a part whose fitting data says press-fit (`footprint.setInfo` `fit` with `mount: pressFit`, from its data sheet) are marked `ComponentDrill,PressFit`, and its Gerber X3 component entry has the mount type `Pressfit` (Gerber 2024.05 §5.6.10, §5.6.16), so the fab sizes those holes for pressed leads; without that data a part is never marked press-fit. A plated hole (a via or a pad's hole) that the board edge or a cut-out cuts through is a castellated hole, for soldering the board onto another: its drill tool is `CastellatedDrill` and its pads `CastellatedPad` on every copper layer (Gerber 2024.05 §5.6.10: "Plated holes cut- through by the board edge; used to join PCBs"). A hole the edge only touches is not one. The job file then says `"Castellated": true` (and `"Press-fit": true` for press-fit holes; Gerber Job Format 2020.08 §2.4); - the pick-and-place files for assembly: `-pos.csv` and JLCPCB's `-cpl.csv`, without parts not fitted, with each part's value from the open circuit. - the Gerber X3 component layers `-component-top.gbr` and `-component-bottom.gbr` for an assembler that reads them: for the same parts, each part's reference point, rotation, value, footprint, mount type (TH or SMD), maker and part number, the footprint's library, the LCSC number as the supplier part when the footprint's `LCSC` field gives one (a KiCad part's), its body height in mm when its library footprint gives a cited height (Footprint editor, or `footprint.setInfo`) or the parts catalogue knows its package body (left out otherwise, never guessed), its courtyard outline and a mark at each pin with its net and the port it joins (the pin function, which the Gerber specification asks for beside the pin number), pin 1 (or A1) marked with a diamond. The pads of the outer copper layers carry the same pin number and port. A bottom part's rotation is counted from the top zero flipped about x, as the Gerber specification asks, so it is the position file's rotation plus 180°. - the bill of materials: `-bom.csv` and JLCPCB's `-bom-jlcpcb.csv`, one line per value, package and part number, for the same parts. The part number comes from the part's catalogue part, its device or the IC part it was placed as; the notes name the lines that have none. - the stack-up drawing `-stackup.svg` for the fabricator: each layer from top to bottom with its copper number, kind, thickness, copper weight, Dk and material (not to scale), and the finished thickness. A value the stack-up does not hold is written as "not given" and the total as unknown, and the notes say so: set the values from your fabricator's stack-up (`board.setStackup`) or agree them in the order. - the Gerber job file `.gbrjob` (Ucamco Gerber Job Format), which a fabricator's software reads for the quote and the set-up: the board size, the copper layer count, the board thickness, the material stack-up from top to bottom with each dielectric's thickness, Dk, loss tangent and material, the outer and inner design rules (minimum clearance, track width, annular ring and edge clearance), and the layer of every Gerber and drill file. Only what the board holds is written: a thickness or rule you have not set is left out, never filled with a default. Copper is given its finished thickness as a note, because the job file's copper thickness is the foil before plating. `layout.extract` reads the whole set back through this file (`path` to the `.gbrjob`) once the stack-up gives every dielectric thickness. - the project and revision in every file: once the board has a project GUID (`board.setTitle {"projectGuid": "new"}` makes a random RFC 4122 version 4 one; give the project its GUID once and keep it for every revision), each Gerber and drill file carries `.ProjectId,,,` in its header and the job file `GeneralSpecs.ProjectId` (Ucamco Gerber 2024.05 §5.6.8, XNC 2021.11 §4.1, Gerber Job Format 2020.08 §2.4), so the fab can check that every file it was sent belongs to the same revision. Raise the revision with `board.setTitle` for each build. Without a GUID nothing is written: only the project's owner can name it. The job file leaves it out when the name or revision holds a comma, which its strings may not. - the finished-hole tolerance: `board.setDrillTolerance {"plated": {"plus": 7.5e-5, "minus": 7.5e-5}, "nonPlated": {...}}` records how far a finished hole may come out larger and smaller than drawn, for the plated and the unplated holes, as your fab gives it (nothing is built in). Each drill file then carries it on every tool as `.DrillTolerance,,` in mm (Ucamco Gerber 2024.05 §5.6.11, XNC 2021.11 §4.1), and `board.fabNotes` lists it. A mixed panel's drill file carries it only when every board gives the same one. - `-fab.zip`, the one file to upload to the fabricator: every Gerber and drill file the job file names, the job file and the stack-up drawing, byte for byte the files beside it (ZIP, deflated, no folders). The position files and BOMs are left out; they go to the assembler. A board with no outline is refused, because the profile is required; draw one rather than expecting a default. The reply's `notes` list text items that are not drawn yet, and its `upload` line says which files go to the fabricator and which to the assembler. The board is not changed. `board.fabNotes {path}` reads the drill table and fabrication notes off the board; `board.writeFabNotes {path, folder}` writes them into the same folder as `-drill-table.csv` (each hole size, slot, plating, span and use with its count and symbol, and the total) and `-fab-notes.txt` (the notes numbered, then what the board does not hold under "To give in the order": a layer thickness or rule it lacks, and always the surface finish, solder mask colour and acceptance class). Nothing is filled in for you. When the board has holes it also writes the drill map `-drill-map.gbr` (Gerber X2 file function `Drillmap`): the outline, every hole at its finished size and place with its drill-table symbol beside it, and the drill table as a legend right of the board. Its letters are `textHeight` and `textWidth` tall and thick when you give them, else the board's silk reference designator size, else its tallest silk text; when the board has none, no map is written and the reply's `drillMap.why` says so. With an outline and the same text size it also writes the fabrication drawing `-fab-drawing.gbr` (Gerber X2 file function `FabricationDrawing`): the outline with its overall width and height as dimension lines, and right of it the stack-up from top to bottom (thickness, copper weight, Dk and material, "not given" where the board has none), the finished thickness, the numbered notes and the values to give in the order; without a text size the reply's `fabDrawing.why` says so. The map and the drawing are for people: the drill files stay the holes the fabricator drills, and `board.checkFab` lists both without checking them. `board.picture {side, assembly: true, image, svg}` draws the assembly drawing for the pick-and-place and rework stations: the pads of one face with the silkscreen (reference designators and polarity marks), the fab and courtyard outlines, the holes and the board edge, and no tracks, pours, vias or far-face copper. Run it once for `top` and once for `bottom`; the bottom is mirrored, as the turned-over board reads. `image` writes a PNG, `svg` an SVG in millimetres. Under the board a parts table lists each part on that face (reference, value, footprint, position and rotation in board coordinates, DNP marked), sorted by reference. The value is the open circuit's, as in the position file; a part that is on no circuit part reads `-`, and with no circuit open the table has no value column. ### Panels `board.panelise {columns, rows, gap, rails, breakaway, fiducials?, tooling?}` steps the board into a fabrication panel and returns each copy's `offset`, the milled `outline`, `vScores`, `tabs`, `mouseBites`, `fiducials` and `toolingHoles` in metres. `breakaway` is `"vScore"` (with `gap` 0) or `{kind: "tabs", width, perEdge, bites?: {diameter, pitch}}`. Every size comes from the fabricator's panel rules or from you. V-score needs a rectangular outline. Tabs take any outline, round corners included: the copies are stepped by the outline's bounding box and the milling follows the real edge. A tab that would land on a round corner or a notch is refused, naming its side and number; use fewer or narrower tabs. Any other refusal names the size at fault. The command changes nothing. To put several different boards in one panel, pass `designs: [{path, count}]` (up to 32 `.vxpcb` files) instead of `path`. The boards fill the grid row by row from the bottom left in the order given, the cells left over stay solid, and every cell is as large as the largest design; each copy in `boards` names its `design`. V-score needs every design to be a rectangle of the same size. With tabs, each board sits in its own milled ring `gap` wide, with tabs on every edge that is not the panel edge and mouse bites on the board end of each tab, and neighbouring rings are kept a solid `web` apart (by default as wide as the gap). `board.exportPanelFab` takes the same `designs` and `web`; with several designs `boardLayers` writes one file per layer holding every design's copies, and every design needs the same number of copper layers. `board.exportPanelFab {folder, boardLayers, maxError, textHeight, textWidth, ...the panel of board.panelise}` writes the files the panel adds: `-panel-profile.gbr` (the material left after milling, the board cut-outs as holes), the rails' fiducials as copper and solder-mask openings on both faces, `-panel-vcut.gbr` with every V-score line drawn right across the panel (Gerber file function `Vcut`; only for a V-scored panel), and `-panel-NPTH.drl` with the tooling holes and mouse bites. Their tools say which is which: `MechanicalDrill,Tooling` for the tooling holes that hold the panel while it is made and `MechanicalDrill,Breakout` for the mouse bites (Gerber 2024.05 §5.6.10), so the fab's CAM does not take a mouse bite for a mounting hole. It also writes `-panel-drawing.gbr`, the array drawing (Gerber file function `ArrayDrawing`, Gerber 2024.05 §5.6.3) for the people who make and assemble the panel: the panel profile, every copy's outline labelled with its row and column (and its design in a mixed panel), the V-score lines, fiducials, tooling holes and mouse bites at their place and size, and a legend with the panel size, the grid, the designs and the hole counts and sizes. Its letters and lines take `textHeight` and `textWidth`, else the first board's silk reference size, else its tallest silk text; with none of them it is not written and `arrayDrawing.why` says what to give. The drawing adds nothing to the data files: the profile, V-cut and drill files stay the panel. Tabs are material, so the panel profile holds them. With `boardLayers: true` it also writes every copper, mask, paste, legend and coat Gerber and the drills of the board, with all copies at their panel offsets, the circuit's test points are `TestPad` on the outer copper of every copy, and the plated holes of a part whose fitting data says press-fit (`footprint.setInfo` `fit`, or its catalogue row) are `ComponentDrill,PressFit` in the drills of every copy (Gerber 2024.05 §5.6.10), as in `board.exportFab` (in a mixed panel only on the open project's board, since another design's parts are not this circuit's); the board's own profile is left out because the panel profile replaces it. The rails' fiducials then go on the board's own outer copper and solder-mask files, and the tooling holes and mouse bites into its unplated through drill file, so the set has one file per layer and reads back as one board (no separate `-panel-fid-*` or `-panel-NPTH.drl`). Without it, send the set of `board.exportFab` beside these files and give the fabricator the step and repeat from `board.panelise`. No Gerber job file is written for the panel: the Gerber Job Format describes one board and leaves panels out (Ucamco, Gerber Job Format 2020.08, §2.1), so send the board's own `.gbrjob` from `board.exportFab`, which gives the board size, layer count and stack-up; the notes say so. The board file is unchanged. ### 3D view and STEP `board.view3d {}` builds the board in 3D from its own data: every stack-up layer as thick as the stack-up says (a copper layer with no finished thickness takes its copper weight at 35 µm per ounce, TI AN-2020; a layer with neither stops the command and is named), the outer copper, the plated holes, the silk, and the solder mask as the mask rules draw it (`board.setRule` `maskExpansion`, `minMaskWeb`, `viaMask`, or a class's or a pad's own): copper inside an opening is bare and the rest lies under the mask. With no mask rule a pad's opening is at copper size and a via is tented, and `mask` in the reply counts both. Each part gets its KiCad 3D model from `modelDir` (or the `KICAD8_3DMODEL_DIR` KiCad sets), else the box or can of its package's data-sheet outline when the catalogue has one (an outline read for one part number, such as the half-bridge's 22 x 30 mm snap-in can, is drawn only for a part with that `part` number, since the same footprint carries taller cans); any other part has no body and `parts` says why. Voltecx never guesses a body. `image` draws a PNG; in the app, **Board > 3D View** shows it live (chapter 13). `board.exportStep {out}` writes the assembled board as a STEP file (AP214, closed faceted solids in metres, z up from the board's bottom face) for an enclosure or a mechanical CAD tool: the laminate with its holes, each face's copper as thick as its layer, and each fitted part's KiCad STEP model (the `.step` KiCad ships beside the `.wrl`) or its cited package body. The mask and the silk have no thickness, so they have no solid. `maxError` (default 10 µm) sets how closely the round edges are followed. The reply gives `solids`, `bounds` and each part's status. ## 9. Review comments, cut-outs, alignment and KiCad round trips ### Design-review comments `board.addComment {item | at, text, author}` pins a comment to a board item (its stable id, from `board.items`) or to a point `at` in metres; one of the two is required. Comments are written to a review file beside the board (`.vxreview`), and the board itself is not changed. `board.comments {open, item}` lists them in the order they were added (`open: true` only the unresolved, `false` only the resolved); `target` names the item each is pinned to, and `orphaned` marks a comment whose item has since been deleted. `board.editComment {id, text, resolved}` changes the text or marks a comment resolved or open again, and `board.removeComment {id}` deletes it. ### Cut-outs and slots `board.addCutout {polygon | slot}` cuts a hole through the board. `polygon` takes vertices as `board.setOutline` does; `slot {from, to, width}` is a milled slot, the stadium that a bit of `width` cuts from centre `from` to centre `to` (`from` equal to `to` drills a round hole of that diameter). The cut-out must lie wholly inside the outline and meet no other cut-out; copper or holes inside it are refused, and each is named. It goes on the profile Gerber, and the edge clearance check and the zone fill keep away from it. `notes` compare a slot's width with the slot-width rules, with their source. `board.removeCutout {index}` removes one (the indices are in `board.get`'s `outline.cutouts`). Each is one `board.undo` step; `board.redo` does a taken-back edit again. ### Text, alignment and heatsinks `board.addText {layer, at, text, height, strokeWidth}` puts a line of text on a silk, fabrication, mask or copper layer, drawn in the stroke font; text on a bottom layer is mirrored so it reads from below. `missing` lists characters the font has no glyph for (for example CJK): they are left out of every output, never replaced. `board.align {ids | refs, edge}` lines up two or more items by their boxes (`left`, `right`, `top`, `bottom`, `centreX`, `centreY`, or `distributeX` and `distributeY` for equal gaps); items only move, and a locked footprint is refused. `board.alignToHeatsink {heatsink, parts}` turns and moves through-hole switches so each tab hole sits on the heatsink footprint's device-hole line. The pitch comes from the footprint's holes, else from `pitch`, else the command says what is missing; nothing is assumed. Parts that cannot be placed stay where they are and are listed in `misfits`. ### Check a fabrication set `board.checkFab {folder, fab}` compares the files `board.exportFab` wrote with the board before you order: one copper file per layer, the profile, masks, paste, drill files whose hole count and sizes match, and, when present, the position file and BOM. A Gerber whose contents no longer match its `.MD5` signature was changed or damaged after it was written: that is the error `md5-mismatch`, and the fix is to export again. The upload archive `-fab.zip` must match the files beside it: an entry that differs from its file (`archive-stale`), a layer, drill or job file it lacks (`archive-missing`) or an archive that does not read (`archive-unreadable`) is an error, fixed by exporting again; an entry with no file beside it is the warning `archive-extra`. The board's own rule check must pass as well. With `fab` (`jlcpcb-2layer`, `pcbway-standard`, ...) its published limits are measured too, including its legend: silk text lower than the smallest character height the fab prints legibly, or drawn with a thinner stroke, is a warning (`legend-height`, `legend-width`). `pass` is true when there is no error, and the summary says "ready to order" only then; each finding is an error, warning or note with a code and, where it has one, a position in millimetres. When the board has a project GUID (`board.setTitle`), each file's `.ProjectId` must name the board's project and revision: files of another project (`project-other`) or of an older revision (`project-revision`) are errors, so after raising the revision export the set again; files under another name (`project-name`) or with no `.ProjectId` (`project-unnamed`) warn. `board.reviewFab {folder, atMm, radiusMm}` instead loads any fabrication set, including one someone else designed, and lists each file's extent, apertures, nets and drill tools, and the project, GUID and revision its `.ProjectId` names; when the files name different projects or revisions, or some carry none beside others that do, its `warnings` name them, since such a set may mix two builds; with `atMm` it lists what lies under that point. In the board window, the side panel's **Fab set to review** draws such a set over the board: type its folder (relative to the project) and press **Load fab set**; each Gerber file is a see-through colour and the drill files are drawn on top, each switched on or off by its name, and the Measure tool reads distances on it. With **Probe the set** on, a click on the board lists what of the set lies there instead of selecting: each file's flashes, draws, regions and holes, with their nets, functions and sizes. Both commands only read. ### KiCad boards `board.openKicad {kicad, path, replace}` reads a `.kicad_pcb` (KiCad 6 to 10) as a Voltecx board with layers, nets, footprints, tracks, vias, zones, keep-outs and the outline; each item keeps the id of its KiCad uuid. Cut-outs of zones, keep-outs, drawn polygons and custom pads come across both ways. An outline edge drawn as a Bézier curve (`gr_curve`) reads as short straight segments within 1 µm of the curve and is written back as part of the outline polygon; a curve on a silk, fab, copper or other board layer, or in a footprint (`fp_curve`), reads as short straight lines of its width within 1 µm of the curve, and is written back as those lines. A text box (`gr_text_box`, or `fp_text_box` in a footprint, where the texts and border belong to the footprint) reads as one text per line, each where KiCad draws it in the box, plus its border as an outlined polygon of the border's width, and is written back as those texts and that polygon; KiCad also breaks a line too long for its box at a space by its own letter widths, so such a line reads unbroken and `warnings` names it. A dimension (`dimension`) that is aligned, orthogonal or a centre mark reads as the lines KiCad draws for it (extension lines, crossbar and arrows, or the cross), each of the dimension's line width, plus its text where KiCad draws it, and is written back as those lines and that text, no longer tied to what it measures. A dimension in a footprint reads the same way, its lines and text belonging to the footprint. A dimension's text that KiCad places itself (outside the crossbar and turned with it) reads where KiCad puts it on open, even when the file holds an older place, as it does for a footprint flipped in KiCad. A leader or radial dimension is left out, and an aligned or orthogonal one with its text on its crossbar reads with the crossbar whole where KiCad breaks it round the text; both end at a box KiCad takes from its own font, and `warnings` names them. A layer alignment target (`target`, a plus or an x) reads as the circle and the two lines KiCad draws for it, each of the target's line width, and is written back as that circle and those lines. A zone or keep-out inside a footprint reads as a zone or keep-out of the board, where KiCad has it, and is written back as a board zone; the board model has no zone of a footprint, so it no longer moves with the footprint, and `warnings` names each one. A reference image (`image`, a PNG on a layer at a scale) is kept with the board and written back as KiCad saves one; like KiCad, Voltecx draws no image into the Gerbers or other outputs. An image inside a footprint reads as an image of the board, where KiCad has it (KiCad does not turn an image with its footprint), and is written back as a board image; it no longer moves with the footprint, and `warnings` names each one. An image on the outline layer is left out and `warnings` names it. A group (`group`) reads into the board's groups with its name, its lock, its items and the groups inside it, and is written back the same way. A dimension in a group puts all its lines and its text in it; a member the board does not hold as an item (a line of the outline) leaves the group and is named in `warnings`; and an item two groups list goes to the later one, as KiCad loads it. A custom pad reads as its anchor joined with the copper of all its primitives, as KiCad merges them: a filled polygon, rectangle or circle grown by half its line width, and a line, arc, Bézier curve or outline (a rectangle, circle or polygon that is not filled; a circle's is a ring) as its stroke of that width with round ends, curves as short straight segments within 1 µm. It is written back as one filled polygon. A primitive that draws no copper (a line of no width) or cannot be read, or copper in separate pieces (only the largest is kept), is listed in `warnings`. A chamfered pad and a trapezoid pad read as a polygon pad of the outline KiCad draws (round corners as short straight segments within 1 µm of the arc), and are written back as KiCad custom pads of that outline. So do footprint texts: the reference designator is KiCad's Reference field, at the place, size and angle of the part's silk reference text, and a footprint's own texts are KiCad user texts. A text KiCad keeps upright reads at the angle KiCad draws it. Drawings and texts on the user layers (`Dwgs.User`, `Cmts.User`, `Eco1.User`, `Eco2.User`, `User.1` to `User.9`), on the board or in a footprint, are kept on their layer and written back on it; no Voltecx output draws them. The same holds for the `Margin` layer. Drawings and texts on the adhesive layers (`F.Adhes`, `B.Adhes`: the glue dots that hold a part for wave soldering) are kept on their face, go to the other face with a part flipped to the bottom, and are written back on their layer; `board.exportFab` writes them as the glue file of their face (`-glue-top.gbr`, `-glue-bottom.gbr`). A filled circle on any layer (a glue dot, a silk dot) reads as the disc KiCad fills and is written back as a circle line that covers the same disc. A knocked-out text (`(layer .. knockout)`, letters cleared from a filled box), on the board or in a footprint, keeps its knock-out and is written back knocked out; Voltecx draws it and makes its outputs as plain letters for now, and `warnings` says so for each one. A footprint's own text that KiCad hides (`hide`, or `(hide yes)`) is kept with the footprint where it was, drawn and checked by nothing in Voltecx, and written back hidden. The coating keep-outs are written on `Eco1.User` (top) and `Eco2.User` (bottom), which the layer table then names `F.Coating` and `B.Coating`, so they open again as keep-outs, also after KiCad has saved the board. What the board model cannot carry (a footprint's value text) is listed in `warnings`. `board.saveKicad {kicad, path, replace}` writes a KiCad 8 board the same way. KiCad keeps a board's design rules in the project file, so `board.saveKicad` also writes them into the `.kicad_pro` of the same name beside the board, and `board.openKicad` reads them back from there (`rules` says what it read): the board minimums (clearance, track width, through-hole drill, via annular ring, hole-to-hole, copper-to-edge) and each net class's clearance, track width and via size, with the nets assigned to it. A project already there keeps its other settings; a file there that is not a KiCad project is left alone and `warnings` says so. A class value left unset takes the Default class's value when it comes back, as KiCad reads it. Rules the project file has no key for (via plating, temperature rise, mask and paste rules, a class's other values) are named in `warnings`. The gallery buck and half bridge, laid out by the board bar, come back from KiCad with every item and the same DRC result. To refresh a board KiCad has already edited, use `pcb.syncBoard` with `toKicad`, which keeps KiCad's own fields. Neither command changes the circuit. ### KiCad libraries `footprint.importKicad {from, licence, folder, names, overwrite}` brings a KiCad footprint library (a `Lib.pretty` folder) or one `.kicad_mod` file into the project's `footprints/` library. Each footprint keeps the library's licence text unchanged (`licence` is the text or `{path}` of the file that holds it) and names the file it came from. With no licence the reply warns, so find and record it before you ship a board made with those footprints. A file that fails to read is listed and the others still come in; items the reader leaves out are listed per footprint in `skipped`, and a trapezoid pad fails that footprint naming the pad. Pads at any angle come in turned, and a chamfered pad (KiCad's chamfered rectangle, with square or rounded other corners) comes in as a polygon pad of the same outline, its rounded corners drawn as short straight segments within 1 µm of the arc. A custom pad comes in as one polygon pad: its anchor (rectangle or disc) joined with its filled polygon primitives, a primitive with a width grown by half that width. A custom pad whose pieces don't touch, or with hollow polygons, lines, arcs, circles or rectangles among its primitives, fails, naming the pad. Run `footprint.check` on them before placing. Existing footprints are kept unless `overwrite` is true. `symbol.importKicad {path|text, names, prefix, licence}` adds the part symbols of a `.kicad_sym` library to the project as user symbols: a box with the visible pins, named like the KiCad pins and numbered like the footprint's pads, placed by electrical type. Hidden pins and power flag symbols are left out, a symbol whose name already exists is kept (`kept`), and the whole import is one undo step. An imported symbol binds to no model until `symbol.bind`. A symbol with several units (a dual op-amp, or a relay's coil and contacts) comes in as one box holding every unit's pins, each pad number once (`units` in the reply). A De Morgan alternate body style is not drawn, and its pins add nothing to the box. A derived symbol (KiCad's `extends`) comes in with its parent's pins and its own properties, falling back to the parent's Reference, Value, Footprint and Datasheet where it leaves them empty. Alternate pin functions (a microcontroller pin's other roles) are counted in the reply (`alternates`) but not drawn. A library KiCad itself would refuse to open is refused with the reason: a unit symbol not named after its symbol, an unknown pin type or style, or a parent that is missing or comes later in the file. Each imported symbol keeps the library and symbol it came from (`source`) and the library's licence text unchanged (`licence`, the text or `{path}` of the file that holds it; `symbol.get` shows both). With no licence the reply warns, so find and record it before you ship a design drawn with those symbols. `library.importKicadTable` passes its `licence` and `licences` to symbol rows as it does to footprint rows. ## Limits - The stack-up values, the via plating and the fabricator's capabilities are yours to supply. Voltecx ships none it has not read from a cited page. - Auto-routing is a first pass for review, not a finished layout, and it leaves out the special nets listed in section 4. - If you keep working in KiCad, `file.exportKicad` writes a schematic, a project file and a rules file from the circuit, and places the footprints in a saved `.kicad_pcb` given as `board`; `pcb.sync` keeps that project in step. See chapter 9. --- # 23. Code generation and FMU export URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/23-codegen-hil-fmu/ A simulated controller is only half done until it runs as firmware against the power stage. Voltecx takes it there in three steps, each a command you can run from the **Tools** menu, the command line, Python or a script: it writes the controller as C for a microcontroller, runs that firmware against a fixed-step model of the power stage on this computer (processor-in-the-loop), and exports the power stage itself, as C for a real-time rig, as Verilog for an FPGA's solve, or as an FMU for a system tool. This chapter walks one shipped example through all of them, from the command line, and says what each step checks and what it does not. [Chapter 13](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/13-tools-menu/#code-generation) is the reference: every parameter, the microcontroller targets register by register, and how each export was checked. Every number below is from a run of version 0.9.0 on a Linux computer with `cc` (GCC); your runs on another computer can differ in the last digits. ## 1. The commands List them with `powercraft-cli commands --filter codegen` (and `--filter hil`, `--filter realtime`, `--filter Fmu`). | Command | Menu | What it does | |---|---|---| | `tools.codeGeneration` | **Tools › Code Generation** | Returns the controller's C files (`.h`, `.c`, and the target's files). | | `file.exportCode` | | Writes the same files, and `_map.json`, into a folder. | | `codegen.ranges` | | Says, before any run, which values may saturate in fixed point and which divisions may divide by zero. | | `codegen.verify` | | Compiles the code with this computer's C compiler and runs it on the model's inputs, sample by sample. | | `codegen.closedLoop` | **Tools › Generated Code in the Loop** | Runs the compiled code in place of the control blocks, in a closed loop with the circuit. | | `codegen.evidence` | | Writes the code, runs the checks above and writes one `_evidence.json` for a review. | | `codegen.diff` | | Compares the code generated for two versions of a circuit: which blocks, fields, files and options changed. | | `codegen.misra` | | Checks the generated C against MISRA C:2012 with cppcheck's MISRA addon and marks each finding against the published deviation list. | | `codegen.isrCycles` | | Counts the interrupt's cycles in a Cortex-M4 build listing. | | `codegen.pil` | **Tools › Processor-in-the-Loop** | Runs the microcontroller firmware against the real-time model of the plant and compares with the circuit's own run. | | `tools.realtimeModel` | | Turns the power stage into fixed-step C (`pc_plant.h`, `pc_plant.c`) and, with `check`, compares it with the reference solver. | | `file.exportRealtimeModel` | | Writes the real-time model into a folder. | | `file.exportFmu` | | Packs the real-time model as an FMI 2.0 or 3.0 co-simulation FMU. | The commands that write files need a folder you allow: in the app, the folder you choose; on the command line, `--root DIR`, and every path is then inside `DIR`. None of these commands edits the circuit. ## 2. Generate the controller's C code Open **File › Open Example** and pick `buckClosedLoop`: a 48 V to 12 V buck at 100 kHz whose output is regulated by a sampled PI controller (`Ref`, `Err` and `PI`, run every 10 µs). The same from the command line: ```sh powercraft-cli run --root w \ --cmd file.openExample --param name=buckClosedLoop \ --cmd file.exportCode --params '{"dir":"ctl","target":"stm32g474"}' ``` This first attempt fails, on purpose: ```text error: file.exportCode: the reference `Ref` of `Err` is 12, above the 3.3 the ADC reads for `vout` at its full scale: set `fullScale` to the range of the board's sense network, or scale the feedback in the circuit ``` The circuit compares the output voltage itself with 12 V, but a microcontroller's ADC reads at most 3.3 V. `fullScale` says what value the ADC's code 4095 stands for, that is, the range of the board's sense divider. With `"fullScale": 20` the export succeeds and `w/ctl` holds seven files: | File | What it is | |---|---| | `pc_control.h`, `pc_control.c` | The controller: `pc_control_init`, `pc_control_reset` and `pc_control_step`, C99, no `malloc`, no globals. | | `pc_control_stm32g474.h`, `_init.c`, `_isr.c` | TIM1 at 100 kHz (period 1699 counts at 170 MHz), ADC1 triggered by TIM1, and the ADC interrupt that runs `pc_control_step` and writes the duty into `TIM1_CCR1`. | | `pc_control_params.csv` | The tunable gains: `PI_kp` = 0.01 and `PI_ki_half_t` = 2e-4 (Ki·T/2, from the Tustin method). | | `pc_control_map.json` | Which field of the code belongs to which block and which circuit signal, and the hash of every file written. | The reply lists what was generated (`supported`: `Ref`, `Err`, `PI`), what was not and why (`unsupported`, empty here), how each continuous block was discretized (`discretized`: `PI` by `tustin`), and the register values (`mcu`). Leave out `target` (or give `portable`) for the two portable files alone, or give `f28379d` for TI's F28379D and a Code Composer Studio project ([chapter 13](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/13-tools-menu/#microcontroller-targets)). ### Check fixed point before you run On a microcontroller without a floating-point unit you want fixed point, and fixed point can overflow. `codegen.ranges` finds where before any run: ```sh --cmd codegen.ranges --params '{"precision":"q15","fullScale":20}' ``` `q15` chooses a 16-bit word with the fewest integer bits that hold every constant, here `q4.11`, which holds −16 to 15.9995. The reply has one finding: the input `vout` may reach 20, so it `saturates`. A wider integer part, `q5.10`, removes the finding (`saturates` 0), but [`codegen.verify`](#check-the-code-against-the-model) then refuses it for another reason: ```text the fixed-point format cannot hold the constant 2e-4 rounds to 0 ``` With 10 fraction bits the smallest step is about 1e-3, so the integral gain becomes 0 and the loop would never remove its error. This controller needs `float` (the default) or `double`. `codegen.ranges` is sound for overflow (a value it does not list cannot leave its range), but it does not judge resolution: that is what the run below is for. ### Check the code against the model `codegen.verify` compiles the generated code with this computer's C compiler and runs it on the inputs the model's own simulation gave it, sample by sample. On `buckClosedLoop` in `float` it runs 1001 samples, and the largest difference of `duty` from the model is 1.7e-7, under the tolerance of 1e-4: `pass` is true. A failure says where the code first leaves the tolerance, for example `` signal `duty` first leaves the tolerance … at sample 6 ``. `codegen.closedLoop` (**Tools › Generated Code in the Loop**) goes one step further: it replaces `Ref`, `Err` and `PI` with the compiled code and simulates the circuit in a closed loop for the circuit's end time (10 ms, 100 000 samples here), with a step of the load and of the input voltage at 5 ms. The output means are 11.447 V with the code and 11.432 V with the model blocks, a relative RMS difference of 0.36 %, under the 0.5 % tolerance. Both commands also report `coverage`: which decisions of each block the run took. Here the PI limiter never reached either limit (`missed`: `below`, `above`), so the run says nothing about the anti-windup. The outputs a back-to-back test compares do not show what happens inside the code. `codegen.verify` takes `contracts` for that: bounds on what a generated block writes, such as `"contracts":[{"block":"PI","min":0,"max":0.9},{"block":"Err","max":5,"from":"2m"}]`. Every signal the block writes must stay finite and within the bounds at every call (from `from` to `to`, when given), observed inside the generated program on the test's inputs. A broken contract fails the call and names the block, the sample and the value; `contracts.results` also gives the lowest and highest value each block wrote, which shows how close an integrator came to its clamp. `codegen.evidence {"dir":"review","target":"stm32g474","fullScale":20}` writes the code again, checks that a second generation gives the same files, runs both checks and writes `pc_control_evidence.json`, with `status` `passed`. Keep it with the firmware's sources: it ties them to the circuit's hash and the Voltecx version. To trace requirements, give `codegen.verify`'s `expect` with a `requirement` ID and `blocks` on each assertion, and `requirements` for ones checked by inspection, e.g. `"requirements":[{"id":"SRS-4","blocks":["PI"]}]` (`file.exportCode` takes it too). The map then names the requirements each block serves, and the bundle lists each requirement's verdict on the model and the code and the generated blocks no requirement covers. `codegen.diff {"from":"old/pc_control_map.json"}` compares the code the open circuit generates now with an earlier `_map.json` (from `file.exportCode` or `codegen.evidence`). It lists the blocks added, removed or changed, the inputs and outputs fields, and each file's size and hash, so a reviewer sees which part of the firmware an edit touched before reading the C. When the old map traces requirements, the new code keeps its links (or give `requirements` again), and `requirements` in the reply names the requirements an edit touched (a block of theirs added, removed or changed), the ones it left alone, whose earlier verdicts still stand, and the changed blocks no requirement covers. It changes nothing. `codegen.misra` takes the same params as `tools.codeGeneration`, generates the code and runs cppcheck's MISRA C:2012 addon on it, when this computer has cppcheck 2.x (`CPPCHECK` names another binary). Each finding is reported by rule number, file and line, and marked against the deviation list in [`docs/workflows/misra-deviations.md`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/workflows/misra-deviations/). `status` is `passed`, `failed` (`violations` counts the findings that no deviation covers) or `skipped` when cppcheck or its addon is missing; a skipped check is never a pass. It is a check by an open-source tool, not a certification, and the rule texts belong to your licensed copy of the standard. It changes nothing. ## 3. Run the firmware against the plant (processor-in-the-loop) `codegen.pil` (**Tools › Processor-in-the-Loop**) compiles the firmware written for the `stm32g474` (or with `"target":"f28379d"` the F28379D) together with the real-time model of the power stage into one program on this computer. A stand-in for the microcontroller's timer and ADC plays the hardware: once every PWM period the ADC samples the plant's output into a 12-bit code, the interrupt runs the control step and writes the compare register, and the new duty drives the switch from the next period. Then the circuit's own simulation runs for as long, and the two are compared. ```sh --cmd codegen.pil --params '{}' ``` On `buckClosedLoop` it runs 1000 PWM periods at the default plant step of 50 ns (200 steps per period). `fullScale` defaults to 1.5 times the native run's peak of `vout`, 18.0 V here (an LSB of 4.4 mV). The steady state is averaged over the last 200 periods: | Signal | Firmware | Circuit | Difference | |---|---|---|---| | `vout` (mean) | 11.9950 V | 11.9999 V | −4.9 mV (0.04 %) | | duty (mean) | 0.2479 | 0.2501 | −0.0021 | `pass` is true: every measured signal is within the 1 % `tolerance` of the native run, no plant step hit the switching-iteration limit (`unsettled` 0), and no ADC sample left 0 to `fullScale` (`clipped` 0). Some difference is expected: the firmware regulates the sample at the start of each period, not the average, the ADC rounds it to one LSB, and the plant reads the gate once per step. A coarser step makes the duty coarser: at `"step":"1u"` the run has 10 steps per period and `dutyResolution` is 0.1. What this run is not: the compiler, the floating-point unit and the interrupt's timing are this computer's, not the microcontroller's, and the conversion takes no time. To learn whether the interrupt fits its period on the real part, build the firmware for it and give the listing to `codegen.isrCycles` ([chapter 13](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/13-tools-menu/#code-generation)). ## 4. The real-time model `tools.realtimeModel` turns the power stage into a fixed-step model in C. Each switch and diode is a low or a high resistance, so a circuit with `n` of them has `2^n` circuit matrices, and the export inverts each one in advance: a step on the target only multiplies. Run it with `check` on the open-loop `buck` example: ```sh powercraft-cli run --cmd file.openExample --param name=buck --cmd tools.realtimeModel --params '{"check":true}' ``` The reply names the gate input `g` and eleven outputs (`v(out)`, `i(L1)` and the rest), the step (50 ns, the circuit's maximum step), and the slowest possible step, `worstCase`: 100 solves of 25 multiply-adds, 2500 in all, which your target must finish within 50 ns. `check` replays the reference solver's gates through the model for the whole run: every output agrees within 5e-8 of its peak. On `buckClosedLoop` the same check shows `v(sw)` and the switch currents off by their full swing, because the controller's PWM edges fall between the model's steps and a switched quantity is then up to one step late; judge the model by the smooth signals (inductor current, capacitor voltage) instead. `file.exportRealtimeModel {"dir":"plant"}` writes `pc_plant.h` and `pc_plant.c`. On the target, call `pc_plant_init` once, then `pc_plant_step` every step with the gate levels, and read the outputs with `pc_plant_outputs`. `numbers: "f32"` writes the model in single precision, and `bfp24` or `bfp18` with block-floating-point tables for an FPGA's multipliers ([chapter 13](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/13-tools-menu/#real-time-model)). ## 5. FMU export An FMU (Functional Mock-up Unit, FMI standard) is a model that system-simulation tools import and co-simulate. `file.exportFmu` packs the real-time model as a co-simulation FMU: ```sh powercraft-cli run --root w --cmd file.openExample --param name=buck \ --cmd file.exportFmu --params '{"path":"buck.fmu","fmiVersion":"3.0","outputs":["v(out)","i(L1)"],"parameters":["Vin"]}' ``` The archive holds `modelDescription.xml`, the C sources in `sources/` (with `buildDescription.xml` for FMI 3.0) and `documentation/index.html`. Its input is the gate `g` (on above 0.5, held through each communication step), and its outputs are the two signals named; without `outputs` it exposes all of them. Leave out `fmiVersion` for FMI 2.0. The FMU carries sources, not a compiled library: the importing tool compiles them. The outputs do not depend directly on the inputs at the same communication point, so connecting the FMU to a controller makes no algebraic loop. Until the first communication step the outputs read the circuit's solution at the start time, fixed at export (the reply's `startValues`); from the first step on they follow the circuit. A communication step that is not a whole number of model steps advances to the last whole step before it. Each output whose quantity the model fixes carries its unit: `V` for a node voltage, `A` for a part's current, `rad/s`, `rad` and `N.m` for a machine's speed, angle and torque (the reply's `units`, `null` for a meter's or sensor's signal). `parameters` names DC sources of the circuit, here `Vin`; each becomes a tunable parameter of the FMU, after the outputs, whose start is the source's value in the circuit (48 V) and whose unit is `V` or `A`. The importing tool can set it before the run, during initialisation and at any communication point, and the model holds the source at that value from the next step on, so a study that sweeps the bus voltage or sags the supply mid-run needs one export. A sine, pulse or other varying source cannot be a parameter. The start values are those of the exported parameter values: an output read before the first step with a parameter set away from its start returns a warning status. ## 6. Limits - **Code generation** covers the sampled control blocks and the step-advancing blocks that feed a PWM's duty ([chapter 13](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/13-tools-menu/#what-is-generated) lists them). Anything else is listed in `unsupported` with the reason, and with a microcontroller target a block that cannot be generated but feeds a duty is refused by name (`strict`), since the firmware would run the loop open. - **The checks run on this computer.** `codegen.verify`, `codegen.closedLoop`, `codegen.pil`, `codegen.evidence` need a C compiler; without one (and in the browser) they answer an error that says so, and `codegen.evidence` reports `incomplete`. No check runs on a microcontroller, an FPGA or a rig. - **Processor-in-the-loop** takes one `pwm` block that drives every gate (on the `stm32g474`, or one `pwm3` block on TIM1's three channels), and no supervisor. The ADC reads each input from `offset` at the code 0 to `fullScale` at 4095, so a phase current reads from mid-scale on either target; a sample outside that range clips and is counted in `clipped`. - **The real-time model** takes at most 12 switches and saturating inductors together. Inductors on a linked catalogue core, nonlinear parts, machines other than PM synchronous ones, and reverse recovery have no real-time model. Losses and temperatures are not computed, and the control blocks are not part of the plant: the firmware replaces them. - **FMU**: export only, co-simulation only. Only DC sources can be parameters (no resistor, capacitor or switch values), and Voltecx does not import FMUs (#4402). ## 7. Error messages Each error names what is wrong and, where it can, what to change. The ones you are most likely to meet: | Message | What to do | |---|---| | `` the reference `Ref` of `Err` is 12, above the 3.3 the ADC reads for `vout` at its full scale: set `fullScale` … `` | Give `fullScale`, the value the ADC's full code stands for (the range of your sense network), or scale the feedback in the circuit. | | `the fixed-point format cannot hold the constant 2e-4 rounds to 0` | The format has too few fraction bits for a gain. Use `float` or `double`, or a format with more fraction bits. | | `` the code differs from the model: signal `duty` first leaves the tolerance … at sample 6 … `` | `codegen.verify` found where the code and the model part. Compare the precision with `double`, then look at that block. | | `` prefix `9abc`: it must start with a letter `` | The prefix is a C identifier: letters, digits and `_`, starting with a letter. | | `no processor-in-the-loop run: the firmware measures nothing, so there is no loop to close` | The circuit's control reads no measured signal (the open-loop `buck` example, or `boost`). Close the loop through a meter first. | | `` no real-time model: `M1`: an induction machine has no real-time model; the export takes PM synchronous machines (surface and interior) `` | The named part has no fixed-step model (section 6). | | `` the model has no output `v(nope)`; its outputs are v(in), v(sw), v(out), … `` | `file.exportFmu`'s `outputs` names a signal the model lacks; pick from the list. | | `` `fmiVersion` must be "2.0" or "3.0", not "1.0" `` | FMI 1.0 is not written. | --- # 24. Conducted EMI and input filters URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/24-conducted-emi/ A switching converter draws its input current in pulses, and part of that current comes back out of the supply leads as noise. Conducted-emission standards limit that noise between 150 kHz and 30 MHz. This chapter covers the conducted estimate, `emi.conducted`: the LISN it puts on the input, the limit lines it checks, how to read its margins, how it sizes a differential-mode and a common-mode input filter, and how it checks that the filter leaves the converter stable. [Tutorial 9](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/09-conducted-emi/) takes the same command step by step on a buck. > **An estimate, not a compliance test.** `emi.conducted` is a pre-compliance estimate against CISPR 32 class A or B, CISPR 11 group 1 class A or B, or CISPR 25 classes 1 to 5, from the simulated input current through a LISN model. The CISPR 11 and CISPR 25 limits were read from secondary sources and not checked against the standards' text. MIL-STD-461 CE102 is not included. It depends on the parasitics in your circuit, and a schematic has few. A pass is a result in Voltecx's models; only a measurement at a test house is a compliance result. ## What the estimate does 1. It makes a copy of the circuit and puts the limit's LISN (line impedance stabilisation network) between the input source and the converter. Your circuit is never changed unless you apply the filter (below). 2. The copy runs for `tSettle` (by default the circuit's end time), then for whole switching periods (by default the periods in 444 µs) with a step no larger than `maxStep` (10 ns by default). 3. The voltage across the LISN's 50 Ω receiver port goes through a model of the receiver: the limit's bandwidth (9 kHz in band B, from CISPR 16-1-1) and its three detectors, peak, quasi-peak (1 ms charge, 160 ms discharge) and average. The levels are in dBµV. 4. Each detector's spectrum is held to the limit band by band. The worst margin, its frequency and its detector are the result. A DC input gets one LISN, on the supply line. A sine source is read as an AC mains input: it gets a LISN on L and on N, runs whole mains periods, then 8 windows at equal phases of the next mains period, and joins their receiver envelopes. With two LISNs the reply also splits the noise into differential mode (`dm`) and common mode (`cm`), the split of C. R. Paul, *Introduction to Electromagnetic Compatibility*, 2nd ed., ch. 6. A DC input whose return is drawn as ground has no common-mode path. Give `cChassis`, the switch node's or heat sink's capacitance to the chassis, and the copies move the converter's return to its own net, hang that capacitance from `chassisNode` (by default the switch node `layout.hints` finds) to ground and put a LISN on both lines. ## The limits `limit` picks the line. When you leave it out, the stored design spec's `spec.emi.limit` (from `spec.set` or `design.auto`) is used, else CISPR 32 class B. | `limit` | Standard and table | Port | LISN | |---|---|---|---| | `cispr32A`, `cispr32B` | CISPR 32:2015 (edition 2.0), Annex A, conducted emission at the AC mains power port | AC mains | 50 µH, 0.1 µF, 50 Ω (CISPR 16-1-2) | | `cispr11A`, `cispr11B` | CISPR 11:2015+A2:2019, group 1, class A (rated input up to 20 kVA) or B; EN 55011:2016+A2:2021 Table 2, as secondary sources cite it | AC mains | 50 µH, 0.1 µF, 50 Ω (CISPR 16-1-2) | | `cispr25Class1` to `cispr25Class5` | CISPR 25 edition 5.0 (2021), voltage method; peak and average from Tables 1 and 2 of an ST article, quasi-peak from Table 5 of a Baltic Lab article | DC supply line | 5 µH with 1 Ω in series, 50 Ω port | The CISPR 32 lines, in dBµV (a limit falls linearly with the logarithm of frequency inside a segment, and at a transition frequency the lower limit applies): | Band | Class A quasi-peak | Class A average | Class B quasi-peak | Class B average | |---|---|---|---|---| | 0.15 to 0.5 MHz | 79 | 66 | 66 falling to 56 | 56 falling to 46 | | 0.5 to 5 MHz | 73 | 60 | 56 | 46 | | 5 to 30 MHz | 73 | 60 | 60 | 50 | Class B is the residential limit and class A the industrial one. CISPR 25 holds only its listed bands (for example 0.15 to 0.3 MHz and 0.53 to 1.8 MHz) and adds a peak limit; frequencies between the bands are not held. The reply's `limit` names the source and edition of the line it used, and its `setup.lisn` the network. ## Run it Choose **Design › Automate › Conducted EMI**. The form opens with the common fields; **More options** shows the rest. ![The Conducted EMI Estimate form with More options open, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/emi-filters/01-form.png) 1. `Limit`: the line, here CISPR 32 class B. 2. `Filter`: `auto` sizes a damped LC input filter when the margin is short of the target, inserts it on a copy and measures again. `oneStage` and `twoStage` force the number of stages, and `none` only measures. 3. `Target margin`: how far below the limit the result must be, 6 dB by default (or the stored spec's `spec.emi.targetMarginDb`). A pass with less margin than this is reported as short. 4. `Apply result`: off, nothing in the circuit changes. On, the sized filter is inserted as one undo step. 5. `[Run]`. The command is long-running, so it goes through the status bar with progress and Cancel. The circuit in the picture is the textbook buck (`buckIdeal`) with a 47 µF input capacitor `Cin` added, as in step 6 of the tutorial. ## Read the result ![The result window: the margin as drawn, the required attenuation, the margin with the filter and the Apply Filter button, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/emi-filters/02-result.png) 1. As drawn: `Fail`, with the worst margin, its frequency and its detector: here −33.2 dB at 200 kHz, the second harmonic of 100 kHz, read with the average detector. 2. `Required attenuation`: how much the emission must drop for the worst frequency to meet the target margin, here 39.2 dB (33.2 dB to the limit plus the 6 dB target). 3. With the input filter: the same measurement on the copy with the filter, here a pass with 11.7 dB of margin. The filter is one stage of 220 µH and 515 nF; its parts are listed under `Input filter`. 4. `[Apply Filter]` inserts those parts into the circuit as one undo step, the same as running again with `Apply result` ticked. 5. `As drawn` over the spectrum: peak, quasi-peak and average against the quasi-peak and average limits, as drawn and, below it, with the filter. `Copy` puts the whole reply on the clipboard as JSON. The keys a script reads: | Key | What it holds | |---|---| | `before.total.pass`, `marginDb`, `worst` | The verdict as drawn, the worst margin and where it is (`fHz`, `detector`, `levelDbuv`, `limitDbuv`) | | `before.total.bands` | Each band's quasi-peak and average margin, the peak-to-quasi-peak gap and the attenuation that band needs | | `before.dm`, `before.cm` | The same for the differential and common mode, with two LISNs; `null` with one | | `filter` | The sized filter: `stages`, `cornerHz`, the parts and the `circuit.apply` edits that insert it | | `after` | The measurement with the filter in, shaped like `before` | | `rounds` | Each sizing round: the filter is sized, measured and sized again for what it lacked, up to 4 rounds | | `pass` | The whole verdict: the margin after the filter meets the target, Middlebrook's check passes and the loop keeps its phase margin | | `notes` | What was assumed or skipped, in English and Traditional Chinese | A large `peakVsQp` in a band means the emission is a few strong lines, not a broad hump; the quasi-peak detector forgives the first less than the second. ## Size the differential-mode filter Each stage is a shunt capacitor on the supply side and a series inductor towards the converter. Above its corner `f0 = 1/(2π·√(L·C))` one stage adds about 40 dB per decade and two stages about 80 dB per decade. The corner is the highest one that gives every frequency its required attenuation at that slope. With `auto` one stage is used while the attenuation at the frequency that sets the corner is at most 40 dB, and two stages above that. The stages are catalogue parts with their data-sheet values in the circuit and the BOM: Coilcraft inductors, Murata or other capacitors from the capacitor catalogue on a DC input, X2 film capacitors on an AC one, and E96 chip resistors. When the catalogue has no part for a role, `filter.catalogue.missing` says which and why, and the value stays ideal. Before you size a filter, look at the input capacitor. A converter without one pushes all of its pulsed current into the supply, and the filter it needs is large: the tutorial's buck needs two 660 µH stages without `Cin` and one 220 µH stage with it. ## Damping and Middlebrook's check An LC filter has no loss, so its output impedance peaks at resonance. A regulated converter draws constant power and looks like a negative resistance of magnitude `V²/P` at its input; a filter peak near that magnitude can make the converter oscillate (R. D. Middlebrook, "Input filter considerations in design and application of switching regulators", IEEE IAS Annual Meeting, 1976). So each inductor gets a damping branch across the capacitance on its converter side: a resistor `Rd` in series with a blocking capacitor `Cd`, sized with the optimal parallel damping of R. W. Erickson and D. Maksimovic, *Fundamentals of Power Electronics*, chapter "Input Filter Design". Voltecx holds the filter's peak output impedance 3 times (about 10 dB) below the converter's input impedance. The check reads the peak of the whole drawn filter, not only the closed form for one stage. - `zinOhm` sets the input impedance the filter is held to. Give `Vin_min²/P` at full load for the worst case; by default it is the measured V/I. - `filter.middlebrook` has the impedance, the peak, the margin and `pass`. - `pmMinDeg` (default the stored spec's, else 45°) and `loopCheck` (on) measure `analysis.loopGain` with and without the filter, and a load step to half the load resistance. `stability` has both phase margins, both dips and the `|Zo(f)|` curve. A circuit without a control loop has no loop gain to measure, and the reply says so. ## Common-mode filter With two LISNs (an AC input, or a DC input with `cChassis`) and a common-mode margin below the target, a common-mode stage is sized: a catalogue common-mode choke in both lines and a Y capacitor from each line to ground. It needs a limit on the Y capacitance, because that limit comes from the product's safety standard and has no default: - `yCapMax`: the largest Y capacitance per line, or - `touchCurrent`: the safety standard's touch-current limit. Each Y capacitor is then at most `touchCurrent/(2π·mainsHz·mainsV)`. On a DC input give `mainsHz` and `mainsV` too. `filter.commonMode` names the choke (manufacturer, part number, inductance, stray inductance, DC resistance, ratings and its data sheet) and the Y capacitor, and says whether the choke's worst-case inductance reaches the corner it needs (`reaches`). ## Apply the filter Tick `Apply result`, pass `"apply": true`, or click `[Apply Filter]` in the result. The filter goes in between the source and the power stage as one undo step, drawn in line with its damping branch below it; its parts are named `EMI_C1`, `EMI_L1`, `EMI_Rd1`, `EMI_Cd1` and so on per stage. The command refuses to apply, and says why in `applyRefused`, when the margin after the filter misses the target, Middlebrook's check fails or the loop's phase margin falls below `pmMinDeg`. After applying, run the simulation again: the converter should still reach its output, and the input current should be smooth. ## Parasitics and a measured spectrum A schematic of ideal parts has a capacitor without ESL and an inductor without winding capacitance, so above a few MHz the estimate is optimistic. With `"parasitics": true` the measured copies get capacitor ESR and ESL, inductor winding capacitance and switch output capacitance from the circuit, from `parasiticValues` (data-sheet values by component name) or from the catalogues. A value none of these gives is skipped and listed, never invented. The reply's `parasitics` shows each value and its source, the margin with and without them, and the change. `measured` overlays a receiver's or spectrum analyser's export (a frequency and a level in dBµV on each line) on the limit and the prediction, with each band's measured and predicted margin and their difference. Use it to see how far the model is from your bench. ## From a script ```sh powercraft-cli run \ --cmd file.openExample --params '{"name":"buckIdeal"}' \ --cmd circuit.apply --params '{"ops":[{"op":"add","name":"Cin","kind":"capacitor","params":{"c":"47u","esr":"10m","v0":48},"ports":{"p":"in","n":"0"},"at":[-5,0]}]}' \ --cmd emi.conducted --params '{"limit":"cispr32B","targetMarginDb":6}' \ --cmd emi.conducted --params '{"apply":true}' \ --cmd simulation.run --params '{}' ``` The first `emi.conducted` only reports; the second inserts the filter it sizes. ## What the estimate does not tell you - It is not a compliance measurement. The test house's layout, cables, ground plane and receiver decide the result. - Coupling through the board's layout (the switch node's capacitance to the heat sink and chassis, magnetic coupling into the filter) is only in the estimate as far as you draw it or give it with `cChassis` and `parasiticValues`. - Above 30 MHz the emission is radiated. `emi.radiated` estimates it from the hot loop and the switch node's common-mode current, and `emi.nearField` maps the board's near field; see chapter 16 and chapter 22. Next: back to the [contents](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/). --- # 25. Thermal and losses URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/25-thermal-and-losses/ A converter is done when its hottest junction stays under the data sheet's limit with margin. This chapter takes one shipped example from a switching run to a junction temperature: the losses of each part (`analysis.losses`), the thermal network that turns watts into degrees (parts, heatsink, ambient), the steady and transient junction temperature (`analysis.thermal`, `thermal.summary`), the margin to the limit, and what to change when a part is too hot. [Chapter 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/04-simulation-settings/#thermal-parts-on-the-schematic) lists the thermal parts, [chapter 6](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/06-analyses/#losses-thermal-and-fft) the analyses; this chapter puts them in one order. The numbers are from a run of the example on a Linux computer; another computer can differ in the last digits. ## 1. The commands | Command | What it does | |---|---| | `simulation.run` | Runs the circuit. The thermal network is part of it: its nodes are signals `T()` in °C. | | `analysis.losses` | Average conduction and switching loss of each switch and diode, and the winding and core loss of magnetics, over a window. | | `analysis.thermal` | First, minimum, maximum and final value of each thermal node; a junction with a limit also gets `limit`, `marginK` and `pass`. | | `thermal.summary` | A temperature for every part that loses power, from the run, a placed heatsink or the data sheet's RthJA, with its margin. | | `thermal.placeHeatsink` | Places a catalogue heatsink and its ambient on a case net, at the heat and airflow you give. | | `thermal.placeFan` | Adds a fan that lowers the heatsinks' resistance at an airflow. | | `design.thermal` | Picks a heatsink and pad (or board copper) for each device and, with `apply`, draws the whole network in one undo step. | ## 2. Losses of a switching run Open **File › Open Example** and pick `buckThermal`: a buck whose switch `Q1` and diode `D1` each heat a thermal net. The same from the command line: ```sh powercraft-cli run --accept-terms --cmd file.openExample --params '{"name":"buckThermal"}' \ --cmd simulation.run --params '{}' \ --cmd analysis.losses --params '{}' ``` The run is 20 ms long, 400 000 steps. `analysis.losses` reads the whole run (`window` 0 to 20 ms; give `t0` and `t1` for a steady part): | Part | Conduction | Switching | Average | |---|---|---|---| | `Q1` | 2.93 mJ | 269.9 mJ | 13.64 W | | `D1` | 39.1 mJ | 0 | 1.95 W | The semiconductors lose 15.60 W in all (`semiconductorW`); this circuit has no magnetic loss model (`magneticsW` 0). The switch loses almost all of its heat while switching, the diode while conducting. **Analysis › Loss Chart** draws the same budget as a picture: ![The loss chart of buckThermal: efficiency and total loss, the Sankey from input to output and losses, one bar per part, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/thermal-chart/01-losses.png) 1. Efficiency 79.53 % and the total loss, 15.6 W: the input 76.2 W less the output 60.6 W. Below it, the input splits into the output, conduction (2.1 W) and switching (13.5 W), and each loss into the parts that cause it. 2. **[Copy CSV]** copies the numbers, one row per part and category. 3. **Show data** lists the same numbers under the chart. ## 3. From watts to degrees A loss becomes a temperature only through a thermal network: a junction net (the part's `thermal` parameter), a resistance or a Foster chain from the junction to the case (`rth`, `foster`, or the chain of the part's library device), a heatsink and an `ambient`. The network is solved with the circuit, so a loss that changes with the switching raises the temperature with its own time constants. In `buckThermal` the junction net is `tj` and the heatsink net `hs`. Place a heatsink on any case net with `thermal.placeHeatsink`; [chapter 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/04-simulation-settings/#example-a-mosfet-on-a-foster-chain-and-a-catalogue-heatsink) runs one end to end (2.30 W into a 11.97 K/W heatsink at a 40 °C ambient gives a 67.59 °C case). With no network at all, `design.thermal {"apply": true}` draws one for you. ## 4. Steady and transient junction temperature ```sh --cmd analysis.thermal --params '{}' \ --cmd thermal.summary --params '{"ambient": 40}' ``` `analysis.thermal` reports, for `T(tj)`, a minimum of 40.00 °C (the start, at ambient), a maximum of 59.05 °C and a final value of 59.03 °C after 20 ms; `T(hs)` stays at 40.00 °C in this run. The curve between the minimum and the final value is the transient: `T(tj)` is a signal like any other, so the scope shows how fast the junction heats at start-up. To begin from the settled state instead of ambient, set `simulation.settings {"thermalStart": "steady"}` ([chapter 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/04-simulation-settings/)); then the first sample is already the steady temperature. `thermal.summary` lists each part that loses power, hottest first. For `Q1` it reads 13.64 W and 59.05 °C with `source` `simulated`: the run's own peak. `D1` has no thermal network and no RthJA in the catalogue, so its `tC` is empty and it says it needs an Rth: nothing is guessed. A temperature needs a source. ## 5. The margin to the data sheet's limit A switch or diode's limit is its `tjMax` (°C), else that of its library device. The example's `Q1` has no limit, so `marginK` is empty and nothing is flagged. With a device from the library, `analysis.thermal` adds `limit`, `limitFrom`, `marginK` (the limit minus the peak), `pass` and `crossedAt`; a run that passes a limit puts the part in `overTemperature`, warns with the time it first crossed, and `circuit.problems` lists an over-temperature problem. `simulation.settings {"stopOnOverTemperature": true}` ends the run at the first crossing. The overlay (**View › Overlays › Thermal Overlay**) tints each part up to its `tjMax` and outlines one that passes it. ## 6. Fixing a part that is too hot Work down the chain; each step shows in the next run: 1. **Cut the loss.** A switch that loses its heat while switching: a slower frequency, a faster gate drive, a lower-Qg device. `analysis.losses` after each change shows what moved. 2. **Lower the case-to-ambient resistance.** A larger heatsink (`thermal.placeHeatsink` at the new part), more airflow (`thermal.placeFan`), a better pad. 3. **Split the heat.** `nParallel` puts N devices on one symbol: each junction carries 1/N of the current. In the shipped `halfBridgeParallelSic` three Wolfspeed C3M0065090D per switch lose 25.9 W in `Q1` (8.6 W each) and reach 67.5 °C on a 58.8 °C heatsink (chapter 4 has the circuit and the test that checks it). 4. **Let the tool choose.** `design.thermal` picks a catalogue heatsink and pad (or board copper) for each device and, with `apply`, puts them on the schematic in one undo step. Then run again and read `thermal.summary`: the hottest part, its margin, and whether any part still says it needs an Rth. ### A worked fix Take `buckThermal` and give `Q1` a poor path to air: set `Rth` to 10 K/W and `Cth` to 200 µJ/K, and give `Q1` a limit of 125 °C (`tjMax`; this generic switch has no data sheet, so the limit here is the reader's own, not a part's). Turn on **View › Overlays › Thermal Overlay** and run: ```sh --cmd circuit.setParam --params '{"component":"Rth","key":"r","value":10}' \ --cmd circuit.setParam --params '{"component":"Cth","key":"c","value":0.0002}' \ --cmd circuit.setParam --params '{"component":"Q1","key":"tjMax","value":125}' \ --cmd simulation.run --params '{}' --cmd analysis.thermal --params '{}' ``` ![The buck with the thermal overlay: Q1 red at 177 °C, past its 125 °C limit, and the 10 K/W Rth, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/thermal-fix/01-too-hot.png) 1. `Q1` loses 13.69 W, and its junction passes 125 °C at 1.94 ms and peaks at 177.19 °C: `marginK` −52.19, `pass` false. The run lists it in `overTemperature`, and the overlay outlines it and labels its peak. 2. `Rth`, 10 K/W: 13.7 W across it is about 137 K above the 40 °C ambient. Almost all of `Q1`'s loss is switching loss, which scales with frequency, so cut the loss first (step 1 above): set the `PWM` block's `freq` from 100 kHz to 50 kHz and run again. ![The same buck at 50 kHz: Q1 at 111 °C, under its limit, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/img/en/thermal-fix/02-fixed.png) 1. `Q1` now loses 7.06 W (switching 137.7 mJ over the 20 ms run, half of the 269.7 mJ before), and its junction peaks at 110.93 °C: `marginK` 14.07, `pass` true, and `overTemperature` is empty. 2. The `PWM` block at 50 kHz. Half the frequency doubles the inductor's current ripple, so check the output ripple and the inductor's saturation current before you keep the change; a larger heatsink (step 2) is the fix that leaves the power stage as it is. --- # 26. Teaching with Voltecx URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/26-teaching/ An instructor who gives every student the same circuit gets the same answer back from everyone. This chapter shows how to give each student their own component values, get an answer key for each, and check what a student hands in. It covers the lessons that declare ranges; today that is the course lesson `course-buck`. ## What a lesson declares A lesson file may carry a `variants` block: the example circuit to start from, the component values that may vary with their range and preferred-number series (E12 or E24, IEC 60063:2015), and the numbers it grades, each with a relative tolerance. A lesson without `variants` has one set of numbers and `lesson.variants` refuses it by name. ## Give every student their numbers `lesson.variants` takes the lesson `id`, a `seed` and either a list of `students` (any text ids you choose, at most 200) or a `count` (ids `s1` to `sN`): ```sh powercraft-cli run --cmd lesson.variants \ --params '{"id":"course-buck","seed":2026,"students":["ana","ben","cy"]}' ``` For each student the reply holds the values, a `setup` list (`file.openExample` and one `circuit.setParam` per value) that rebuilds that student's circuit, and the answer key, measured by running that variant. Your open circuit is not touched: every variant runs in a scratch session. A variant that fails shows its `error` and the others still run. The same seed and the same id give the same values on every machine, so you can regenerate the key later. Voltecx stores nothing about the student beyond the id text you pass; keep your own list of who has which id. ## Check what a student handed in `lesson.report` takes the lesson, the same `seed`, the `student` id and the student's `answers` as numbers: ```sh powercraft-cli run --cmd lesson.report \ --params '{"id":"course-buck","seed":2026,"student":"ana","answers":{"ripple":0.9,"load-current":5}}' ``` Each answer is marked correct when it lies within the lesson's tolerance of the measured value; a missing answer counts as wrong. `allCorrect` is the summary. Next: back to the [contents](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/). --- # Voltecx user manual URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/ This manual is for engineers who are new to Voltecx. It assumes you know power electronics (what a buck converter is, what a loop gain plot shows) but not this program. It is written for version 0.9.0. A Traditional Chinese edition is in [`../zh-Hant/`](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/manual/). ## Chapters | # | Chapter | You will learn | |---|---|---| | 1 | [Install](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/01-install/) | Get the app and the command-line tool running | | 2 | [Your first circuit](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/02-first-circuit/) | Open or build a buck converter and simulate it | | 3 | [Wiring and shortcuts](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/03-wiring-and-shortcuts/) | Place parts, wire them, work fast | | 4 | [Simulation settings](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/04-simulation-settings/) | Fixed or variable step, the two solvers, end time | | 5 | [The scope](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/05-scope/) | Tabs, cursors, measurements, export | | 6 | [Analyses](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/06-analyses/) | AC sweep, loop gain, sweeps, optimize, losses, parts | | 7 | [The Design panel](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/07-design-panel/) (beta) | Size L, C and compensators from targets | | 8 | [Problems and quick fixes](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/08-problems-and-fixes/) (beta) | Read an error, apply the fix | | 9 | [Import, export and LaTeX](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/09-import-export/) | SPICE, LTspice, PLECS, waveforms, thesis figures | | 10 | [Models](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/10-models/) | Motor drives, ICs, non-ideal parts, digital control | | 11 | [Chat and the command line](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/11-chat-and-mcp/) | Talk to the built-in assistant in a terminal; drive the app from scripts | | 12 | [The agent panel](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/12-agent-panel/) | Work with an assistant inside the app: proposals, checkpoints, suggestions | | 13 | [The Tools menu](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/13-tools-menu/) | Parameter Sweep, scripts and C code generation | | 14 | [Preferences and saving](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/14-preferences-and-saving/) | Settings, autosave, recovery, the last result, versions and variants, circuits in git | | 15 | [Examples](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/15-examples/) | Open the ready-made circuits, by category | | 16 | [Automatic design](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/16-automatic-design/) | Write a spec, run `design.auto`, read the report, and use each design tool alone | | 17 | [Python](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/17-python/) | Run any command from Python and Jupyter; waveforms as numpy arrays, sweeps | | 18 | [The Test Bench](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/18-test-bench/) | Run one test case, see its waveforms against the limits, compare runs | | 19 | [The command line](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/19-command-line/) | `powercraft-cli`: sim, analyses, batch, sweep, compare, exports, completion, exit codes | | 20 | [Troubleshoot](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/20-troubleshoot/) | From a wrong reading on the bench to the faulty part, one measurement at a time | | 21 | [The field solver](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/21-field-solver/) (Preview) | Inductance, core loss, heat and force from the field of the part: examples, 2D and 3D, drawing, exports, limits and the accuracy report | | 22 | [The board](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/22-board/) | Stack-up, impedance, placement, routing, zones, design rule check, board diff and fabrication files, as commands | | 23 | [Code generation, HIL and FMU export](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/23-codegen-hil-fmu/) | Controller C for a microcontroller, the firmware against the plant, the real-time model, HIL test sequences and FMUs, as one worked run | | 24 | [Conducted EMI and input filters](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/24-conducted-emi/) | The LISN and the CISPR limit lines, reading the margins, sizing a damped differential-mode and a common-mode input filter, Middlebrook's check, applying it | | 25 | [Thermal and losses](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/25-thermal-and-losses/) | From a switching run to a junction temperature: losses, thermal network, steady and transient Tj, margin, fixes | | 26 | [Teaching with Voltecx](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/26-teaching/) | Per-student component values from a seed, an answer key for each, and checking what a student hands in | ## Conventions - **Cmd** means the Command key on a Mac and the Ctrl key on Windows and Linux. - **(beta)** marks a feature that was developed on a branch that had not been merged when this release was prepared. It exists in the beta build, but it has had the least testing, and its details may change. Every feature in 0.9.0 is a beta in the wider sense; the mark tells you where to expect rough edges. - **Values** accept SI suffixes: `10k`, `4.7u`, `100n`, `1meg`. A bare number is in base units (volts, amperes, ohms, seconds, hertz). - **Names** of signals are written `v(out)` for a node voltage and `i(L1)` for the current in element `L1`. ## One program, three doors Everything Voltecx does is a named command, for example `simulation.run` or `analysis.acSweep`. You can reach a command from the menus and shortcuts, from Quick Open (Cmd+K), from the command-line tool (`powercraft-cli`), and from the built-in assistant. This manual shows the menu path first and names the command so you can find it in the other places. The list of every command comes from `powercraft-cli commands`. Menu items that need parameters open a form: one field per parameter, filled in from what you selected, the traces on the scope, the visible time window and the circuit's settings. Numbers take engineering notation (`4.7u`, `10k`), a field you get wrong is marked in red, Enter runs the command and Esc closes the form. Fields with a **▾** button list the parts, pins, nets, signals or variables you can pick. **Advanced (JSON)** shows the command's parameters as JSON text instead, for keys the form has no field for; the chapters show example parameters you can paste there. A command without a form opens the JSON box directly. The result appears in a window titled with the command's name: tables for losses, FFT harmonics, sweeps, Monte Carlo runs and frequency responses (with small plots), and lists for checks and the circuit's parts. Numbers are shown with SI prefixes (`6.32 mW`). **Copy** puts the table on the clipboard as CSV, with the full numbers. A result of any other shape shows as JSON. ## Where to go for depth | Topic | Document | |---|---| | Build from source, tests, browser build | `docs/development.md` | | Optimize, sensitivity, worst case | [`docs/workflows/optimize.md`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/workflows/optimize/) | | Debugging a misbehaving circuit | [`docs/workflows/debugging.md`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/workflows/debugging/) | | Picking real parts from a simulation | [`docs/workflows/part-selection.md`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/workflows/part-selection/) | | AI chat | [`docs/workflows/ai-chat.md`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/workflows/ai-chat/) | | Motor-drive models and equations | `docs/motor-drive.md` | | File formats | `docs/formats/` | | JSON control protocol | `docs/control-protocol.md` | The in-depth documents are written in Traditional Chinese. Their command names, parameters and JSON examples are the same as here. --- # 用對話建電路:Voltecx 的內建助理 URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/workflows/ai-chat/ 這份文件回答一個問題:「我跟 CLI 聊天,它能不能理解我要什麼,然後幫我把電路接好?」 可以。Voltecx 的助理就是內建的對話:桌面版的 AI 助理面板,以及終端機裡的 `powercraft-cli chat`。用自然語言描述規格,助理會呼叫 Voltecx 的指令建電路、模擬、讀波形,再把結果講給你聽。外部的 AI 工具無法操作 Voltecx:沒有對外的 MCP server(#3564)。為了讓「一句話建好電路」真的走得通,引擎提供三個專為對話設計的指令: | 指令 | 做什麼 | |---|---| | `circuit.template` | 給拓樸與規格(輸入電壓、輸出電壓、電流、頻率、漣波),依教科書公式算出零件值,開一個新電路,已排好圖面 | | `circuit.wire` | 用 `元件.接腳` 接線,例如 `S1.n` 接 `L1.p`,不必自己取網路名稱 | | `schematic.autoLayout` | 把任何電路排成教科書的樣子:電源在左、串聯路徑在上、並聯元件向下接地、控制方塊在上方 | 以下數值預期是依公式推算,沒有在寫文件時實際執行。實際結果以指令回傳為準。 ## 內建聊天:`powercraft-cli chat` 在終端機可以直接跟 Voltecx 聊天。CLI 自己把你的話送給 Claude,Claude 呼叫的是 Voltecx 的工具(與桌面版助理同一份工具清單、同樣的參數說明,在程序內對一個 headless session 執行),做完後把結果用文字回給你。 ```sh export ANTHROPIC_API_KEY=sk-ant-... # 你自己的金鑰 mkdir -p work cargo run -q -p powercraft-cli -- chat --automation-read-root work --automation-write-root work ``` ```text you> 建一個 48V 轉 12V、5A、100kHz 的 buck,告訴我輸出漣波 → circuit.template {"fsw":"100k","iout":5,"topology":"buck","vin":48,"vout":12} ok → sim_run ok → waveform_stats {"signals":["v(out)"],"t0":0.000153} ok 輸出平均約 12 V,峰對峰漣波約 0.1 V(設計值 0.12 V)…… [3 tool calls, 9120 tokens in, 480 out] you> /save buck48.voltecx [saved: {"path":"buck48.voltecx","warnings":[]}] you> /exit ``` (上面的輸出是示意,實際數字以指令回傳為準。)每一行 `→` 是一次工具呼叫,下一行是它成功(`ok`)或失敗(`error: ...`,Claude 會看到錯誤並修正)。 **金鑰與資料** - 用你自己的 Anthropic API 金鑰,費用算在你的帳號。金鑰只從環境變數 `ANTHROPIC_API_KEY` 讀取,不會寫進檔案、日誌或歷史;沒設定時 `chat` 一開始就報錯並說明怎麼設。 - **對話內容與每一次工具結果(電路資料、波形數值、你允許它讀的檔案內容)都會送到 Anthropic 的 API。** 不想送出的資料就不要放進讀取資料夾,也不要貼進對話。 - 引擎本身仍然完全離線運作;只有 `chat` 子指令會連網,而且只連 `api.anthropic.com`。 **選項** | 選項 | 意思 | |---|---| | `--model ID` | 模型(預設 `claude-opus-5-5`) | | `--max-tokens N` | 每次模型回覆的輸出上限,包含思考(預設 64000,最多 128000) | | `--max-tool-calls N` | 一則訊息最多呼叫幾次工具(預設 200,最多 1000)。到上限就停下並說明,輸入「繼續」可以接著做 | | `--effort LEVEL` | 模型思考的深度:`low`、`medium`、`high`、`xhigh` 或 `max`(預設 `high`;Claude 4.6 以後的模型) | | `--automation-read-root DIR`、`--automation-write-root DIR` | 與 `serve` 完全相同的檔案規則:沒給就完全不能讀寫;路徑相對於資料夾,絕對路徑與 `..` 一律拒絕。也可用 `POWERCRAFT_AUTOMATION_READ_ROOT`、`POWERCRAFT_AUTOMATION_WRITE_ROOT` | **聊天中的指令** | 指令 | 做什麼 | |---|---| | `/save 檔名` | 把目前的電路存成 `.voltecx`(走 `circuit_save`,需要 `--automation-write-root`) | | `/reset` | 忘掉對話,換一個空的 session | | `/help` | 說明 | | `/exit`(或 Ctrl-D) | 離開 | | Ctrl-C | 取消正在處理的這則訊息;對話保持有效,之後可以接著問。閒置時只會提示怎麼離開 | 限制與提醒: - `sim_run` 是同步的,Ctrl-C 要等它跑完才生效(見下方「限制與提醒」);其他情況會在不到一秒內停下,已經執行的工具不會被復原,電路維持在停下時的狀態。 - 對話不會跨程序保存:關掉就沒了,電路要自己 `/save`。很長的對話請用 `/reset`。 - 回覆不串流,Claude 做完一輪才會顯示;工具呼叫的 `→` 行是即時印出的。 - 預設不啟用伺服器端的拒答備援(`fallbacks`);模型因安全分類器拒絕時,會顯示 `[the model declined this request (...)]`,換個說法再問即可。 - HTTPS 用戶端(`ureq` + rustls)在 `chat` cargo 功能裡,預設開啟,只存在於 `apps/powercraft-cli`;`cargo build -p powercraft-cli --no-default-features` 可以建出完全沒有網路程式碼的 CLI(`chat` 子指令會說明需要這個功能)。 ## 可以直接貼給 AI 的提示 | 你說 | AI 會做 | |---|---| | 「建一個 48V 轉 12V、5A、100kHz、電感漣波 20% 的 buck,告訴我輸出漣波。」 | `circuit.template`(buck)→ 模擬 → 量 `v(out)` 的峰對峰值 | | 「輸出電容減半,漣波變多少?」 | `circuit.setParam` 改 `Cf`(或 `analysis.paramSweep`)→ 重新模擬 → 比較 | | 「boost 12V 升到 24V、輸出 2A,把占空比 D 從 0.4 掃到 0.6,畫出輸出電壓。」 | `circuit.template`(boost)→ `analysis.paramSweep`(變數 `D`)→ 整理成表 | | 「做一個 400V 的半橋,輸出 300V。」 | `circuit.template` 回傳錯誤:方波半橋在這個輸入電壓下只能給約 180 V rms,AI 會把原因轉述給你並提出替代(改輸入電壓或拿掉 `vout`) | | 「幫我接線:V1 的正端接 S1 的 p,S1 的 n 接 L1 的 p,L1 的 n 接地……」 | `circuit.wire`,一次一個清單,只留一個歷史步驟 | | 「把圖面排整齊。」 | `schematic.autoLayout` | | 「存成 `buck48.voltecx`。」 | `circuit_save`(存到 `work/`) | | 「做一個 12V→-24V 的反相升降壓,1A。」 | `circuit.template`(buckBoost) | | 「RLC 串聯、共振 10kHz、過衝 20%,輸入 10V。」 | `circuit.template`(rlc) | 幾個讓 AI 表現更好的說法: - 把規格寫成數字加單位(`100kHz`、`20% 漣波`),AI 會直接對應到 `fsw`、`ripplePct`。 - 要它「先說公式與假設再模擬」,它會引用 `circuit.template` 回傳的 `values[].formula`。 - 要它「模擬後和設計值比較」,它會用回傳的 `expect` 與實際量測對照,差距大時告訴你。 ## AI 在背後呼叫什麼 以第一個提示為例,助理會依序做這些事(每一步都是一次工具呼叫): 1. `command_list {"filter": "template"}`:找到 `circuit.template`,讀它的參數說明(說明文字就寫在 `params` 欄位,包含各拓樸的預設值)。 2. `command_run {"id": "circuit.template", "params": {...}}`: ```json { "topology": "buck", "vin": 48, "vout": 12, "iout": 5, "fsw": "100k", "ripplePct": 20 } ``` 回傳(節錄;完整回覆還有 `parts`、`sim`、`signals`、`notes`): ```json { "name": "buck", "values": [ {"name": "D", "value": 0.25, "unit": "", "formula": "D = Vout/Vin = 12/48"}, {"name": "dI", "value": 1.0, "unit": "A", "formula": "ΔI = ripplePct·Iout = 20%·5 A"}, {"name": "Lf", "value": 9e-05, "unit": "H", "formula": "L = (Vin − Vout)·D/(fsw·ΔI) = (48 − 12)·0.25/(100k·1)"}, {"name": "dV", "value": 0.12, "unit": "V", "formula": "ΔV = vripplePct·Vout = 1%·12 V"}, {"name": "Cf", "value": 1.0417e-05, "unit": "F", "formula": "C = ΔI/(8·fsw·ΔV) = 1/(8·100k·0.12)"}, {"name": "Rload", "value": 2.4, "unit": "Ω", "formula": "R = Vout/Iout = 12/5"} ], "expect": {"meanVout": 12.0, "outputRipplePP": 0.12, "inductorRipplePP": 1.0, "duty": 0.25}, "sim": {"tEnd": 0.000306, "maxStep": 5e-08} } ``` 3. `sim_run {}`:同步模擬(約 6000 步,很快)。 4. `waveform_stats {"signals": ["v(out)", "i(L1)"], "t0": 0.000153}`:只看後半段(穩態)。回傳 `mean`、`peakToPeak`、`rms` 等。 5. 回答你:「輸出平均約 12 V,峰對峰漣波約 0.1 V 左右(設計值 0.12 V,理想電容;實際電容的 ESR 會讓它更大)。電感電流漣波 1 A p-p。」 6. 想看圖時:`waveform_render {"signals": ["v(out)"]}` 回傳 PNG,AI 看得到。 手動建電路時的呼叫順序是 `circuit_new` → `circuit.addComponent`(每個元件一次)→ `circuit.setParam` → `circuit.wire`(把所有線放在一個清單)→ `schematic.autoLayout` → `circuit.check`(檢查是否有浮接節點)→ `sim_run`。每個編輯指令恰好記一個歷史步驟,所以一句話做的事在 GUI 裡可以一次復原。 ## `circuit.template` ```json {"topology": "buck", "vin": 48, "vout": 12, "iout": 5, "fsw": "100k", "ripplePct": 20, "vripplePct": 1, "name": "my_buck"} ``` | 參數 | 意思 | |---|---| | `topology` | `buck`、`boost`、`buckBoost`、`halfBridge`、`fullBridge`、`inverter3`、`flyback`、`rcLowPass`、`rlc` | | `vin` | 輸入電壓(V);橋式是直流母線電壓 | | `vout` | 輸出電壓(V)。反相升降壓寫 `24` 或 `-24` 都可以(輸出是 −24 V)。半橋與全橋可省略;逆變器是**相電壓**有效值 | | `iout` | 輸出(負載)電流(A,有效值) | | `fsw` | 切換頻率(Hz)。RC 是轉折頻率 fc,RLC 是共振頻率 f0 | | `ripplePct` | 電感電流漣波,佔平均電流的百分比(預設 20)。RLC 是想要的過衝百分比 | | `vripplePct` | 輸出電壓漣波,佔輸出電壓的百分比(預設 1) | | `fout` | 只給 `inverter3`:輸出基頻(Hz,預設 50) | | `name` | 新電路的名稱(預設是拓樸名稱) | 數字可以是數值或帶單位的字串(`"100k"`、`"10u"`)。拼錯的參數名稱(例如 `vOut`)會被拒絕並指出是哪一個,避免默默用預設值設計出錯的電路。 各拓樸的預設值: | 拓樸 | vin | vout | iout | fsw | |---|---|---|---|---| | `buck` | 48 | 12 | 5 | 100k | | `boost` | 12 | 24 | 2 | 100k | | `buckBoost` | 12 | −24 | 1 | 100k | | `flyback` | 24 | 12 | 1 | 100k | | `halfBridge`、`fullBridge` | 400 | 由方波決定 | 10 | 20k | | `inverter3` | 600 | 線性範圍的 80% | 10 | 10k | | `rcLowPass` | 10 | (不使用) | 0.01 | 1k | | `rlc` | 10 | (不使用) | 1 | 10k | ### 公式(教科書,理想連續導通) 出處:Erickson 與 Maksimović《Fundamentals of Power Electronics》第 2、6 章;Mohan、Undeland 與 Robbins《Power Electronics》第 7、8 章;Ogata《Modern Control Engineering》二階系統的步階響應。每一條公式也在回傳的 `values[].formula` 裡,附上代入的數字。 | 拓樸 | 公式 | |---|---| | `buck` | D = Vout/Vin;L = (Vin − Vout)·D/(fsw·ΔI);C = ΔI/(8·fsw·ΔV);R = Vout/Iout;ΔI = ripplePct·Iout | | `boost` | D = 1 − Vin/Vout;IL = Iout·Vout/Vin;L = Vin·D/(fsw·ΔI),ΔI = ripplePct·IL;C = Iout·D/(fsw·ΔV) | | `buckBoost`(反相) | D = \|Vout\|/(Vin + \|Vout\|);IL = Iout/(1 − D);L = Vin·D/(fsw·ΔI);C = Iout·D/(fsw·ΔV) | | `flyback` | 取 D = 0.4;匝數比 n = Ns/Np = Vout·(1 − D)/(Vin·D);ILm = n·Iout/(1 − D);Lm = Vin·D/(fsw·ΔILm);C = Iout·D/(fsw·ΔV);耦合係數 0.995,加與範例相同的 RC 緩衝電路 | | `halfBridge` | 50% 方波,負載看到 ±Vin/2,基波 V1 = √2·Vin/π(有效值);Z = V1/Iout;功率因數 0.8 落後的 RL 負載;每顆母線電容 C = √2·Iout/(π·fsw·ΔV);輸出頻率就是 fsw | | `fullBridge` | 負載看到 ±Vin,V1 = 4·Vin/(π·√2);其餘同上 | | `inverter3` | 正弦三角 PWM,線性範圍的相電壓峰值為 ma·Vdc/2,所以 ma = 2√2·Vphase/Vdc(要求 ma ≤ 1);Y 接 RL 負載,功率因數 0.8;載波對基頻比必須在 10 到 2500 之間 | | `rcLowPass` | R = Vin/Iout;C = 1/(2π·fc·R);τ = RC | | `rlc` | Z0 = Vin/Iout;L = Z0/ω0;C = 1/(ω0·Z0);ζ = −ln(OS)/√(π² + ln²(OS));R = 2ζ·Z0 | 零件值都寫成**電路變數**(`Vin`、`D`、`fsw`、`Lf`、`Cf`、`Rload`……),元件參數引用它們,所以 `analysis.paramSweep`、`analysis.optimize` 可以直接掃。電路預設的模擬設定:最大步長 = 1/(fsw·200);模擬時間約 10 倍的 √(LC),但至少 30 個切換週期、最多 5000 個。DC-DC 轉換器的電感電流與電容電壓已預先設為穩態初值,短時間模擬就能讀到穩態;橋式、逆變器與 RC / RLC 從零初值開始。 ### 會被拒絕的規格 規格做不到時,指令回傳錯誤並說明原因,不會默默給你一個沒意義的電路: | 情況 | 訊息重點 | |---|---| | buck 的 `vout ≥ vin` | 降壓轉換器只能降壓,建議改用 `boost` 或 `buckBoost` | | boost 的 `vout ≤ vin` | 升壓轉換器只能升壓 | | 占空比不在 0.02 到 0.95 | 例如 48V 降到 0.5V,或 12V 升到 400V | | 半橋、全橋的 `vout` 與方波基波差超過 5% | 說明這個 `vin` 實際給多少伏特,建議的 `vin` | | 逆變器的 `vout` 超過線性範圍 | 說明線性極限 Vdc/(2√2),需要過調變 | | 載波與基頻比不在 10 到 2500 | 說明合法範圍 | | 零件值小於 1e-15 或大於 1e15 | 表示漣波規格太極端,無法實作 | | 電壓、電流、頻率 ≤ 0 或太大,漣波超出範圍,`fsw` 低於 1 kHz(切換電路) | 指出是哪個參數 | ## `circuit.wire` ```json {"from": "S1.n", "to": "L1.p"} {"wires": [{"from": "V1.p", "to": "S1.p"}, ["S1.n", "L1.p"], ["V1.n", "0"]]} ``` - 兩端寫成 `元件.接腳`。引擎替你處理網路名稱:兩個接腳都沒接過就取新名稱 `n1`、`n2`……;任一個已經有網路就沿用;兩個都有不同網路就**合併**(接地網路 `0` 優先保留)。 - 一端可以是不含 `.` 的網路名稱,但只能是接地(`0`、`gnd`、`GND`)或已存在的網路,用來接地或接到既有節點。如果你寫了 `S1`(忘了接腳),錯誤訊息會告訴你 `S1` 是元件並列出它的接腳。 - 一次呼叫可以給一份清單(最多 1000 條),整份只記一個歷史步驟;其中任何一條失敗,整份都不套用,錯誤訊息會指出是第幾條。 - 錯誤都附上可行動的資訊:接腳不存在時列出該元件所有合法接腳(`valid pins: p, n, gate`),大小寫打錯時提示正確的名稱,元件不存在時列出現有元件,訊號接腳接到電氣接腳時說明不同域不能相連。 - 合併網路時,直接引用被合併掉的網路名稱的探針(`probes`)不會自動更新。 `circuit.connect {component, port, net}` 仍然可用,需要指定網路名稱時用它。 ## `schematic.autoLayout` ```json {"style": "textbook"} ``` 排版規則: 1. 電源在最左邊,垂直放置,正端朝上。 2. 串聯路徑(開關、電感、串聯電阻……)排在上方的軌道上,電位較高的接腳在左。 3. 接地的並聯元件(二極體、電容、負載、下橋開關……)垂直向下,接腳向上接軌道。 4. 接地符號在最下面。控制方塊在整個電路上方,依訊號流向由左到右排列。 5. 所有位置都是整數格點,每個元件有自己的格子,所以不會重疊,接腳一定在格點上。 這是啟發式演算法,限制如下: - 針對梯形的功率級(電源 → 串聯路徑 → 並聯元件)最漂亮。橋式、多分支、回授很多的電路排出來可讀,但不精緻;畫布以直線畫網路,跨越多條分支的網路會穿過別的元件。 - 三個以上軌道網路的元件(耦合電感)畫在最低層網路上,其他接腳的線會比較長。 - 不處理子系統內部,只排實例。最多 2000 個元件,每個元件最多 64 個接腳,超過會回傳錯誤。 - 結果是確定性的:同一個電路永遠排出同一個版面。它只改位置與旋轉,不動網表;一次呼叫一個歷史步驟,可以復原。 `circuit.template` 開的電路已經排好,不必再呼叫一次。 ## `circuit.explain`:先看懂電路再動手 AI 拿到一張不熟的電路(從 LTspice、PLECS 匯入,或別人給的檔案)時,第一個該呼叫的指令。它不模擬,只讀網表,一次回答四件事: ```json {"detail": "short"} ``` | 回傳欄位 | 內容 | |---|---| | `topology` | 辨識出的拓樸(buck 含同步與非同步、boost、反相 buck-boost、SEPIC、Cuk、flyback、forward、半橋、全橋、三相兩階逆變器、二極體整流器、PFC boost、LLC/串聯諧振、DAB、馬達驅動)、信心值,以及每個元件的角色,例如 `{"S1": "high-side switch", "D1": "freewheel diode", "L1": "output inductor"}` | | `partition` | 功率級、閘極驅動、感測、控制、參考值、負載與機械、熱各有哪些元件 | | `controlLoops` | 哪個量測(例如 `v(out)`)經過哪個控制器(PI)和調變器(PWM)推到哪個閘極;沒有迴路的閘極列在 `openLoopGates`(開迴路) | | `parameters`、`estimates` | 從參數與變數讀出的 Vin、占空比、fsw、L、C、負載、匝數比,以及教科書公式算出的 Vout、電感電流與漣波、輸出漣波、導通模式(CCM 或 DCM)、諧振頻率;馬達驅動另有 `drive`(極數、同步轉速) | | `notes` | 審查者會提的事:沿用 `circuit.diagnose` 的靜態規則(缺死區、閘極無驅動、浮接節點),加上開迴路、無輸出電容、DCM、漣波過大、過調變 | | `summary` | `en` 與 `zhHant` 各一段白話,例如「48V → 12V buck converter at 100kHz, open loop …; expected Vout ≈ 12V, ΔIL ≈ 900mA p-p …」 | 辨不出來時 `topology.kind` 是 `unknown`,其餘欄位仍然盡量填(元件清單、電源、控制迴路),不會出錯。`{"detail": "full"}` 多回傳每一個候選階段、完整分區與電源清單。這個指令唯讀,不會記錄歷史步驟,也不會改電路。 估算都假設理想元件與穩態;匯入的電路請當作「先對一下」,要決定設計前還是要模擬。 ## 限制與提醒 - `circuit.template` 是理想元件、連續導通的設計起點,不含導通損耗、ESR、死區以外的寄生效應。拿結果做設計決策前,請用 `analysis.losses`、`analysis.worstCase` 等指令再檢查。 - 輸出漣波的設計值假設理想電容;模擬量到的值會因為電容的 ESR、開關壓降而略有不同。 - `sim_run` 是同步的,不能中途取消。模板的預設模擬都在約一百萬步以內。 - 逆變器與橋式的負載是固定功率因數 0.8 的 RL 負載,要別的負載請事後改 `Rload`、`Lload`。 - AI 可能會誤解需求;請它「先重述規格再建」是個好習慣,因為 `circuit.template` 的回覆會原樣列出它採用的 `spec`。 ## 驗證這些指令 ```sh cargo test -p powercraft-engine template_cmds cargo test -p powercraft-engine wire_cmds cargo test -p powercraft-engine layout_cmds cargo test -p powercraft-engine explain_cmds cargo test -p powercraft-engine --test panic_hunt cargo test -p powercraft-automation --test chat_helpers cargo test -p powercraft-cli chat cargo test -p powercraft-ui-egui --test autolayout_geometry ``` --- # 除錯手冊:電路出問題時,從症狀開始找原因 URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/workflows/debugging/ 這份文件回答一個問題:「實體電路或模擬測試出了問題,我該先量什麼、先查什麼?」做法是從你看到的症狀開始,每個症狀都列出三件事:要量什麼、怎麼量,常見原因,以及怎麼在 Voltecx 裡重現與驗證。 文中的數值(頻率、波形大小、百分比)是依公式推算或依一般經驗,沒有在寫文件時實際執行。實際結果以指令回傳為準。 ## 先認識三個除錯指令 | 指令 | 它做什麼 | 最小的用法 | |---|---|---| | `circuit.diagnose` | 檢查電路,列出問題。每一筆都寫明哪個元件或節點、原因、下一步 | `{"run": true, "tEnd": "2m"}` | | `waveform.compare` | 把模擬波形和示波器匯出的 CSV 比對,算出誤差並用白話說明可能原因 | `{"csv": "", "map": {"v(out)": "CH1"}, "timeShift": "auto"}` | | `debug.fitToMeasurement` | 調整你列出的元件參數,讓模擬和示波器的 CSV 吻合,並說明每個數值有多可信 | `{"csv": "", "map": {"i(L1)": "CH2"}, "params": [{"component": "L1", "key": "l", "min": "50u", "max": "200u"}]}` | | `fault.inject` | 在電路裡放一個故障(開路、短路、閘極卡住、參數漂移),用來重現症狀 | `{"component": "S1", "kind": "stuckOff"}` | 另外兩個配套指令:`fault.list` 列出目前的故障,`fault.clear` 移除故障。 第四個指令把前兩個合起來:`debug.locateFault` 拿一份示波器 CSV,依序在電路的複本裡放入每一個候選故障、跑模擬、和量測比對,再依誤差排名。用法:`{"csv": "", "map": {"v(out)": "CH1", "i(L1)": "CH2"}}`。 ### circuit.diagnose:它找什麼 只給 `{}`(或不給參數)時只做靜態檢查,不跑模擬,速度很快。加上 `"run": true` 會另外跑一段短模擬(預設用電路自己的 `tEnd`,最多約 30 萬步;用 `tEnd` 可以指定更短或更長),再檢查波形。這段模擬不會改動電路,也不會取代你目前的模擬結果。 每一筆結果長這樣: ```json { "severity": "error", "rule": "shoot-through", "where": "Q1/Q2", "message": "`Q1` and `Q2` conduct together for 25.00 us (50.0% of the run), connecting the rails through node `mid`", "suggestion": "Add or lengthen dead time ..." } ``` 結果依嚴重程度排序:`error`(一定要處理)、`warn`(很可能有問題)、`info`(提醒)。 | 規則 `rule` | 嚴重度 | 檢查什麼 | 需要 `run` | |---|---|---|---| | `compile` | error | 電路無法編譯,訊息會指出是哪個元件的哪個參數 | 否 | | `ground.missing` | error | 沒有任何腳接地,節點電壓沒有參考點 | 否 | | `island.floating` | warn | 一群節點和地之間沒有路徑(例如沒有接地的隔離繞組) | 否 | | `pin.unconnected` | warn | 元件的腳或控制輸入沒接 | 否 | | `net.dangling` | warn | 一個節點只接到一隻腳,電流無處可去 | 否 | | `gate.undriven` | error | 開關的閘極沒接,或接到沒有人驅動的訊號 | 否 | | `signal.undriven` | warn | 控制訊號有人讀,但沒有任何方塊輸出它 | 否 | | `signal.unused` | info | 某個方塊的輸出沒有人用 | 否 | | `signal.node_voltage` | info | 控制輸入接在功率網路上,讀取該網路對地的電壓(隱含的電壓表,與 PSIM、PLECS 相同) | 否 | | `leg.deadtime` | warn | 半橋臂(兩個開關串聯,中間接負載)的閘極路徑沒有 `deadtime` 方塊 | 否 | | `leg.shared_gate` | error | 同一臂的兩個開關接到同一個閘極訊號 | 否 | | `shoot-through` | error | 同一臂的兩個開關同時導通,寫明重疊多久與峰值電流 | 是 | | `device.rating` | error 或 warn | 電流或電壓超過元件資料庫的額定值(超過是 error,達 80% 是 warn) | 是 | | `ringing` | warn | 在開關頻率的 5 倍以上有一條不屬於諧波的頻譜線,且大於訊號擺幅的 5% | 是 | | `oscillation.growing` | error | 振盪的包絡線越來越大,電路或控制迴路不穩定 | 是 | | `control.saturated` | warn | `pi`、`limiter`、`integrator` 方塊在超過 20% 的時間卡在上限或下限 | 是 | | `shunt.lowCurrent` | warn | `shuntRegulator`(TL431 類)在模擬後半段有超過 20% 的時間陰極電流低於資料手冊建議的 1 mA;模型照樣調節,實際元件可能不會 | 是 | | `steady.state` | warn 或 info | 最後兩個時間窗的平均值還在移動,代表還沒到穩態;或是模擬太短,無法判斷 | 是 | | `inductor.mode` | info | 每個電感在最後一段時間是連續導通(CCM)還是不連續導通(DCM) | 是 | | `simulation` | error | 診斷用的短模擬失敗,訊息會說明原因 | 是 | | `circuit.check` | info | 編譯時的其他警告(上面已經涵蓋的警告不會重複列出) | 否 | | `run.shortened` | info | 為了限制工作量,診斷的模擬被截短了 | 是 | 限制要先知道: - `ringing` 需要電路裡有 `pwm`、`pwm3` 或 `carrier` 方塊,才知道開關頻率。穩態與 CCM、DCM 的判斷會把時間窗取成整數個週期:週期取自 PWM 與正弦電源裡最慢的那一個。 - 診斷用的模擬很短時,`ringing` 與 `oscillation.growing` 會因為資料不夠而不判斷,不是代表沒問題。 - 理想開關沒有寄生電感與電容,所以模擬裡不會自己出現真實電路的振鈴。看到 `ringing`,代表你的電路裡已經有會共振的元件。 - `device.rating` 只檢查有指定 `device` 參數的開關與二極體(資料來自內建元件庫或電路內嵌的元件資料)。 - 目前只檢查最上層的元件,子系統內部的元件不在檢查範圍。 ### waveform.compare:它怎麼比 先用 `simulation.run` 跑出結果,再比對。`map` 是「模擬訊號 → CSV 欄位」。 ```json { "csv": "Model,MSO...\nTime (ms),CH1 (V)\n0,0.01\n0.01,0.02\n...", "map": {"v(out)": "CH1", "i(L1)": "CH2"}, "t0": "2m", "timeShift": "auto", "render": true } ``` - **CSV 的讀法**:開頭的機型、序號、取樣間隔等說明行會被略過;標題裡的單位會被讀懂並換成 SI(`Time (ms)` 換成秒,`CH1 (mV)` 換成伏特);時間欄靠欄名(`Time`、`t`、`s` 等)或「第一個嚴格遞增的欄」認出來;完全沒有時間欄的話,用檔頭的 `Sample Interval`。重複的時間點會被丟掉,轉換過程寫在回傳的 `notes`。 - **檔案來源**:`csv` 放 CSV 全文。`powercraft-cli serve` 與 headless MCP 也接受 `path`(檔案必須在讀取根目錄 `--automation-read-root` 之內);桌面 app 與 MCP bridge 請用 `csv`。 - **時間偏移 `timeShift`**:預設 0。給秒數就照用;給 `"auto"` 會用相關係數搜尋偏移(最多找時間範圍的 25%)。回傳的 `timeShift` 是「加到量測時間軸上」的秒數:負值代表量測波形比模擬晚。週期性訊號有多個等價的偏移,會選最小的那個。 - **比對範圍**:`t0`、`t1` 限制比對的時間窗。起動暫態常常不是你要比的,用 `t0` 跳過去。 - **每個訊號的結果**:`rmsError`、`relativeRms`(誤差 RMS 除以模擬 RMS)、`maxAbsError` 與 `maxErrorAt`、`mean`、`peakToPeak`、`ripple`(最後 20% 去除斜率後的峰對峰)、`gain` 與 `offset`(量測 ≈ gain × 模擬 + offset)、`correlation`、`match`(`good` 小於 2%,`fair` 小於 10%,其餘 `poor`)與 `verdict`。 - **`verdict` 會說什麼**:量測是模擬的 0.5 倍,會指向探棒衰減、垂直刻度;直流準位差很多,會指向負載、電源、元件值或探棒的接地參考;漣波大很多,會指向電容 ESR 與 ESL、探棒頻寬與接地線長度、開關雜訊耦合;漣波小很多,會指向示波器或探棒頻寬不足,或模型的 ESR 太大。 - **`render: true`**:額外回傳一張疊圖(PNG,base64),模擬與量測各一條線,前三組訊號會被畫出來。 ### debug.fitToMeasurement:從量測反推參數 `waveform.compare` 告訴你「差多少」;形狀對了、數值不對時,`debug.fitToMeasurement` 幫你找出「實際是多少」。它和 `waveform.compare` 一樣讀 CSV(`csv` 或 `path`)、`map`、`t0`、`t1`、`timeShift`(只接受秒數,預設 0),另外要一個 `params` 清單,最多 8 個: ```json { "csv": "", "map": {"v(out)": "CH1", "i(L1)": "CH2"}, "params": [ {"component": "L1", "key": "l", "min": "30u", "max": "300u"}, {"component": "C1", "key": "esr", "min": "1m", "max": 0.5} ], "t0": "0.2m" } ``` - **它在做什麼**:每次評估都用新的參數值跑一次模擬,把每個對應訊號重新取樣到同一組時間點,誤差是「RMS 誤差 ÷ 量測峰對峰值」,多個訊號取平方平均。先粗掃一遍範圍(1 個參數 9 點、2 個參數 5×5、更多時用 Halton 點,加上電路目前的數值),再從最好的那一點用 `analysis.optimize` 的 Nelder–Mead 細找。`min` 大於 0 時用對數刻度搜尋。 - **常見用法**:電感從電流漣波的斜率(對應 `i(L1)`);輸出電容的 `esr` 從輸出電壓漣波的階躍(對應 `v(out)`);迴路或寄生電感從振鈴頻率;死區時間從開關節點的邊緣。 - **回傳**:`fitted`(每個參數的擬合值)、`error.before` 與 `error.after`(擬合前後的誤差)、`signals`(每個訊號的前後誤差),以及每個參數的 `confidence`: - `high`:數值移動不到 5%,誤差就會增加一成;`medium`:5% 到 20%;`low`:更寬,或停在範圍邊界(`atBound` 是 `min` 或 `max`,表示範圍太窄)。 - `unidentifiable`:這個參數在這段時間窗裡完全不影響對應的訊號,量測無法決定它。換一個訊號、換時間窗,或把它拿掉。 - `uncertaintyPct` 是上述「誤差增加一成」對應的數值變化(百分比);`note` 與 `noteZh` 用白話說明。 - **`apply: true`**:擬合結果比原電路更吻合時,把數值寫回電路,算一個歷史步驟,一次 `edit.undo` 就還原。**`render: true`**:額外回傳擬合後的模擬與量測疊圖。 - **成本**:預設 `maxEvals` 120 次模擬(最多 400),每次跑完整的 `tEnd`。用 `tEnd` 縮短模擬、用 `t0` 跳過起動暫態,會快很多。 ### fault.inject:故障怎麼放 故障都是普通的電路編輯,所以看得到、存得下來,一次 `edit.undo` 就消失,而且每次只記錄一個歷史步驟。 | `kind` | 做了什麼 | `value` | |---|---|---| | `open` | 在一隻腳串一顆大電阻 `Fault_open_<元件>`(用 `port` 指定哪隻腳,預設第一隻電氣腳) | 電阻值,預設 1e9 Ω | | `short` | 在前兩隻電氣腳之間並一顆小電阻 `Fault_short_<元件>` | 電阻值,預設 1e-3 Ω | | `stuckOn` | 用一個常數方塊把閘極固定為 1。二極體則改成短路 | 無 | | `stuckOff` | 用一個常數方塊把閘極固定為 0。二極體則改成開路 | 無 | | `drift` | 把參數改成「原值 × 係數」。原值存在電路變數 `Fault_drift_<元件>__<參數>` | 係數,預設 1.2;`key` 指定參數,預設是該元件最常用的那個(電阻 `r`、電容 `c`、電感 `l`、開關 `ron` 等) | | `ground` | 從一隻腳(`port`,預設第一隻電氣腳)到地(網路 `0`)並一顆小電阻 `Fault_ground_<元件>` | 電阻值,預設 1e-3 Ω | 不放在元件上時:`{"net": "a", "kind": "ground"}` 把網路 `a` 對地短路(`Fault_netGround_a`),`{"between": ["a", "b"], "kind": "short"}` 把兩個網路短接(`Fault_netShort_a__b`)。 加上 `at`(秒)時,開路、短路與接地故障會在那個時間才出現:故障元件變成一個理想開關,由階躍方塊 `Fault_…_t` 在 `at` 切換,所以一次模擬就看得到故障前、故障當下與保護動作。檢查串聯保險絲的選擇性用 `protection.fuseCoordination`,保險絲與斷路器混用時用 `protection.coordination`。 規則:同一個元件同一種故障只能放一個;`stuckOn` 與 `stuckOff` 互斥;元件要先有那個參數的明確值才能漂移(沒有就先用 `circuit.setParam` 設)。`fault.clear` 會把電路還原成注入前的樣子(元件、接線、參數都一樣,只有內部的編號計數器不同)。 ### debug.locateFault:哪個零件最可能壞了 - **候選故障**:預設是電路裡每一個電阻、電容、電感(開路、短路、`drift` 0.8 倍與 1.2 倍)、二極體(開路、短路)和開關(`stuckOn`、`stuckOff`)。`candidates` 只試你列出的元件,`kinds` 只試你列出的故障種類,`drift` 改漂移係數。 - **誤差**:每個對應的訊號算「均方根誤差 ÷ 量測值的均方根」,再對所有訊號取均方根。`timeShift` 預設 `"auto"`:取「不平移」與「估計的平移」兩者中誤差較小的那一個。 - **基準**:同時對沒有故障的電路算一次誤差(`baseline`)。只有當最好的故障誤差不超過基準的 (1 − `margin`) 倍(`margin` 預設 0.3)時才回報 `found: true`;否則回報「未找到故障」。 - **上限**:最多 `maxRuns` 次(預設 64,最多 256),各次平行執行;超過 `budget` 秒(預設 120)後還沒開始的就略過,數量寫在 `skipped`。`tEnd` 可縮短每次模擬。 - **回傳**:`ranked` 依誤差由小到大排列,每一列有 `component`、`kind`、`factor`、`error`、`improvement`(比基準好多少)、每個訊號的誤差,以及英文與繁中的一句說明;`summary` 是整體結論;不能放的故障列在 `notTried`,模擬失敗的列在 `failed`。電路本身不會被改動;如果電路裡已經有故障,請先 `fault.clear`。 ## 通用流程 1. **先跑 `circuit.diagnose`**,只看 `error` 與 `warn`。很多問題(沒接地、閘極沒接、沒有死區時間)在這一步就會被指出來。 2. **確認模擬能代表真實電路**:用 `waveform.compare` 比對一個你信得過的訊號(通常是輸出電壓),看 `verdict`。如果連這個都對不上,先找模型與實體的差異,不要急著找症狀的原因。 3. **確認症狀**:用 `scope.measure`、`analysis.fft`、`waveform.render` 看模擬裡有沒有同樣的症狀。 4. **用 `fault.inject` 重現**:懷疑哪個零件,就把它弄壞,看波形是不是和實體一樣。重現成功,原因就找到八成。不知道從哪個零件開始時,先跑 `debug.locateFault`,從排名第一的故障開始驗證。 5. **修好之後**用 `waveform.compare` 再比一次,並用 `analysis.paramSweep` 或 `analysis.monteCarlo` 確認不是剛好在這一組數值才好。 ## 量測前的準備 很多「問題」其實是量測造成的。下面幾項先確認,再下結論。 | 項目 | 怎麼做 | 為什麼 | |---|---|---| | 探棒接地 | 用接地彈簧(ground spring)或最短的接地環,不要用長鱷魚夾線 | 接地線約 1 nH/mm。10 cm 的線大約 100 nH,會和探棒電容共振,讓開關節點多出一段假的振鈴 | | 頻寬 | 示波器加探棒的頻寬要大於你關心的最高頻率的 5 倍;看邊緣的話,頻寬約等於 0.35 ÷ 上升時間 | 5 ns 的邊緣至少要約 70 MHz 才量得到;想看 50 MHz 的振鈴,要 250 MHz 以上 | | 取樣率 | 至少是頻寬的 2.5 倍,邊緣上至少有 10 個取樣點 | 取樣太稀會把尖峰量小 | | 探棒衰減 | 探棒的 ×1、×10 開關和示波器通道設定要一致 | 不一致時,量到的是 10 倍或 0.1 倍。`waveform.compare` 的 `gain` 約等於 0.1 或 10 就是這個原因 | | 電流探棒 deskew | 電壓探棒和電流探棒的傳遞延遲不同(常差數 ns 到十幾 ns)。用 deskew 治具把兩者對齊後再量開關損耗 | 沒對齊,電壓與電流的重疊面積會算錯,開關損耗可以差一倍以上 | | 高端量測 | 用差動探棒,不要把示波器的地線浮接 | 浮接會讓人觸電,也讓共模雜訊直接進到量測 | | 觸發與紀錄長度 | 看穩態用夠長的紀錄;抓偶發事件用單次觸發 | 紀錄太短會看不到低頻的漂移或振盪 | ## 症狀一:直流準位不對 輸出電壓比預期高、低,或是跟設定值差一個固定的量。 **要量什麼** - 輸入電壓、輸出電壓、負載電流,同時量。量在元件腳位上,不要量在連接器上(連接器到元件之間有壓降)。 - 閘極訊號的責任週期。 - 用三用電表和示波器各量一次,確認不是量測的問題(探棒衰減、接地)。 **常見原因** - 責任週期不對:參考值、分壓電阻、回授接線錯誤。 - 負載比預期輕,轉換器進入 DCM,電壓增益和 CCM 不同。 - 導通電阻、二極體壓降、電感的銅損讓輸出比理想值低。 - 回授分壓電阻的誤差或參考電壓的誤差,直接變成輸出誤差。 - 控制器卡在上限或下限(輸出已經是最大責任週期)。 - ADC 的偏移或增益誤差,讓控制器以為已經到了設定值。 **在 Voltecx 重現與驗證** 1. `circuit.diagnose` 加 `run: true`。看 `inductor.mode`(是不是 DCM)、`control.saturated`(控制器是不是卡住)、`steady.state`(是不是還沒到穩態)。 2. `waveform.compare`,`t0` 設在穩態之後。`verdict` 若寫「DC level ...」,代表直流準位差,照它列出的原因檢查:負載、電源、元件值、探棒接地。 3. `scope.measure` 取 `mean`,確認模擬的穩態值。 4. `analysis.paramSweep` 掃責任週期變數 `D` 或負載電阻,看輸出怎麼變,找出哪個因素最敏感。 5. `analysis.monteCarlo` 對回授分壓電阻加公差,看輸出落在多大範圍。 6. `analysis.losses` 看各元件吃掉多少功率,確認壓降是不是主要來自某個元件。 7. 用 `fault.inject` 的 `drift` 把負載或分壓電阻改 ±5%,看是不是能重現實測的偏差。 ## 症狀二:振盪 輸出或開關節點出現不該有的週期性波動,幅度固定、變大,或只在特定負載出現。 **要量什麼** - 振盪頻率。靠近開關頻率的一半(次諧波)、遠低於開關頻率(迴路不穩)、遠高於開關頻率(寄生共振,見症狀三),原因完全不同。 - 振幅是固定、變大,還是只在暫態出現。 - 它是否隨輸入電壓、負載、溫度改變。 - 可以的話,打開迴路,在迴路中注入小訊號,量迴路增益與相位邊限。 **常見原因** - 控制迴路相位邊限不足:補償器太激進、輸出電容 ESR 零點位置不對、右半平面零點。 - 數位延遲(取樣、計算、PWM 更新)吃掉相位。 - 責任週期接近 0.5 的電流模式控制缺少斜率補償。 - 比較器沒有遲滯,在雜訊下反覆跳動。 - DCM 與 CCM 邊界上的增益變化。 **在 Voltecx 重現與驗證** 1. `circuit.diagnose` 加 `run: true` 並把 `tEnd` 設得夠長(至少讓診斷的時間窗涵蓋數個迴路時間常數)。若出現 `oscillation.growing`,代表模擬裡就是不穩定。 2. 用 `analysis.fft` 在穩態時間窗量振盪頻率,和實測比對。 3. 迴路增益:`analysis.loopGain` 可以看交越頻率與相位邊限。注意:這個指令在 AC 分析分支,合併進主線之前無法使用。 4. 用 `analysis.paramSweep` 掃控制器增益(例如 PI 的 `kp`),看振盪從哪個值開始出現。 5. 分辨「真的振盪」和「數值振盪」:把 `maxStep` 縮小為十分之一重跑,或換成 `solver: "reference"`。真實的振盪不會因此改變,數值振盪會變或消失。 6. 用 `fault.inject` 的 `drift` 把輸出電容 `c` 設成 0.5 倍,或把電容的等效串聯電阻改掉,看穩定度怎麼變。 ## 症狀三:開關節點振鈴與過衝 開關節點(半橋中點、MOSFET 汲極)在邊緣之後出現衰減的高頻振盪,電壓峰值比輸入電壓高很多。 **要量什麼與怎麼量** - 用接地彈簧量,頻寬要大於振鈴頻率的 5 倍(見「量測前的準備」)。 - 量三個數:振鈴頻率 f0、過衝峰值、衰減到穩定的時間。 - 估計寄生電容與電感:在開關節點並一顆已知電容 Cx,調到振鈴頻率降為原來的 1/√2。此時 Cx 就等於原本的寄生電容 Cp,寄生電感 L = 1 ÷ ((2π × f0)² × Cp)。 - 阻尼用的 RC 緩衝器(snubber):電阻約等於 √(L ÷ Cp),電容約為 Cp 的 3 到 4 倍。這只是起點,要再微調。 **常見原因** - 迴路寄生電感(走線、封裝)與開關的輸出電容 Coss、二極體電容共振。 - 二極體的反向恢復電流在關斷時突然停止。 - 閘極驅動太快(dv/dt、di/dt 太大)。 - 探棒的接地線太長(先排除這一項)。 **在 Voltecx 重現與驗證** 1. 理想開關沒有寄生元件。要重現,就在電路裡明確加上:開關節點的對地電容、迴路的寄生電感(串一顆小電感)。 2. `circuit.diagnose` 加 `run: true`:`ringing` 會寫出振鈴頻率與大小,`device.rating` 會告訴你電壓峰值離額定值多近。 3. `waveform.compare`:模擬沒有振鈴、量測有,且 `verdict` 寫「ripple ... larger」,先懷疑探棒頻寬與接地線,再懷疑模型缺少寄生元件。 4. `analysis.paramSweep` 掃緩衝器的 R 與 C(以電路變數表示),找過衝與損耗的平衡點。內建的 `flyback` 範例就有一個 RC 緩衝器可以參考。 5. `analysis.losses` 確認緩衝器的電阻消耗多少功率,避免為了壓振鈴而增加太多損耗。 ## 症狀四:直通(shoot-through) 半橋的上下兩個開關在切換瞬間同時導通,匯流排被短路,電流尖峰很大,開關很快過熱甚至炸掉。 **要量什麼與怎麼量** - 同一個示波器同時量上下兩個閘極對源極電壓(Vgs),看兩者之間的死區時間:上管關斷到下管導通之間要有間隔。 - 用電流探棒量匯流排電流,看每次切換有沒有尖峰。 - 量低端 Vgs 在高端導通瞬間有沒有被拉高(米勒效應造成的誤導通)。 **常見原因** - 沒有死區時間,或死區時間比較慢的開關的關斷時間還短(高溫時關斷更慢)。 - 兩個閘極接到同一個訊號。 - 驅動器的傳遞延遲不一致。 - 高 dv/dt 透過米勒電容把閘極拉高,造成誤導通。 - 控制器啟動或重置時的閘極雜訊。 **在 Voltecx 重現與驗證** 1. `circuit.diagnose`(不用 `run`)就會給 `leg.deadtime`(閘極路徑沒有 `deadtime` 方塊)與 `leg.shared_gate`(兩個開關接同一個訊號)。 2. 加上 `run: true`:`shoot-through` 會寫出兩個開關同時導通多久、佔整段模擬的幾 %、峰值電流;`device.rating` 會顯示電流超過額定值。 3. 修法:在 PWM 輸出與每個閘極之間放 `deadtime` 方塊,`td` 取比較慢的開關的關斷時間再加餘裕(幾百 ns 到 1 µs 是常見的起點)。內建的 `halfBridge` 範例就是這個接法。 4. 想看後果:對一個開關用 `fault.inject` 的 `stuckOn`,另一個照常切換,看電流和損耗。 5. 修好之後再跑一次 `circuit.diagnose` 加 `run: true`,確認 `shoot-through` 消失。 ## 症狀五:過熱 元件或散熱片比預期熱,效率比預期低。 **要量什麼與怎麼量** - 輸入功率、輸出功率,算出總損耗。 - 殼溫(熱電偶或熱像儀;熱像儀要設對發射率)。 - 環境溫度與氣流。 - 把損耗分成導通損耗與開關損耗:降低開關頻率,看溫度掉多少。 **常見原因** - 導通損耗:Rds(on) 在高溫時會變成室溫時的 1.5 到 2 倍。 - 開關損耗:開關頻率太高、閘極太慢、振鈴、二極體反向恢復。 - 電感磁芯損耗或飽和(飽和時電流尖峰變大)。 - 直通(症狀四)。 - 過載、散熱片接觸不良、熱介面材料不足。 **在 Voltecx 重現與驗證** 1. `analysis.losses` 列出每個元件的平均損耗(瓦)與導通、開關各自的能量。先看最大的那一個。 2. `analysis.thermal` 看熱網路各節點的最終溫度與最大值。內建的 `buckThermal` 範例有 MOSFET 到散熱片的熱模型,可以當作寫法的參考。 3. `circuit.diagnose` 加 `run: true`:`device.rating` 看電流是否逼近額定值,`shoot-through` 看有沒有直通。 4. `analysis.paramSweep` 掃開關頻率 `fsw` 或導通電阻,看損耗與溫度怎麼跟著變。 5. 用 `fault.inject` 的 `drift`(`key` 設為 `ron`,`value` 設為 2)模擬高溫下導通電阻變大。 6. 注意:Voltecx 的電感是線性的,不會模擬飽和。要判斷飽和,看 `i(L1)` 的峰值(用 `scope.measure` 的 `max`)有沒有超過資料手冊的飽和電流。 ## 症狀六:雜訊與 EMI 輸出有高頻雜訊、感測訊號被干擾,或是傳導與輻射量測超標。 **要量什麼與怎麼量** - 先分清楚雜訊出現在哪裡:輸出、輸入、感測線、地線。 - 雜訊是否和開關邊緣同步(用開關節點觸發)。如果是,原因在切換;如果不是,可能是外部干擾。 - 用近場探棒找最強的位置;傳導量測用 LISN,並把差模與共模分開看。 - 量測時用接地彈簧,並確認雜訊不是探棒接地線拾取的。 **常見原因** - 邊緣太快(dv/dt、di/dt),電流迴路面積太大。 - 開關節點振鈴(症狀三)。 - 二極體反向恢復。 - 共模電流經過開關對散熱片的寄生電容。 - 地線彈跳:感測電路與功率電路共用地線的一段。 **在 Voltecx 重現與驗證** 1. `analysis.fft` 量開關節點電壓或輸入電流在穩態時間窗的頻譜,確認雜訊在開關頻率的哪些倍數。 2. `circuit.diagnose` 加 `run: true` 的 `ringing` 會指出高頻共振。 3. `waveform.compare` 的 `ripple` 比值可以量化「實測比模擬多出多少漣波」。 4. 限制要先知道:理想開關的邊緣是瞬間的,也沒有共模寄生電容。想看這類效應,要自己把寄生電容、寄生電感加進電路;Voltecx 不會自動模擬輻射。 5. 用 `analysis.paramSweep` 掃輸入濾波器的電感與電容,看漣波與共振怎麼改變。 ## 症狀七:起動失敗 上電後輸出不起來、起來又掉下去,或起動時保護跳脫、電流暴衝。 **要量什麼與怎麼量** - 輸入電壓的上升方式、控制器的供電(Vcc)與欠壓鎖定(UVLO)。 - 啟動腳(enable)與軟起動腳的時序。 - 湧入電流(inrush):用電流探棒單次觸發抓第一個尖峰。 - 起動後最初幾個週期的開關節點與閘極電壓。 **常見原因** - Vcc 在輸入電壓還沒夠高時就開始動作,或 UVLO 門檻太接近正常輸入範圍。 - 沒有軟起動,PI 控制器一開始就飽和,積分器累積太多(windup),造成過衝。 - 湧入電流過大,觸發過電流保護。 - 高端驅動的自舉電容還沒充電。 - 負載在起動時就吃滿電流(例如定功率負載或有電流限制的負載)。 - 輸出電容與電感的初值和實際不同。 **在 Voltecx 重現與驗證** 1. 初值:電容用 `v0`、電感用 `i0` 設起動時的狀態。 2. `circuit.diagnose` 加 `run: true`:`control.saturated` 會指出 PI 在多少 % 的時間卡在上限,這是最常見的起動問題。 3. 縮小 `tEnd` 與 `maxStep`,專看前 1 ms:用 `waveform.get` 的 `t0` 與 `t1` 取前幾個週期。 4. 用 `step` 方塊延遲啟動、用 `lookup` 方塊做軟起動的責任週期斜坡,看起動是否變得平順。 5. `fault.inject` 的 `stuckOff` 放在高端開關,看輸出是不是永遠起不來;放在低端,看會發生什麼事。 6. `analysis.paramSweep` 掃軟起動時間或 PI 的限幅,找出不會過衝的範圍。 ## 症狀八:感測器與 ADC 問題 控制器讀到的值和實際不同、讀值很吵,或控制器的行為跟著取樣時間而改變。 **要量什麼與怎麼量** - 把 ADC 的原始值換算回物理量,和示波器的實測值比,求出偏移與增益。 - 靜止狀態下讀很多筆,看標準差(雜訊底)。 - 取樣時間點相對於 PWM 的位置:理想是取在導通時間的中間,或電流的谷值,避開開關邊緣。 - 抗混疊濾波器的截止頻率、感測放大器的頻寬、參考電壓的雜訊。 **常見原因** - 取樣點落在開關邊緣,讀到切換雜訊。 - 沒有抗混疊濾波,開關頻率的雜訊混進低頻。 - 感測電阻或分壓電阻的誤差、運算放大器的偏移。 - 感測放大器頻寬不足,讀值落後實際電流。 - 感測地線與功率地線共用,被大電流造成的壓降影響。 - 量化誤差(位元數不夠)。 **在 Voltecx 重現與驗證** 1. 用 `sampleHold` 方塊(要設 `period`)模擬取樣,用 `delay` 方塊模擬計算與更新延遲,看控制迴路對這些延遲有多敏感。 2. `waveform.compare` 回傳的 `gain` 與 `offset` 可以直接當作感測鏈路的校正量(量測 ≈ gain × 模擬 + offset)。 3. 用 `fault.inject` 的 `drift` 把感測增益方塊的 `k`(`gain` 方塊的參數)改成 0.9 或 1.1,看控制迴路和輸出怎麼偏。 4. `analysis.monteCarlo` 對分壓電阻、感測電阻加公差,看輸出的分布。 5. `analysis.fft` 看感測訊號有沒有混疊:雜訊成分是不是落在開關頻率的倍數附近。 6. 目前沒有量化與 ADC 位元數的模型;要看量化的影響,可以用 `lookup` 方塊自己做階梯函數。 ## 症狀九:保護誤動作 過電流、過電壓、欠壓或過溫保護在不該動作時動作,或是該動作時沒動作。 **要量什麼與怎麼量** - 是哪一個保護在動作,門檻是多少,有沒有消隱時間(blanking)與濾波。 - 動作前後的波形:用單次觸發,觸發點設在保護訊號。 - 動作時的感測訊號有沒有被開關邊緣的尖峰推過門檻。 **常見原因** - 門檻離正常峰值太近,沒有餘裕。 - 開關邊緣的尖峰(振鈴、二極體反向恢復)超過門檻,卻沒有前緣消隱。 - 感測濾波太慢,保護來不及;或太快,被雜訊觸發。 - 沒有遲滯,在門檻附近反覆動作。 - 起動時的湧入電流(症狀七)。 **在 Voltecx 重現與驗證** 1. 用 `scope.measure` 的 `max` 量被保護的電流或電壓峰值,和門檻比;`circuit.diagnose` 加 `run: true` 的 `device.rating` 會在達到額定值 80% 時給出警告。 2. 用 `comparator` 方塊(門檻)加 `sampleHold` 或 `delay` 方塊建立保護邏輯,再看它在模擬裡什麼時候動作。 3. `analysis.paramSweep` 掃門檻或負載,找出會誤動作的邊界;`analysis.monteCarlo` 加零件公差,看誤動作的機率。 4. 用 `fault.inject` 把負載短路(`short`)或開路(`open`),確認保護能在預期的時間內動作。 5. 對振鈴造成的誤動作,先回到症狀三。 ## 模擬測試失敗了,怎麼辦 這一節是給「自動測試或比對沒有通過」的情況,例如和參考波形的誤差超標、兩個求解器的結果不一致、掃描中某些點失敗。依序做,每一步都可能就找到原因。 1. **完整讀訊息。** `simulation.run` 的回傳有 `warnings`,`circuit.check` 會說出編譯能不能過與各種警告。常見的錯誤訊息與意思: | 訊息 | 意思 | 處理 | |---|---|---| | `node ... has no defined voltage` | 這個節點只接到電流源或空接,沒有電壓定義 | 接一顆大電阻到地,或檢查接線 | | `... is in a loop of voltage sources, ammeters or transformer windings with no resistance` | 電壓源、電流表或變壓器繞組形成零電阻迴路 | 在迴路中加一顆小電阻 | | `switch states did not settle at t = ...` | 開關狀態在同一個時間點來回翻轉,找不到一致的解 | 檢查二極體與電流源串聯、理想開關形成迴路;縮小 `maxStep` | | `... parameter ... must be positive` | 參數必須大於 0 | 用 `circuit.setParam` 改正;掃描時檢查範圍 | | `signal ... has no source; it reads 0` | 控制訊號沒有人輸出 | 接上方塊的輸出 | 2. **用同樣的設定再跑一次。** 模擬是確定性的:同一個電路、同樣的 `solver` 與 `maxStep`,結果每次都一樣。如果同樣設定下結果不同,問題在電路或參數被改動過;先用 `circuit.inspect` 確認電路狀態。把 `solver`、`maxStep`、`tEnd` 記下來。 3. **縮小步長。** 把 `maxStep` 縮小為十分之一重跑(`simulation.settings`)。結果不變,代表步長夠小;結果明顯改變,代表原本的步長太粗,測試的結論取決於步長。經驗上,步長要小於開關週期的 1/100;內建範例大約是 1/200。 4. **比較兩個求解器。** 用 `simulation.run` 的 `solver` 參數,分別用 `reference`(參考實作,簡單、逐步重新分解)與 `fast`(快取分解、事件對齊)各跑一次,再比較同一個訊號。兩者差距遠大於 1%,就是數值問題,用較小的步長與 `reference` 當作基準。 5. **看 `waveform.compare` 的結果。** 測試失敗時,比對的 `worst` 指出最差的是哪個訊號,`maxErrorAt` 指出最大誤差發生在什麼時間,`verdict` 說出最可能的原因。先用 `t0` 跳過起動暫態,再用 `timeShift: "auto"` 排除時間偏移,剩下的誤差才是真的差異。 6. **二分法縮小電路。** 一次拿掉或換掉一半的電路,看問題還在不在。可以用 `circuit.removeComponent` 移除元件,或把一段電路換成理想電源與電阻;每次嘗試完用 `edit.undo` 回復。每一次都跑 `circuit.diagnose`,它會指出被你拆壞的地方。 7. **用故障反證。** 懷疑某個零件造成失敗時,用 `fault.inject` 把它弄壞,看失敗是不是變得更嚴重;用 `fault.clear` 還原後問題消失,就是它。 8. **留下最小重現。** 用 `file.serialize` 存下剛好能重現問題的最小電路,記下 `solver`、`maxStep`、`tEnd` 與失敗的指令與參數,回報或寫成回歸測試。 ## 症狀與第一個要用的指令 | 症狀 | 第一個指令 | 接著 | |---|---|---| | 直流準位不對 | `circuit.diagnose`(`run: true`) | `waveform.compare`、`analysis.paramSweep` | | 振盪 | `circuit.diagnose`(`run: true`) | `analysis.fft`、`analysis.loopGain`(AC 分支)、換 `solver` 與縮小 `maxStep` | | 開關節點振鈴與過衝 | `circuit.diagnose`(`run: true`) | 加寄生元件、`waveform.compare`、`analysis.paramSweep` | | 直通 | `circuit.diagnose` | 加 `deadtime`、`fault.inject` 的 `stuckOn` | | 過熱 | `analysis.losses` | `analysis.thermal`、`analysis.paramSweep` | | 雜訊與 EMI | `analysis.fft` | `circuit.diagnose` 的 `ringing`、加寄生元件 | | 起動失敗 | `circuit.diagnose`(`run: true`) | 設 `v0` 與 `i0`、縮小 `tEnd`、`analysis.paramSweep` | | 感測器與 ADC | `waveform.compare` | `sampleHold`、`delay`、`analysis.monteCarlo` | | 保護誤動作 | `scope.measure`(`max`) | `device.rating`、`analysis.paramSweep`、`analysis.monteCarlo` | | 模擬測試失敗 | `circuit.check` | 縮小 `maxStep`、換 `solver`、二分法 | --- # 設計:一個入口,從選元件值到驗證結果 URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/workflows/design/ 設計一個電源常常要在好幾個工具之間跳:算電感電容、調補償器、量效率、查溫度、選零件,算完還要把數字手動抄回電路,最後也沒人幫你確認「抄對了、真的有效」。Voltecx 把這些放在**同一個「設計」入口**: - 每個項目只有幾個欄位,而且**會先從你的電路讀好**(電壓、電感、電容、負載、開關頻率…),你只改想改的。 - 每個項目都給**一個主要數字**、**一張圖**,以及一段**白話的算法說明**(中文與英文):用哪條公式、為什麼用這些預設值。 - 按「套用」會把結果寫進電路,**只佔一個歷史步驟**,隨時可以復原,然後立刻**驗證**:用模擬或獨立的計算確認結果真的達到目標;沒達到時會告訴你下一步具體要改什麼。 ## 怎麼用 - **GUI**:選單「設計」,或快速鍵 `Cmd+Shift+D`,開啟下方面板的「設計」分頁(在「示波器」旁邊)。選項目、檢查欄位、按「執行」看結果與圖、按「套用」寫入並驗證。欄位留空就是「用電路裡的值,沒有就用預設」;欄位旁的小字會寫出這個值是從**電路**、**預設**、**你輸入**還是**推算**來的。「進階」摺疊裡是很少需要改的欄位。 - **CLI / MCP / 聊天**:同樣的七個引擎指令,用 `command_run` 或 `powercraft-cli run --in 電路.voltecx --cmd --params JSON` 呼叫,GUI 看到的就是這份回覆。 | 項目 | 指令 | 做什麼 | |---|---|---| | 轉換器 | `design.converter` | 依電壓、電流與漣波目標算電感、電容(與開關頻率建議) | | 電壓迴路 | `design.voltageLoop` | 電壓模式迴路的補償器(PI 或 Type II / III) | | 電流迴路 | `design.currentLoop` | 馬達或負載電流環的 PI(極點零點對消) | | 速度迴路 | `design.speedLoop` | 速度環的 PI(對稱最佳化) | | 效率 | `design.efficiency` | 負載掃描的效率曲線、滿載損耗分解 | | 熱 | `design.thermal` | 每個開關與二極體的接面溫度,過不過關 | | 元件選型 | `design.parts` | 為每個開關與二極體挑元件庫中損耗最低且夠用的零件 | ### 每個指令的回覆都是同一個形狀 ```json { "task": "converter", "inputs": [{"key":"vin","value":48,"unit":"V","source":"circuit"}, …], "result": {"headline":[{"name":"L","value":9e-5,"unit":"H","label":{"en":"Inductor","zh-Hant":"電感"}}], "values":[…]}, "plot": {"title":"…","xLog":true,"panels":[{"yLabel":"…","series":[{"name":"…","x":[…],"y":[…]}]}]}, "formula": {"en":"…","zh-Hant":"…"}, "apply": [{"component":"L1","key":"l","value":9e-5,"old":1e-4,"unit":"H"}], "applied": false, "verify": {"pass":true,"status":"pass","method":{…},"checks":[{"name":"…","measured":…,"target":…,"status":"pass"}],"next":null} } ``` - `inputs`:用了哪些輸入,`source` 是 `circuit`(讀自電路)、`default`(指令預設)、`user`(你給的)或 `derived`(推算)。 - `apply`:套用時會寫的參數清單。若電路裡某個參數指向電路變數(例如 `L1.l = Lf`),就改**變數**,掃描與最佳化不會被打斷。 - `apply: true`:一個歷史步驟寫入全部,並預設跑 `verify`(`verify: false` 可關掉,`verify: true` 可只驗證不套用;驗證永遠在「已套用後的電路副本」上做,所以套用與否結果相同)。 - 參數打錯(未知的鍵、超出範圍、型別不對)一律回傳錯誤,不會悄悄改變設計。 --- ## 1. 轉換器:電感與電容(`design.converter`) **什麼時候用**:電路是降壓、升壓或反相升降壓轉換器,想知道電感和電容該多大。 | 欄位 | 預設 | 說明 | |---|---|---| | `vout` | 電路的目標值(閉迴路讀參考值,開迴路由責任比算出) | 輸出電壓 | | `iout` | `vout` ÷ 負載電阻 | 滿載電流 | | `fsw` | PWM 方塊的頻率,沒有則 100 kHz | 開關頻率 | | `ripplePct` | 20 | 電感電流漣波,佔平均電感電流的 % | | `vripplePct` | 1 | 輸出電壓漣波,佔輸出電壓的 % | | 進階:`vin`、`topology` | 電源的電壓、由接線認出 | 電路認不出來時要自己給 | **公式**(連續導通、理想元件):與 `circuit.template` 完全同一份,這裡只是讀它的結果,不另外重寫。降壓:D = Vout/Vin,L = (Vin − Vout)·D ÷ (fsw·ΔI),C = ΔI ÷ (8·fsw·ΔV)。升壓:D = 1 − Vin/Vout,IL = Iout·Vout/Vin,L = Vin·D ÷ (fsw·ΔI),C = Iout·D ÷ (fsw·ΔV)。反相升降壓:D = |Vout|/(Vin + |Vout|),IL = Iout/(1 − D),其餘同升壓。出處:Erickson 與 Maksimovic《Fundamentals of Power Electronics》第 3 版第 2 章;Mohan 等《Power Electronics》第 3 版第 7 章。 **開關頻率建議**:L 與 C 都和 1/fsw 成正比,所以回覆裡的 `fswForPresentParts` 是「用你電路裡**現有**的 L 和 C,開關頻率至少要多高才達到漣波目標」,取 1-2-5 數列的上一檔。 **套用**:寫入電感 `l`、輸出電容 `c`;開迴路時也寫責任比(控制它的常數方塊,或它指向的變數 `D`),讓輸出真的是 `vout`;閉迴路不動責任比(控制器決定)。若你給的 `fsw` 和電路不同,也寫 PWM 的頻率。 **驗證**:用快速求解器模擬一小段,初始電流與電壓放在預期的工作點,量最後 10 個切換週期。三項檢查:電感電流漣波 ≤ 目標的 1.15 倍、輸出漣波 ≤ 目標的 1.15 倍(理想公式不含電容 ESR,留 15 % 餘裕)、平均輸出和目標差 ≤ 5 %。沒過時會算出具體的新值,例如「電感加大到約 180 µH(電流漣波與 L 成反比)」。 --- ## 2. 電壓迴路:補償器(`design.voltageLoop`) **什麼時候用**:閉迴路的電壓控制(電路裡有一個 PI 方塊驅動 PWM),或想知道類比補償網路的元件值。 | 欄位 | 預設 | 說明 | |---|---|---| | `controller` | `auto`:電路的 PI 做得到就用 `pi`,做不到(或沒有 PI 方塊)就用 `typeIII` | `auto`、`pi`、`typeII`、`typeIII` | | `fc` | fsw/10 | 想要的交越頻率(迴路增益為 1 的頻率) | | `pm` | 60° | 想要的相位裕度 | | 進階:`delayTs` | 0.5 | PWM 與取樣的延遲,單位是開關週期 | | 進階:`pwmGain` | 1 | 控制器輸出 1 對應的責任比(本模擬器的 PWM 方塊直接吃責任比) | | 進階:`r1` | 10 kΩ | Type II / III 運算放大器網路的縮放電阻 | | 進階:`loopCheck` | 開 | 驗證時是否量迴路增益(比較慢) | | 其他:`vin`、`vout`、`l`、`c`、`rload`、`fsw`、`topology` | 讀自電路 | 電路認不出來時要自己給 | **受控體**:轉換器責任比到輸出電壓的小訊號轉移函數(Erickson 第 3 版 table 8.2):Gd0·(1 − s/ωz) ÷ (1 + s/(Q·ω0) + (s/ω0)²)。降壓:Gd0 = Vin、ω0 = 1/√(LC)、Q = R√(C/L)、無右半平面零點。升壓與升降壓:D' = 1 − D,Gd0 = Vin/D'²、ω0 = D'/√(LC)、Q = D'R√(C/L),右半平面零點升壓 ωz = D'²R/L、升降壓 ωz = D'²R/(D·L)。再乘上調變器增益與延遲 e^(−s·delayTs/fsw)。電容 ESR、開關導通電阻不在模型裡。 **PI**:Kp·(1 + ωz/s)。在交越頻率 ωc,PI 必須提供的相位是「相位裕度 − 180° − 受控體相位」,PI 只能落後(0° 到 −90°),所以 ωz = ωc·tan(落後角),Kp = cos(落後角) ÷ |受控體增益|,Ki = Kp·ωz。 **Type II / III**(K 因子法,H. D. Venable, *The K Factor*, Powercon 10, 1983):需要補償的角度 boost = PM − 受控體相位 − 90°;Type II:K = tan(boost/2 + 45°),零點在 ωc/K、極點在 ωc·K;Type III:K = tan²(boost/4 + 45°),雙零點在 ωc/√K、雙極點在 ωc·√K;增益讓交越點的迴路增益剛好是 1。回覆給出反相運算放大器網路的 R2、C1、C2(Type III 另有 R3、C3)。 **為什麼預設會改用 Type III**:降壓的 LC 濾波器在 f0 之後相位掉到接近 −180°,PI 無法「超前」,所以 PI 能做到的最高交越頻率在 f0 以下,在這裡負載步階的回復還會明顯過衝。`controller` 預設是 `auto`:電路有 PI 方塊時先試 PI,如果 PI 達不到要求的交越頻率與裕度,就**自動改用 Type III**,回覆的 `inputs.controller` 標為「推算」,並在說明裡寫明原因(「PI can't cross above the LC resonance; Type III used」),結果也能通過驗證。你自己指定 `controller: "pi"` 時,指令會找出 PI 能達到的最高交越頻率(`inputs.fc` 標為「推算」),驗證可能如實地失敗,建議裡會寫「改用 Type III(`controller: typeIII`)」。你自己指定的 `fc` 做不到時則回傳錯誤,並說明最高能做到多少。每個設計都要滿足「迴路增益只穿越 0 dB 一次」,避免交越點落在諧振尖峰上。 **套用**:PI 寫 PI 方塊的 `kp`、`ki`(上下限不動)。Type II / III 寫成 `tf` 方塊(`num`、`den` 依 s 的降冪排列,分母首項為 1,原點有一個積分器):驅動 PWM 的 PI 方塊會原地換成同名、同接線的 `tf` 方塊(PI 自己的增益與上下限不保留),迴路裡已經有 `tf` 方塊時只更新係數,所以套用兩次不會多出方塊。整個動作是一個復原步驟。驅動 PWM 的既不是 PI 也不是 `tf` 時,沒有東西可以套用,會回傳錯誤。 **驗證**(Type II / III 不是電路方塊,所以只做第 1 項模型檢查,量測與模擬的兩項標為「略過」): 1. **模型**:用數值重新找交越頻率與相位裕度,確認與設計一致(交越頻率差 ≤ 3 %)。 2. **量測的迴路增益**(`loopCheck`):在 PI 輸入端斷開迴路,用擾動法掃描 fc/3 到 2.5·fc(不超過 fsw/4)共 7 點,量出交越頻率與相位裕度;相位裕度要 ≥ max(目標 − 15°, 30°),交越頻率與設計相差 ≤ 60 %。 3. **負載步階**:在輸出加上 50 % 負載電流的步階,量下陷、回復的過衝(≤ 下陷的 40 %)、是否穩定,以及最後輸出和原來差多少(≤ 2 %)。 沒過時給具體建議,例如「把交越頻率降到約 …(fc)」。 --- ## 3. 電流迴路(`design.currentLoop`)與速度迴路(`design.speedLoop`) **電流迴路**,欄位:`r`、`l`、`lq`(讀自馬達:永磁同步機用 `rs`、`ls`(或 `ld`、`lq`);感應機用 σLs 與 Rs + Rr·(Lm/Lr)²;直流機用電樞 `ra`、`la`)、`fsw`(PWM 方塊的頻率)、`fc`(預設 fsw/10)、`delayTs`(預設 0.5)、`piD`、`piQ`。 - **公式**:受控體 1/(R + sL);極點零點對消 **Kp = L·ωc、Ki = R·ωc**,ωc = 2π·fc,開迴路變成 ωc/s,閉迴路是頻寬 ωc 的一階系統,10–90 % 上升時間 ln9/ωc(沒有延遲時;有延遲時迴路是 ωc·e^(−sTd)/s,積分器在延遲後以斜率 ωc 直線爬升,實際上升時間會比 ln9/ωc 短,驗證只要求不超過它的幾倍)。延遲 Td 會從 90° 的裕度扣掉 ωc·Td,所以相位裕度 = 90° − 360°·fc·delayTs/fsw;預設 fsw/10、0.5 Ts 是 72°。若用數位控制(取樣保持加一拍計算),請把 `delayTs` 設成 1.5,此時 fsw/10 只剩 36°,說明裡會提醒。 - **找 PI**:輸出(直接或經過加總、增益、限幅方塊)接到反 Park 或 dq→abc 方塊 `d`、`q` 腳位的 PI,分別是 d 軸與 q 軸電流控制器;認不出來時用 `piD`、`piQ` 指定,否則只算不套用。 - **套用**:兩個 PI 的 `kp`、`ki`,一個歷史步驟。凸極機(`ld` ≠ `lq`)d、q 軸各算各的 Kp,Ki 都是 R·ωc。 - **併網換流器**:電路裡沒有馬達、但有三相電網(`grid3`)經串聯電感接到橋臂時,從電網 a 相往橋臂走,讀出 `L1`(橋臂側)、`L2`(電網側)與兩者之間的串聯阻尼電容(`Rd`、`Cf`)。受控體是剛性電網電壓後的 L1 + L2 加上 LCL 諧振,沒有電阻可對消,所以和 `design.auto` 一樣設計:**Kp = (L1 + L2)·ωc,PI 零點放在交越頻率以下十倍頻,Ki = Kp·ωc/10**;沒給 `fc` 時從 fsw/10 起每次乘 0.9 往下找,直到相位裕度 ≥ 45° 且增益裕度 ≥ 6 dB。回覆多了 `gridFilter`,驗證多了增益裕度檢查。 - **驗證**:模型相位裕度 ≥ 45°;接著把設計好的 PI 放進「R-L 受控體加取樣延遲」的小型控制電路,用求解器模擬步階響應,要求過衝 ≤ 25 %、上升時間 ≤ 預測的 2 倍、最後值與參考差 ≤ 2 %。 **速度迴路**,欄位:`j`、`b`(馬達加上同一軸上的慣量與摩擦元件)、`kt`(永磁機 = 3/2·極對數·ψf;感應機要給磁化電流 `imr`,Kt = 3/2·pp·(Lm²/Lr)·imr)、`fci`(電流環頻寬:沒給就由電路裡 q 軸 PI 的 Kp ÷ L 推得,再沒有就 fsw/10)、`fs`(預設 fci/10)、`a`(對稱係數,預設 4)、`piSpeed`。 - **公式**:受控體 Kt/(J·s + B),前面是閉迴路電流環,在速度環頻率下等效為頻寬 fci 的一階落後。對稱最佳化(C. Kessler, *Das symmetrische Optimum*, Regelungstechnik, 1958):PI 零點放在交越頻率的 1/a,**Kp = J·ωs·a ÷ (Kt·√(1 + a²)),Ki = Kp·ωs/a**。 - **套用**:速度 PI 的 `kp`、`ki`。 - **驗證**:模型相位裕度 ≥ 40°;步階響應(PI → 電流環落後 → Kt → 慣量與摩擦)過衝 ≤ 30 %(PI 零點本來就會讓參考步階過衝,用斜坡參考可以消除)、穩定、最後值誤差 ≤ 2 %。 > 電流與速度迴路是用「它假設的受控體」在求解器裡做的**獨立步階模擬**來驗證,不是整個驅動電路;本版本的內建範例沒有完整的 FOC 電路,整個驅動的閉迴路驗證要你自己的電路。 --- ## 4. 效率(`design.efficiency`) 欄位:`fromPct`(預設 10)、`toPct`(預設 100)、`points`(預設 10)、`tEnd`(預設用電路的模擬時間)。滿載(100 %)一定會算。支援降壓、升壓、反相升降壓,需要找得到負載電阻。 - **做法**:每個負載點是一次模擬,把負載電阻設成 R/負載比;各點用電腦的多個核心**並行**跑(與 `analysis.paramSweep` 同一套機制)。 - **公式**:η = Pout/Pin,Pout 是負載上 v·i 的平均,Pin 是電源上 v·i 的平均,取最後整數個切換週期。電感與電容裡還在流動的能量變化 dE/dt 從 Pin 扣掉,所以即使模擬還沒完全穩定,也得到穩態值;效率寫成 Pout ÷ (Pout + 已列出的損耗 + 其餘損耗),其餘損耗若因量測雜訊略為負值就當成 0。 - **滿載損耗分解**:每個開關與二極體的平均損耗取自求解器的損耗統計(等同 `analysis.losses`,視窗內 `E(元件)` 的變化量),再依整段模擬的能量分成導通與切換兩部分;剩下的列為「其他損耗」(電阻、ESR)。 - **一個主要數字**:滿載效率。回覆另有 `curve`(每個負載點)與 `losses`(分解)。 - **驗證**(預設開):0 < η ≤ 100 %;半導體以外的損耗 ≤ 輸入的 5 %(否則提醒有損耗沒被列出);儲能漂移 ≤ 輸出功率的 10 %(否則請提高 `tEnd`)。 - 沒有東西可以「套用」:`apply: true` 會回錯誤。 --- ## 5. 熱(`design.thermal`) 欄位:`ambient`(環境溫度:電路的環境溫度元件,沒有則 40 °C)、`rthHeatsink`(散熱器熱阻 K/W:電路的熱網路已涵蓋整條路徑時為 0,否則 1)、`tjMax`(接面溫度上限,預設 125 °C,與 `analysis.stress` 的降額值相同)、進階:`rthCase`(外殼到散熱器,預設 0.1,由電路熱網路得到時為 0)、`rthJc`(接面到外殼)、`airflow`(風速 m/s,預設 0 為自然對流)、`tEnd`。 - **做法**:以電路目前的樣子(滿載)模擬一次,取每個開關與二極體的平均損耗 P。 - **公式**(穩態熱路徑,所有元件共用一個散熱器):**Tj = Ta + ΣP·Rth,sa + P·(Rth,jc + Rth,cs)**。散熱器承載所有元件損耗的總和,每個接面再加上自己經過接面到外殼、外殼到散熱器的溫降。 - **接面到外殼的熱阻從哪來**(由先到後):你給的 `rthJc`;元件指定的 `device` 在元件庫(或電路內嵌)的熱鏈總和;電路自己的熱網路(從元件的 `thermal` 熱節點沿著 `rth` 元件走到環境溫度);都沒有就用 1 K/W 並在說明裡標明。 - **結果**:一個主要數字(最熱的接面溫度)、每個元件的 `tjC`、`marginK`、`pass`,以及「最熱接面剛好達到上限時的散熱器熱阻」(`maxRthHeatsink`)。圖是「最熱接面對散熱器熱阻」,上限畫成水平線。 - **驗證**(預設開):每個接面溫度 ≤ 上限,不過就列出「改用 … K/W 以下的散熱器」或「即使散熱器完美仍有 … °C,請降低損耗或換接面到外殼熱阻較低的元件」。若電路本身有熱網路並被模擬(`T(熱節點)`),還會把靜態模型和模擬的溫度對照(差距 ≤ 上升量的 25 % 或 8 K)。 - **散熱方式**(`cooling`):從有出處的目錄 `crates/engine/parts/heatsinks.json` 挑選。TO-220 或 TO-247 元件各裝一個散熱器,依規格書溫升表在該元件損耗與風速下讀出 Rth,sa,選最輕且讓 **Tj = Ta + P·(Rth,jc + Rth,cs + Rth,sa)** 不超過上限的一個,介面材料取 Rth,cs 最低者(規格書最低壓力下的 TO-220 數值;TO-247 沿用此值)。SMD 元件選規格書評定的最小銅箔(最小焊墊或測試板),**Tj = Ta + P·Rth,ja**。沒有封裝或沒有資料的元件會在說明中列出,不做猜測。 - 沒有東西可以套用:`apply: true` 會回錯誤。 --- ## 6. 元件選型(`design.parts`) 欄位:`limit`(每個零件列幾個備選,預設 3)、進階:`t0`(量測視窗起點,預設模擬的後半)、`tj`(估算損耗用的接面溫度)、`derating`(同 `analysis.stress`)。 - **做法**:這個指令是 `analysis.stress` 與 `device.recommend` 的薄包裝,不另外發明規則。若電路沒有模擬結果、或結果已過期(電路在模擬後被改過),先自動模擬一次;然後量出每個開關與二極體實際承受的電壓與電流(降額規則見 `docs/workflows/part-selection.md`),再把模擬的電流電壓代入元件庫每個合格零件的損耗表,依估計損耗排序。 - **結果**:每個零件一列(`components`):目前的零件、建議的零件、估計損耗、備選、所需額定值;主要數字是建議零件的估計總損耗。 - **套用**:把每個零件的最佳元件寫進它的 `device` 參數,**一個歷史步驟**(單獨呼叫 `device.recommend apply` 則是每個零件一步);已經是最佳的零件不動。 - **驗證**:放入元件後重新模擬,再用 `analysis.stress` 評等:每個零件的額定值(電壓、電流、接面溫度)都要過,且沒有額定值不足的零件。沒過就建議換更高額定值的零件(`library.search`)或放寬 `derating`。 - 內建元件庫的數字只是示意用的典型值(見 part-selection.md),要做真正的選型請用自己的資料表建零件。 --- ## 7. 閘極驅動、保護、安全、可靠度與量產 「設計」選單後來又多了幾個指令。回覆形狀都和上面相同(`inputs`、`result`、`formula`、`notes`、`apply`、`verify`;`design.fmea` 另外附一張失效模式表);它們都**不寫入電路**(給 `apply: true` 會被拒絕並說明原因),也都可以單獨在任何電路上執行。參數、範例與限制寫在使用手冊第 16 章(`docs/manual/zh-Hant/16-automatic-design.md`)。 | 指令 | 選單 | 做什麼 | 要特別知道的限制 | |---|---|---|---| | `design.gateDrive` | 設計 > 閘極驅動 | 選驅動器、閘極電阻、自舉電容;Qg 換算到實際驅動電壓,並檢查 VGS 額定值 | Qg 無法換算時沿用資料手冊值並註記 | | `design.inputProtection` | 設計 > 輸入保護 | 保險絲、保持時間電容、湧浪限制(NTC 或主動)、突波 TVS、反接保護 | 交流輸入電流取功率因數 1,是下限;沒有 `surge` 就沒有 TVS | | `design.safety` | 設計 > 安全距離 | 找出隔離屏障與工作電壓,套用 IEC 62368-1 的空間距離與沿面距離方法 | 標準的表格沒有附上,距離都是 `null`,`verify` 在 #374 之前都失敗 | | `design.reliability` | 設計 > 可靠度 | 電容壽命、每個零件的降額表、選用的 MTBF | MTBF 要你自己提供失效率;只有三個 Panasonic 系列有壽命公式 | | `design.lifetime` | 設計 > 壽命 | 任務剖面下功率半導體的熱循環壽命:查表損耗與 Foster 熱阻抗求 Tj、雨流計數(ASTM E1049)、LESIT 或 AN 21-001 模型、Miner 法則 | CIPS2008 係數要你自己提供;不含開關週期內的漣波 | | `design.tradeoff` | 設計 > 取捨分析 | 每個電容替代方案的效率、板面積、每片成本與最短壽命,以及相對基準的增減(如成本 +12 % 換壽命 +4 年) | 沒有價格的零件不會被捏造價格;尺寸是面積不是體積 | | `design.fmea` | 設計 > 失效模式與影響分析 | 逐一注入開路、短路、漂移故障,記錄影響與是否被保護偵測 | FMEDA 欄位留空給你填;不宣稱符合任何標準 | | `design.testPlan` | 設計 > 測試計畫 | 生產測試程序,每個限值附出處 | 耐壓測試電壓是 `null`(表格沒有附上) | | `design.compliance` | 設計 > 法規符合性 | 依市場(美國或歐盟)列出每項法規要求的通過、失敗或未檢查 | 只讀你給的結果;不是認證 | ## 已知限制 - 電壓迴路的模型是連續導通的平均模型;不連續導通、電容 ESR、電感飽和、輸出濾波器之外的寄生元件都不在內。量測的迴路增益會看到這些差異,所以驗證的容許範圍(±15° 相位、±60 % 交越)刻意比模型寬。 - 迴路增益的量測用求解器的擾動法,最慢;`loopCheck: false` 可跳過。 - `design.efficiency` 與 `design.thermal` 的損耗取自求解器的損耗表;內建元件的數字是示意值,不是任何廠商的零件。 - 一次最多模擬 400 萬步(每個負載點、每個驗證各算一次);太長的 `tEnd` 會被拒絕並說明。 --- # 數位控制:類比與數位方塊、取樣時間、離散化方法與 MCU 時序 URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/workflows/digital-control/ 這份文件回答三個問題:Voltecx 有哪些類比(s 域)與數位(z 域)控制方塊、它們怎麼和求解器一起運作,以及怎麼用它們建出一個接近真實 DSP/MCU 的數位驅動(例如數位 FOC)。 文中的數值(延遲、相位、頻率)是依公式推算,沒有在寫文件時實際執行。實際結果以指令回傳與模擬波形為準。公式的出處寫在各模組的原始碼註解(`crates/control/src/analog.rs`、`digital.rs`、`logic.rs`、`mcu.rs`)。 ## 1. 方塊一覽 連續方塊(`gain`、`sum`、`product`、`integrator`、`pi`、`limiter`、`comparator`、`lookup`…)原本就有,取樣方塊只有 `sampleHold` 與 `delay`。這次新增四組: | 組 | 方塊 id | 輸入 → 輸出 | 用途 | |---|---|---|---| | 類比(s 域) | `tf` | `in` → `out` | 轉移函數 B(s)/A(s) | | | `pid` | `in` → `out` | PID,微分有濾波,輸出有限幅與反飽和 | | | `lowpass2`、`bandpass`、`notch` | `in` → `out` | 二階低通、帶通、陷波 | | 數位(z 域) | `zoh` | `in` → `out` | 取樣並保持(零階保持) | | | `zDelay` | `in` → `out` | z⁻ⁿ,延遲 n 個取樣 | | | `ztf` | `in` → `out` | 離散轉移函數 | | | `dpi`、`dpid` | `in` → `out` | 離散 PI、PID(前向、後向或 Tustin) | | | `dIntegrator` | `in` → `out` | 離散積分器 | | | `fir`、`iir` | `in` → `out` | FIR 濾波器、IIR(二階節串接) | | 邏輯 | `and`、`or`、`xor`、`nand`、`nor` | `in1`…`in4` → `out` | 閘(`n` 設輸入數,2 到 4) | | | `srff` | `s`、`r` → `q`、`qn` | SR 正反器(reset 優先) | | | `dff` | `d`、`clk` → `q`、`qn` | 上升緣觸發的 D 型正反器 | | | `counter` | `clk`、`rst`、`down` → `count` | 計數器(模數、上下數、重設) | | | `monostable` | `trig` → `out` | 單穩態(脈寬 `width`) | | MCU | `mcu` | `a`、`b`、`c` → `da`、`db`、`dc`、`overrun`、`load` | PWM 輸出級的時序:ISR、運算延遲、暫存器更新、解析度 | 每個方塊的參數、單位與預設值用 `component.describe` 查(例如 `{"kind":"control","block":"dpid"}`),單位與說明就是這些指令回傳的 `params`。 ## 2. 類比方塊(s 域) ### 轉移函數 `tf` `num` 與 `den` 是 s 的**降冪**係數,用逗號分隔。`"1"`、`"0.002, 1"` 就是 1/(0.002·s + 1)。分子次數不可高於分母(必須是正則,proper),分母階數最多 16,否則編譯時回傳錯誤(寫明是哪個方塊)。 實作用可控標準型(controllable canonical form,Ogata《Modern Control Engineering》§9-3)。每個被接受的步長 h,狀態用梯形法(Tustin)積分,等於對轉移函數做雙線性轉換: x⁺ = (I − hA/2)⁻¹ · [(I + hA/2)·x + (h/2)·B·(u + u_prev)] 這個公式對任何步長都穩定(A-stable)、二階準確,所以可變步長求解器縮短或拉長步長都沒問題。步長不變時矩陣只算一次。分母有極點恰在 2/h 時(梯形法在那裡奇異)會回傳錯誤,請縮小步長。 分子次數等於分母(biproper)時有直通項,輸出直接受輸入影響;分子次數較低時沒有直通項,可以像積分器一樣把代數迴路拆開。 ### PID `pid` C(s) = Kp + Ki/s + Kd·N·s/(s + N) 微分項被一階濾波,極點在 N(rad/s,參數 `n`)。輸出限幅 `lo`、`hi`,抗積分飽和用**反算法**(back-calculation,Åström 與 Hägglund《Advanced PID Control》§6.4):積分項多一項 Kb·(實際輸出 − 未限幅輸出),`kb` 不設時取 Ki/Kp(Kp 為 0 時取 1)。設 `kb` 為 0 就關掉抗飽和。 和 `tf` 同樣用 Tustin:對相同的 Kp、Ki、Kd、N,`pid` 與下面這個轉移函數在無限幅時算出完全相同的離散輸出(測試用它互相驗證): C(s) = [(Kp + Kd·N)s² + (Kp·N + Ki)s + Ki·N] / [s(s + N)] 微分作用在誤差上(沒有「微分踢」處理);請把設定值變化拿到 `in` 之前先平滑。 ### 二階濾波器 `lowpass2`、`bandpass`、`notch` `f0`(Hz)與 `q`。以 ω0 = 2π·f0: | 方塊 | 轉移函數 | 特性 | |---|---|---| | `lowpass2` | ω0² / (s² + (ω0/Q)s + ω0²) | 直流增益 1;f0 處增益為 Q;Q = 1/√2 時是巴特沃斯,f0 處 −3 dB | | `bandpass` | (ω0/Q)s / (s² + (ω0/Q)s + ω0²) | f0 處增益 1;−3 dB 頻寬為 f0/Q | | `notch` | (s² + ω0²) / (s² + (ω0/Q)s + ω0²) | f0 處增益 0;缺口寬度約 f0/Q | 預設 `q`:`lowpass2` 為 0.7071,另外兩個為 1。Tustin 會讓頻率軸壓縮:頻率接近取樣頻率的 1/10 時,缺口與轉折點會往低頻移動約 (ω·h)²/12 的比例。求解步長通常遠小於信號週期,這個誤差可忽略;需要時請縮小步長。 ## 3. 數位方塊(z 域) ### 取樣時間與事件 每個數位方塊都有取樣時間 `ts`(必填)與 `offset`(第一個取樣時刻,預設 0)。它只在 `offset + k·ts`(k = 0、1、2…)這些時刻更新,其餘時間輸出保持不變。 方塊把這些時刻當作**事件**回報給求解器:`fastsolve` 在固定步長與可變步長下都會把步長截短,剛好落在取樣時刻上(和 `pwm` 的邊緣、`sampleHold` 的取樣時刻同一個機制);`refsolve` 永遠以 `maxStep` 前進,取樣時刻要落在格點上(`maxStep` 整除 `ts`)才會剛好。所以方塊讀到的是取樣時刻的輸入,不是晚一步的值。 為了讓這件事成立,求解器的方塊執行順序也調整過:新方塊中沒有直通項的(`zDelay`、前向積分、`b0 = 0` 的濾波器、分子次數較低的 `tf`、`dff`、`counter`、`monostable`),以前的規則會讓它們讀到前一步的輸入,現在只要不會形成迴路,就排在它的輸入來源之後執行;真的在迴路裡時才退回舊行為(既有的 `integrator`、`sampleHold`、`delay` 維持原狀)。換句話說,迴路要靠 `zDelay`、前向(forward)積分或這些沒有直通項的方塊來拆代數迴路,這和真實程式裡「這一拍用上一拍的結果」一致。`zoh` 與 `mcu` 有直通項,所以放在迴路裡會被回報為代數迴路,請加一個 `zDelay`。 t = 0 的第一次取樣在求解器第一次執行控制方塊時進行,那時電壓表與電流表還沒讀到初始解(與 `sampleHold` 相同),所以 t = 0 取到的量測值是 0;從 `ts` 之後起所有取樣都是真實量測值。 ### 離散化方法 `dIntegrator`、`dpi`、`dpid` 用 `method` 選積分(`dpid` 的微分濾波器也用同一個方法)。設取樣時間 T,輸入 e,積分 x = ∫K·e: | `method` | 替換 | x[k] | X/E | |---|---|---|---| | `forward` | s → (z − 1)/T | x[k−1] + K·T·e[k−1] | K·T·z⁻¹ / (1 − z⁻¹) | | `backward` | s → (z − 1)/(z·T) | x[k−1] + K·T·e[k] | K·T / (1 − z⁻¹) | | `tustin` | s → 2(z − 1)/(T(z + 1)) | x[k−1] + K·T/2·(e[k] + e[k−1]) | K·T/2·(1 + z⁻¹) / (1 − z⁻¹) | 選擇的建議(出處:Åström 與 Wittenmark《Computer-Controlled Systems》§8.3;Franklin、Powell、Workman《Digital Control of Dynamic Systems》§6.2): - `forward`:輸出不受當拍輸入影響(沒有直通項),可以拆代數迴路,但穩定範圍最小。微分濾波器用 forward 時要 `n·ts < 2`,否則編譯時就會被拒絕。 - `backward`:永遠穩定,是 `dpi`、`dpid` 的預設。韌體裡「先累加再輸出」就是這個。 - `tustin`:保留連續設計的穩定性、精度最好,但頻率軸會壓縮(沒有做預扭曲,prewarping)。 `dpi` 與 `dpid` 有 `lo`、`hi` 限幅與 `kb` 反算抗飽和,用法同 `pid`。`dpi` 會忽略 `kd`。 ### 離散轉移函數與濾波器 - `ztf`:`num`、`den` 是 z⁻¹ 的**升冪**係數:H(z) = (b0 + b1·z⁻¹ + …)/(1 + a1·z⁻¹ + …),也就是 y[k] = b0·u[k] + b1·u[k−1] + … − a1·y[k−1] − …。`den` 第一項會被正規化為 1,不可為 0。用直接型 II 轉置(direct form II transposed,Oppenheim 與 Schafer《Discrete-Time Signal Processing》§6.4)。 - `iir`:`sections` 是二階節,每節六個數 `b0, b1, b2, a0, a1, a2`(SciPy 的 `sos` 排法),`gain` 乘在輸入端,各節串接。 - `fir`:`coeffs` 是 h0、h1、…,y[k] = Σ hi·u[k−i],最多 4096 個。 - `zDelay`:`n` 個取樣(整數,最多 4096)。 - `zoh`:取樣並保持。和舊的 `sampleHold` 的差別是多了 `offset`,而且它有直通項(取樣時刻的輸出就是當時的輸入)。 ### 連續設計轉離散的快速對照 設計一個連續 PI(Kp、Ki)再丟進 `dpi`: | 方法 | 離散轉移函數(z⁻¹ 升冪) | |---|---| | `forward` | num = [Kp, Ki·T − Kp],den = [1, −1] | | `backward` | num = [Kp + Ki·T, −Kp],den = [1, −1] | | `tustin` | num = [Kp + Ki·T/2, Ki·T/2 − Kp],den = [1, −1] | `dpi` 的輸出和把這組係數放進 `ztf` 的輸出逐點相同(測試涵蓋三種方法)。零階保持(ZOH)等效的一階對象 1/(τs + 1):a = e^(−T/τ),`ztf` 的 num = [0, 1 − a],den = [1, −a],在取樣時刻和連續步階響應相同(也有測試)。 ## 4. 邏輯方塊 輸入大於 0.5 為真,否則為假;輸出一定是 0 或 1。 - 閘有四個接腳 `in1`…`in4`,由 `n` 決定讀前幾個(預設 2);沒接的腳讀 0。XOR 是奇偶(奇數個輸入為真時輸出 1)。 - `srff`:`s` 與 `r` 都為真時 reset 優先;`q0` 設起始輸出。 - `dff`、`counter`、`monostable` 在**上升緣**動作(上一步 ≤ 0.5、這一步 > 0.5)。t = 0 的求解器計算不算邊緣,所以一開始就是高電位的時脈不會觸發。這三個方塊沒有直通項,所以 `dff` 的 `qn` 可以接回 `d`(T 型正反器、二除頻)。 - `dff` 取的是**上一步**的 `d`(時脈動之前的值),所以兩個 `dff` 共用一個時脈是正確的移位暫存器,不受方塊執行順序影響。 - `counter`:`mod` 為模數(預設 256),`init` 為起始與重設後的值,`down` 為真時往下數,`rst` 為真時保持在 `init`(優先於時脈)。 - `monostable`:觸發的上升緣讓 `out` 在 `width` 秒內為 1,結束時刻會被回報成事件,所以求解器剛好落在脈衝結束點。`retrigger` 為 1 時,脈衝期間的邊緣會重新計時。 時脈建議用 `pwm` 方塊的輸出:它的邊緣是求解器落點的事件,所以每個邊緣都被看到。來自其他方塊(比如 `comparator`)的時脈,只在求解器某一步前後被看到變化,邊緣會晚一步。 ## 5. MCU 時序:為什麼數位迴路會損失相位 數位控制和連續設計差在四件事,`mcu` 方塊模擬的就是這四件事(不模擬控制器的算式,算式由前面的 `zoh`、`abc2dq`、`dpi`、`svpwm` 等方塊負責): 1. **取樣時刻**:ADC 在 PWM 週期的哪裡觸發。`align` = `start` 是載波谷底(t = k/fpwm),`peak` 是載波峰值(t = (k + ½)/fpwm)。在谷底或峰值取樣,可以避開開關瞬間的雜訊。 2. **運算延遲**:ISR 從取樣到算出結果要時間,`delay` 以取樣週期為單位(預設 1,可以是小數)。 3. **暫存器更新**:算出的佔空比什麼時候進入比較暫存器。`update` = `period`(預設)是影子暫存器,在下一個載波谷底才生效;`immediate` 是一算完就生效。 4. **解析度**:比較暫存器是整數計數,`counts`(或 `bits`,等於 counts = 2^bits)把佔空比四捨五入成 1/counts 的倍數。 延遲怎麼來:令 T = 1/fs。在谷底取樣、運算延遲一個取樣、下一個谷底更新時,t = kT 取樣算出的佔空比從 (k + 1)T 起生效,在載波週期內的平均效果落在約 (k + 1.5)T。也就是控制迴路看到: - 一個取樣週期的運算延遲:T - PWM 的保持(把佔空比在整個週期內維持不變)平均再加半個週期:0.5T 合計約 **1.5T**(Briz、Degner、Lorenz,IEEE Trans. Ind. Appl. 2000;Holmes 與 Lipo《Pulse Width Modulation for Power Converters》ch. 4;Franklin 等《Digital Control of Dynamic Systems》§6.3,零階保持等於半個取樣延遲)。延遲 Td 在頻率 f 造成的相位落後是 φ = −360° · f · Td = −540° · f / fs(Td = 1.5T 時) 例:fs = 10 kHz 時,f = 500 Hz 損失 27°,f = 1 kHz 損失 54°。所以電流迴路的穿越頻率通常取在 fs 的十分之一以下;想更高就要做延遲補償(例如把轉角預估到 1.5T 之後)或縮短延遲。 用 `mcu` 時: - `delay` = 0 且 `update` = `immediate` 時延遲最小,只剩 PWM 保持的部分。 - 想看延遲對穩定度的影響,只要改 `delay`(以及 `update`),其他不動,比較波形。 - `delay` 從 `mcu` 自己的中斷時刻起算,不是從 ADC 取樣起算。取樣就在中斷時刻(`zoh` 的 `offset` 與 `align` 一致)時,`delay` = 1 加 `update` = `period` 是典型的一個週期延遲:kT 的取樣在 (k + 1)T 進入暫存器。若 ADC 比中斷時刻晚觸發(例如谷底之後再加一段觸發延遲來抵銷感測器的群延遲),`mcu` 在中斷時刻讀到的是前一個取樣算出的佔空比,已經晚了一個週期,這時要用 `delay` = 0;用 `delay` = 1 會變成兩個週期(#397,測試 `the_mcu_block_loads_the_duty_of_a_sample_one_carrier_period_later`)。 - ISR 的執行時間(#534):以 `tIsr`(秒),或 `cycles` 加 CPU 時脈 `fclk`(例如 `cargo xtask armgcc` 對產生的 STM32G474 ISR 估出的約 1437 個週期,在 170 MHz)取代 `delay`。每次 ISR 從它的時刻開始,前一次還沒結束就等它結束;`update` = `end`(即 `immediate`)在 ISR 結束時載入,`period` 在之後的下一個谷底載入。在下一個時刻之前都無法開始的 ISR 會遺失。輸出 `load` = tIsr·fs,`overrun` 在 load ≥ 1 時為 1,`load` 畫在方塊上方、`overrun` 畫在下方,所以既有接線的腳位不動。沒有給執行時間時兩者為 0,其餘行為逐位元不變(測試 `the_defaults_release_the_same_registers_bit_for_bit_and_report_no_load`)。`design.digitalize` 用同樣的參數算延遲,損失的相位裕度就是 e^{-sΔT} 在交越頻率的 360°·fc·ΔT(測試 `the_isr_time_costs_the_phase_of_its_delay_at_the_crossover`)。 `mcu` 沒有模擬:ADC 的量化與雜訊、計時器的死區單元、比較暫存器的重載點與載波計數器的不同模式、多個 ISR 的搶佔。要模擬 ADC 解析度,可以在 `zoh` 後接 `gain` 與 `limiter` 近似,沒有現成方塊。 ## 6. 範例:DSP 數位 FOC 怎麼接 目標:和 `docs/motor-drive.md` 的 PMSM 一起,用取樣的電流與角度做 dq 電流控制,輸出經 `mcu` 到 `pwm3`。下面的名稱只是示例,方塊 id 與腳位是實際的。取 fs = fpwm = 10 kHz(ts = 100 µs),ISR 在載波谷底。 資料流: ```text 電流、角度(量測)──► zoh(ts = 1/fs, offset = 0) │ ▼ abc2dq ──► sum(+−,參考減量測)──► dpi(d 軸、q 軸)──► dq2abc ──► svpwm(output = duty) (a,b,c,theta) (kp, ki, ts, lo, hi) (d,q,theta) (a,b,c,vdc) │ gates ◄── pwm3(freq = fpwm) ◄── mcu(fs, fpwm, delay, bits) ◄┘ ``` 接法(腳位名稱即方塊的接腳): | 步驟 | 方塊 | 腳位與參數 | |---|---|---| | 1 | `zoh` × 4:`ia`、`ib`、`ic`(電流表)與 `theta`(`positionSensor` 的 `elec` 腳) | `in` ← 量測,`ts` = `100u`(即 1/fs),`offset` = 0(`align` = `start`);`peak` 時 `offset` = `0.5/fpwm`(`50u`) | | 2 | `abc2dq` | `a`、`b`、`c` ← 取樣後電流,`theta` ← 取樣後角度,輸出 `d`、`q` | | 3 | `sum`(`signs` = `+-`)× 2 | `in1` ← 參考(`id*` 通常 0、`iq*` 來自速度迴路),`in2` ← 量測的 d 或 q | | 4 | `dpi` × 2 | `in` ← 誤差,`ts` = `100u`,`kp`、`ki`、`method`、`lo`、`hi`(限幅在 ±vdc/√3 附近) | | 5 | `dq2abc` | `d`、`q` ← 兩個 `dpi` 的輸出,`theta` ← 取樣後角度,輸出 `a`、`b`、`c`(電壓,V) | | 6 | `svpwm` | `a`、`b`、`c` ← `dq2abc`,`vdc` ← 直流鏈電壓,`output` = `duty`,輸出 `ma`、`mb`、`mc`(0–1) | | 7 | `mcu` | `a`、`b`、`c` ← `svpwm` 的三個輸出;`fs`、`fpwm`、`delay` = 1、`update` = `period`、`bits`(例如 10) | | 8 | `pwm3` | `a`、`b`、`c` ← `mcu` 的 `da`、`db`、`dc`,`freq` = `fpwm`,輸出 `ga`、`gb`、`gc` 接開關 | 要點: - 第 1、4 步的 `ts` 必須和 `mcu` 的 `1/fs` 一樣,`offset` 必須和 `align` 對應,否則取樣與更新會錯開(`mcu` 捕捉的是它的 ISR 時刻那一拍的輸入)。 - `mcu` 的輸入是已經算好的佔空比,所以放在 `svpwm`(duty)之後,`pwm3` 之前。`pwm3` 的載波是相位 0 的三角波,谷底在 t = k/fpwm,和 `mcu` 的 `update` = `period` 一致。 - 用 `positionSensor` 的角度 `theta` 去做 `dq2abc` 時,輸出電壓要在 1.5T 之後才生效,這段時間轉子轉了 ω·1.5T:可以在 `dq2abc` 的 `theta` 前加一個 `sum`:`theta + 1.5·ω·T`(ω 由 `speedSensor` 取得)做延遲補償。 - 去耦合(−ω·L·iq 項)、前饋、速度迴路用既有的 `sum`、`product`、`gain`、`dpi` 組出。 - 想比較連續與數位:把 `zoh` 換成 `gain`(k = 1)、`dpi` 換成 `pi`、拿掉 `mcu`,其餘不動,就是連續設計。 求解設定:`maxStep` 取 ts 的整數分之一(例如 ts = 100 µs,`maxStep` = 1 µs 到 5 µs),固定步長時取樣時刻就在格點上。可變步長(`fixedStep` = false)時取樣、`mcu` 的更新時刻與 PWM 邊緣都是事件,不需要特別安排。 最小範例:用 `circuit.addComponent` 與 `circuit.connect` 加一個取樣方塊與 `mcu`(`kind` 要帶 `block`): ```json {"name": "ZIA", "kind": {"kind": "control", "block": "zoh"}, "params": {"ts": "100u"}} {"name": "DPI_D", "kind": {"kind": "control", "block": "dpi"}, "params": {"ts": "100u", "kp": 2, "ki": 2000, "method": "backward", "lo": -50, "hi": 50}} {"name": "MCU", "kind": {"kind": "control", "block": "mcu"}, "params": {"fs": "10k", "fpwm": "10k", "delay": 1, "update": "period", "bits": 10}} ``` ## 7. 注意事項與已知的簡化 - **讀輸入的時刻**:數位方塊用取樣時刻當下算出的輸入。沒有直通項的方塊如果真的在迴路中,會讀前一步的值(這是拆迴路的代價)。 - **不重新取 t = 0 的樣**:見第 3 節。 - **沒有預扭曲**:Tustin 不做頻率預扭曲。 - **離散方塊不跨取樣時刻補插**:步長比 `ts` 大時(`maxStep` > `ts`),固定步長求解器會跳過取樣時刻,每個步只做一次更新。請讓 `maxStep` ≤ `ts`。 - **穩態偵測**:`simulation.steadyState` 推算基本週期時會把數位方塊的 `ts` 與 `mcu` 的 1/fs 納入,它們必須和 PWM 週期互為整數倍,否則請直接給週期。 - **PLECS 與 PSIM 對照**:這些方塊的行為依公開教科書與公式實作,沒有參考任何商業軟體的程式、說明或範例。 ## 8. 驗證 ```sh cargo test -p powercraft-control # 單元測試:解析解、差分方程式、真值表、mcu 延遲與量化 cargo test -p powercraft-engine --test digital_blocks # 透過指令與兩個求解器(含可變步長) cargo test -p powercraft-circuit # 參數規格 cargo test -p powercraft-ui-egui # 元件庫、符號與繁體中文名稱 cargo test -p powercraft-engine --test panic_hunt ``` --- # IC 行為模型:從 datasheet 到可模擬的 IC 與典型應用電路 URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/workflows/ic-models/ 這份文件回答一個問題:「我手上有某顆 IC 的 datasheet,能不能建出這顆 IC 和它的典型應用電路,接好線,再分析?」答案是可以,但建出來的是**行為模型**,不是原廠的電晶體級 SPICE 模型。做法是把 datasheet 上的數字(臨界電壓、延遲、電阻、增益頻寬……)填進一個 IC 模板,模板用 Voltecx 已有的元件(電壓表、受控源、理想開關、控制方塊)拼成一個有命名腳位的子系統。 文中的預期數值(延遲、頻率、增益、準位)是依公式推算,寫文件時沒有實際執行模擬。實際結果以指令回傳與模擬波形為準。程式碼是在沒有編譯與執行環境下寫的,測試由審查者跑。 ## 內建的 IC | 模板 `name` | 是什麼 | 預設參數出自的公開 datasheet | 腳位 | |---|---|---|---| | `gateDriverIso` | 隔離閘極驅動器,UVLO、傳遞延遲、源/沈電阻、DESAT 保護、軟關斷、鎖存的 FLT | TI UCC21756-Q1(SLUSEN8A,2024 年 6 月版)。論文使用的驅動器 | `IN` `FLT` `VDD` `VEE` `OUT` `COM` `DESAT` | | `opAmp` | 單極點運算放大器:DC 增益、GBW、迴轉率、受自身電源限制的輸出、輸入失調 | TI LM358B(SLOS068AB,2024 年 10 月版) | `INP` `INN` `OUT` `VCC` `VEE` | | `comparatorHyst` | 有遲滯的比較器:遲滯、上升與下降傳遞延遲、開汲極或推挽輸出 | TI LM393B(SLCS005AH,2025 年 4 月版)。LM393B 本身沒有遲滯,`vHys` 的預設值是假設 | `INP` `INN` `OUT` `VCC` `GND` | | `pwmController` | 峰值電流模式 PWM 控制器(UC384x 類,通用):RT/CT 振盪器、誤差放大器、電流感測比較器、最大工作比、UVLO、可選軟啟動 | TI UCx84x(SLUS223H,2024 年 10 月版,UCx843 的數字) | `VFB` `COMP` `CS` `OUT` `VCC` `GND` | | `syncBuckController` | 電壓模式同步降壓控制器(LM5145 類,通用):RT 振盪器、輸入電壓前饋斜坡、誤差放大器、軟啟動、EN/UVLO、谷值限流與打嗝保護、PGOOD、上下臂驅動與死區時間 | TI LM5145(SNVSAI4B,2020 年 11 月版) | `VIN` `EN` `SS` `FB` `COMP` `PGOOD` `ILIM` `BST` `HO` `SW` `LO` `VCC` `GND` | | `syncBoostController` | 峰值電流模式同步升壓控制器(LM5122 類,通用):RT 振盪器、電流感測放大器、由 SLOPE 電阻設定並乘上 D′ = VIN/VOUT 的斜率補償、誤差放大器、軟啟動、UVLO、逐週期限流與 RES 打嗝計時、上下臂驅動與死區時間 | TI LM5122(SNVS954H,2017 年 6 月版) | `VIN` `UVLO` `SS` `FB` `COMP` `SLOPE` `RES` `CSP` `CSN` `BST` `HO` `SW` `LO` `VCC` `GND` | | `ccmPfcController` | CCM 升壓 PFC 控制器(UCC28180 類,平均電流模式,不需感測市電):FREQ 電阻設定頻率、M1 增益的電流放大器、M2 斜坡的前緣 PWM、轉導電壓放大器(軟啟動、預充、EDR)、UVLO、OLP、ISOP、OVP_L/OVP_H、軟過電流、逐週期峰值限流、15.2 V 箝位閘極驅動 | TI UCC28180(SLUSBQ5D,2016 年 7 月版) | `GND` `ICOMP` `ISENSE` `FREQ` `VCOMP` `VSENSE` `VCC` `GATE` | | `multiplierPfcController` | 乘法器式升壓 PFC 控制器(UC3854 類,感測市電的平均電流模式):IAC 市電波形、VRMS² 前饋的類比乘法器、電壓與電流運算放大器、RSET/CT 振盪器與後緣 PWM、PKLMT 峰值限流、軟啟動、ENA、VCC UVLO、7.5 V 參考、14.5 V 箝位閘極驅動 | TI UC3854(SLUS336A,2016 年 12 月版) | `GND` `PKLMT` `CAOUT` `ISENSE` `MULTOUT` `IAC` `VAOUT` `VRMS` `VREF` `ENA` `VSENSE` `RSET` `SS` `CT` `VCC` `GTDRV` | | `crmPfcController` | 轉態模式升壓 PFC 控制器(UCC38050 類,臨界導通):零電流偵測與 400 µs 重新啟動計時器導通、CS 對簡單乘法器關閉的自激式 PWM、具轉換率增強的轉導電壓放大器、零功率停止、OVP、VO_SNS 致能、VCC UVLO、閘極驅動 | TI UCC38050(SLUS515G,2015 年 12 月版) | `VO_SNS` `COMP` `MULTIN` `CS` `ZCD` `GND` `DRV` `VCC` | | `qrFlybackController` | 準諧振返馳式控制器(NCP1342 類,峰值電流模式):CS 設定點 V(FB)/KFB 與 FB 內部 20 kΩ 上拉、最小峰值電流、前緣遮沒、最大導通時間;輔助繞組的谷底偵測與第 1 到第 6 個谷底的谷底鎖定(表 7 遲滯)、MPCM 降頻與死區時間、谷底逾時、25 kHz 最低頻率、跳週期、ZCD/OPP 的過功率保護(式 2)、軟啟動、UVLO、12 V 箝位閘極驅動 | onsemi NCP1342(NCP1342/D Rev. 31,2026 年 9 月) | `FB` `ZCD` `CS` `VCC` `GND` `DRV` | | `tmPfcController` | 轉態模式升壓 PFC 控制器(UCC28056 類,定導通時間):TON = TONMAX0·GFF·V(COMP)/VCOMax(式 8)、汲極分壓的零電流偵測與重建的 VInSynth、七級市電前饋 GFF 與遲滯、轉導誤差放大器(大誤差增益)、突發模式、UVLO、brown-in、OVP1、逐週期過電流、13.7 V 限壓閘極驅動 | TI UCC28056(SLUSD37E,2019 年 11 月版) | `VOSNS` `ZCD` `VCC` `GND` `DRV` `COMP` | | `llcController` | 半橋 LLC 控制器(UCC25640x 類,混合遲滯控制):FB 電流轉控制量、VCR 比較器加 ±2 mA 補償斜坡、死區時間、BLK 啟動與停止、LL/SS 軟啟動、OCP1 與偏壓繞組過壓(跳脫後等 1 秒)、RVCC、上下臂閘極驅動與 HB − HS UVLO | TI UCC25640x(SLUSD90F,2026 年 8 月版,UCC256404 的數字) | `GND` `VCC` `RVCC` `BLK` `FB` `ISNS` `VCR` `BW` `LLSS` `HB` `HO` `HS` `LO` | | `psfbController` | 相移全橋控制器(UCC28950 類):RT 設定振盪器、誤差放大器轉成責任週期與相移、每臂兩輸出的程式死區、同步整流驅動、閉迴路軟啟動、VDD UVLO 與 CS 逐週期限流 | TI UCC2895x(SLUSDB2B,2024 年 10 月版) | `GND` `VDD` `VREF` `EAP` `EAN` `COMP` `SS` `CS` `OUTA` `OUTB` `OUTC` `OUTD` `OUTE` `OUTF` | | `currentSenseAmp` | 電流感測放大器:增益、單極點頻寬、失調、輸出箝位 | TI INA180A3(SBOS741H,2022 年 7 月版) | `INP` `INN` `OUT` `VS` `GND` | | `timer555` | 555 計時器:內部 5k/5k/5k 分壓(真的電阻,CTRL 可外加電壓)、臨界與觸發比較器(觸發優先)、SR 閂鎖、放電電晶體、低態有效的 RESET、輸出級 | TI NE555(SLFS022)。輸出級電阻由兩列典型值推得,`rDis` 是假設 | `VCC` `GND` `TRIG` `THR` `CTRL` `DIS` `OUT` `RESET` | | `shuntRegulator` | 可調式並聯穩壓器(TL431 類):參考電壓、REF 電流、單極點轉導、偏壓電流、0 到 `ikMax`、最低陰極電壓;全部與電路一起求解 | TI TL431C(SLVS543S,2024 年 5 月版)。`gm` 與 `fPole` 讀自 Figure 6-10,`vKaMin` 是假設 | `K` `A` `REF` | | `optocoupler` | 光耦合器:LED、電流傳輸比對 LED 電流(Fig. 13)與溫度(Fig. 8)的曲線、光電晶體極點、飽和 | Vishay TCET1100(文件 83503,Rev. 2.5,2026 年 4 月)。曲線值讀自圖上 | `AN` `CAT` `C` `E` | | `digitalIsolator` | 單通道數位隔離器:隨 VCC1 變動的臨界、傳遞延遲、推挽輸出、兩側 UVLO、預設輸出 | TI ISO7710(SLLSER9E,2024 年 12 月版) | `IN` `VCC1` `GND1` `OUT` `VCC2` `GND2` | | `highSpeedOpto` | 高速邏輯輸出光耦合器(10 MBd 等級):LED 臨界電流與遲滯、tPHL 與 tPLH(脈寬失真)、開集極或圖騰柱輸出、輸出電容、電源範圍、CMTI | 無:通用參數組,每一列標「typical, user must set」。Voltecx 還沒有這類零件的資料手冊(見下方「待提供的資料手冊」) | `AN` `CAT` `VCC` `OUT` `GND` | | `fiberTx` | 光纖發射器(650 nm 塑膠光纖等級):輸入臨界值、延遲、以 `OPT` 訊號表示的發射光功率 | 無:通用參數組,每一列標「typical, user must set」 | `IN` `VCC` `GND` `OPT` | | `fiberRx` | 光纖接收器與光纖:每公尺衰減、連接器損耗、靈敏度、過載、延遲、飛行時間、有種子的抖動、最小脈寬、推挽輸出 | 無:通用參數組,每一列標「typical, user must set」 | `OPT` `VCC` `OUT` `GND` | | `pvDriver` | 光伏 MOSFET 驅動器(固態繼電器驅動):LED、與 LED 電流成正比的短路電流、開路電壓箝位、關斷電路 | 無:通用參數組,每一列標「typical, user must set」 | `AN` `CAT` `VOP` `VON` | | `ldo` | 低壓差穩壓器:負載調節、一個零點與一個極點的電源抑制、壓差、電流限制、靜態電流、致能、啟動斜坡 | TI LP5907 3.3 V(SNVS798Q,2025 年 7 月版)。零點與極點擬合四列 PSRR,`rHf` 與 `vDo0` 是假設 | `IN` `OUT` `GND` `EN` | | `voltageReference` | 串聯參考電壓:與 `ldo` 同一個模型,沒有致能腳 | TI REF3025(SBVS032K,2025 年 12 月版)。PSRR 與輸出阻抗讀自 Figure 6-38 與 6-37,`rDo` 是假設 | `IN` `OUT` `GND` | | `currentTransformer` | 比流器:單匝一次側、1:100 二次側、會飽和的激磁電感、二次側電阻與負擔電阻;只通過交流 | Coilcraft CS4100V-01L(Document 132,2021 年 5 月 5 日修訂)。飽和後的電感比例 `lsatFrac` 是假設 | `IPP` `IPN` `OUT` `GND` | | `rogowskiCoil` | 羅氏線圈與積分器:靈敏度、低與高截止頻率、輸出限制 | PEM CWT Ultra-mini(Rev. 10/25,CWTUM/1 那一列)。資料手冊沒有給線圈本身的互感,所以線圈與積分器沒有分開建模 | `IPP` `IPN` `OUT` `GND` | | `closedLoopHall` | 閉迴路霍爾電流轉換器:從 DC 起二次側電流 = 一次側 / 1000、單極點頻寬、失調、最大二次側電流;輸出是電流,要接量測電阻 | LEM LA 55-P(N° 97.13.25.000.0,version 19,2023 年 7 月 6 日) | `IPP` `IPN` `M` `GND` | | `isolatedVoltageSensor` | 電阻分壓接到隔離放大器:增益、頻寬、截波、差動輸出 | TI AMC1311(SBAS786C,2022 年 6 月修訂) | `HVP` `HVN` `OUTP` `OUTN` `GND2` | | `ganPowerStage` | 整合驅動與保護的 600 V GaN FET:IN 遲滯與延遲、VDD UVLO、隨 `tj` 的導通電阻、關斷時的第三象限壓降、Co(er)、逐週期過電流與鎖存的短路保護(以 window 時間區分)、過溫理想二極體模式、FAULT 與 OC 推挽輸出 | TI LMG3422R030(SNOSDA7F,2024 年 8 月版)。RDRV 的 dv/dt 與晶片溫度狀態沒有建模 | `DRAIN` `SOURCE` `IN` `VDD` `FAULT` `OC` | 每個參數的預設值、單位、合法範圍,以及它出自 datasheet 的哪個表格與頁碼,都可以用 `ic.describe` 讀出來。標「assumption」的預設值是模型假設,不是 datasheet 直接給的數字。標「typical, user must set」的是通用參數組,不是任何零件的數值,使用前必須依你的零件設定。 ### CMTI(共模暫態抗擾度,#1295) `optocoupler`、`highSpeedOpto`、`digitalIsolator`、`gateDriverIso` 在模擬中以 1 ns 窗口量測屏障兩側的電壓斜率,超過 `cmti` 時輸出誤動作 `tGlitch`,模擬後 `circuit.problems` 列出 `isolation.cmtiExceeded` 警告並指名元件。`cmti` = 0 表示未設定。已引用的額定:ISO7710 100 kV/µs typ(SLLSER9E §5.9)、UCC21750 150 kV/µs min(SLUSD78C 表 6.8,p.8,在 `UCC21750` 預設組)。`tGlitch` 是假設值。 隔離工作電壓:`isolatedAmplifier`(AMC1301)有 `vIowm`(1500 V,SBAS667G §6.6 VIOWM DC,p.7)。模擬後 `IPN` 到 `GND2` 的電壓峰值超過它時,`circuit.problems` 列出 `isolation.workingVoltageExceeded` 錯誤並指名元件。`vIowm` = 0 表示未設定、不檢查。 迴路中的延遲:`circuit.applicationCircuit {ic:"isolatedAmplifier", topology:"currentLoopBuck"}` 是遲滯電流模式降壓轉換器,比較器(模組 `XCTL`)只透過 AMC1301 讀取電感電流。斜坡電流的讀值延遲 `tDelay + 1/(2π·bw)` ≈ 1.83 µs(步階 50 % 為 1.6 µs,SBAS667G §6.10),測試 `the_buck_current_loop_turns_off_the_amc1301_delay_after_the_current_passes_its_threshold` 在兩個求解器上量測每次開關切換。 ### 待提供的資料手冊 下列零件的資料手冊尚未讀入 Voltecx,所以 `highSpeedOpto` 沒有預設零件、TCET1100 與 UCC21756-Q1 沒有 CMTI。請擁有者提供(文件編號與版次),再逐列引用建立預設組: - 高速邏輯輸出光耦合器:Broadcom 6N137 / HCPL-2601 / HCPL-2611、Broadcom ACPL-W611 或 ACPL-K64L(含 CMTI 與 tPHL、tPLH、PWD 表)、Toshiba TLP2361 或 TLP2362、onsemi FOD8001。 - 光纖鏈路:Broadcom HFBR-1521Z / HFBR-2521Z(Versatile Link,650 nm 塑膠光纖)、Broadcom HFBR-1528Z / HFBR-2528Z、Broadcom AFBR-1624Z / AFBR-2624Z、Industrial Fiber Optics IF-E96E / IF-D95T;以及所用光纖的衰減資料(例如 1 mm PMMA 塑膠光纖在 650 nm 的 dB/m)。需要的列:耦合進光纖的光功率、接收器靈敏度與過載、傳遞延遲、脈寬失真、最小脈寬或資料速率、抖動。 - 光伏 MOSFET 驅動器:Vishay VOM1271、Toshiba TLP3906 或 TLP3910、Infineon PVI5033R、IXYS(Littelfuse)FDA217。需要的列:開路電壓與短路電流對 LED 電流(表或圖)、導通與關斷時間及其測試電容、LED 順向電壓。 - CMTI 列:Vishay TCET1100(文件 83503)的共模暫態抗擾度、TI UCC21756-Q1(SLUSEN8A)的 CMTI。 ## 指令 | 指令 | 用途 | |---|---| | `ic.list {}` | 列出內建 IC 與目前電路裡的子系統定義 | | `ic.describe {"name"}` | 腳位(含說明)、參數(單位、預設值、範圍、datasheet 出處)、模型有做與沒做的事、可用的應用電路與它們的參數 | | `ic.place {"name","instance"?,"params"?}` | 把 IC 的定義放進電路(`Circuit.subsystems`),再放一個實例;腳位都沒接,之後用 `circuit.connect` 接線。一個歷史步驟 | | `ic.fromSpec {"spec"}` 或 `{"path"}` | 依一份 JSON spec 建出新的 IC 定義(「datasheet → IC」的路徑);`path` 讀 `ic.fromDatasheet` 存下的 spec 檔。一個歷史步驟 | | `ic.fromDatasheet {"text", …}` | 直接讀 datasheet 的文字,自動選模板、填參數、改腳位名稱,並在測試電路中核對 datasheet 的數值(見下節) | | `circuit.applicationCircuit {"ic","topology","name"?,"params"?,"icParams"?}` | 開一個新電路,內含該 IC 的典型應用,已用 `schematic.autoLayout` 排好 | ## 從 datasheet 文字直接建模:`ic.fromDatasheet` 把 datasheet 的文字交給 `ic.fromDatasheet {"text": …}`:可以是 PDF 轉出的文字(保留版面,欄位以多個空白對齊),或貼上的表格(以 `|` 或 tab 分隔)。它會: 1. **讀取**:標題、版次、腳位表(表頭有 PIN 或 NO. 以及 NAME)、電氣特性表(表頭有 MIN、TYP、MAX),取典型值欄並換成 SI 單位(dB 增益、`%`、V/mV 都會換算)。 2. **分類**:依關鍵字、腳位與表格列,選出最符合的行為模板;不夠明確時回傳問題,請給 `template`。 3. **對應**:表格列對到參數時會核對單位(電壓列只會填電壓參數),腳位改成 datasheet 的名稱。每個值都標出來源:`datasheet`、`testCondition`(例如振盪列測試條件中的 RT、CT)、`derived`(例如 UVLO 遲滯 = 上升門檻減下降門檻)、`given`,或 `default`。`default` 的值沒有從這份 datasheet 讀到,是模板參考元件的預設值,會列在 `assumed` 中。 4. **詢問**:同一參數有多列不同的值(例如 UCx842 與 UCx843 的啟動門檻),而標題只列出一個型號時會自動選該型號的列;否則回傳問題,請給 `variant`(列中標示型號的文字)或在 `params` 中直接給值。有問題未解決時不會建立任何東西。 5. **驗證**:在小型測試電路中模擬 datasheet 的數值並比對(預設容差為典型值的 5 %,`tolerancePct` 可調): - `pwmController`:振盪頻率、最大責任週期、VCC 啟動門檻; - `gateDriverIso`:傳遞延遲(上升與下降緣的平均)、VDD 欠壓鎖定上升門檻; - `comparatorHyst`:遲滯; - `opAmp`:增益頻寬積、迴轉率; - `shuntRegulator`:陰極接 REF、經電阻供電(datasheet 的 V_KA = V_ref 測試電路,10 mA)時的參考電壓; - `ldo`:輸入比輸出高 1 V、EN 接 IN、10 mA 負載與 1 µF 電容下穩定後的輸出電壓。 其他模板目前沒有測試電路,回覆中會說明。 6. **存檔**:`savePath` 經由檔案服務寫出 spec 檔,之後可用 `ic.fromSpec {"path"}` 再建一次。 找不到合適模板的元件(需要狀態機或特殊保護邏輯,例如閂鎖、時序控制器)用 `template: "custom"` 建立:一個子系統加一個 C 方塊。 - **腳位**來自腳位表,名稱照 datasheet(非法字元換成 `_`)。角色依說明猜:寫 output 的是輸出,寫 input、enable、reset、sense 的是輸入,名稱或說明是接地的是接地參考,其餘(電源等)只是沒有內部連線的腳位。猜錯時用 `logic.inputs`、`logic.outputs`、`logic.ground` 指定。 - **邏輯**寫在 `logic.code`(PSIM C):`in[k]` 是第 k 支輸入腳對地的電壓,`out[k]` 是第 k 支輸出腳要驅動的電壓(伏特),`static` 變數保存狀態,`t` 是時間。依 datasheet 的功能表或狀態圖撰寫。程式碼以 `_logic` 存在電路中。 - **輸出**經電阻 `rOut` 驅動腳位;沒有給時是 1 Ω 的假設值,會列在 `assumed`。 - **測試電路**:把功能表寫成 `bench` 步驟 `[{t, inputs:{腳位:V}, expect:{腳位:V}, row}]`。輸入維持到下一個改變它的步驟;輸出在每一步的 95 % 處讀取,與最大的期望電位相比,在 `tolerancePct` 之內才算通過。 - 沒有寫程式碼、程式碼無法編譯、或沒有接地腳時,回覆的是問題,不會建立任何東西。 依關鍵字選出的模板若沒有任何一列對應到它的參數(模型會全是預設值),也會回傳問題,選項中包含 `custom`,不會直接套用。 ## 從 datasheet 到 spec JSON `ic.fromSpec` 要的 spec 是一個 JSON 物件,AI agent 讀完 datasheet PDF 後填寫: ```json { "spec": { "name": "myDriver", "template": "gateDriverIso", "pins": [{"role": "OUT", "name": "OUTH"}, {"role": "IN", "name": "INP"}], "params": {"tPd": "75n", "rSource": 3, "vUvloOn": 11.5, "vDesat": 6.5}, "instance": "U1", "source": "XYZ1234 datasheet SLUxxxx, Table 6.5 p.9" } } ``` - `template`:選行為。這是模型的骨架,datasheet 的數字只改參數,不會改骨架。IC 的保護方式和模板不同(例如沒有軟關斷)就不能用這個模板,要另外加模板。 - `pins`:把模板的腳位角色改成 datasheet 的腳位名稱。可寫成 `{"role","name"}` 的陣列,或 `{"OUT": "OUTH"}` 的物件。沒改名的角色保留原名。名稱要是合法名稱(字母開頭,字母、數字、`_`),不能重複,不能以 `x_` 開頭(內部節點保留)。 - `params`:數字或帶單位字尾的字串(`"75n"`、`"1.2meg"`)。`ic.describe` 列出的每個 key 都有範圍,超出範圍、拼錯 key 都會被拒絕並指出是哪個欄位。 - `instance`:選填;給了就一併放一個實例。 - `source`:選填,原樣放進回傳值,方便把出處留在紀錄裡。 `name` 不能和內建 IC 同名,也不能和電路裡已有的定義同名。建好之後可以用 `ic.place {"name": "myDriver"}` 再放更多實例。 ### 每個參數去 datasheet 的哪裡找 | IC | 參數 | 找哪個表格或章節 | |---|---|---| | `gateDriverIso` | `vInH` `vInL`、`vUvloOn` `vUvloHys`、`rSource` `rSink`、`iSto`、`vDesat` `iChg` `iDchg` `tLeb` `tDesatOff` `tFltDelay`、`rFltOn` | Electrical Characteristics:Logic Inputs、VDD UVLO、Gate Driver Stage、DESAT Protection、Internal Soft Turn Off、FLT and RDY Reporting | | | `tPd` | Switching Characteristics(`tPDLH`、`tPDHL`) | | | `tReset` | 腳位表的 RST/EN 說明(低電位要維持多久才算重設) | | | `vStoEnd`、`vStoRef` | 假設:軟關斷結束的準位取 Miller clamp 臨界(`VCLMPTH`);`vStoRef` 取 `ISTO` 的測試條件 | | `opAmp` | `a0` `gbw` `sr` `vos` `headHi` `headLo` `rOut` `pm` `cmrr` `ib` | Electrical Characteristics:Offset Voltage、Open-Loop Gain、Frequency Response(`GBW`、`SR`、相位裕度 φm)、Output(`VO` 離電源軌的距離、`RO`)、Input Voltage(`CMRR`)、Input Bias Current(`IB`) | | `comparatorHyst` | `vos` `rOutLo` | Electrical Characteristics(`VIO`、`VOL`:`rOutLo` = VOL ÷ 測試電流) | | | `tPdLh` `tPdHl` | Switching Characteristics(response time) | | | `vHys` | 有內建遲滯的零件在 Electrical Characteristics 有;沒有的零件(如 LM393B)是外加正回授做出來的,值由你的電路決定 | | | `openDrain` `rOutHi` | 輸出型式(開集極/開汲極或推挽),`rOutHi` 取推挽輸出的導通電阻 | | `pwmController` | `rt` `ct` | 振盪器:頻率 = 1.72 ÷ (RT × CT)(UCx84x 的 Oscillator 章節);填你的 RT、CT,模板自己算頻率 | | | `dmax` `vRef` `a0` `gbw` `vCompLo` `vCompHi` `acs` `vcsMax` | Electrical Characteristics:PWM(`DMAX`)、Error Amplifier、Current Sense | | | `vccOn` `vccOff` `rOutHi` `rOutLo` | UVLO、Output Section | | | `vCompOff`、`tSoft`、`rCompOut` | 假設(`vCompOff` 的 datasheet 只在「電流感測臨界對誤差放大器輸出」的圖裡給);`tSoft` 是模型的選配功能 | | `syncBuckController` | `rt` | 振盪器:頻率 = 1 ÷ (RT × 99.63 pF + 37 ns),由 LM5145 電氣特性的三列頻率(100 kΩ、25 kΩ、12.5 kΩ)擬合;填你的 RT | | `syncBoostController` | `rt` | 振盪器:RT = 9×10⁹ ÷ fSW(LM5122 第 7.3.3 節式 4);填你的 RT。斜率補償電阻 RSLOPE 與打嗝電容 CRES 是外部零件,接在 SLOPE 與 RES 腳 | | `ccmPfcController` | `fTyp` `rTyp` `rInt` `vFreq` | 頻率:fsw = fTYP·RTYP·(RINT + RFREQ) / (RFREQ·(RINT + RTYP))(UCC28180 第 9.2.2.2 節式 12 反解);FREQ 腳保持 1.5 V,RFREQ 是外部零件。M1、M2 取自第 9.2.2.12 節式 81 至 88,其餘取自電氣特性 | | `multiplierPfcController` | `kOsc` `vRset` `kMult` `vaOffset` `kIacLimit` | 頻率:f = 1.25/(RSET·CT)(UC3854 腳位說明式 1);乘法器 IMO = k·IAC·(VAOUT − 1)/VRMS²(第 7.5 節註 2),上限 2·IAC 與 3.75 V/RSET(第 9.2.2.2 節式 4);RSET 與 CT 是外部零件。`gbwVa` 讀自圖 2,其餘取自電氣特性 | | `crmPfcController` | `kMult` `vMultOffset` `vCompOffset` `vCompMax` `vCsMax` `tRestart` | 乘法器 0.65·(VMULTIN + 75 mV)·(VCOMP − 2.5 V)(第 7.3.6 節),COMP 動態範圍上限 4 V,最大 CS 門檻 1.7 V;重新啟動計時 400 µs(第 6.5 節);轉換率增強取自第 7.1、7.3.2 與 7.3.5 節,CS 內部濾波 40 kΩ/5 pF 取自方塊圖(第 7.2 節);VCOMP high 沒有典型值,取 4.5 V 到 5.5 V 的中間 | | `qrFlybackController` | `tDtMax` `rDrvH` `rDrvL` `vCsMin` `vMpcmDelta` | `tDtMax` 36 µs 取自第 19 頁說明(表 6 只給最小 32 µs);`rDrvH`、`rDrvL` 由 12 V 箝位與 500 mA/800 mA 推得;`vCsMin`、`vMpcmDelta` 是 A 選項(xxxAx、xxxxA)。未模擬 HV 腳(啟動、brownout、X2 放電)、Fault、FMAX、抖頻、quiet-skip、MPCM 離開臨界與計時、異常過電流與過載計時;谷底逾時直接開始新週期 | | `tmPfcController` | `vCoMax` `tauSynth` `tPeakHold` `tZcdDrv` | VCOMax = 5.0 V 由第 9.2.2.5.2 節式 98、99 的數字推得;`tauSynth` 與 `tPeakHold` 是假設值(規格書只說汲極波形取週期平均、峰值偵測視窗 12.3 ms);`tZcdDrv` 是 TZCDR0,DRV 對地電阻 RDG 選的延遲要自己加上 ΔTZCDR。未模擬輕載 DCM | | `llcController` | `vFb` `iFb` `rFb` `vcm` `iRamp` `vBlkStart` `vBlkStop` | 取自 UCC256404 的電氣特性(第 6.5 節)與第 7.3.1 節的控制式(VTH、VTL = VCM ± VCOMP / 2)。`avdd` 的資料表只要求至少為 2·VCM,模型用下限;`rClamp` 與 `tDead` 的來源見參數的 `source`;各參數的條文與頁碼在 `ic.describe` | | `psfbController` | `rt` `rTmin` `rAb` `rCd` `rEf` `dMax` `iSs` `vSsStd` `vCsLim` | 取自 UCC28950 的電氣特性(第 5.5 節)、時序(第 5.6 節)與第 6.3.4、6.3.6 至 6.3.10 節的式 3、4、6、8、10;`rSsDown` 與 `rOff` 的來源見參數的 `source`;各參數的條文與頁碼在 `ic.describe` | | `currentSenseAmp` | `gain` `bw`(同一欄的不同型號對應不同值,例如 A1 到 A4) `sr` `vos` `swingHi` `swingLo` | Electrical Characteristics:Input(`VOS`)、Output(`G`、`EG`、`VSP`、`VSN`)、Frequency Response(`BW`、`SR`) | | `timer555` | `rDiv` | 方塊圖中的分壓電阻(雙極性 555 為 5 kΩ,CMOS 版本大得多) | | | `vReset` | Electrical Characteristics:reset voltage | | | `vOhDrop` `rOutHi`、`rOutLo` | Electrical Characteristics:`VOH` 的兩列(零電流壓降與斜率)、`VOL` 的兩列 | | | `rDis` | 放電飽和電壓 ÷ 測試電流;datasheet 沒有時用預設(假設) | datasheet 常給 min/typ/max 三欄。預設值取 typ;要做最壞情況分析時,自己填 min 或 max。 ## 放進電路與接線 ```json {"name": "gateDriverIso", "instance": "U1", "params": {"tPd": "90n"}} ``` `ic.place` 之後,電路裡有一個子系統實例 `U1`,腳位名稱就是 IC 的腳位。同一電路放兩個參數不同的實例,會各自得到自己的定義(`gateDriverIso`、`gateDriverIso_2`)。接線用 `circuit.connect {"component": "U1", "port": "OUT", "net": "gate"}`。 子系統內的接地是整個電路的地(`0`)。所以 `gateDriverIso` 的 `IN`(對地讀取)與 `FLT`(開汲極,對地拉低)以電路的地為參考;輸出側的其他腳位互相參考(`VDD` − `COM` 等)。 ## 典型應用電路 `circuit.applicationCircuit` 會開一個新電路。`params` 是應用電路自己的值(`ic.describe` 列出每個拓樸的參數),`icParams` 覆蓋 IC 的 datasheet 值。設計目標會用 datasheet 的公式計算外部元件並取標準值(電阻 E96、電容 E12):halfBridgeLeg 的 `tBlank` 決定 C_blk = ICHG·t/VDESAT,astable 的 `freq` 與 `duty` 決定 RA、RB,monostable 的 `width` 決定 R,boost 的 `fsw` 決定 RT = 1.72/(fsw·CT),shuntMonitor 的 `iFullScale` 與 `vFullScale` 決定分流電阻 Vfs/(G·Ifs)(向下取 E12),schmittTrigger 的 `vRise` 與 `vFall` 決定外部遲滯的 R1 = R2·(ΔV − 2h)/(VOH − VOL + 2h)(取 E96,R2 為 `rFb`)與參考電壓 Vref,已扣除 IC 本身的遲滯與偏移電壓。每個算出的元件都列在 `values.designed`,附公式、取整前的值與取整後的結果(英文與繁體中文)。 | IC | `topology` | 內容 | |---|---|---| | `gateDriverIso` | `halfBridgeLeg` | 低側 MOSFET 臂:匯流排、負載電感加飛輪二極體、驅動器、`Rg,on`/`Rg,off`(各串二極體)、`Cgs`、DESAT 的 `R_DESAT`、`D_DESAT`、`C_blk`,FLT 的上拉電阻。`shortCircuit: 1` 讓負載在 `tShort` 被短路 | | `opAmp` | `nonInverting`、`inverting` | 兩個電阻設定的放大器,正弦輸入、正負電源;步長依頻寬自動選 | | `comparatorHyst` | `schmittTrigger` | 正弦輸入、開汲極上拉;輸出在 ±`vHys`/2 切換 | | `pwmController` | `boost` | 峰值電流模式升壓:電感、MOSFET、感測電阻、二極體、輸出電容、分壓、型 II 補償。電感、感測電阻與補償由設計公式算出,值在回傳的 `values` 裡 | | `syncBuckController` | `syncBuck` | 電壓模式同步降壓:上下臂 MOSFET、自舉電容、型 III 補償(兩個零點在 LC 共振、兩個極點在 fsw/2、穿越頻率 fsw/10)、軟啟動電容、EN 分壓、R_ILIM 谷值限流;`shortCircuit` 在輸出加短路,看打嗝保護 | | `syncBoostController` | `syncBoost` | 峰值電流模式同步升壓:輸入分流電阻、上下臂 MOSFET、自舉電容、RSLOPE(斜坡等於感測到的電感下降斜率)、型 II 補償、軟啟動電容、UVLO 分壓、CRES 打嗝計時;`overload` 在輸出加第二個負載,看逐週期限流與 RES 打嗝 | | `ccmPfcController` | `ccmPfc` | 通用輸入 CCM 升壓 PFC:市電、整流橋、回流路徑上的感測電阻、升壓級;RFREQ、CIN、L、RSENSE、COUT(保持時間)、VSENSE 分壓與濾波、CICOMP、VCOMP 補償全依規格書第 9.2.2 節的設計流程算出並列在 `values.designed`。輸出電容與 VCOMP 電容先充到工作點,模擬幾個市電週期 | | `multiplierPfcController` | `multiplierPfc` | 規格書圖 9 的 250 W 前級穩壓器:市電、整流橋、回流路徑上 0.25 Ω 感測電阻、1 mH、450 µF;IAC 經 910 kΩ(另 220 kΩ 到 VREF)、VRMS 兩極濾波、RSET 15 kΩ、CT 820 pF、電流放大器網路、511 kΩ/10 kΩ 分壓與電壓放大器的 180 kΩ ∥ 47 nF、PKLMT 分壓。從 VRMS² 前饋決定的工作點開始,模擬三個市電週期;圖與內文不一致處在 notes 說明 | | `crmPfcController` | `transitionModePfc` | 規格書圖 19 的通用輸入 100 W 前級穩壓器:市電、整流橋、C5 560 nF、1.0 mH 電感與輔助繞組、開關下方 0.2 Ω 感測電阻、220 µF;MULTIN 經 D2、D3 與 2.2 MΩ/15 kΩ 分壓、CS 經 330 Ω/1 nF、VO_SNS 分壓 1.02 MΩ/6.34 kΩ(404.7 V)、COMP 的 11.5 kΩ + 1 µF 與 120 nF、ZCD 經 22 kΩ/18 pF。輔助繞組匝數比依第 7.3.3 與 10.1.2 節的規則算出(圖上未標)。輸出與 COMP 電容先充到工作點 | | `qrFlybackController` | `qrFlyback` | 以規格書第 16 頁 ZCD/OPP 設計範例(VAUX 18 V、NP:AUX 0.18、RZCD 1 kΩ、ROPPL 1 kΩ、ROPPU 270 kΩ)建出 65 W、19 V 返馳式:反射電壓 100 V、NP:NS = 100 V/(VOUT + VF)、0.25 Ω 感測電阻(式 2 在 370 V 的 0.55 V 限制)、TL431 與光耦合器回授。輸出電壓、激磁電感、汲極電容、輸出電容與迴路零件是設計輸入;VCC 用 18 V 電源代替偏壓繞組 | | `tmPfcController` | `tmPfc` | 規格書圖 26 的 165 W、390 V 前級穩壓器,在 110 VAC、60 Hz 執行:200 µH、0.47 µF、2 × 68 µF、0.13 Ω ∥ 0.13 Ω、ZCD 分壓 9.72 MΩ/24.3 kΩ 與 10 pF/3770 pF、VOSNS 分壓、COMP 的 33 nF ∥(180 kΩ + 1 µF)、R4 82.5 kΩ(TZCDR1)。從工作點開始,模擬兩個市電週期;EMI 濾波與突波零件省略 | | `llcController` | `llcHhc` | 半橋 LLC:匯流排電源、半橋、依規格書功率級流程(第 8.2.2.2 至 8.2.2.5 節)算出的諧振槽、變壓器、整流橋、輸出電容與負載;BLK 分壓、ISNS 微分器、VCR 電容分壓、BW 分壓、軟啟動電容與 LL/SS 分壓、自舉電容依第 8.2.2.15 至 8.2.2.19 與 8.3.2 節算出並列在 `values.designed`。光耦合器與次級穩壓器簡化成輸出電壓的 PI,從 FB 拉出電流;預設半載,因為模型沒有電容區保護 | | `psfbController` | `psfbVoltageMode` | 相移全橋:輸入電源、全橋、分流電感、變壓器(含激磁電感)、二極體整流橋、輸出濾波與負載;電流感測網路、參考與輸出分壓、Type 2 補償、軟啟動電容與 RT、RTMIN、DELAB、DELCD、DELEF 的電阻依第 7.2.2 節算出並列在 `values.designed`。次級用二極體取代規格書的中心抽頭同步整流,所以 OUTE、OUTF 只驅動一個閘極電容;模組為電壓模式,RSUM 只算出不放置 | | `currentSenseAmp` | `shuntMonitor` | 分流電阻上的負載電流階躍,輸出照單極點跟隨 | | `timer555` | `astable` | RA、RB、C 的無穩態振盪器:f = 1.44 / ((RA + 2 RB) C),責任比 (RA + RB) / (RA + 2 RB);CTRL 的旁路電容預先充到 2/3 VCC | | | `monostable` | R、C 的單穩態:`tTrig` 時 TRIG 被拉低一個短脈波,輸出高 ln 3 · R · C(約 1.1 R C) | | `shuntRegulator` | `shuntReference` | 電源經 `rFeed` 接陰極,`r1`/`r2` 分壓接 REF;電源在 `tStep` 跳升,陰極維持 vref · (1 + r1/r2) + iRef · r1 | | `optocoupler` | `currentTransfer` | LED 電流由 `if1` 跳到 `if2`,集極經 `rPull` 上拉;集極電流 = 電流傳輸比 × LED 電流,經光電晶體極點跟隨 | | `digitalIsolator` | `logicLink` | 方波輸入,輸出側接地比輸入側高 `vIso`;輸出延遲 `tPd` 後跟隨 | | `ldo` | `postRegulator` | 輸入有漣波,負載在 `tStep` 加重;輸出 vOut − rLoad · I,漣波依電源抑制衰減 | | `voltageReference` | `referenceLoad` | 負載在 `tStep` 加重;輸出 vOut − rLoad · I | | `ganPowerStage` | `inductiveSwitch` | 匯流排經負載電感接 DRAIN,飛輪二極體加 `rFree` 回匯流排,IN 以 `freq`、`duty` 脈波驅動;每個脈波電流上升 vbus·duty/(freq·l),到 `itOc` 時過電流保護在本週期剩餘時間關斷通道 | 閘極驅動的應用裡,MOSFET 模型沒有閘極電荷,所以閘極網路(`Rg`、`Cgs`)是真的,閘極電壓經電壓表與比較器(`vgsTh`)決定 MOSFET 是否導通。這讓 `Rg` 與 `Cgs` 真的會影響開關速度。 ### 在 Voltecx 裡跑一次 ```text circuit.applicationCircuit {"ic": "gateDriverIso", "topology": "halfBridgeLeg", "params": {"shortCircuit": 1}} simulation.run {} waveform.get {"signals": ["v(des)", "v(flt)", "v(gate)", "i(Q2)"]} ``` 預期的故事:短路在 5 µs 發生,開關節點跳到匯流排,`D_DESAT` 反向阻擋,`C_blk` 以 `iChg / C_blk`(預設 5 V/µs)充電到 5 V,再過約 200 ns 的偵測延遲鎖存故障,軟關斷把閘極拉下,電流約在短路後 1 µs 結束,`FLT` 拉低並維持,直到 `IN` 低電位持續 `tReset`(1 µs)。 ## 振盪器範例 `file.openExample` 可以開四個以 IC 建成的振盪器(開啟時自動排版)。設計公式與預設值如下;`crates/engine/tests/oscillators.rs` 從波形的過零點量頻率,與公式比對(容許 3 %)。 | 名稱 | 電路 | 設計頻率 | |---|---|---| | `relaxationOscillator` | `comparatorHyst`(無內部遲滯、±5 V 推挽)加 R1 = R2 = 10 kΩ 的正回授(β = 1/2),Rt = 10 kΩ、Ct = 10 nF 接到 INN | f = 1 / (2 R C ln((1 + β) / (1 − β))) = 4.55 kHz | | `timer555Astable` | `timer555` 的 `astable` 應用電路,RA = 1 kΩ、RB = 10 kΩ、C = 10 nF | f = 1.44 / ((RA + 2 RB) C) = 6.86 kHz,責任比 11/21 | | `wienBridge` | `opAmp`(輸出電阻 0)非反相增益 1 + (18k + 4.7k)/10k = 3.27 起振;4.7 kΩ 兩端並聯一對反向二極體,導通後增益降到 2.8,振幅因此穩定。Wien 網路 R = 10 kΩ、C = 10 nF | f = 1 / (2π R C) = 1.59 kHz | | `colpitts` | `opAmp` 反相放大(Ri = 10 kΩ,Rf = 8.2k + 4.7k,4.7 kΩ 並聯二極體限幅)經 Ro = 1 kΩ 驅動 C1–L–C2 π 網路,L = 100 mH、C1 = C2 = 200 nF | f = 1 / (2π √(L C1 C2 / (C1 + C2))) = 1.59 kHz | Colpitts 用運算放大器而不用 `npn`:電晶體模型是分段線性的,增益在接面壓降以上是固定的 β、以下是零,振盪的起振與限幅靠每個週期把接面切斷再導通,頻率就取決於求解器怎麼處理這些切換。運放版本在二極體限幅之前是線性的,頻率由 π 網路決定。 沒有石英(Pierce)振盪器範例:晶體大約儲存 Q 個週期的能量,Q 是數萬時,起振需要數萬個週期、每週期至少上百步,一個範例就要上百萬步。要看晶體,用 `demo:crystal`(Q 降到 200 看起振)或 `analysis.impedance`(串聯諧振 fs 的阻抗最低、並聯諧振 fp = fs √(1 + cm/c0) 的阻抗最高)。 晶體元件 `crystal` 在模擬前展開成 `rm`–`lm`–`cm` 串聯支路再並聯 `c0`。參數給 `fs`、`q`(加 `cm`),或直接給 `lm`、`cm`、`rm`,兩組不能混用;`c0` 兩種都用。 ## 行為模型抓得到什麼、抓不到什麼 行為模型抓得到:datasheet 表格裡的靜態與時序數字所決定的外部行為(臨界、遲滯、延遲、電阻、頻寬、迴轉率、限幅),以及這些行為在電路裡的交互作用(DESAT 的消隱與 `C_blk`、補償網路與誤差放大器的極點)。 抓不到、要靠原廠模型或實測的: - 隨溫度、電源、負載電流、製程變異的漂移(模型只用一組典型值;最壞情況要自己換 min/max)。 - 內部的非線性與寄生:輸出級壓降隨電流增加、輸入偏壓電流、共模範圍、CMRR、PSRR、雜訊、第二極點與相位裕度(運算放大器模型是乾淨的單極點,看不出電容負載造成的不穩)。 - 隔離屏障:CMTI、屏障電容、工作電壓。 - 各 IC 模板自己列出的「沒做」清單,用 `ic.describe` 的 `notModelled` 讀。 - 控制訊號到達開關比變化晚一個到兩個求解器步長,所以每個延遲都有最多約兩個 `maxStep` 的誤差;要看奈秒級的細節,把 `maxStep` 設成要解析的延遲的十分之一以下。 原廠 SPICE 模型能看電晶體級的暫態、寄生與漂移,但通常慢、不一定收斂,而且不能自由改參數;行為模型快、永遠能改參數、能讓 agent 從 datasheet 直接建出來,代價是上面那份「抓不到」。 ## 數值注意事項 - 求解器每步結束才讀電壓表、更新控制訊號,下一步才生效。步長太大時,運算放大器和電流感測放大器(顯式積分)會失真甚至發散:保持 `maxStep` 小於 `1 / (10 · 2π · 最高關心的頻寬)`;應用電路已經自動選好。 - `pwmController` 的誤差放大器 GBW 預設 1 MHz,所以預設情況下建議 `maxStep` 在 50 ns 以下。 - `syncBuckController` 的誤差放大器增益與 GBW 取自 LM5145 規格書(94 dB、6.5 MHz),應用電路的步長是週期的 1/200(預設約 13 ns)。 - `syncBoostController` 的應用電路步長同樣是週期的 1/200(450 kHz 時約 11 ns)。RES 與 SS 的放電開關關斷電阻是 10 GΩ,否則 1 MΩ 的漏電會吃掉 5 µA 的 RES 電流。 - 峰值電流模式沒有斜率補償:工作比超過 50% 的升壓或反激電路會次諧波振盪。`boost` 應用電路拒絕工作比超過 0.45 的設定。 - 比較器遲滯與 UVLO 用「鎖存」做:積分方塊加上下限,一步就飽和。這在 `maxStep / 4096` 以上的步長都成立(快速求解器最小的步長)。 ## TL431 與光耦合器回授的返馳式範例 `file.openExample {"name": "flybackTl431"}` 開一個 12 V 輸入、12.06 V 輸出的返馳式轉換器,迴路經由二次側的 `shuntRegulator` 與 `optocoupler` 閉合,與離線式電源的做法相同。功率級在不連續導通模式下運作,受控體是一階,極點在 1/(π R C) = 133 Hz。`Rz` 與 `Cz` 從陰極接到 REF,與光耦合器極點一起組成 type II 補償:零點 480 Hz 放在交越頻率的五分之一處(放在受控體極點 133 Hz 會在穩定過程留下 (Rup + Rz)·Cz 的慢尾巴),光耦合器極點 10.3 kHz(`Rpull` 3.3 kΩ、`Cpole` 4.7 nF)放在交越頻率(滿載約 2.5 kHz)之上。完整的設計推導寫在 `crates/engine-core/src/ic/flyback_tl431.rs` 的模組說明裡。一次側的 PWM 把 FB 腳讀成工作比 (V(FB) − 1 V)/2 V,並有 2 ms 的軟啟動。 測試在兩種求解器下執行這個範例,滿載與 4 ms 之後的半載,輸出平均值都在 12.06 V 的 1 % 以內。 ## 電源 IC 設計的架構方塊(#1397) `crates/engine-core/src/ic/arch/` 有通用的架構方塊:`pcmModulator`(峰值電流模式加斜率補償)、`cotModulator`(固定導通時間)、`hystModulator`(遲滯控制)、`softStartRef`(軟啟動參考與 RUN)、`uvloComparator`(欠壓鎖定加遲滯電流)、`ocpHiccup`(打嗝式過電流保護)、`ovpComparator`(輸出過電壓保護,可自動恢復或鎖定關閉)、`hbDriverArch`(固定或自適應死區的半橋驅動器)與 `ldoArch`(LDO 迴路:誤差放大器極點、閘極極點與輸出電容 ESR 零點)。它們不是零件:每個預設值都標示為「typical, user must set」,方程式出處(Ridley 1991、Erickson 與 Maksimovic 第 12 章、Unitrode U-97、Redl 與 Sun 2009、Li 與 Lee 2010、LM5145 SNVSAI4B §7.3 的架構、TI SLUA618 與 SLVAF84、TI SLVA115A 第 1 節的 LDO 迴路與 ESR 範圍規則)寫在模組說明與 `ic.describe` 的 `source`。範例 `pcmBuckArch`、`cotBuckArch`、`hystBuckArch` 用它們閉合同步降壓轉換器;`arch/tests.rs` 與 `arch/ldo_tests.rs` 以各自的方程式檢查每個迴路。研究、現況與缺口(#1460 到 #1469)見 `docs/design/power-ic-architecture.md`。 --- # 製造輸出:從佈好線的電路板到下單的檔案 URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/workflows/manufacturing-outputs/ 這份文件回答一個問題:「電路板在 KiCad 佈好線了,要交給板廠和組裝廠的檔案怎麼產生?還缺什麼?」答案是一個指令:`file.manufacturingOutputs`。它呼叫 kicad-cli 跑完設計規則檢查和所有輸出,最後回報下單前還缺的東西。 Voltecx 不幫你佈線。流程是: 1. `file.exportKicad` 寫出原理圖、專案檔(含網路類別)與 `.kicad_dru` 規則檔。 2. 在 KiCad 指定還沒有的封裝,執行「從原理圖更新 PCB」並存檔關閉,再以 `file.exportKicad {path, board: ".kicad_pcb"}` 擺零件(不需要 Python,也不再寫出 `_place.py`),然後佈線。 3. `file.manufacturingOutputs` 產生製造檔案,並告訴你還缺什麼。 4.(選用)`layout.extract` 從佈好線的板子抽出功率迴路的寄生電感與開關節點電容,放回電路重新模擬(見下方「佈線後驗證」)。 ## 怎麼用 ```sh # --root 授權 kicad-cli 讀寫這個資料夾;路徑都相對於它 powercraft-cli run --root work --cmd file.manufacturingOutputs \ --params '{"project": "buck/buck.kicad_pro", "dir": "buck/fab", "assembler": "jlcpcb"}' ``` MCP 用 `command_run {id: "file.manufacturingOutputs", params: {...}}`;桌面 app 在 **設計 > 自動化 > 製造輸出…**。 ### 參數 | 參數 | 說明 | |---|---| | `project` | 佈好線的電路板:`.kicad_pcb`,或旁邊的 `.kicad_pro`。同名的 `.kicad_sch` 用來產生物料清單 | | `dir` | 輸出資料夾;不存在時會建立,但它的上一層必須存在(舊名 `outDir` 仍可使用) | | `assembler` | `generic`(預設)或 `jlcpcb`,決定物料清單與座標檔的格式 | ### 產生的檔案 | 檔案 | kicad-cli 指令 | 內容 | |---|---|---| | `-drc.json` | `pcb drc --format json --severity-all --refill-zones [--schematic-parity]` | 用電路板與專案 `.kicad_dru` 的規則檢查;有原理圖時也比對原理圖 | | `gerbers/` | `pcb export gerbers --check-zones --layers …` | 所有銅層(板子沒有的內層會略過)、錫膏、絲印、防焊與板框,加上 `.gbrjob` | | `drill/` | `pcb export drill --format excellon --excellon-units mm --generate-map --map-format pdf` | Excellon 鑽孔檔與 PDF 鑽孔圖 | | `-pos.csv` | `pcb export pos --format csv --units mm --side both --exclude-dnp` | 兩面的零件座標(毫米) | | `-cpl.csv` | (由座標檔轉換,僅 `jlcpcb`) | JLCPCB 的 CPL:Designator、Mid X、Mid Y、Layer、Rotation | | `-bom.csv` | `sch export bom --fields … --labels … --group-by …` | 依組裝廠格式的物料清單,同料號合併成一行,位號逐一列出不用範圍 | | `-assembly.pdf` | `pcb export pdf --layers F.Fab,B.Fab --common-layers Edge.Cuts --mode-multipage` | 組裝圖:正反面製造層各一頁,附板框、焊墊輪廓與標題欄 | 物料清單的欄位: - `generic`:Designator、Qty、Value、Footprint、MPN、Manufacturer。 - `jlcpcb`:Comment、Designator、Footprint、LCSC Part #、MPN、Manufacturer。JLCPCB 說明文章 81(How to generate the BOM and Centroid file from KiCAD)要求至少前四欄;CPL 的欄位與毫米單位見說明文章 46(Pick & place file for PCB assembly)。LCSC Part # 取自每個符號的 `LCSC` 欄位,Voltecx 不會替你填。第一次下單請在 JLCPCB 的預覽檢查旋轉角度:KiCad 封裝庫與 JLCPCB 的零件方向可能差 90° 或 180°。 ### 回覆 ```json {"ready": false, "kicadCli": {"found": true, "version": "10.0.6"}, "board": "buck/buck.kicad_pcb", "schematic": "buck/buck.kicad_sch", "assembler": "jlcpcb", "files": [{"kind": "drc", "path": "buck/fab/buck-drc.json"}, {"kind": "gerbers", "path": "buck/fab/gerbers"}, "…"], "steps": [{"step": "drc", "ok": true, "exitCode": 0, "message": ""}, "…"], "drc": {"errors": 0, "warnings": 0, "unconnected": 0, "unroutedNets": [], "parity": 0, "violations": []}, "bomLines": 5, "partsWithoutMpn": ["R1"], "placedParts": 5, "missing": [{"kind": "mpn", "en": "1 parts have no MPN: R1", "zhHant": "1 個零件沒有製造商料號(MPN):R1"}], "notes": ["…"]} ``` `missing` 的種類: | `kind` | 意思 | |---|---| | `kicadCli` | 找不到 kicad-cli,而且有 Voltecx 檢查不了的項目(略過的 `.kicad_dru` 規則、讀不到的子圖檔)。找不到 kicad-cli 時,Voltecx 自行寫出 Gerber、鑽孔檔、座標檔與物料清單(`writer` 為 `voltecx`,檔名與 kicad-cli 一樣取自電路板檔名;物料清單取自封裝的 MPN、Manufacturer 與 LCSC 欄位,即「從原理圖更新 PCB」由符號帶過來的欄位,不含「不放置」(DNP) 的零件),並用 Voltecx 自身的 DRC 檢查電路板寫出 `-drc.json`(套用 `.kicad_pcb` 與 `.kicad_pro` 的規則:電路板最小值與網路類別的間距;以及 `.kicad_dru` 中沒有 `layer`、條件為空或只指名網路類別或網路(`A.NetName == 'sw'`)的規則:全板的最小間距、線寬、板邊間距、孔徑、孔環、孔距與最大孔徑,類別或網路的最小間距、最小與最大線寬與板邊間距(網路規則放進該網路的類別副本 `<類別> [<網路>]`),規則只會收緊數值;只適用部分層或物件的規則與 `opt` 目標值,若全板最小值已涵蓋則不需檢查,更嚴格的走線寬度(`outer`、`inner` 或指名銅層,條件為空或 `A.Type == 'Track'`)與孔徑、孔環(沒有 `layer`;所有導通孔與鑽孔焊墊,或條件 `A.Type == 'Via'`、`A.Type == 'Pad'`、`A.Pad_Type == 'Through-hole'` 或 `'NPTH, mechanical'` 挑出的那些;孔環只量導通孔與電鍍焊墊,與 kicad-cli 相同,所以 `'NPTH, mechanical'` 焊墊的孔環規則讀取後不會找到問題)則在那些物件上檢查;條件在 A 與 B 各指名一個類別、網路或物件種類(`A.Type` 為 Track、Via、Pad 或 Zone)的間距規則(`A.NetClass == 'HV' && B.NetClass == 'LV'`、`A.Type == 'Pad' && B.Type == 'Via'`),在所有銅層或其 `layer` 子句指名的銅層上,只在這兩方之間檢查;並與同名的 `.kicad_sch` 比對原理圖(階層式原理圖連同同目錄或其下資料夾的子圖檔;同一子圖畫兩次時各用該次的參考編號,子圖 `A` 的區域標籤 `x` 對應電路板網路 `/A/x`):缺少、多出或重複的封裝,Value 與封裝不同,焊墊在錯的網路,有標籤的網路改了名),組裝圖 `-assembly.pdf` 也由 Voltecx 畫(與 `board.picture {assembly: true}` 相同:第 1 頁正面、第 2 頁背面,各有焊墊、絲印、製造層與禁置區圖形、板框與零件表);只有略過的 `.kicad_dru` 規則(列在 notes 與報告的 `rules`)與讀不到的子圖檔仍需 kicad-cli,其餘情況不列 kicadCli | | `emptyBoard` | 電路板沒有封裝:還沒「從原理圖更新 PCB」 | | `unroutedNets` | 還有沒佈線的連線(DRC 的 `unconnected_items`),列出網路名稱 | | `drcErrors` | 規則違反中有錯誤等級的項目;細節在 `drc.violations`(最多列 50 筆,計數包含全部) | | `schematicParity` | 電路板與原理圖不一致(少了封裝、欄位不同等):重新「從原理圖更新 PCB」 | | `schematic` | 電路板旁沒有同名的 `.kicad_sch`:用 kicad-cli 時無法產生物料清單;不用 kicad-cli 時無法比對原理圖 | | `mpn` | 物料清單中 MPN 空白的位號 | | `stepFailed` | 某個 kicad-cli 步驟失敗,附上它的錯誤輸出 | | `unreadable` | 讀不回或看不懂 kicad-cli 寫出的檔案 | `ready` 只有在 `missing` 是空的時候才是 true。DRC 通過不等於安全審查:`.kicad_dru` 裡高壓網路的間距是 IPC-2221B 的電氣間距,不是產品標準要求的沖擊距離或爬電距離。 ## 佈線後驗證:`layout.extract` `file.manufacturingOutputs` 檢查的是板子能不能下單;`layout.extract` 檢查佈好的線對電路有什麼影響。它直接讀 `.kicad_pcb`(KiCad 6 到 10,不需要 kicad-cli),依元件編號在板上找出每個功率迴路(輸入電容、上臂開關、下臂開關或二極體)與每個開關的閘極迴路,沿最短的銅箔把各段的部分電感加總(含導通孔),並依疊層算出開關節點對各平面的電容。 ```sh powercraft-cli run --in work/buck.voltecx --root work --cmd simulation.run \ --cmd layout.extract --params '{"path": "buck/buck.kicad_pcb", "apply": true}' ``` `apply: true` 會用一個歷史步驟插入 `Lpcb` 與 `Cpcb__`,再重新跑模擬、`analysis.stress`、`emi.conducted` 與 `spec.verify`(`rerun`,預設同 `apply`)。回覆的 `worstLoop` 指出過衝最大的迴路。沒有模擬平面的鏡像電流(實際電感比加總值低)、封裝電感與邊緣效應。參數與限制的細節見使用手冊第 16 章。 ## kicad-cli 從哪裡來 只在桌面版:引擎本身不啟動程式,主機(`powercraft-cli run --root`、`serve`、`mcp` 與桌面 app 的 `--automation-*-root`)安裝一個 kicad-cli 執行器(`crates/automation/src/kicad_cli.rs`)。它依序找: 1. `PATH` 上的 `kicad-cli`(Windows 為 `kicad-cli.exe`); 2. 標準安裝位置:macOS `/Applications/KiCad/KiCad.app/Contents/MacOS/kicad-cli`;Linux `/usr/bin`、`/usr/local/bin`、`/snap/bin`;Windows `C:\Program Files\KiCad\{10.0,9.0,8.0}\bin\kicad-cli.exe`。 路徑和檔案服務走同一套規則:輸入檔必須在讀取根目錄下,輸出檔在寫入根目錄下且上一層已存在,其他一律在啟動程式之前拒絕。kicad-cli 印出的訊息會去掉根目錄,所以回覆裡不會出現你的絕對路徑。網頁版沒有這個執行器;這時和找不到 kicad-cli 一樣,由 Voltecx 用 `powercraft_io::fab_out` 的 Rust 寫出器(與 `board.exportFab` 相同)產生 Gerber X2、Excellon、座標檔與物料清單,`notes` 的第一行會寫明「kicad-cli cannot run here」。 ## 版本 參數是照 KiCad 10.0(`kicad-cli pcb export <種類> --help`、`pcb drc --help`、`sch export bom --help`)寫的,並在 KiCad 10.0.6 上實際跑過。KiCad 8 與 9 的 kicad-cli 大致相同,但有些選項可能不存在或寫法不同;本指令沒有在 KiCad 8、9 上測試過。版本不是 10 時,回覆的 `notes` 會註明;如果某步驟失敗,請先升級到 KiCad 10。 ## 測試 - 引擎單元測試(`crates/engine/src/manufacturing/tests.rs`):參數組成,以及用 KiCad 10.0.6 實際產生的 DRC 報告、座標檔、物料清單當 fixture 測解析與整個指令(用假的 kicad-cli)。 - 整合測試(`crates/automation/tests/kicad_manufacturing.rs`):只有安裝了 kicad-cli 才跑,否則印出略過的原因。電路板 fixture 在 `crates/automation/tests/data/kicad/`:`buck.kicad_sch` 是 buck 範例經 `file.exportKicad` 的輸出,再替 L1、R1 指定封裝;`buck.kicad_pcb` 由同資料夾的 `make_board.py` 用 KiCad 10 的 pcbnew 擺件與佈線(頂層走 sw、out,底層整面 GND),DRC 為零錯誤、零未連線、與原理圖一致。 --- # MISRA C:2012 check and deviation list of the generated code URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/workflows/misra-deviations/ `codegen.misra` generates the control code as `tools.codeGeneration` does (same params) and runs cppcheck's MISRA C:2012 addon on it, when the machine has cppcheck 2.x (`CPPCHECK` names another binary). It reports each finding by rule number, file and line, and marks it against the list below. MISRA's rule texts belong to the standard, so neither Voltecx nor cppcheck prints them: read the rule in your licensed copy of MISRA C:2012. - `status: "passed"`: no finding outside the deviations below and the unresolved vendor calls. - `status: "failed"`: `violations` findings are not deviated. They are the generator's to fix, or yours to deviate in your own project with a reason. - `status: "skipped"`: cppcheck or its MISRA addon is not on this machine, or could not run. This is never a pass. - `unresolved`: a rule 17.3 finding on a call into the STM32Cube LL library (`LL_...`). The LL headers are not part of the check; your build, with them, settles it. This is a check by an open-source tool, not a certification: cppcheck's addon covers part of the rule set, and a finding it does not report is not proof of compliance. ## Deviations Each deviation covers one rule, in the named files, on lines that hold the named construct (`{prefix}` is the code's `prefix`, `{PREFIX}` its upper case). Any other finding of the same rule is still reported. | ID | Rule | Scope | Reason | |---|---|---|---| | VX-MISRA-D1 | 2.5 | `#define {PREFIX}_...` in the generated headers | The headers publish the sample time, the PWM frequency, the clocks and the scales for the integrator's code; the generated code need not use each one itself. | | VX-MISRA-D2 | 8.7 | `{prefix}_reset` and `{prefix}_stm32g474_adc_isr` | They are the code's interface: the integrator's code calls the reset on a restart and the interrupt entry from its vector, which a check of the generated files alone cannot see. | | VX-MISRA-D3 | 8.4 | interrupt handlers named by the vendor's vector table (`..._IRQHandler`) | The vendor's startup file declares the handler in its vector table, outside the generated files. | | VX-MISRA-D4 | 11.4 | the XMC4200 register macros `{PREFIX}_SCU`, `_CCU80`, `_CC8` and `_NVIC_...` | The XMC4200 target writes its peripheral registers at their fixed addresses (XMC4200 reference manual) without the vendor's headers, so the address is an integer cast to a volatile pointer. | | VX-MISRA-D5 | 21.15 | the copy between a float and its 32-bit word in `{prefix}_tune.c` and `{prefix}_log.c` | The tuning and serial-log frames carry a value as its IEEE 754 binary32 bits. Copying the object's bytes with memcpy is how C99 reads and writes that representation without breaking the aliasing rules; the float and the word have the same size. | ## Findings not deviated (2026-11-03, cppcheck 2.13.0, `buckClosedLoop`) In float, with `fullScale` 20 on the MCU targets, `buckClosedLoop` has no finding that is not deviated on the portable, stm32g474, f28379d and cortexm targets: the generator writes explicit parentheses (12.1), one exit in the duty-to-compare helpers and the STM32G474 interrupt entry (15.5), the interrupts' inputs and outputs as their own statics (8.9), no cast of a composite expression (10.8) and `(void)memcpy` (17.7) (#3780). In fixed point (`q15`, which is `q4.11` here, and `q31`) the portable, stm32g474 and f28379d targets have no finding that is not deviated either (before: 9 of 10.1 and 5 of 12.1 on portable `q15`, 3 more on each MCU target). The format's macros carry their values (`((int64_t)2048) /* 2^11 */`) instead of shifting a signed `1` (10.1); the saturating helpers parenthesize every condition (12.1) and keep their result in a local for one exit (15.5); and the targets' ADC conversion to the format rounds into a local before its cast (15.5, 10.8). The cortexm and xmc4200 targets run float only. With the supervisor (soft start of `Ref`, UVLO and OVP, latched; float, `fullScale` 20) the portable, stm32g474 and f28379d targets have no finding that is not deviated either (before: 7, 12 and 10). Every function of `{prefix}_supervisor.c` and the supervised STM32G474 step has one exit, at its end (15.5): the PWM-off branch and the control law are an `if` and its `else`. Every condition is parenthesized (12.1); the supervisor's inputs are the step's own static (8.9); and the targets' enable functions store 1 or 0 in an `if` instead of a conditional expression (10.6) (#3780). With run-time tuning (`tune: true`; float, double and `q7.24`), `{prefix}_tune.c` and `{prefix}_tune.h` have no finding that is not deviated (before: 22 in the `.c` file, 24 in fixed point, and 4 of 2.5 in the header). Every function has one exit, at its end (15.5); every condition is parenthesized and the CRC step is an `if` (12.1); `memcpy` and `memmove` are `(void)` (17.7); the queue's length is updated before the move, so no composite expression is cast (10.8); the fixed-point saturation's `else if` ends in an `else` (15.7). Without `-D{PREFIX}_TUNE` the four functions are real functions that do nothing instead of empty macros in their names, which removes 5.5, 2.5 and the unused typedef (2.3). The copy between the float and its frame word is VX-MISRA-D5 (#3780). With the serial log (`log`; float and `q7.24`), `{prefix}_log.c` and `{prefix}_log.h` have no finding that is not deviated (before: 11 in the `.c` file and 5 of 2.5 on the header's macros). `{prefix}_log_value` drops a frame that does not fit in an `if` and queues it in its `else`, so it has one exit (15.5); the CRC step is an `if` and every condition is parenthesized (12.1); `memcpy` is `(void)` (17.7). Without `-D{PREFIX}_LOG` the five functions are real functions that do nothing instead of empty macros in their names, which removes 5.5, 2.5 and the unused typedef (2.3). The copy between the float and its frame word is VX-MISRA-D5 (#3780). Still open in the generator (#3780), not deviated: - xmc4200: 15.5 on the init's early return when `{prefix}_port_init` fails (and in the VADC calibration wait). - The F28379D modules (5.5 on the SCI names), measured 2026-11-04 but not fixed yet. - The supervisor on xmc4200 and cortexm is not measured yet. --- # 非理想元件:寄生參數與模擬速度 URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/workflows/non-ideal/ Voltecx 的元件預設都是**理想**的:電容沒有 ESR,電感沒有線圈電阻,開關瞬間切換、沒有雜散電感。這讓第一版設計又快又好懂。需要更貼近實機時,才為元件加上寄生參數。 - 每個寄生參數都是**選用**的,預設值就是理想元件(0,或「不設定」)。沒有設任何寄生參數的電路,編譯出來的網表和以前**一模一樣**,波形逐位元相同(測試 `explicit_zero_parasitics_give_bit_for_bit_the_same_waveforms` 驗證)。 - 設了寄生參數,編譯時會把元件展開成教科書上的等效電路(多幾個元件與內部節點)。兩個求解器、因式分解快取、可變步長的誤差控制都照常運作,不需要特別處理。 - 內部節點叫 `<元件>:x1`、`<元件>:x2`,波形裡看得到,例如 `v(C1:x1)`;展開出來的元件叫 `<元件>.esr`、`<元件>.ls` 等,電流是 `i(C1.esr)`。元件本身保留原名,`i(C1)` 仍是電容本體的電流。 ## 1. 兩個指令 ```json {"command": "circuit.makeRealistic", "params": {"components": ["C1", "L1", "S1", "D1"], "level": "typical"}} {"command": "circuit.makeIdeal", "params": {}} ``` - `circuit.makeRealistic`:把**尚未設定**的寄生參數填成典型值(已經設的值不會被蓋掉)。`components` 省略就是所有最上層元件。一個歷史步驟,可復原。元件指定了 `device` 時,資料表裡有的數字優先用(見第 3 節)。回傳 `set`:每個元件填了哪些值。 - `circuit.makeIdeal`:清掉所有寄生參數,回到理想電路。一個歷史步驟。 - 兩者在沒有東西要改時不會留下空的歷史步驟。子系統裡面的元件目前不處理。 - 想看一個零件有哪些寄生參數、單位、預設值與**典型範圍**:`component.describe`(每個參數多一個 `typical: [低, 高]`)。屬性面板也會列出這些參數,滑鼠移上去看說明。 典型值是**一般功率電路(幾瓦到幾千瓦)的概略值**,不是任何一顆零件。要做真正的設計,請從資料表讀值(下表第 4 欄)。 ## 2. 每個參數:模型、資料表來源、典型值 ### 電容 | 參數 | 單位 | 模型 | 資料表上哪裡找 | 典型值 | |---|---|---|---|---| | `esr` | Ω | 串聯電阻 | "ESR" 或 "Z"(阻抗)曲線在漣波頻率的實部;也可由損耗角 tan δ:ESR = tan δ ÷ (2π·f·C) | 電解 ESR·C ≈ 50 µΩ·F(100 µF → 0.5 Ω);陶瓷/薄膜 2–50 mΩ | | `esl` | H | 串聯電感 | 自共振頻率 f₀:ESL = 1 ÷ ((2π·f₀)²·C),或 "ESL" 欄 | 徑向引線 10–20 nH;SMD 1–5 nH | | `rleak` | Ω | 與電容並聯的電阻(預設不設定 = 沒有漏電) | 漏電流 I_L:R = V ÷ I_L;電解約 0.01·C·V | 100 ÷ C(100 µF → 1 MΩ) | 等效電路:`p — ESR — ESL — (C ∥ Rleak) — n`。 ### 電感 | 參數 | 單位 | 模型 | 資料表上哪裡找 | 典型值 | |---|---|---|---|---| | `dcr` | Ω | 串聯電阻 | "DCR"(直流電阻),通常標 typ 與 max(用 max 較保守) | 1 mΩ·√(L ÷ 1 µH)(100 µH → 10 mΩ) | | `rcore` | Ω | 與電感並聯的電阻(鐵損,預設不設定) | 用鐵損 P_core 在工作點估:R = V_rms² ÷ P_core;或由核心 Q:R = Q·2π·f·L | 100 kHz、Q = 200:R = 1.26×10⁸·L(100 µH → 12.6 kΩ) | | `isat` | A | 飽和電流(預設不設定 = 不飽和) | "Isat",通常定義在電感值下降 20 % 或 30 % 的電流 | `makeRealistic` **不猜**,要看你的設計電流 | | `lsat` | H | 飽和後的電感 | 電感值對電流曲線的尾端 | 未設定且有 `isat` 時取 0.2·L | 等效電路:`p — DCR — (L(i) ∥ Rcore) — n`。 **飽和模型(兩段式):** 電感量在 |i| ≤ `isat` 時是 `l`,超過後是 `lsat`(磁通 λ 連續,每個極性一個轉折點)。每一步用**上一個已接受步的電流**決定電感量(`di/dt = v / L(i)`),所以矩陣不需要 Newton 迭代,求解器的結構完全不變;代價是越過轉折點時落後一步(誤差約為一步內的電流變化乘以電感差,步長取小就可忽略)。快速求解器的因式分解快取會把「是否飽和」放進鍵,所以飽和與不飽和的矩陣不會混用。 **鐵損:** 一個固定的並聯電阻,只在一個頻率上準確(相當於 Steinmetz 公式在單一頻率的等效電阻),所以寬頻或有大直流偏壓的電路請自己換成適合工作點的值。 ### 電壓源 | 參數 | 單位 | 模型 | 典型值 | |---|---|---|---| | `rs` | Ω | 與電壓源串聯的電阻(直流、正弦、脈衝三種電壓源) | 電池或電源供應器 10–50 mΩ | ### 開關(理想開關、MOSFET、IGBT、閘流體、二極體) | 參數 | 單位 | 模型 | 資料表上哪裡找 | 典型值 | |---|---|---|---|---| | `ls` | H | 與開關串聯的雜散(迴路)電感 | 封裝電感(TO-247 約 10 nH 含引腳)加上換流迴路的 PCB 電感;用 `ls = L_loop` 放在關鍵開關上 | 0.5–50 nH;`makeRealistic` 5 nH | | `coss` | F | 跨在開關兩端的線性輸出電容 | "Coss"(MOSFET)、"Coes"(IGBT),選**時間等效** C_o(tr) 或在工作電壓下的值;資料表的 Coss 隨電壓變,這裡用一個常數 | 10 pF–5 nF;MOSFET 200 pF,IGBT 100 pF(或 3 pF/A × 額定電流,若有 `device`) | | `cj` | F | 跨在元件兩端的線性接面電容(和 `coss` 並聯相加) | 二極體 "C_J" 或 "C_T" | 5 pF–2 nF;二極體 50 pF | | `tdon`、`tdoff` | s | 閘極訊號的導通/關斷延遲(純延遲,慣性:比延遲短的脈衝過不去) | "t_d(on)"、"t_d(off)"(包含驅動器的傳遞延遲) | 1–500 ns;MOSFET 20/50 ns,IGBT 100/300 ns | | `qrr` | C | 二極體(或 MOSFET 體二極體)的逆向恢復電荷,0 = 理想 | "Qrr"(資料表會註明 di/dt、If、Vr 與溫度) | 1 nC–5 µC;快速二極體 100 nC,體二極體 200 nC | | `trr` | s | 儲存電荷的時間常數(只在 `qrr` > 0 時用,預設 100 ns) | "t_rr" | 10 ns–1 µs | 等效電路:`p — Ls — (開關 ∥ Coss ∥ Cj) — n`,閘極經過延遲方塊。 **逆向恢復模型(電荷控制):** 依 Mohan、Undeland、Robbins《Power Electronics》第 19 章,Erickson 與 Maksimovic《Fundamentals of Power Electronics》§4.1.2,以及 Lauritzen 與 Ma,*A simple diode model with reverse recovery*,IEEE Trans. Power Electron. 6(2),1991。二極體導通時儲存電荷 `Qs` 以時間常數 `trr` 趨向 `qrr`。電流反向時二極體**繼續導通**(像一個短路),逆向電流把 `Qs` 抽走(`dQs/dt = i − Qs/trr`,`i` 為順向電流,此時為負);`Qs` 用完就關斷。逆向電流的斜率由迴路電感決定,所以**尖峰面積 ≈ qrr**(扣掉復合損失),峰值約 √(2·qrr·di/dt)。這是逐步的模型:關斷落在 `Qs` 用完的那一步;快速求解器用四分之一步長重試找出換相點,所以面積更準;參考求解器的誤差約為尖峰電流乘一個步長。沒有迴路電感(`ls` = 0)時逆向電流只受導通電阻限制,會是一個很大的單步尖峰,請一起設 `ls`。`qrr` 只作用在二極體與 MOSFET 的體二極體,對其他開關會有警告並忽略。 **ESR 與漣波:** buck 的電容電流是電感漣波電流 ΔI(扣掉負載分流)。ESR 把它變成三角形的電壓 ESR·ΔI,只要它大於電容本身漣波(ΔI ÷ 8·f·C)的幾倍,輸出漣波的峰對峰值就**等於 ESR·ΔI_C**,其中 ΔI_C = ΔI_L ÷ (1 + ESR ÷ R)。測試用 100 mΩ 對 48 → 12 V、100 kHz、100 µH、100 µF 的 buck 驗證這個式子。 ### 量測元件(電壓表、電流表) | 參數 | 單位 | 模型 | 典型值 | |---|---|---|---| | `bandwidth` | Hz | 一階低通(預設不設定 = 瞬時),時間常數 τ = 1 ÷ (2π·fc) | 電壓 1 MHz,電流 200 kHz(霍爾感測器);範圍 1 kHz–20 MHz | | `delay` | s | 純延遲(線性內插) | 0–10 µs | | `gain` | — | 增益誤差:輸出 = gain·x + offset | 0.9–1.1 | | `offset` | 量測單位 | 偏移誤差 | — | 順序是:增益與偏移 → 低通 → 延遲。原始讀值也留在訊號 `<元件>:raw`。`makeRealistic` 只設 `bandwidth`(不憑空編造增益與偏移誤差)。 ### ADC 方塊(控制方塊 `adc`) | 參數 | 單位 | 意義 | |---|---|---| | `bits` | — | 解析度,1–24,預設 12 | | `range` | 輸入單位 | 滿量程跨度(必填) | | `min` | 輸入單位 | 代碼 0 對應的輸入,預設 0(輸入範圍 `min … min + range`) | | `fs` | Hz | 取樣率;0(預設)= 連續轉換;> 0 時像 `sampleHold`,保持到下一個取樣時刻,且模擬步長會落在取樣時刻上 | 一個量化步長 = `range ÷ 2^bits`,輸出 = `min + round((x − min) ÷ 步長)·步長`,輸入超出範圍時夾在上下限。 ## 3. 用 `device` 資料表時 元件指定了 `device`(電路內嵌或元件庫)時,`makeRealistic` 會用資料表裡有的數字: - 二極體的順向壓降 `vf`:由導通曲線在額定電流 1/4 與 1/2 兩點的截距取得; - 逆向恢復電荷 `qrr`:由逆向恢復能量 E_rr 在一半額定電壓與電流下取得,`Qrr ≈ 2·E_rr ÷ V`(三角形恢復的近似,Erickson §4.1.2); - 輸出電容 `coss`:每安培額定電流 3 pF。 裝置檔格式目前沒有 Coss、Qrr、trr 這些欄位(只有損耗能量表),所以這幾項是用上述近似換算,**不是資料表上的實測值**。有自己資料表的人請直接設參數。 ## 4. 對模擬速度的影響 寄生參數把**快速動態**帶進電路,而求解器的步長必須追得上它們。 | 寄生參數 | 引入的時間尺度 | 建議 | |---|---|---| | `esr`、`dcr`、`rs`、`rleak`、`rcore` | 只是電阻,沒有新的時間常數 | 不影響步長 | | `esl` | ESL 與電容的諧振,f = 1 ÷ (2π·√(ESL·C)),通常在 MHz | 步長取該週期的 1/20 以下,或用可變步長 | | `ls` 加 `coss`/`cj` | **振鈴** f = 1 ÷ (2π·√(Ls·Coss)):5 nH 與 200 pF 約 160 MHz(週期 6 ns),每次開關動作後出現,要幾百奈秒才衰減 | 見下 | | `tdon`、`tdoff` | 延遲量化到步長(固定步長下誤差約一步) | 步長取延遲的 1/5 以下;快速求解器會在延遲到期的時刻精確落點 | | `qrr` | 恢復時間約 qrr ÷ Irm(幾奈秒到幾十奈秒) | 步長 ≤ 1 ns 才畫得出尖峰;快速求解器會自動細分 | | `bandwidth` | 時間常數 1 ÷ (2π·fc) | 通常比開關頻率慢,不影響 | **建議用可變步長**:`simulation.settings {"fixedStep": false, "maxStep": "100n", "minStep": "<見下>"}`。可變步長以梯形法的局部截斷誤差控制步長(`relTol`、`absTolV`、`absTolI` 維持預設,不要為了讓振鈴過關而放寬),在開關動作後自動縮短步長解析振鈴,振鈴衰減後再放大,漣波與穩態部分仍用長步。含 `ls`、`coss`、`esl` 的 buck 在這個設定下,每個開關週期的步數遠少於用固定 1 ns 步長。 **`ls` 與 `coss`(或 `cj`)都設了時,請設 `minStep ≤ 2π·√(Ls·C) ÷ 200`**(C = coss + cj;`suggestedMinStep` 另外把與該開關共用非接地網路的其他開關與二極體的 `coss`、`cj` 也算進 C,例如 buck 的 S1 `ls` 會和 D1 的 `cj` 在 `sw` 上振鈴,#87),即振鈴週期的 1/200 以下。步長階梯是 `maxStep·2^-k`,最短的一階是不小於 `minStep` 的那一階,所以 1/200 保證最短步長小於週期的 1/100,這是局部誤差控制要解析振鈴所需的。例如 Ls = 3 nH、Coss = 300 pF:週期 5.96 ns,`minStep` ≤ 29.8 ps。`minStep` 留 0(自動 = `maxStep ÷ 1024`,上例約 0.1 ns)解析不了這種振鈴,求解器會回報「the local error of `S1.coss` … even at the shortest step」。`circuit.makeRealistic` 在回傳裡給出 `suggestedMinStep` 與 `hint`(Problems 面板目前沒有對應的規則,只有這個提示與本文件)。注意: - `minStep` 太大(例如 10 ns,而振鈴週期 6 ns)時,最短一階仍超出誤差,求解器回報錯誤;請照上面的 `minStep ≤ 週期 ÷ 200`。步長越短步數越多,振鈴不衰減時模擬會變慢(見下一點)。 - **奈秒級的振鈴(例如 3 nH 與 300 pF,週期約 6 ns)加上可變步長可以執行。** 起動時開關第一次導通,`ls` 與 `cj` 被電源階躍激發出幾乎不衰減的振鈴;在最短一階(`minStep`)上,梯形法的誤差若仍超過容許值,`fastsolve` 會改用一個向後歐拉步(會衰減這個振鈴),不再回報錯誤(`crates/fastsolve/src/variable.rs`)。連續 16 次(`MAX_EULER_FALLBACKS`)都沒有任何一步通過誤差估計,或向後歐拉步在最短一階仍超出容許值時,才回報「the local error of `S1.coss` … even at the shortest step」;這時請把 `minStep` 設得更細,或改用**固定步長**(`fixedStep: true`,`maxStep` 取振鈴週期的 1/10 到 1/12,例如 0.5 ns)。測試 `a_buck_with_every_parasitic_runs_with_a_fixed_step_in_both_solvers` 與 `a_buck_with_every_parasitic_runs_in_variable_step_mode` 分別涵蓋固定與可變步長。 - 振鈴的阻尼來自開關的 `ron` 與迴路電阻;`ron` 只有 1 mΩ 的理想開關加上 `ls` 與 `coss` 會**幾乎不衰減**地一直振鈴,步長會一直停在最短一階,模擬因此很慢。真實的 MOSFET 有 10–100 mΩ 的導通電阻,請設合理的 `ron`。 - 固定步長若大於振鈴週期,振鈴頻率會算錯(梯形法仍穩定,不會發散,但那個振鈴不可信)。平均值、漣波與損耗不受影響。 - 開關兩端的 `coss`、`cj` 初始電壓是 0(求解器沒有直流工作點步驟),所以第一個開關週期前可能有一個起動暫態。 ## 5. 已知限制 - 飽和是兩段式、落後一步;磁滯與溫度效應沒有模型。 - 逆向恢復是電荷控制的簡化模型,沒有軟度因子;崩潰(snap-off)後的振鈴由 `ls` 與 `cj` 決定。 - `coss` 是常數;真實的 Coss 隨電壓非線性變化,要更準請取關鍵工作電壓下的值(資料表的 C_o(tr) 或 C_o(er))。 - 交流分析(`analysis.acSweep`)會包含展開出來的電阻、電感與電容,但不支援 `adc`、增益/低通/延遲方塊。 - Problems 面板目前沒有「超出典型範圍」的規則;典型範圍只在 `component.describe` 回傳。 - 子系統裡面的元件,`makeRealistic` 與 `makeIdeal` 都不會動;請在子系統定義裡直接設參數。 --- # 最佳化、敏感度與最壞情況分析 URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/workflows/optimize/ 這份文件回答一個問題:「這個設計該怎麼調得更好?」Voltecx 有三個指令負責這件事: | 指令 | 回答的問題 | 模擬次數 | |---|---|---| | `analysis.optimize` | 哪組數值能讓目標最好,同時守住限制? | 最多 `maxEvals`(預設 100,上限 500) | | `analysis.sensitivity` | 哪個零件對結果影響最大? | 2n + 1 次(n 是變數個數) | | `analysis.worstCase` | 零件有公差時,結果最差會到哪裡? | 2^n + 1 次(`corners`),或 2n + 1 次(`sensitivity`) | 三個指令共用同一套「變數」與「指標」的寫法,下面先說明這兩個概念,再用 Buck 範例走一遍。 以下的數值預期是依公式推算,沒有在寫文件時實際執行。實際結果以指令回傳為準。 ## 該用哪一個 | 你想做的事 | 用 | |---|---| | 看一個變數從 A 掃到 B,結果怎麼變(要畫曲線、要看全貌) | `analysis.paramSweep` | | 隨機抽樣零件公差,看結果的分布與標準差 | `analysis.monteCarlo` | | 找到「讓某個結果等於目標值」或「最大 / 最小」的數值 | `analysis.optimize` | | 還不知道該調哪個零件,想先排出影響力順序 | `analysis.sensitivity` | | 確認在 ±5%、±20% 公差下規格還守得住(要保證,不是機率) | `analysis.worstCase` | 建議的順序是:先用 `sensitivity` 找出真正有影響的 1 到 3 個變數,再用 `optimize` 調這幾個,最後用 `worstCase` 檢查公差。一次丟很多變數給 `optimize` 通常比較慢也比較不準(見「常見陷阱」)。 `paramSweep` 適合看全貌;`optimize` 只回報它找到的最好那一點。 ## 變數:要動哪個數值 三個指令的 `vars` 可以指名兩種東西: - **電路變數**,例如 `D`。先用 `circuit.variables` 建立,並在元件參數裡引用它(範例 Buck 已有 `Vin`、`D`、`fsw`)。 - **元件參數**,寫成 `元件名.參數名`,例如 `L1.l`、`C1.c`、`R1.r`、`PWM.freq`。這個參數必須已經設定過(沒設定過的參數,用 `circuit.setParam` 先寫入一次預設值)。 指令會在每次模擬時用新值覆蓋它,所以參數原本是數字、運算式或變數參照都可以。找不到的名稱會直接回傳錯誤並指出是哪一個。 `optimize` 的每個變數要給範圍:`{"name":"D","lo":0.02,"hi":0.5}`。可選的 `x0` 是起點;沒給時,用目前的值(若在範圍內),否則用範圍中點。範圍越窄,搜尋越快越準。 ## 指標:從波形量出一個數字 每次模擬之後,指令會依 `metrics` 在波形上量出幾個數字。寫法: ```json "metrics": { "vout": {"signal": "v(out)", "stat": "mean", "t0": "3m"}, "iripple": {"signal": "i(L1)", "stat": "pp", "t0": "3m"} } ``` 名稱(`vout`、`iripple`)由你取,必須以字母開頭,只用字母、數字與底線,不能叫 `pi` 或 `e`,也不能和電路變數同名。 | `stat` | 意思 | |---|---| | `mean` | 平均值(依時間加權) | | `rms` | 方均根 | | `pp` | 峰對峰值(最大減最小),拿來量漣波 | | `min`、`max` | 最小、最大 | | `last` | 時間窗最後一點的值 | | `ripplePct` | 100 × 峰對峰值 ÷ \|平均值\|,單位是百分比 | | `meanProduct` | 兩個訊號相乘後的時間平均,要多給 `signal2`;用來算功率 | `t0`、`t1` 是時間窗(秒,可以寫 `"3m"`),沒寫就用整段。 ### 效率怎麼算 波形裡只有電壓 `v(節點)` 與電流 `i(元件)`,沒有現成的功率訊號,所以用 `meanProduct`: ```json "metrics": { "pin": {"signal": "v(in)", "signal2": "i(Vin)", "stat": "meanProduct", "t0": "3m"}, "pout": {"signal": "v(out)", "signal2": "i(R1)", "stat": "meanProduct", "t0": "3m"} } ``` 接著目標寫成 `"expr": "pout/abs(pin)"`。電壓源在供電時,支路電流依求解器的符號慣例是負的(電流從 `p` 端穿過電源流向 `n` 端),所以 `pin` 會是負值;用 `abs()` 就不必管正負號。節點名稱與元件名稱要換成你電路裡的名字(Buck 範例的電源叫 `Vin`、負載叫 `R1`、輸入節點叫 `in`)。 ### 目標與限制是運算式 `objective` 與 `constraints` 都是運算式,可以用的名稱有:指標名稱、電路變數、被調整的變數(元件參數直接寫 `L1.l`)。支援 `+ - * / ^`、括號,以及 `sqrt`、`abs`、`min`、`max`、`ln`、`exp` 等函式(同參數運算式)。 ```json "objective": {"expr": "pout/abs(pin)", "sense": "max"}, "constraints": [{"expr": "iripple", "op": "<=", "value": 0.5}] ``` `sense` 一定要寫(`min` 或 `max`),不給預設值,避免方向弄反。 ## 範例一:Buck 要輸出 5 V,D 該設多少 範例 `buck` 輸入 48 V。理論上平均輸出 = D × 48,所以 D 約等於 5 / 48 ≈ 0.104。用 `optimize` 讓模擬自己找: ```sh cargo run -p powercraft-cli -- run \ --cmd file.openExample --params '{"name":"buck"}' \ --cmd simulation.settings --params '{"tEnd":"4m","maxStep":"100n","solver":"fast"}' \ --cmd analysis.optimize --params '{ "vars":[{"name":"D","lo":0.02,"hi":0.5}], "metrics":{"vout":{"signal":"v(out)","stat":"mean","t0":"3m"}}, "objective":{"expr":"(vout-5)^2","sense":"min"}, "maxEvals":60, "apply":true}' \ --cmd circuit.variables --params '{}' \ --out buck5v.voltecx ``` 說明: - `"tEnd":"4m"` 與 `"t0":"3m"`:只量最後 1 ms。Buck 啟動時輸出電容從 12 V 開始,要幾個時間常數才會穩定,不能量暫態。 - `"solver":"fast"`:快速求解器在 PWM 邊緣精準落點,占空比不會被步長量化。 - 目標用 `(vout-5)^2`:越接近 5 V 越小。 - `"apply":true`:找到後把 `D` 寫回電路,**恰好記錄一個歷史步驟**,可以 `edit.undo`。不寫 `apply`(預設 false)時電路完全不變。 - 最後的 `circuit.variables` 不帶參數,只是把目前的變數值印出來,確認 `D` 已更新。 回傳是一行 JSON,重點欄位: | 欄位 | 內容 | |---|---| | `best` | 找到的最佳數值,例如 `{"D":0.104…}` | | `objective` | 在最佳點的目標值 | | `metrics` | 最佳點的各個指標(這裡應該接近 `vout` ≈ 5) | | `constraints` | 每個限制的實際值、違反程度、是否滿足 | | `feasible` | 所有限制是否都滿足 | | `evaluations`、`stop` | 模擬次數;`converged` 表示搜尋收斂,`maxEvals` 表示用完次數 | | `applied` | 有沒有寫回電路 | | `history` | 每次嘗試的點與目標值(最多 200 筆,超過時保留前後各一半,`historyOmitted` 是省略的筆數) | | `warnings` | 該注意的事:有幾次模擬失敗、沒收斂、目標值完全沒變化等 | ## 範例二:電感最小要多大才能守住漣波 限制:電感電流峰對峰漣波不超過 0.5 A,電感越小越便宜,所以目標是 `L1.l` 越小越好。依公式,漣波 = (Vin − Vout) × D / (L × f) = 9 / (L × 100 kHz),所以 L 約需 180 µH。 ```sh cargo run -p powercraft-cli -- run \ --cmd file.openExample --params '{"name":"buck"}' \ --cmd simulation.settings --params '{"tEnd":"4m","maxStep":"100n","solver":"fast"}' \ --cmd analysis.optimize --params '{ "vars":[{"name":"L1.l","lo":"50u","hi":"500u"}], "metrics":{"iripple":{"signal":"i(L1)","stat":"pp","t0":"3m"}}, "objective":{"expr":"L1.l","sense":"min"}, "constraints":[{"expr":"iripple","op":"<=","value":0.5}], "maxEvals":80}' ``` 限制是用二次懲罰項處理的:違反限制越多,目標越差。所以最佳點會停在限制邊緣,可能超出一點點。回傳的 `satisfied` 容許相對 0.1% 的誤差,超過就會 `feasible:false`,並在 `warnings` 說明。若 `feasible` 是 false 又帶了 `apply:true`,**不會寫回電路**。 ## 範例三:哪個零件影響最大 ```sh cargo run -p powercraft-cli -- run \ --cmd file.openExample --params '{"name":"buck"}' \ --cmd simulation.settings --params '{"tEnd":"4m","maxStep":"100n","solver":"fast"}' \ --cmd analysis.sensitivity --params '{ "vars":["D","L1.l","C1.c","fsw"], "metrics":{ "vout": {"signal":"v(out)","stat":"mean","t0":"3m"}, "iripple":{"signal":"i(L1)", "stat":"pp", "t0":"3m"}}, "rel":0.01}' ``` 每個變數各往上、往下動 1%(中央差分),算出「正規化敏感度」:變數變 1%,指標變幾 %。回傳的 `sensitivities` 已依絕對值由大到小排好。預期:`D` 對 `vout` 約為 1(輸出和 D 成正比);`L1.l` 與 `fsw` 對 `iripple` 約為 −1(漣波和 L、f 成反比);`C1.c` 對 `vout` 平均值幾乎是 0。 每筆有兩個數字:`normalized`(正規化)與 `absolute`(對變數的偏微分,單位是「指標單位 / 變數單位」)。指標值是 0 時沒有正規化意義,`normalized` 會是 `null`。變數目前的值是 0 時,指令會回傳錯誤,因為「變動 1%」沒有大小。 ## 範例四:公差下的最壞情況 ```sh cargo run -p powercraft-cli -- run \ --cmd file.openExample --params '{"name":"buck"}' \ --cmd simulation.settings --params '{"tEnd":"4m","maxStep":"100n","solver":"fast"}' \ --cmd analysis.worstCase --params '{ "vars":[{"name":"L1.l","tol":0.2},{"name":"C1.c","tol":0.2},{"name":"R1.r","tol":0.05}], "metrics":{"vripple":{"signal":"v(out)","stat":"pp","t0":"3m"}}}' ``` `tol` 是相對公差(0.2 代表 ±20%)。預設的 `corners` 方法把每個變數取下限或上限,跑完全部 2^n 種組合(這裡 8 種,再加一次標稱值),回報每個指標的最小值、最大值,以及是哪一組數值造成的(`at`)。這是**保證**的範圍(在這些組合之內),不是機率。 變數超過 8 個時,`corners` 會回傳錯誤並建議改用 `"method":"sensitivity"`。這個方法只跑 2n + 1 次,假設指標在公差範圍內是線性的,回傳最壞情況加總與方均根(`rss`)兩種估計,以及每個變數的貢獻。它是估計,不是保證;若指標對變數是明顯非線性(例如有切換點),請改用 `corners`。 任何一組組合模擬失敗時,會列在 `failedCorners`,極值只涵蓋成功的那些。最壞情況本身很可能就是那個失敗的組合(例如電感太小造成不連續導通),要留意。 ## 常見陷阱 **1. 暫態沒有結束,目標值會有雜訊。** 這是最常見的問題。模擬太短、或時間窗還在暫態裡,量到的平均值會隨變數亂跳,搜尋就找不到穩定的最佳點。做法: - 估算時間常數(RLC 輸出約 1 / (ζω₀)),`tEnd` 取其 5 到 10 倍以上。 - 指標一律用 `t0` 只量穩態的最後一段,且涵蓋整數個切換週期。 - 可以把電容初始電壓 `v0`、電感初始電流 `i0` 設在接近穩態的值,縮短所需的 `tEnd`。 - 看 `history`:同一區間內目標值不平滑,就是雜訊太大。 **2. 搜尋可能落在區域最佳點。** `optimize` 是 Nelder–Mead(不用微分、只做局部搜尋,每次結果相同)。目標有多個谷底時,它只會走到離起點最近的那一個。做法:先用 `paramSweep` 看全貌;用 `x0` 換幾個起點分別跑;把 `lo` / `hi` 縮到你相信的範圍。 **3. 變數太多。** Nelder–Mead 在變數多的時候收斂很慢,`maxEvals` 很快用完(`stop` 是 `maxEvals`,並附警告)。建議一次不超過 3 到 4 個變數;先用 `sensitivity` 排出重要的,其餘固定。 **4. 單位差好幾個數量級的變數放在一起。** 搜尋是在各變數範圍內按比例(0 到 1)進行的,所以 `lo` / `hi` 給得合理就沒問題;但範圍跨好幾個數量級(例如 1 µH 到 10 mH)時,大部分的範圍是無意義的,請縮小。 **5. 目標值完全沒變。** 回傳 `warnings` 會寫「the objective never changed」。常見原因:變數寫對名字但其實沒有被模型使用(元件參數名稱拼錯,會直接報錯;但變數沒被任何參數引用就不會);指標的時間窗超出模擬範圍(這會讓每次模擬都失敗,錯誤訊息寫「no samples」)。 **6. 限制寫太緊或不可能達成。** 此時 `feasible` 是 false,最佳點會是違反最少的那一點。放寬限制或擴大 `lo` / `hi`。 **7. 模擬太長會被擋下。** 指令會先估算「模擬次數 × 每次步數」,超過 1 億步就直接回傳錯誤,一次模擬都不跑。降低 `maxEvals`、縮短 `tEnd` 或加大 `maxStep`。`tEnd` 參數可以在三個指令裡臨時覆蓋電路的設定,不會改到電路。 **8. 切換電路請用 `"solver":"fast"`。** 固定步長的參考求解器(`reference`)把切換時刻量化到步長,占空比只能是步長的整數倍,目標會變成階梯狀,搜尋容易停在平台上。 ## 上限一覽 | 項目 | 上限 | |---|---| | `maxEvals` | 500(預設 100) | | 變數、指標、限制個數 | 各 32 | | `worstCase` 的 `corners` | 8 個變數(256 組) | | 總模擬步數(次數 × 每次步數) | 1 億 | | `history` 回傳筆數 | 200 | 所有參數錯誤(空的 `vars`、`lo` 不小於 `hi`、NaN、找不到的變數或訊號、運算式寫錯)都會直接回傳錯誤並指出名稱,不會開始模擬。 --- # 選零件:從模擬到資料表,再回到模擬 URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/workflows/part-selection/ 選 MOSFET、二極體或 IC 很難,因為「這個零件夠不夠用」要看它在你的電路裡實際承受什麼。Voltecx 的做法是先模擬,量出每個元件的真實應力,再用降額規則算出零件至少要有多大的額定值,最後從元件庫挑出損耗最低的零件,換進電路重新模擬。 如果你手上有資料表(datasheet),可以把它變成元件庫裡的一筆資料,第 4 節說明每個欄位要從資料表的哪一張表或哪一條曲線讀。 > 內建元件庫的數字都是**示意用的典型值**(`source` 欄寫明 "Not a real part"),不是任何廠商的零件。要做真正的選型,請用自己的資料表建立零件(第 4 節)。 ## 1. 整體流程 ```text simulation.run 先模擬,跑到穩態 analysis.stress 量每個元件的電壓、電流應力,算出所需額定值 library.search 依額定值、Rds(on)、Vf 等條件在元件庫搜尋 device.recommend 只留下額定值夠的零件,依估計損耗排序 device.recommend apply 把第一名(或你指定的)零件放進電路,一個歷史步驟,可復原 simulation.run 用該零件的損耗表與熱模型重新模擬 analysis.losses / analysis.thermal 確認損耗與接面溫度 ``` 每一步都是引擎指令,GUI、CLI、MCP 與 AI agent 都用同一個 id 呼叫。 ## 2. 量測應力:`analysis.stress` ```json {"command": "file.openExample", "params": {"name": "buck"}} {"command": "simulation.settings", "params": {"tEnd": "4m", "maxStep": "100n", "solver": "fast"}} {"command": "simulation.run", "params": {}} {"command": "analysis.stress", "params": {"t0": "3m"}} ``` - `t0`、`t1`:量測視窗。預設是整段模擬,**請把 `t0` 設在啟動暫態之後**,視窗最好涵蓋整數個切換週期。 - 每個元件(電阻、電容、電感、開關、二極體)一列,內容: - `measured`:電流峰值、RMS、平均值、最大與最小值;跨壓峰值;最大 di/dt、dv/dt;二極體的峰值逆向電壓;電容的 RMS 漣波電流;電感的峰對峰電流;電阻的功率;開關與二極體的平均損耗(來自 `analysis.losses`);有熱模型時的接面溫度峰值。 - `required`:零件**至少**要有的額定值,也就是量測值除以降額係數。 - `device`:若元件已指定 `device`,這裡列出該零件的額定值對所需額定值的餘裕(`voltageMargin = 額定 ÷ 所需 − 1`,0.25 代表還有 25 %,負數代表額定值不足)、`pass` 與 `issues`。沒有指定零件的元件這一欄是 `null`。 - `underRated`:額定值不足的元件名單。 - `stale`:為 `true` 代表電路在這次模擬之後被改過,結果已過期,請重新模擬。 buck 範例(48 V 降到 12 V,D = 0.25,100 kHz,100 µH,5 A 負載)可以用手算核對,這些也是測試的依據: | 量 | 手算 | 公式 | |---|---|---| | 開關的峰值電壓 | 約 48 V | 約等於輸入電壓 | | 電感漣波 ΔI | 0.9 A | (Vin − Vout)·D ÷ (L·f) | | 電感 RMS 電流 | 約 5.007 A | √(I² + ΔI²/12) | | 電容 RMS 漣波電流 | 約 0.26 A | ΔI ÷ √12 | | 二極體平均電流 | 約 3.75 A | (1 − D)·I | ### 降額規則(可覆寫) 降額是工程上常見的做法:讓零件的實際應力只用到額定值的一部分,留給溫度、老化與量測誤差。預設值依零件類別取自 NASA EEE-INST-002(NASA/TP-2003-212242,2003 年 5 月,含 2008 年 4 月 Addendum 1)各章的表 4(#3036);每一列的 `required.rules` 會寫出它依據的規則: | 零件 | 電壓 | 電流 | 其他 | |---|---|---|---| | 開關(S1 表 4,電晶體) | 0.75 | RMS 0.75 | 接面溫度上限 125 °C,或比元件最高接面溫度低 40 °C,取較低者 | | 二極體(S1 表 4) | 逆向峰值 0.70 | **平均**電流 0.50 | 接面溫度同上 | | 陶瓷、薄膜電容(C1 表 4) | 直流加漣波峰值 0.60 | 漣波:製造商額定值 | | | 鋁電解、高分子電容 | C1 沒有此列:製造商額定值(1) | 製造商額定值 | 壽命由 `design.reliability` 依核心溫度檢查 | | 鉭質電容 | 假設值 0.60:Voltecx 未收錄 C1 表 4 的鉭質列,請自行核對 | 製造商額定值 | | | 電感 | M1 只對溫度降額:製造商額定值 | RMS 與飽和電流:製造商額定值 | | | 電阻(R2 表 4) | 0.80 | | 功率 0.60(未套用高溫段的線性下降,屬假設) | 電容的介質用 `"derating": {"dielectric": {"C1": "mlcc"}}` 指定(mlcc、film、tantalum、electrolytic、polymer);沒指定時採用收錄中最嚴的 0.60,並註明為假設。`voltage`、`currentRms`、`currentPeak`、`tjMax`、`power` 會對所有類別取代預設值,例如 `"derating": {"voltage": 0.7, "tjMax": 110}`。係數必須在 (0, 1],不認得的鍵會回傳錯誤並列出所有合法的鍵。 ### 讀數字時要知道的限制 - **dv/dt、di/dt** 取自相鄰取樣點。理想開關在一個步長內切換,所以這兩個數字受 `maxStep` 限制,不是真實的邊緣速率;想看真實邊緣需要更細的步長與寄生參數,目前的模型沒有。 - 子系統內部的零件、耦合電感與變壓器的繞組目前不分析(列在 `skipped`)。 - 電容、電感、電阻沒有元件庫資料,所以只給 `required`,沒有餘裕。請依 `required` 去看資料表(電容看額定電壓與漣波電流,電感看飽和電流與 RMS 電流)。 ## 3. 搜尋與推薦 ### `library.search` ```json {"command": "library.search", "params": { "type": "mosfet", "filters": {"vdsMin": 600, "idMin": 20, "rdsonMax": "60m"}, "sort": "rdson", "limit": 10 }} ``` `type` 是 `mosfet`、`igbt`、`diode`(元件庫目前**只有半導體**;填 `capacitor` 或 `inductor` 會回空清單與說明,請改看 `analysis.stress` 的 `required`)。搜尋範圍是內建元件庫加上你加入的零件(開著電路時 `device.add` 把零件嵌入電路,沒開電路時加進本次工作階段的元件庫)。`module` 為 `true` 只列 IGBT 功率模組(半橋、六合一),`false` 只列分離式零件;模組那一列的 `module` 寫出拓樸、封裝與各開關位置的接腳。 | 篩選 | 對應欄位 | |---|---| | `vdsMin`、`vceMin`、`vrrmMin`(同義)、`vdsMax` | `vMax`:Vds、Vces 或 Vrrm 額定電壓(V) | | `idMin`、`icMin`、`ifMin`(同義)、`idMax` | `iMax`:連續電流額定值(A) | | `rdsonMax` | 由 `conduction` 表推得的導通電阻(Ω):最接近 25 °C 那條曲線最後兩點的斜率 | | `vfMax` | `conduction` 表在 `iMax`、25 °C 的導通壓降(V) | | `rthJcMax` | `thermalJc` 各級 R 的總和(K/W) | 篩選值可以是數字或 `"60m"` 這類字串。不認得的篩選名稱會回傳錯誤並列出所有合法名稱。`sort` 可用 `id`、`vMax`、`iMax`、`rdson`、`vf`、`rthJc`,前面加 `-` 變成由大到小;沒有該數值的零件排在最後。 ### `device.recommend` ```json {"command": "device.recommend", "params": {"component": "S1", "limit": 5}} ``` 1. 取該元件的應力與降額後的所需額定值。 2. 只保留種類相符且額定電壓、額定電流都**不低於所需值**的零件(理想開關可換 MOSFET 或 IGBT;MOSFET、IGBT、二極體各自只換同類)。額定值不足的零件列在 `rejected`,附原因。 3. 把這個元件在模擬中的電流與電壓波形,**用每個候選零件自己的損耗表重播一次**:導通損耗是表上的壓降乘電流;每次開通加 `eOn`、關斷加 `eOff`(二極體關斷加 `eRr`),都取該次切換的阻斷電壓與電流。這和求解器計算損耗的規則相同。 4. 依總損耗由小到大排序(相同時依 id),每個候選附一行說明,例如:`Vds 650 V >= 62.5 V needed; Id 30 A >= 3.6 A needed; est. loss 3.1 W (conduction 1.2 W + switching 1.9 W at Tj 125 °C)`。 可調參數:`tj`(估計損耗用的接面溫度,預設是降額的 `tjMax`,也就是偏保守的熱態表)、`t0`/`t1`、`derating`。 `"apply": true` 把第一名放進元件的 `device` 參數,是**一個歷史步驟**,可以用 `edit.undo` 復原。想選第二名以後的,加 `"choose": ""`(必須是合格的候選)。 注意: - 估計值依賴你模擬的那個工作點。**負載、輸入電壓、頻率變了就要重新模擬再推薦。**視窗至少要涵蓋一個完整切換週期。 - 元件若自己設了 `ron` 或 `vf` 參數,電氣模型仍使用它;損耗改由零件的表計算。`notes` 會提醒這件事。 - 推薦是用來縮小範圍的,不取代對資料表的檢查(閘極驅動、寄生電容、安全工作區、封裝與成本都不在這個估計裡)。 ### 換上零件後重新模擬 ```json {"command": "circuit.setParam", "params": {"component": "S1", "key": "thermal", "value": "hs"}} {"command": "circuit.addComponent", "params": {"name": "HS", "kind": {"kind": "thermal", "element": "ambient"}, "params": {"t": 50}}} {"command": "circuit.connect", "params": {"component": "HS", "port": "a", "net": "hs"}} {"command": "simulation.run", "params": {}} {"command": "analysis.losses", "params": {"t0": "3m"}} {"command": "analysis.thermal", "params": {}} {"command": "analysis.stress", "params": {"t0": "3m"}} ``` `thermal` 指定的網路 `hs` 是外殼(散熱器)節點,`ambient` 元件固定它的溫度。零件有 `thermalJc`(接面到外殼的 Foster 鏈)時,模擬會多出接面節點 `T(S1.j)`,`analysis.stress` 會把它的峰值與 `tjMax` 比較。外殼到環境的熱阻可以再加 `rth` 元件模擬散熱器。 ## 4. 把資料表變成零件:`device.add` 流程(人或 AI agent 都一樣):讀資料表 PDF,填下面的 JSON,先呼叫 `device.validate` 檢查,沒有錯誤再加入。 ```json {"command": "device.validate", "params": {"device": { ... }, "add": false}} {"command": "device.validate", "params": {"device": { ... }, "add": true}} ``` `device.add` 只檢查檔案能解析、表格的 x 軸遞增且為有限值、Foster 的 R 與 tau 為正。`device.validate` 另外檢查資料表抄錄時常見的錯誤: - **錯誤**(不會被加入):`vMax`、`iMax` 不是正數;id 含空白或看起來像數字;`conduction` 沒有曲線;導通壓降為負數,或壓降隨電流增加而**下降**;同一溫度或同一(電壓、溫度)有兩條曲線;能量為負;溫度超出 −100 到 400 °C(可能填成了克氏溫度)。 - **警告**:能量大於 1 J(多半是 mJ 當成 J);壓降大於 50 V;`eOn`、`eOff` 空白;二極體填了 `eOn`;沒有 `thermalJc`;只有一個溫度;表格延伸超出額定值;`notes`、`source` 空白。 `add: true` 只在沒有錯誤時才呼叫 `device.add`,有錯誤就回傳錯誤訊息並列出全部問題。 ### 完整範例 下面的數字是**編出來示範格式的**,不是任何廠商的零件;請換成你的資料表數字: ```json { "id": "example/sic-mosfet-650v-30mohm", "kind": "mosfet", "manufacturer": "Example", "part": "EX-650-30", "source": "範例:請填 廠商 資料表名稱 版本 日期", "vMax": 650, "iMax": 50, "conduction": {"curves": [ [25, {"x": [0, 10, 25, 50], "y": [0, 0.30, 0.75, 1.50]}], [150, {"x": [0, 10, 25, 50], "y": [0, 0.45, 1.13, 2.25]}] ]}, "diodeConduction": {"curves": [ [25, {"x": [0, 10, 25, 50], "y": [0, 3.0, 3.3, 3.8]}] ]}, "eOn": {"curves": [ {"v": 400, "t": 25, "curve": {"x": [0, 10, 25, 50], "y": [0, 6.0e-5, 1.5e-4, 3.2e-4]}}, {"v": 400, "t": 150, "curve": {"x": [0, 10, 25, 50], "y": [0, 6.5e-5, 1.6e-4, 3.4e-4]}} ]}, "eOff": {"curves": [ {"v": 400, "t": 25, "curve": {"x": [0, 10, 25, 50], "y": [0, 2.0e-5, 5.0e-5, 1.1e-4]}}, {"v": 400, "t": 150, "curve": {"x": [0, 10, 25, 50], "y": [0, 2.2e-5, 5.5e-5, 1.2e-4]}} ]}, "eRr": {"curves": [ {"v": 400, "t": 25, "curve": {"x": [0, 10, 25, 50], "y": [0, 5.0e-6, 1.2e-5, 2.5e-5]}}, {"v": 400, "t": 150, "curve": {"x": [0, 10, 25, 50], "y": [0, 6.0e-6, 1.4e-5, 3.0e-5]}} ]}, "thermalJc": [{"r": 0.20, "tau": 2.0e-4}, {"r": 0.30, "tau": 2.0e-3}], "notes": "Vgs = -4/18 V, Rg = 5 ohm, Vdc = 400 V, 預設的閘極電阻與測試電路請照資料表填" } ``` ### 欄位與資料表的對應 單位一律是 SI:伏特、安培、焦耳、歐姆、秒、攝氏。資料表常用 mJ、µJ、mΩ、ns,**填之前要換算**(1 mJ = 1e-3 J)。 | 欄位 | 資料表哪裡找 | 注意 | |---|---|---| | `id` | 自訂 | 用 `廠商/料號` 的小寫形式,不含空白,不要像數字(例如 `10u`)。電路用 `device` 參數以這個 id 引用 | | `kind` | 零件種類 | `mosfet`(SiC、GaN HEMT 也用這個)、`igbt`、`diode` | | `manufacturer`、`part` | 資料表標題 | | | `source` | 資料表檔名、版本、日期 | 誠實寫出數字來自哪裡;之後有人要追溯 | | `vMax` | Absolute Maximum Ratings 的 Vds,max/Vces/Vrrm | 單位 V,是阻斷電壓額定值 | | `vgsMax` | Absolute Maximum Ratings 的 Vgs/Vge 正向額定值 | 單位 V,選填;SiC 常只給暫態最大值(例如 +19 V),請在 `notes` 寫明取的是哪一列。資料表沒有讀到就不要填 | | `vgsMin` | 同一列 Vgs/Vge 的負向額定值 | 單位 V,選填,必須小於零,且要與 `vgsMax` 一起給(例如 SiC 的 -8 V)。資料表沒有讀到就不要填 | | `iMax` | Absolute Maximum Ratings 的連續電流 Id/Ic/If(AV) | 取**你會實際運作的外殼溫度**那一列(例如 Tc = 100 °C),不要用 25 °C 的值,也不要用脈衝電流。這是 `device.recommend` 比對的額定電流 | | `conduction` | MOSFET:Rds(on) 對 Tj 的表或 Id–Vds 輸出特性;IGBT:Vce(sat) 對 Ic 的輸出特性;二極體:Vf 對 If 的特性 | 每個接面溫度一條曲線,格式 `[Tj, {"x": [電流 A], "y": [壓降 V]}]`。MOSFET 的壓降 = Id × Rds(on)(Tj),例如 Rds(on) = 30 mΩ、10 A 取 0.30 V。第一點填 (0, 0)。至少要兩個溫度(例如 25 與 150 °C),才能反映導通電阻隨溫度上升。最後兩點請落在線性區,因為模擬器用它們的斜率當預設的導通電阻 | | `diodeConduction` | MOSFET 的體二極體 Vsd 對 Isd 的曲線 | 格式同上。MOSFET 反向導通時用它;沒有就留空,會沿用 `conduction` | | `eOn` | 「開通能量 Eon 對 Id(或 Ic)」圖 | 每個(阻斷電壓 Vdc,Tj)一條,格式 `{"v": Vdc, "t": Tj, "curve": {"x": [電流 A], "y": [能量 J]}}`。Vdc、閘極電阻 Rg、閘極電壓要記在 `notes`。能量表沒有 Rg 這個軸,請取資料表標示的條件,或你設計用的 Rg 那條曲線。只有一個典型值時,填 `[0, 0]` 與 `[額定電流, 值]` 兩點 | | `eOff` | 「關斷能量 Eoff 對 Id」圖 | 格式同 `eOn` | | `eRr` | 二極體(MOSFET 體二極體、IGBT 的反並聯二極體或獨立二極體)的「反向恢復能量 Err 對 If」圖 | 格式同 `eOn`。如果只有 Qrr,粗估 Err ≈ ½ × Qrr × Vdc(取 Qrr 的 Vdc 與 Tj 條件),並在 `notes` 寫明是估計。蕭特基(SiC)二極體幾乎沒有恢復損耗,可以填電容電荷 Qc 的估計值或留空 | | `thermalJc` | 暫態熱阻抗 Zth(j-c) 的 Foster 參數表(r1、τ1、r2、τ2…) | 每級 `{"r": K/W, "tau": 秒}`。模擬器用 R 與 C = τ/R 並聯成一級,各級串聯。資料表只給穩態 Rth(j-c) 時,填一級 `{"r": Rth, "tau": 估計值}`,並註明。若資料表給的是 Cauer 的 R、C 對,不能直接貼上,要先擬合成 Foster 級 | | `charges` | MOSFET 的動態特性表:Qg、Qgs、Qgd、Qsw、Qg(th)、Qoss(或某個 Vds 下的 Coss)、平台電壓、Vgs(th) 與 gfs、Rg(int) | 選填,格式 `{"qgs": C, "qgd": C, "qsw": C, "qgTh": C, "qoss": C, "vPlateau": V, "rgInt": Ω}`,另有 `qg`、`coss` 與 `vCoss`、`vth`、`gfs`。只在 `eOn` 與 `eOff` 都空白時使用:開關能量依閘極電荷法估計(Infineon 應用筆記 Graovac 等,2006)。開通與關斷時間 = Qsw ÷ 閘極電流,閘極電流由驅動電壓、平台電壓與外部加內部 Rg 決定;E = ½·V·I·t,開通再加 Qoss·V(或 ½·Coss·V²)。電路的 MOSFET 設了 `von`、`voff`、`rgon`、`rgoff` 就用它們,否則用 10 V、0 V、2 Ω。所有回報損耗的地方都會註明這是估計值 | | `notes` | 測試條件 | Rg、Vgs、Vdc、電感量與換流二極體、Tj。日後比較兩個零件時最需要這些 | 模型**不使用**這些資料表參數(填了也不影響模擬):Qg、安全工作區、絕對最大 Tj。Ciss/Coss/Crss、閘極臨界電壓與 Rg(int) 只用在 `gate`(動態開關層級)與 `charges`(沒有能量表時的開關損耗估計)。選型時要自己對照資料表。 ### 用 MCP 讓 agent 做 agent 讀 PDF,依上表填 JSON,呼叫 `command_run`: 1. `device.validate {"device": {...}}`,依 `errors` 修正,`warnings` 逐項確認(特別是單位)。 2. `device.validate {"device": {...}, "add": true}`。 3. `library.search` 確認找得到,再用 `device.recommend` 或直接 `circuit.setParam {"component": "S1", "key": "device", "value": ""}` 使用它。 人工填的 `source` 與 `notes` 不能省:零件資料的可信度全靠這兩欄。 ### 用 CSV 匯入:`device.import` 資料表的數字常常是表格,不必先改寫成 JSON。把表格寫成 CSV 文字,用 `device.import` 一次讀進來: ```json {"command": "device.import", "params": {"format": "csv", "name": "mine/part-1", "text": "..."}} ``` `device.export` 會把元件庫裡的任何零件寫成同樣的 CSV,可以當範本。格式如下,完整的說明與例子在使用手冊第 6 章「元件庫:廠商零件與你自己的資料表」: - 空白行與 `#` 開頭的行會被略過。 - 先寫零件的資料列,每列是名稱、逗號、值(值是該行逗號之後的全部文字):`id`、`kind`、`manufacturer`、`part`、`source`(必填)、`vMax`(V)、`iMax`(A)、`vgsMax`(V,選填)、`vgsMin`(V,選填,小於零)、`notes`。`name` 參數會取代 `id`。 - 再寫表格。`section,conduction`、`section,diodeConduction`、`section,switching`、`section,thermal` 各開始一張表,下一列是欄位名稱,單位寫在欄位名稱裡。 - `conduction`、`diodeConduction`:欄位 `tj_c`、`i_a`、`v_v`(或 `v_mv`),每個溫度一條曲線。 - `switching`:欄位 `tj_c`、`v_v`、`i_a`,加上 `eon_j`、`eoff_j`、`err_j` 之中的任何幾個(也可以用 `_mj`、`_uj`,資料表常用 mJ 與 µJ)。每個(測試電壓,溫度)一條曲線。某一列沒有某種能量時,該格留空。 - `thermal`:欄位 `r_k_per_w`、`tau_s`(或 `tau_ms`、`tau_us`),每列一級 Foster。只有穩態 Rth,jc 時,改用單一欄位 `rth_jc_k_per_w` 寫一列,這時時間常數 1 ms 是匯入的假設,匯入會在 `notes` 寫明。 匯入的檢查比 `device.add` 嚴:欄位名稱不認得(例如 `tj_k`)、數值帶單位文字、電流沒有遞增、數值為負或不是有限數、某一列的格子數與欄位數不同、檔案超過上限(256 KiB、5000 列資料、每條曲線 200 點、10 級熱阻),都會被拒絕,錯誤訊息會指出行號。通過後,匯入會接著執行 `device.validate` 的檢查(有錯誤就不加入),再用 `device.add` 的方式加入,所以回傳結果與 `device.validate` 的 `add: true` 相同,含 `warnings`。 ### 內建的廠商零件 元件庫除了 6 個示意用的通用元件,還有從廠商資料表讀出來的零件(`devices/vendor.json`)。`library.deviceModels`、`library.search`、`device.recommend` 的每一列都有 `class`:`vendor`(廠商資料表)、`generic`(示意)或 `user`(你加入的、或嵌在電路裡的)。每個廠商零件的 `source` 寫明廠商、資料表網址、版本與日期,以及用到的圖與表的編號;`notes` 寫明描點方式與測試條件。 注意這幾點: - 曲線只描 4 到 10 個點,是粗略的數位化,不是廠商的模型檔。 - 有些資料表只給一個溫度的開關能量曲線(例如只有 150 °C 或 175 °C),那個零件就只有那一個溫度的曲線,其他溫度的損耗會偏高或偏低,`notes` 都有寫。 - 熱阻若資料表沒有 Foster 參數,是我們用資料表的 Zth 曲線擬合的,`notes` 會寫明擬合誤差。 - 資料表沒有給的表格(例如碳化矽蕭特基二極體的反向恢復)就是空的,不是 0 的實測值。 - 資料表本身有時圖與表不一致,`notes` 會寫出兩個數字,並說明採用哪一個。 要確認某個零件的數字與資料表一致,請以 `source` 指的網址與圖號為準。 ## 5. 選 IC:閘極驅動器、控制器、電流感測放大器 目前的模擬器把這些 IC 當成理想的控制方塊(`pwm`、`comparator`、`deadtime`、`delay`、`limiter`、`sampleHold`、`pi` 等)。**IC 的行為模型是之後的步驟**,目前沒有 `device.add` 對應的 IC 資料格式,也沒有 IC 的元件庫。選 IC 時,資料表上這些參數會影響模擬結果,建議先記下來,並用現有的控制方塊近似: | IC | 影響模擬的資料表參數 | 目前怎麼近似 | |---|---|---| | **閘極驅動器** | 傳播延遲 tPLH/tPHL 與兩者的差(造成脈寬失真)、輸出上升/下降時間、峰值灌電流與拉電流(決定開關速度,也就是開關損耗)、欠壓鎖定 UVLO 的開啟與關閉閾值與遲滯、DESAT 偵測閾值與遮蔽時間(blanking)、最小脈寬、內建死區 | 延遲與死區可用 `deadtime`(延遲上升緣)與 `delay` 方塊;UVLO 可用 `comparator` 搭配閘極訊號;開關速度要靠 `eOn`/`eOff` 的 Rg 條件反映,目前沒有獨立的閘極電流模型 | | **PWM 控制器** | 切換頻率與精度、斜坡或鋸齒波振幅、參考電壓精度、軟啟動時間、限流閾值與前緣遮蔽時間、最小導通時間與最大佔空比、誤差放大器的增益頻寬 | `pwm`、`carrier`、`pi`、`limiter`、`step`(軟啟動)可近似;增益頻寬與遮蔽時間尚未建模 | | **電流感測放大器** | 增益與增益誤差、頻寬、壓擺率、輸入偏移電壓與溫漂、共模輸入範圍、輸出擺幅、建立(settling)時間 | `gain`、`sampleHold`、`delay` 可近似增益與延遲;偏移與頻寬可用 `sum` 加常數、再接一個一階濾波(`pi`/`integrator` 組合)近似,不精確 | 挑 IC 的順序建議:先由 `analysis.stress` 與 `device.recommend` 定下功率級(電壓、電流、切換速度),再依功率級的需求選驅動器:峰值驅動電流要夠把所選 MOSFET 的閘極電荷在目標時間內充完,UVLO 閾值要高於 MOSFET 的完全導通所需的閘極電壓,DESAT 遮蔽時間要長過導通的電壓降穩定時間,這些要用資料表對照,模擬器目前不會替你檢查。 ## 6. 指令與測試 | id | 作用 | |---|---| | `analysis.stress` | 每個元件的應力、所需額定值、對已指定零件的餘裕 | | `library.search` | 在元件庫依額定值搜尋、排序 | | `device.recommend` | 依估計損耗排序候選,可 `apply` | | `device.validate` | 檢查資料表抄錄的零件,可 `add` | | `device.import` | 讀 CSV(或 JSON)資料表,嚴格檢查後加入零件 | | `device.export` | 把元件庫裡的零件寫成 CSV(或 JSON) | 測試在 `crates/engine-core/src/stress_cmds.rs`、`selection_cmds.rs`、`device_check_cmds.rs`、`device_csv.rs`、`device_import_cmds.rs` 各自的 `tests` 模組,以及 `crates/engine/tests/vendor_devices.rs`: ```sh cargo test -p powercraft-engine stress_cmds cargo test -p powercraft-engine selection_cmds cargo test -p powercraft-engine device_check_cmds cargo test -p powercraft-engine device_csv cargo test -p powercraft-engine device_import_cmds cargo test -p powercraft-engine --test vendor_devices cargo test -p powercraft-engine --test panic_hunt ``` --- # 匯出電路圖:放進報告與論文 URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/workflows/schematic-export/ 這份文件回答一個問題:「我在 Voltecx 畫好(或載入)的電路圖,怎麼變成報告或論文裡的一張圖?」答案是兩個指令,三種格式: | 指令 | 用途 | |---|---| | `file.exportSchematic` | 把目前的電路圖寫成 `svg`、`png` 或 `tex`(circuitikz) | | `file.print` | 寫一份黑白、可以直接列印或轉成 PDF 的 `svg`(或 `png`)。不開列印對話框 | 文中沒有在寫文件時實際編譯 LaTeX:這台機器沒有 `pdflatex`、`lualatex`、`xelatex`,所以 `tex` 輸出只對照論文套件(`thesis-circuits.sty`、`symbol-sheet.tex` 與幾張參考圖)的寫法與單元測試核對過,沒有真的排版過。第一次放進論文時請照最後一節檢查一遍。 ## 圖和畫面一致 三種格式用的是同一份幾何:符號形狀、導線路徑、交叉跳線、接點圓點、標籤位置,都和畫布畫的一樣,只是輸出的格式不同。程式碼在 `crates/schematic`(`powercraft-schematic`):畫布(egui)和匯出指令讀同一份「繪圖清單」,所以你改了符號或導線規則,畫面和匯出的檔案一起改。 這個 crate 放在 L4,原因是引擎(L5)要能直接呼叫它,CLI 與 MCP 才能不開視窗就匯出;而 L6 的 `ui-egui` 不能被引擎依賴。 ## 怎麼用 三條路都走同一個指令: ```sh # CLI:載入內建的 buck 範例,匯出論文用的 circuitikz。--root 授權寫入這個資料夾 powercraft-cli run --root figs \ --cmd file.openExample --params '{"name":"buck"}' \ --cmd file.exportSchematic --params '{"format":"tex","path":"fig-buck.tex"}' # 已有的電路檔 powercraft-cli run --in buck.voltecx --root figs \ --cmd file.exportSchematic --params '{"format":"svg","theme":"print","path":"buck.svg"}' ``` MCP 用 `command_run {id: "file.exportSchematic", params: {...}}`;桌面 app 的指令面板與選單 File › Print 也是同一個指令,沒帶參數時會開參數對話框。 重要:路徑一律經過引擎的檔案服務(`FileService`)。沒有授權資料夾(CLI 沒給 `--root`、網頁版、沒授權的 MCP)時指令回傳錯誤,不會寫任何檔案。 ### 參數 ```json {"path": "fig-buck.svg", "format": "svg|png|tex", "theme": "light|dark|print", "scheme": "classic|ink"} ``` | 參數 | 預設 | 說明 | |---|---|---| | `path` | 必填 | 要寫的檔案,相對於授權資料夾 | | `format` | `svg` | `svg`、`png` 或 `tex` | | `theme` | `light` | `light`、`dark` 或 `print`(白底黑字)。`tex` 不看這個參數:顏色由論文套件決定 | | `scheme` | `print` 時 `ink`,其他 `classic` | `classic` 是課本風(深藍導線、暗紅元件、綠色控制);`ink` 是元件與導線都用墨色、控制訊號用藍色 | 回覆:`{"path","format","bytes","width","height"}`,其中 `width`、`height` 是圖的大小(格點單位)。`tex` 另外有 `unitCm`(一格點等於幾公分)、`widthCm`(估計寬度,公分)和 `unsupported`(論文套件沒有符號、被畫成方塊的元件名稱)。 `file.print` 的參數是 `{"path", "format": "svg|png"}`,主題固定是 `print`。它不接受 `tex`。 ## 三種格式 ### SVG 手寫的 SVG 1.1,沒有任何依賴。一個繪圖項目對應一個元素,順序和畫布的繪製順序相同,每個元素帶有 `data-part`、`data-net`、`data-pin` 或 `data-label` 屬性,用 Inkscape 或程式可以按元件名稱挑出來。座標單位是畫布在縮放 1 的點數(一格點 12 單位),線寬 1.6 與 1.4、文字 9 到 13,和畫面一樣。 字型寫成 `IBM Plex Mono`/`IBM Plex Sans`,沒有安裝時退回系統的等寬與無襯線字型。文字寬度是估計值,標籤位置因此可能和畫面差一點點。 ### PNG 自己畫的反鋸齒線條,編碼用 `powercraft-waveform` 的 PNG 編碼器。**不畫文字**:沒有字型可用,所以位號、數值、腳名與方塊內的文字都不在圖上。要文字請用 SVG 或 `tex`。預設一格點 24 像素;圖超過 8192 像素時自動降低倍率,再放不下就回傳錯誤。 ### tex(circuitikz,論文套件的風格) 輸出是「只有內容」的檔案:一段註解標頭,加上 ```tex \begin{thesiscircuit} ... \end{thesiscircuit} ``` 只用論文套件允許的符號與樣式: | Voltecx 元件 | 輸出 | |---|---| | 電阻、電感、電容 | `to[R]`、`to[L]`、`to[C]` | | 直流電壓源 | `to[dcsource]`(從負端畫到正端,和 `fig-precharge.tex` 一樣) | | 弦波、脈衝電壓源;直流電流源;受控源 | `to[sV]`、`to[V]`、`to[I]`、`to[cV]`/`to[cI]` | | 二極體、閘流體 | `to[D]`、`to[thyristor]` | | 理想開關 | `to[contactor]`,閘極用虛線箭頭 `pwm` 指向開關 | | MOSFET、IGBT | `node[nigfete, bodydiode]`、`node[nigbt]`,腳接到 `.D`/`.S`/`.G`(IGBT 是 `.C`/`.E`/`.G`) | | 接地(含畫面上自動掛的接地符號) | `node[ground]` | | 電壓表、電流表 | `to[voltmeter]`、`to[ammeter]` | | 控制方塊 | `node[block]`,輸入引線用 `sig` 箭頭;`gain` 與 `integrator` 用 `gain`(反向時 `gainrev`)與 `integ` | | 導線交叉不連接 | `node[jump crossing]`,兩條線都接在它的 `.west/.east/.north/.south` 錨點 | | 三條以上導線交會 | `node[branch]` | 論文套件沒有符號的元件(變壓器、耦合電感、馬達、機械與熱元件、外掛、子系統)會畫成有標籤的 `block`,前面有一行 `% unsupported by the kit: ...` 註解,標頭也會列出名單,指令回覆的 `unsupported` 也有。論文裡要用真正的符號時,請在套件加好樣式後,手動替換那一段。 規則(照論文套件的 `SKILL.md`): - **座標是畫布的格點。** 一格點等於固定的公分數,一張圖一個值:從 0.30、0.25、0.20、0.15、0.12 公分中挑最大且使圖寬不超過 14.5 公分的那個。符號的大小由論文套件固定(`bipoles/length` 等),所以格點縮小只會讓導線變短,不會讓符號變小。**從不使用 `scale=`**,也不設線寬、顏色或字型。 - **圓點只在真正的接點。** 和畫布同一條規則:三個以上導線方向交會才畫 `node[branch]`;轉角與直線經過不畫。 - **交叉用 `jump crossing`。** 兩條導線交叉但不連接的地方,輸出一個 `jump crossing` 節點,兩條線都在它的錨點斷開。節點上的跳線弧固定畫在水平那條線上,畫布則是「後畫的網」跳過先畫的,所以兩者可能差在哪條線跳,電氣上相同。 - **位號用數學模式。** `S1` → `$S_1$`、`Lout` → `$L_\mathrm{out}$`、`SCR12` → `$\mathrm{SCR}_{12}$`,拆法和畫布一樣。 - **數值用 siunitx。** `l = 100u` → `\qty{100}{\micro\henry}`、`r = 2.2k` → `\qty{2.2}{\kilo\ohm}`。沒有單位的值用 `\num{}`。變數若在電路裡定義成數字,顯示那個數字;沒定義就顯示變數名稱(數學模式)。 - 兩端元件的位號與數值用 `l=`、`a=` 放(由 circuitikz 排,不會壓到符號);其他元件的位號與數值是自由文字節點,放在畫布標籤的位置。 - 標頭註解寫明「由 Voltecx 從哪個電路產生」、格點公分數與估計寬度。檔案是產生出來的:要改圖就改電路再重新匯出。 單一接腳網路的網路名稱(畫布上會顯示)不輸出。 ## 放進論文 假設論文用的是 `ntust-thesis` 套件,把匯出的檔案放到 `figures/power/`: ```tex % 序言:論文套件已載入 thesis-circuits.sty 與 thesis-notation.sty(siunitx 在裡面) \begin{figure}[t] \centering \input{figures/power/fig-buck.tex} \caption{降壓轉換器。} \label{fig:buck} \end{figure} ``` 不要在 `\input` 外面包 `\resizebox` 或 `scale=`:套件規定圖不可縮放。圖超過 14.5 公分時,到 Voltecx 把元件拖近一點再匯出一次。 ## 限制,以及第一次要檢查的地方 - **沒有實際排版過。** 沒有 TeX 的環境下寫成;請用套件的 `tools/preview.sh fig-buck.tex` 排一次,看 PNG,檢查標籤有沒有壓到線、方向有沒有對。 - **電晶體的方向。** MOSFET 與 IGBT 照畫布的方向旋轉:輸出 `rotate=…`,鏡像的元件另加 `yscale=-1`(這是翻轉,不是縮放,但單純搜尋 `scale=` 會找到它)。順序依 TikZ「後面的選項先作用」的規則推出,需要在圖上確認閘極與汲極/源極的位置沒有反。 - **電源與電流源的極性。** 電壓源一律從負端畫到正端,電流源從 `p` 畫到 `n`;circuitikz 的符號方向以第一次排版為準。 - **標籤位置是估計的。** 畫布標籤的位置用字元數估計文字大小(等寬字約 0.6 em),不是實際量出來的;密集的地方可能需要手動微調 `\node` 的座標。 - **PNG 沒有文字**(見上)。 - **一格點的公分數會隨圖寬降低。** 很寬的電路(例如三相逆變器)用 0.15 公分,導線比窄電路短;符號不變。圖寬在最小的 0.12 公分仍超過 14.5 公分時,照樣輸出並在標頭註解寫出估計寬度,請自行拉近元件。 - 畫布上的選取框、格線、拖曳預覽不輸出。未接的腳在 SVG 與 PNG 會畫成空心圓(和畫布一樣),`tex` 不畫。 ## 自己驗證 ```sh cargo test -p powercraft-schematic # 幾何、SVG、PNG、circuitikz cargo test -p powercraft-engine export_cmds # 兩個指令 cargo test -p powercraft-engine --test panic_hunt cargo test -p powercraft-ui-egui # 畫布仍用同一份幾何;色票與設計 token 一致 cargo xtask layers ``` --- # 腳本:把一串引擎指令存成文字檔 URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/workflows/scripting/ 這份文件回答一個問題:「同一串操作要做很多次,能不能寫下來重播?」Voltecx 的腳本就是一個文字檔,每行一個引擎指令。它不是程式語言:只能執行指令、從上一個結果取值、把幾行重複幾次。 腳本能做的事,和你手動執行同樣的指令一模一樣,不多也不少。它沒有自己的檔案、網路或系統存取;要讀寫檔案,只能用 `file.open`、`file.save` 這類指令,而這些指令有它們本來的限制(桌面版是你選的路徑,CLI 要加 `--root`,瀏覽器版沒有)。 ## 三個入口 | 入口 | 怎麼用 | |---|---| | 桌面版 | 選單 Tools › Scripting 開啟視窗。上面是編輯區,按 Run 執行,下面列出每一步的行號、指令與結果 | | 命令列 | `powercraft-cli script FILE [--root DIR]`。每一步印一行 JSON;遇到錯誤以代碼 1 結束,並說明是第幾行 | | 指令 | `script.run {"text": "..."}`,給控制通道與 MCP 的 agent 使用,回傳 `{steps, ok}` | 三個入口跑的是同一個引擎指令 `script.run`,所以行為一致。 ## 格式 ```text # 這是註解;空行也會略過 file.openExample {"name": "rc"} simulation.settings {"tEnd": "5m", "maxStep": "10u"} for r in 1k, 2.2k, 4.7k circuit.setParam {"component": "R1", "key": "r", "value": ${r}} simulation.run end ``` (範例中的元件名稱以你的電路為準;先用 `circuit.inspect` 確認。) | 寫法 | 意思 | |---|---| | `指令.id {JSON 參數}` | 執行一個引擎指令。參數是一個 JSON 物件;不需要參數時可以省略,等於 `{}` | | `# 文字` | 註解,整行略過 | | 空行 | 略過 | | `let 名稱 = /指標` | 從「上一個執行的指令」的結果取一個值,存成變數 | | `${名稱}` | 在之後的參數裡,換成該變數的 JSON 文字 | | `for 名稱 in 值1, 值2, ...` … `end` | 把中間的各行,對每個值各執行一次 | 每行一個陳述;指令 id 就是 `command.list` 看到的 id(例如 `circuit.setParam`),參數說明也在那裡。 ### let:取上一個結果裡的值 `let` 用 RFC 6901 的 JSON 指標(和 `serde_json` 的 `Value::pointer` 相同)指向上一個指令的結果: ```text circuit.addComponent {"name": "R2", "kind": "resistor"} let n = /name let id = /id circuit.addComponent {"name": "${n}b", "kind": "capacitor"} circuit.setParam {"component": "R2", "key": "r", "value": ${id}} ``` - 指標是空字串(`let all =`)時,取整個結果。 - `/a/0/b` 表示結果的 `a` 欄位、第 0 個元素的 `b` 欄位。 - 名稱以字母或底線開頭,之後可以是字母、數字、底線。 - 上一個指令是指「最近一個成功執行的指令」;`let` 本身不會改變它。一個指令都還沒執行就用 `let`,或指標指到的位置沒有值,腳本在這一行停止。 ### ${名稱}:把變數放進參數 換掉的是變數的 JSON 文字,在參數被解析成 JSON 之前進行: - 放在字串**外面**:字串值帶引號,數字就是數字。`"value": ${r}` 在 `r` 是 `1k` 時變成 `"value": "1k"`。 - 放在字串**裡面**(前後已經有引號):字串值不再多帶引號,其他值用它的 JSON 文字。`"name": "R${i}"` 在 `i` 是 `3` 時變成 `"name": "R3"`;特殊字元會自動跳脫。 - 名稱找不到會報錯。名稱能不能用,在執行前就會檢查,並指出行號。 ### for:重複幾行 `for 名稱 in 值1, 值2, ...` 到 `end` 之間的各行,對每個值執行一次,`${名稱}` 就是目前的值。 - 值用逗號分隔。逗號出現在字串、陣列或物件裡面時不算分隔:`for v in "a, b", [1, 2], {"k": 3}` 是三個值。 - 值是 JSON(`3`、`"文字"`、`[1, 2]`)時照 JSON 解讀;不是 JSON 的字(`100u`、`resistor`)當成字串,所以 `for r in 1k, 2.2k` 的 `${r}` 是 `"1k"`、`"2.2k"`。以 `"`、`[`、`{` 開頭卻不是合法 JSON,會當成錯誤。 - 迴圈裡面可以再有一層迴圈(最多兩層)。 - 離開迴圈後,迴圈變數回到進入前的值(原本沒有就消失)。迴圈裡面用 `let` 建立的變數會留下。 - 每個 `for` 都要有 `end`,每個 `end` 都要有 `for` 或 `if`。 ### let 變數/指標:讀保留的結果 `let r =`(空指標)保留整個結果;之後 `let eta = r/efficiencyPercent` 從變數 `r` 讀值,不必是上一個指令的結果。 ### set:計算 `set 名稱 = 運算式` 用參數運算式語言(`crates/expr`)算出一個數字:`+ - * / % ^`、比較(`<`、`<=`、`>`、`>=`、`==`、`!=`,真為 1、假為 0)、`&&`、`||`、`!`、`min`、`max`、`abs`、`if(c, a, b)` 等函式,以及 `100u`、`2.2k` 這類字尾。變數直接寫名稱(不用 `${}`):數字照用,`true`/`false` 是 1/0,能讀成數字的字串(`"100u"`)就是那個數字,其他值會在那一行停止。 ### if / else if / else:分支 `if 運算式` … `else if 運算式` … `else` … `end` 執行第一個運算式為真(大於 0.5,和 `if()` 一樣)的分支。運算式裡的名稱在執行前就會檢查。區塊(`for` 與 `if`)最多巢狀八層。 ### break:離開迴圈 `break` 立刻離開最內層的 `for`;只能寫在 `for` 裡面。 ## 限制與錯誤 - **步數上限 10,000、時間上限 10 分鐘。** 每執行一個指令、一個 `let`、一個 `set`、一次 `if` 判斷、一次迴圈就算一步,超過就停止並回報,所以腳本不可能無限跑下去。`script.run` 的 `maxSteps`(1 到 10,000)與 `maxSeconds`(最多 86,400;在步驟之間檢查,瀏覽器沒有時間限制)可以調整。腳本文字上限 1 MiB;參數換入變數後也不能超過 1 MiB。 - **先檢查、再執行。** 整份腳本會先完整解析;有語法錯誤(參數不是合法 JSON、`for` 沒有 `end`、用了沒定義的變數、指令 id 寫法不對……)就整份不執行,電路完全沒有變動。錯誤訊息開頭是 `line N:`,N 從 1 開始。 - **遇到第一個錯誤就停止。** 指令失敗(找不到元件、參數不對、指令目前不能用……)、`let` 找不到值,或換入變數後的參數不是合法 JSON,腳本在那一行停止,後面的行不執行。已經執行的步驟留在電路裡(見下面的復原)。 - 腳本裡不能再執行 `script.run`。 - 指令都是同步執行,和 `engine.execute` 一樣。模擬指令(`simulation.run` 等)會跑到結束才進入下一行;桌面版在這段時間視窗不會更新。 ### 回傳的報告 ```json { "steps": [ {"line": 2, "command": "file.openExample", "ok": true, "result": {"...": "..."}}, {"line": 5, "command": "circuit.setParam", "ok": false, "error": "no component `R9`"} ], "ok": false, "error": {"line": 5, "message": "no component `R9`"} } ``` - `steps` 依序列出執行的指令,失敗的那一步在最後。`let` 只有失敗時才出現(`command` 是 `let`)。 - `ok` 是整份腳本是否都成功;失敗時另有 `error`,記下停止的行號與訊息。 - `vars` 是結束時的變數(數字、布林與短字串),`used` 是用掉的步數。 - 結果很大的腳本(累計超過 4 MiB),之後的步驟的 `result` 會改成 `{"omitted": ...}`;`let` 仍然讀得到完整的結果。 - 語法錯誤不是報告,而是 `script.run` 本身回傳的錯誤(`bad params: line N: ...`)。 ## 復原 **整份腳本是一個復原步驟**:腳本改了 12 個地方,Edit › Undo 按一次就全部回復。這一步叫做「腳本」,或是 `script.run` 的 `label` 參數給的名稱。腳本停在失敗的那一行時,步驟叫做「腳本(停在第 N 行)」,復原一次仍回到執行之前的狀態。 - 腳本裡的 `edit.undo`、`edit.redo` 照常運作,例如先加再撤回,最後只留下一步。 - 腳本把狀態復原到比開始時更早,就不合併任何步驟,原有的步驟都留著。 - 沒有修改電路的腳本不會留下步驟。 - 腳本用 `file.new` 或 `file.open` 開啟的電路,在開啟的那一步之後只多一個步驟。 ## 寫腳本的小訣竅 - 先在桌面版手動做一遍,再從 `command.list` 與各指令的參數說明抄參數。 - 用小的迴圈試跑:先 `for r in 1k, 2k`,確認每一步都是你要的,再加大範圍。 - 失敗時看報告裡最後一步的 `error`;它就是該指令平常會回的錯誤訊息。 - 腳本只是文字,可以放進版本控制,和 `.voltecx` 一起保存。 --- # Component reference URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/) Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. ## Passive - [Resistor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/resistor/): Limits current in proportion to the voltage across it. - [Inductor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/inductor/): Stores energy in its current. Can add winding resistance, core loss and saturation. - [Capacitor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/capacitor/): Stores energy in its voltage. Can add series resistance, series inductance and leakage. - [Quartz Crystal](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/crystal/): A quartz crystal for oscillators and filters, drawn as its equivalent circuit. - [Supercapacitor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/supercap/): A very large capacitor with series resistance, leakage and a slow inner branch. - [Three-Phase R-L-C](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/rlc3/): The same resistor, inductor and capacitor in series in each of three phases. - [Varistor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/varistor/): A metal-oxide varistor whose current rises steeply above its varistor voltage. - [NTC Thermistor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/ntc/): A resistor that falls as it heats, used to limit inrush current. - [PTC Thermistor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/ptc/): A resistor that climbs steeply when it gets hot, used as a resettable fuse. - [Fuse](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/fuse/): A resistor that opens for good once its melting I²t is reached. - [Gas Discharge Tube](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/gdt/): A tube that is open until its sparkover voltage, then shorts the line through an arc. - [Ferrite Bead](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/ferriteBead/): A bead that acts as a resistor at noise frequencies and as a small inductor at low frequencies. - [Pi-Section Line](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/piLine/): A transmission line as series R-L with half its shunt capacitance at each end, from per-metre values and a length, in one or more pi sections in cascade. - [Three-Phase Pi-Section Line](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/piLine3/): Three pi-section lines, one per phase, with the positive-sequence values per metre and a length. - [Transmission Line](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/tline/): A distributed lossless line given by its characteristic impedance and one-way delay, with an optional series resistance lumped at its ends: waves travel along it and reflect where the impedance changes. ## Sources - [Fuel Cell](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/fuelCell/): A fuel cell stack whose voltage falls with current along its polarisation curve. - [Water Electrolyzer](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/electrolyzer/): A water electrolyzer stack, a load whose voltage rises with current above the reversible voltage of water. - [DC Voltage Source](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/dcVoltageSource/): Holds a fixed voltage between its two terminals. - [Sine Voltage Source](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/sineVoltageSource/): Produces a sine-wave voltage with offset and phase. - [Three-Phase Sine Voltage Source](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/sine3VoltageSource/): A balanced, ideal three-phase sinusoidal voltage source in star, with its star point brought out. - [Pulse Voltage Source](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/pulseVoltageSource/): Produces a pulse or square-wave voltage. - [DC Current Source](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/dcCurrentSource/): Pushes a fixed current through itself. - [Controlled Source](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/controlledSource/): Makes a voltage or current equal to a signal times a gain. - [Ground](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/ground/): The zero-volt reference of the circuit. - [Test Point](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/testPoint/): A probe pad on the board, for measuring a net during bring-up. - [Battery](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/battery/): A rechargeable battery whose voltage follows its state of charge. - [Solar Module](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/pv/): A photovoltaic module that turns sunlight into current. - [Three-Phase Grid](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/grid3/): A three-phase voltage source with a neutral, for grid-tied converters. - [Electrical Constant-Power Load](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/powerLoad/): A load that draws the same power at any voltage, like a regulated converter or an electronic load in CP mode. - [Nonlinear Rectifier Load](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/rectifierLoad/): A single-phase diode bridge with a smoothing capacitor and a load resistor, the classic load that draws harmonic current from the line. - [Wind Turbine](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/windTurbine/): A wind turbine rotor that drives a shaft with the torque the wind gives it. - [Mounting Hole](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/mountingHole/): A board-only part: a hole for a screw or standoff, shown on the schematic and never simulated. - [Fiducial](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/fiducial/): A board-only part: a bare copper mark the pick-and-place camera aligns to. It has no pins and is never simulated. - [Standoff](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/standoff/): A board-only part: a spacer that holds the board off its chassis. It has no pins and is never simulated. - [Bracket](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/bracket/): A board-only part: an angle bracket that fixes the board or a heatsink to the chassis. It has no pins and is never simulated. - [Logo](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/logo/): A board-only part: a logo, title or marking on the silkscreen. It has no pins and is never simulated. - [Terminal Block, 2 Positions](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/terminalBlock2/): A screw terminal block with 2 positions: where a supply or load wire enters the board. - [Terminal Block, 3 Positions](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/terminalBlock3/): A screw terminal block with 3 positions: where a supply or load wire enters the board. - [Terminal Block, 4 Positions](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/terminalBlock4/): A screw terminal block with 4 positions: where a supply or load wire enters the board. - [Pin Header, 2 Pins](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/pinHeader2/): A 2.54 mm pin header with 2 pins: where a gate drive or signal from off the board plugs in. - [Pin Header, 3 Pins](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/pinHeader3/): A 2.54 mm pin header with 3 pins: where a gate drive or signal from off the board plugs in. - [Pin Header, 4 Pins](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/pinHeader4/): A 2.54 mm pin header with 4 pins: where a gate drive or signal from off the board plugs in. ## Switches - [Ideal Switch](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/idealSwitch/): Opens or closes a path when its gate signal goes low or high. - [Diode](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/diode/): Lets current flow one way, with a forward drop when it conducts. - [Zener Diode](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/zener/): A diode that holds its reverse voltage near the Zener voltage. - [TVS Diode](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/tvs/): A surge suppressor diode that clamps a voltage spike above its stand-off voltage. - [LED String](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/ledString/): A string of LEDs in series, with strings in parallel, as the load of an LED driver. - [MOSFET](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/mosfet/): A gate-controlled switch with a body diode. Can add stray parts and losses. - [IGBT](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/igbt/): A gate-controlled switch that passes current one way, with a fixed drop. - [Thyristor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/thyristor/): Turns on with a gate pulse and stays on until its current reverses. - [TRIAC](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/triac/): A bidirectional thyristor: a gate current fires it either way, and it stays on until its current falls below the holding current. - [DIAC](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/diac/): A trigger diode that breaks over at vbo in either direction, then conducts at a lower voltage until its current dies away. - [GTO Thyristor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/gto/): A thyristor that a positive gate turns on and a negative gate turns off. - [IGCT](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/igct/): A thyristor with an integrated gate unit that conducts forward while its on/off command is high. - [Relay](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/relay/): Uses a small coil current to switch another circuit. - [NPN Transistor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/npn/): A bipolar transistor where a small base current controls a larger collector current. - [PNP Transistor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/pnp/): The NPN Transistor with every current and voltage reversed. - [N-channel MOSFET (level 1)](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/nmos/): An n-channel MOSFET whose current follows its gate voltage. - [P-channel MOSFET (level 1)](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/pmos/): The N-channel MOSFET with every voltage and current reversed. - [Circuit Breaker](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/breaker/): A three-pole breaker that opens at a set time or on overcurrent after a delay, and may close again. - [Fault](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/fault/): A short circuit that joins chosen lines of a three-phase system, or those lines and ground, during a time window. - [Six-Switch Module](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/sixSwitch/): Six switches in three legs with a diode across each, for a three-phase inverter or an active rectifier. - [Three-Phase Diode Bridge](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/diodeBridge3/): Six diodes that turn a three-phase AC input into a DC output. - [MMC Arm](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/mmcArm/): One arm of a modular multilevel converter: n half- or full-bridge submodules in series, each with its own capacitor, inserted by the signal m. ## Magnetics - [Coupled Inductor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/coupledInductor/): Two windings that share magnetic flux, with a coupling coefficient k. - [Common-Mode Choke](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/cmChoke/): Two equal coupled windings that block common-mode noise and pass the load current. - [Transformer](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/transformer/): A transformer with turns ratio n, and optional magnetizing inductance, leakage, winding resistance, core loss and saturation. - [Three-Phase Transformer](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/transformer3/): A three-phase transformer with a chosen vector group, a line-to-line voltage ratio, leakage and magnetizing inductance. - [Multi-Winding Transformer](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/multiTransformer/): A transformer with one primary and up to three secondaries on one core, each secondary with its own turns ratio, leakage and winding resistance. - [Winding](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/winding/): N turns that join an electrical circuit to a magnetic circuit of reluctances. - [Reluctance](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/reluctance/): A linear flux path: a core leg, an air gap or a whole core, from its geometry or a catalogue core. - [Saturable Core](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/saturableCore/): A flux path that saturates: its permeance falls to the air path once the flux density reaches Bsat. - [Leakage Path](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/leakagePath/): A linear flux path that returns flux outside the core, so windings link less than all of it. - [Flux Probe](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/fluxProbe/): Reads the flux, or the flux density, through a magnetic path as a signal. ## Control - [Constant](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/constant/): Outputs one fixed value for the whole run. - [Gain](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/gain/): Multiplies the input by a fixed factor k. - [Sum](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/sum/): Adds or subtracts two signals, as set by signs. - [Product](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/product/): Multiplies two signals. - [Maximum](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/max/): Outputs the larger of two signals. - [Minimum](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/min/): Outputs the smaller of two signals. - [Absolute Value](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/abs/): Outputs the size of the input, never negative. - [Logic NOT](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/not/): Turns a high logic signal low and a low one high. - [Comparator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/comparator/): Outputs 1 while in1 is above in2, otherwise 0. - [Limiter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/limiter/): Keeps the input between a lower limit lo and an upper limit hi. - [Integrator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/integrator/): Adds up its input over time, with optional output limits. - [PI Controller](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/pi/): Corrects an error with proportional and integral action, and limits its output. - [Carrier](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/carrier/): A triangle or sawtooth wave between 0 and 1 for PWM. - [PWM Generator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/pwm/): Turns a duty from 0 to 1 into a gate signal. - [Three-Phase PWM](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/pwm3/): Turns three duties into three gate signals with one shared carrier. - [Sine Source](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/sine/): Outputs a sine wave with set amplitude, frequency, phase and offset. - [Three-Phase Sine Source](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/sine3/): Outputs a balanced three-phase sine set on three pins. - [Step Source](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/step/): Changes once from a before value to an after value at time t0. - [Sample and Hold](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/sampleHold/): Samples its input once per period and holds the value. - [ADC](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/adc/): Rounds its input to a set number of bits, with optional sampling. - [Sample Delay](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/delay/): Delays its input by one sample period. - [Memory (one-step delay)](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/memory/): Outputs its input as it was at the previous solver step. - [Dead Time](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/deadtime/): Delays the rising edge of a gate signal and passes the falling edge at once. - [Lookup Table](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/lookup/): Looks up an output from a table of points, with straight lines between them. - [Clarke Transform](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/clarke/): Turns three phase quantities into two fixed components, alpha and beta. - [Inverse Clarke Transform](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/invClarke/): Turns alpha and beta back into three phase quantities. - [Park Transform](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/park/): Rotates a fixed alpha-beta vector into the rotating d-q frame. - [Inverse Park Transform](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/invPark/): Rotates a d-q vector back into the fixed alpha-beta frame. - [abc to dq Transform](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/abc2dq/): Turns three phase quantities into rotating d and q components in one block. - [dq to abc Transform](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/dq2abc/): Turns rotating d and q components back into three phase quantities in one block. - [Space-Vector Modulator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/svpwm/): Turns three phase voltages and the DC-link voltage into three modulation signals. - [Angle Generator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/angle/): Turns an electrical speed into an angle that wraps around. - [Vector Angle (atan2)](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/atan2/): The angle of the alpha-beta vector, atan2(beta, alpha), wrapped to 0 ... 2*pi. - [Instantaneous Power (p, q)](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/pq/): The instantaneous active and reactive power from the alpha-beta voltage and current. - [C Block](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/cblock/): Runs C code you write, a PSIM C Block or a PLECS C-Script, as a control block, in a sandbox that cannot crash or hang the simulation. - [Multiplexer](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/mux/): Passes one of up to eight inputs to its output, picked by the `sel` signal. - [Bus Mux](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/busMux/): Joins up to eight signals into one bus, a single wire that carries them all. - [Bus Demux](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/busDemux/): Splits a bus into its elements, one scalar signal per output. - [Bus Selector](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/busSelect/): Picks some elements of a bus, in any order, as a smaller bus or a single signal. - [Ramp](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/ramp/): A ramp that rises while a gate is on (slope compensation) or restarts at each clock edge (a clock-synced sawtooth). - [Random Source](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/random/): A seeded random signal: a new uniform or Gaussian value every 1/fs seconds, held in between. - [Type II / Type III Compensator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/compensator/): The error-amplifier compensator of a switch-mode power supply: an integrator with one or two zero-pole pairs, output limits and anti-windup. - [Transfer Function](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/tf/): Describes a plant or compensator with two coefficient lists. - [PID Controller](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/pid/): Adds up proportional, integral and derivative action on an error signal. - [Second-Order Low-Pass](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/lowpass2/): Smooths a signal by removing changes faster than a corner frequency. - [Second-Order Band-Pass](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/bandpass/): Passes one band of frequencies around a centre frequency. - [Notch Filter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/notch/): Removes one frequency and lets the rest pass. - [Zero-Order Hold](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/zoh/): Samples its input at fixed times and holds the value. - [Unit Delay (z^-n)](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/zDelay/): Delays its input by a whole number of samples. - [Discrete Transfer Function](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/ztf/): Filters or controls a sampled signal with two coefficient lists. - [Discrete PI Controller](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/dpi/): A PI controller that runs once every sample time. - [Discrete PID Controller](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/dpid/): A PID controller that runs once every sample time. - [Discrete Integrator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/dIntegrator/): Adds up its input over time, one sample at a time. - [FIR Filter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/fir/): Filters a sampled signal with a fixed list of weights. - [IIR Filter (Biquad Cascade)](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/iir/): Filters a sampled signal with a chain of second-order sections. - [AND Gate](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/and/): Outputs 1 only when every input read is above 0.5. - [OR Gate](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/or/): Outputs 1 when any input read is above 0.5. - [XOR Gate](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/xor/): Outputs 1 when an odd number of inputs are above 0.5. - [NAND Gate](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/nand/): Outputs 0 only when every input read is above 0.5. - [NOR Gate](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/nor/): Outputs 1 only when every input read is at or below 0.5. - [SR Latch](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/srff/): Remembers a fault or state until it is reset. - [D Flip-Flop](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/dff/): Copies its data input to the output on each rising clock edge. - [Counter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/counter/): Counts rising clock edges and wraps around at a set number. - [Monostable (One-Shot)](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/monostable/): Makes one pulse of a fixed length after a rising edge. - [MCU Output Stage](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/mcu/): Adds the timing of a digital controller to a duty command before the PWM. - [Sliding-Mode Observer](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/smo/): Estimates the rotor angle and speed of a permanent-magnet motor without a position sensor. - [Droop Control (Grid-Forming)](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/droop/): Sets an inverter's frequency and voltage amplitude from the power it delivers, so inverters in parallel share a load. - [Virtual Synchronous Machine (Grid-Forming)](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/vsm/): Makes an inverter behave like a synchronous generator: its frequency follows the power through a virtual inertia and a droop damping. - [Voltage-Controlled Oscillator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/vco/): An oscillator whose frequency follows its control input. - [Phase Detector](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/phaseDetector/): Compares the phase of two signals and outputs the difference. - [Phase-Locked Loop (single-phase)](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/pll/): Locks onto a single-phase signal and reports its frequency and phase. - [Three-Phase SRF-PLL](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/srfPll/): Locks onto a three-phase signal and gives the grid angle and speed. - [RMS Meter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/rms/): The RMS of a signal over a sliding window, while the circuit runs. - [THD Meter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/thd/): The total harmonic distortion of a signal and its fundamental, while the circuit runs. - [Harmonic Meter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/harmonic/): The amplitude and phase of one harmonic of a signal, while the circuit runs. - [Power Factor Meter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/powerFactor/): The power factor and displacement factor of a voltage and current, while the circuit runs. - [Power Meter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/powerMeter/): The average input and output power and the efficiency of a converter, while the circuit runs. - [FFT Block](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/fft/): Samples a signal and outputs one bin of its discrete Fourier transform once a period. - [State Machine](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/stateMachine/): Runs a sequence of named states; guard expressions over its inputs and the time in the state move it from one state to the next. - [MMC Submodule Selection](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/mmcBalance/): Picks which submodules of an MMC arm to insert: how many from the insertion index m, which ones by sorting the capacitor voltages. - [Communication Link](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/commLink/): Carries up to four values from one controller to another with the timing of a bus: a rate, a latency, a seeded jitter and a seeded loss. - [Expression (Fcn)](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/expr/): Computes its output from a formula of up to eight inputs, the time and the circuit variables. - [2-D Lookup Table](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/lookup2d/): Looks up an output from a table over two inputs, with bilinear interpolation between the grid points. - [State-Space Model](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/stateSpace/): A linear plant or filter given by its A, B, C and D matrices, one input and one output. - [Zero-Pole-Gain](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/zpk/): A transfer function given by its zeros, its poles and a gain. - [Filtered Derivative](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/derivative/): The rate of change of its input, times a gain, with a first-order filter so it does not amplify noise without bound. - [Rate Limiter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/rateLimiter/): Follows its input, but changes no faster than a rising and a falling rate. - [Transport Delay](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/transportDelay/): Delays a signal by a fixed time. - [Relay with Hysteresis](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/hysteresis/): Switches its output to one level when the input rises above a threshold and back when it falls below a lower one. ## Thermal - [Thermal Resistance](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/rth/): Slows the flow of heat between two thermal nodes, in K/W. - [Thermal Capacitance](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/cth/): Stores heat at a thermal node, in J/K. - [Ambient Temperature](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/ambient/): Holds a thermal node at a fixed temperature, like ground for heat. - [Heat Source](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/qsource/): Puts a fixed heat into a thermal node, for a part that is not simulated. - [Foster Chain](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/foster/): A device's transient thermal impedance from its data sheet's Foster table: R and tau stages between two thermal nodes. - [Cauer Chain](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/cauer/): A ladder of thermal resistances with a heat capacity at every node, between two thermal nodes. - [Zth Curve](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/zth/): A transient thermal impedance fitted from points read off a data sheet's Zth(t) curve. - [Heatsink](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/heatsink/): A catalogue heatsink's sink-to-ambient thermal resistance, read off its data sheet at a heat and an airflow. - [Cooling Fan](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/coolingFan/): A fan that blows across heatsinks: in the thermal simulation it makes them use their data sheet's resistance at its airflow, and it goes on the BOM and the board. ## Machines - [Induction Machine](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/machines/induction/): A three-phase cage motor that runs from the mains or an inverter. - [Wound-Rotor Induction](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/machines/inductionWound/): A three-phase induction motor with the rotor windings brought out. - [Surface PMSM](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/machines/spmsm/): A magnet motor whose d and q inductances are equal. - [Interior PMSM](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/machines/ipmsm/): A magnet motor with different d and q inductances, so it also makes reluctance torque. - [DC Machine](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/machines/dc/): A DC motor with separate armature and field windings. - [PM DC Machine](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/machines/dcPm/): A DC motor with magnets and a single armature winding. - [BLDC Machine](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/machines/bldc/): A brushless DC motor with a trapezoidal back-EMF and built-in Hall outputs. - [Wound-Field Synchronous](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/machines/syncWound/): A synchronous machine with a field winding and optional damper windings. - [Switched Reluctance](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/machines/srm/): A motor with no magnets whose phase inductance changes with rotor angle. - [Stepper Motor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/machines/stepper/): A two-phase hybrid stepper motor with a magnet rotor. - [Saturating Induction](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/machines/inductionSat/): A cage induction motor that saturates at high main flux. ## Mechanical - [Inertia](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/inertia/): Adds rotating mass to a shaft, with an optional starting speed. - [Friction](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/friction/): Drag that grows in step with speed, from a shaft to the frame. - [Load Torque](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/torque/): A constant load torque that pushes back against forward rotation. - [Fan Load](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/fan/): A fan or pump load whose torque grows with the square of speed. - [Constant-Power Load](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/constantPower/): A load that takes constant power, so torque rises as speed falls. - [Vehicle Load](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/vehicle/): A road vehicle seen at its wheel shaft: mass, rolling resistance, air drag and road grade. - [Speed Source](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/speed/): Forces a shaft to turn at a fixed speed and supplies any torque needed. - [Gear](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/gear/): An ideal gear that links two shafts with a speed ratio and an optional loss. - [Torsional Spring](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/spring/): A torsional spring between two shafts: the torque grows with the twist. - [Torsional Damper](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/damper/): A viscous damper between two shafts: the torque grows with their speed difference. - [Elastic Shaft](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/elasticShaft/): A compliant shaft between two masses: a torsional spring and a damper in parallel. - [Backlash](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/backlash/): Free play between two shafts, such as in a gear mesh: no torque inside the gap, a stiff contact outside it. - [Speed Sensor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/speedSensor/): Reads shaft speed as a signal without loading the shaft. - [Position Sensor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/positionSensor/): Reads the shaft angle, mechanical and electrical, as signals. - [Torque Sensor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/torqueSensor/): Joins two shafts and reads the torque passing through. - [Hall Sensors](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/hall/): Makes three Hall signals from the shaft angle, 120 degrees apart. - [Incremental Encoder](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/encoder/): Gives quadrature signals, an index pulse and a position count from the shaft angle. - [Resolver](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/resolver/): Outputs the sine and cosine of the shaft's electrical angle. ## Meters - [NTC Temperature Sensor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/meters/ntcSensor/): A thermistor that reads the temperature of a thermal net as a resistance, by the Steinhart-Hart or the B equation. - [Voltmeter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/meters/voltmeter/): Reports the voltage between p and n as a signal on out. - [Ammeter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/meters/ammeter/): A zero-volt meter in series that reports the current as a signal on out. - [LISN](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/meters/lisn/): One line of the 50 uH network that sits between the supply and the equipment for a conducted-EMI bench. ## ICs - [Isolated Gate Driver with DESAT Protection](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/gateDriverIso/): Drives a power switch gate and shuts it down softly on a short circuit. - [Half-Bridge Gate Driver with Bootstrap](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/halfBridgeDriver/): Drives the high-side and low-side switch of a half-bridge from one supply, with a bootstrap for the high side. - [Low-Side Gate Driver](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/lowSideDriver/): Drives one ground-referenced switch from one supply, such as the switch of a boost or a flyback. - [GaN Power Stage](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/ganPowerStage/): Switches a 600 V GaN FET with its own driver and protection in one package. - [Single-Pole Operational Amplifier](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/opAmp/): Amplifies a small input difference, with limited speed and output swing. - [Comparator with Hysteresis](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/comparatorHyst/): Compares two voltages and gives a high or low output. - [Peak-Current-Mode PWM Controller](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/pwmController/): Controls a converter switch by comparing its current with a set level. - [Synchronous Buck Controller (Voltage Mode)](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/syncBuckController/): Controls both switches of a synchronous buck from its output voltage, with soft start and current limit. - [Buck Regulator (Integrated High-Side MOSFET)](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/buckRegulator/): A complete step-down regulator IC with its own high-side switch: you add the catch diode, inductor, output capacitor, divider and compensation. - [Synchronous Boost Controller (Peak Current Mode)](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/syncBoostController/): Controls both switches of a synchronous boost from its output voltage and inductor current, with soft start, current limit and hiccup. - [CCM Boost PFC Controller (Average Current Mode)](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/ccmPfcController/): Shapes the input current of a boost PFC to follow the line voltage without sensing the line, and regulates the output voltage. - [Multiplier Boost PFC Controller (Average Current Mode with Line Sensing)](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/multiplierPfcController/): Shapes the input current of a boost PFC from the sensed line waveform through an analog multiplier with RMS feedforward, and regulates the output voltage. - [Transition-Mode Boost PFC Controller (Critical Conduction with Zero-Current Detection)](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/crmPfcController/): Runs a boost PFC at the boundary of continuous conduction: each pulse starts when an inductor winding shows the current at zero and ends when the switch current reaches a multiplier of the line and the error voltage. - [Transition-Mode Boost PFC Controller (Constant On-Time)](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/tmPfcController/): Runs a boost PFC in transition mode: a constant on-time per line cycle, the next cycle starting when the drain shows the inductor current is zero, so the line current follows the line voltage. - [Quasi-Resonant Flyback Controller (Valley Lockout)](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/qrFlybackController/): Runs an off-line flyback in peak current mode and turns the switch on in a drain valley read from the auxiliary winding; FB picks the valley, and at light load the controller folds the frequency back and skips. - [LLC Resonant Controller (Hybrid Hysteretic Control)](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/llcController/): Drives a half-bridge LLC from an optocoupler feedback current, with the data sheet's start sequence, soft start and protections. - [Phase-Shifted Full-Bridge Controller](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/psfbController/): Drives a full bridge from an error amplifier with the data sheet's frequency, delays, soft start and current limit. - [Current-Sense Amplifier](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/currentSenseAmp/): Turns the small voltage across a shunt into a larger ground-referenced signal. - [Hall-Effect Current Sensor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/hallCurrentSensor/): Measures current through a conductor and gives a proportional voltage, isolated. - [Shunt Amplifier with Shunt](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/shuntAmplifier/): A shunt resistor and amplifier that read current in both directions. - [Isolated Amplifier with Shunt](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/isolatedAmplifier/): A shunt resistor and amplifier whose reading crosses an isolation barrier. - [Isolated Amplifier with Shunt, ±50 mV](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/isolatedAmplifierAmc1302/): A low-loss shunt and an isolated amplifier with a ±50 mV input and a gain of 41. - [Current Transformer](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/currentTransformer/): A one-turn primary through a core with a secondary winding and its burden, giving a voltage proportional to an AC current. - [Rogowski Coil with Integrator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/rogowskiCoil/): An air-cored coil around a conductor and its integrator, giving a voltage proportional to the AC current. - [Closed-Loop Hall Transducer](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/closedLoopHall/): A compensated Hall current transducer whose secondary current is the primary current over the turns ratio, from DC. - [Isolated Voltage Sensor with Divider](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/isolatedVoltageSensor/): A resistive divider into a high-impedance isolated amplifier, giving a low-voltage reading of a high voltage. - [555 Timer](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/timer555/): Makes timed pulses or a steady square wave from a resistor and a capacitor. - [Adjustable Shunt Regulator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/shuntRegulator/): Sinks current at its cathode to hold REF at its reference voltage. - [Optocoupler](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/optocoupler/): Passes a current across an isolation barrier through an LED and a phototransistor. - [Digital Isolator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/digitalIsolator/): Passes a logic signal to an isolated ground after a short delay. - [High-Speed Logic Optocoupler](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/highSpeedOpto/): Passes a fast logic signal across an isolation barrier through an LED and a logic output stage. - [Fiber-Optic Transmitter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/fiberTx/): Turns a logic signal into light for a fiber, with its delay and launched power. - [Fiber-Optic Receiver](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/fiberRx/): Turns the light from a fiber back into a logic signal, with the fiber's losses, the sensitivity, delay and jitter. - [Photovoltaic MOSFET Driver](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/pvDriver/): Charges a MOSFET gate across an isolation barrier from an LED, with no supply on the gate side. - [Low-Dropout Regulator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/ldo/): Makes a clean fixed voltage from a slightly higher supply. - [Voltage Reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/voltageReference/): Gives a precise voltage that changes little with supply and load. - [Peak-Current-Mode Modulator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/pcmModulator/): Turns a switch on at each clock and off when the sensed current plus a ramp reaches the control voltage. - [Constant On-Time Modulator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/cotModulator/): Starts a fixed or adaptive on-time whenever the feedback falls below the reference. - [Hysteretic Modulator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/hystModulator/): Turns the switch on below a window around the reference and off above it. - [Soft-Start Reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/softStartRef/): Raises the reference with a capacitor charged by a current, and enables the modulator. - [UVLO Comparator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/uvloComparator/): Says when the input is high enough to run, with hysteresis. - [OCP with Hiccup](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/ocpHiccup/): Stops switching for a fixed time after a sustained over-current, then lets the converter restart. - [Output OVP](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/ovpComparator/): Holds the switch off while the feedback voltage is above a multiple of the reference, non-latched or latch-off. - [LDO Loop (Architecture)](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/ldoArch/): The loop of a low-dropout regulator with its error-amplifier and gate poles, to choose the output capacitor's ESR window. - [Half-Bridge Driver with Dead Time](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/hbDriverArch/): Drives both switches of a half-bridge from one PWM command, with a fixed or an adaptive dead time. ## Custom blocks - [Plug-in Block](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/custom/plugin/): A custom block you write as a sandboxed WebAssembly module. - [Subsystem](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/custom/subsystem/): A reusable group of parts, shown as one block with pins. ## Field solver commands The commands of the field solver, from drawing a section to exporting its field. Chapter 21 of the manual shows them in use. - [Export FEMM Model](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/magnetics-femmExport/): `magnetics.femmExport` - [Import FEMM Results](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/magnetics-femmImport/): `magnetics.femmImport` - [Field Solve](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/magnetics-fieldSolve/): `magnetics.fieldSolve` - [Field Core Loss](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/magnetics-fieldCoreLoss/): `magnetics.fieldCoreLoss` - [Coupled Inductor Report](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/magnetics-coupledReport/): `magnetics.coupledReport` - [Field Flux Map](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/magnetics-fieldFluxMap/): `magnetics.fieldFluxMap` - [3D Field Tables](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-tables3d/): `field.tables3d` - [Field Table Lookup](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-tableLookup/): `field.tableLookup` - [Winding Capacitance](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-windingCapacitance/): `field.windingCapacitance` - [DC Conduction](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-dcConduction/): `field.dcConduction` - [3D Electrostatics](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-electrostatic3d/): `field.electrostatic3d` - [Field Transient](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/magnetics-fieldTransient/): `magnetics.fieldTransient` - [Field-Check Designs](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/magnetics-fieldCheck/): `magnetics.fieldCheck` - [Field Torque](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/magnetics-fieldTorque/): `magnetics.fieldTorque` - [Machine Sketch](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/magnetics-machineSketch/): `magnetics.machineSketch` - [Export 3D Field Model as STL](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-exportModelStl/): `field.exportModelStl` - [Export 3D Field Model as STEP](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-exportModelStep/): `field.exportModelStep` - [Export Field Solve Diagnostics](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-exportDiagnostics/): `field.exportDiagnostics` - [Thermal Field Solve](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-thermalSolve/): `field.thermalSolve` - [Open Field Example](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-openExample/): `field.openExample` - [Extract Conductor Impedance (PEEC)](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-peec/): `field.peec` - [Import DXF Conductors for PEEC](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-peecImportDxf/): `field.peecImportDxf` - [Import GDSII Conductors for PEEC](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-peecImportGds/): `field.peecImportGds` - [Insert Conductor Impedance into Circuit](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-peecInsert/): `field.peecInsert` - [Reduce Conductor Impedance Matrix](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-peecReduce/): `field.peecReduce` - [Winding AC Loss](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-windingAc/): `field.windingAc` - [Field Sweep](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-sweep/): `field.sweep` - [Field Line Profile](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-lineProfile/): `field.lineProfile` - [Field Region Table](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-regionTable/): `field.regionTable` - [Field Force and Torque](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-force/): `field.force` - [Export Field Image](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-exportImage/): `field.exportImage` - [Export Field CSV](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-exportCsv/): `field.exportCsv` - [New Field Drawing](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-new/): `geometry.new` - [Field Drawing](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-get/): `geometry.get` - [Add Point](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-addPoint/): `geometry.addPoint` - [Add Segment](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-addSegment/): `geometry.addSegment` - [Add Arc](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-addArc/): `geometry.addArc` - [Add Rectangle](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-addRectangle/): `geometry.addRectangle` - [Add Circle](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-addCircle/): `geometry.addCircle` - [Move Drawing Items](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-move/): `geometry.move` - [Delete Drawing Items](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-delete/): `geometry.delete` - [Label Region](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-label/): `geometry.label` - [Add Dimension](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-addDimension/): `geometry.addDimension` - [Set Dimension](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-setDimension/): `geometry.setDimension` - [Undo Drawing Edit](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-undo/): `geometry.undo` - [Redo Drawing Edit](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-redo/): `geometry.redo` - [Field Calculator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-calculator/): `field.calculator` - [Field Studies](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-studies/): `field.studies` - [New Field Study](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-newStudy/): `field.newStudy` - [Open Field Study](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-openStudy/): `field.openStudy` - [Rename Field Study](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-renameStudy/): `field.renameStudy` - [Set Up Field Study](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-setStudy/): `field.setStudy` - [Delete Field Study](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-deleteStudy/): `field.deleteStudy` --- # abc to dq Transform (`abc2dq`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/abc2dq/ > Turns three phase quantities into rotating d and q components in one block. ![abc2dq](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/abc2dq.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/abc2dq/) **Group:** Control · **Kind:** `{"block":"abc2dq","kind":"control"}` ## When to use it Use it on the measured phase currents in a field-oriented control loop. Use Clarke Transform and Park Transform separately if you also need alpha and beta. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | signal | Phase a input | | `b` | signal | Phase b input | | `c` | signal | Phase c input | | `theta` | signal | Frame angle in radians, electrical | | `d` | signal | Direct-axis component output | | `q` | signal | Quadrature-axis component, 90 degrees ahead of d | | `zero` | signal | Zero-sequence output, (a + b + c)/3; it does not rotate with the frame. | ## Model The block applies `clarke` (`alpha = (2*a - b - c)/3`, `beta = (b - c)/sqrt(3)`) and then `park` (`d = alpha*cos(theta) + beta*sin(theta)`, `q = -alpha*sin(theta) + beta*cos(theta)`). A balanced cosine set at the angle theta gives `d = A` and `q = 0`. The zero sequence `(a + b + c)/3` comes out on `zero`. Power is `1.5*(vd*id + vq*iq)`. ## Common mistakes - The currents must flow into the machine, with the same sign convention as the machine model. A reversed ammeter makes iq negative and the speed loop drives the wrong way, so check the sign of the first torque step. - theta must be the electrical angle in radians. The mechanical angle on a multi-pole machine makes the frame too slow, and an open theta reads 0. - The measured currents carry switching ripple. A digital drive reads them once per period, so put a Sample and Hold at the carrier period, or a filter, in front when the ripple disturbs the current loop. Problems rules: `pin.unconnected` ## Datasheet and sources No datasheet applies. The a, b and c inputs come from three ammeters in A, and theta from a position sensor (its elec output) or from an Angle Generator. ## Example Open the example with the command `file.openExample` and the name `demo:abc2dq`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Absolute Value (`abs`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/abs/ > Outputs the size of the input, never negative. ![abs](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/abs.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/abs/) **Group:** Control · **Kind:** `{"block":"abs","kind":"control"}` ## When to use it Use it to rectify a signal, for example to take the size of a current for an overcurrent check. Put a Comparator after it for a trip signal. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal of any sign | | `out` | signal | Size of the input, never negative | ## Model out = abs(in), with direct feedthrough and no state. The result is not negative and keeps the unit of the input. It has a corner at zero. ## Common mistakes - The sign is lost. If a controller needs the direction of the error, take the absolute value only after the sign has been used, not in the loop path. - An input left open reads 0 and the output stays at 0. If a protection Comparator never trips, look for an open pin. Problems rules: `pin.unconnected` ## Datasheet and sources No datasheet applies. The input is a measured value from your circuit, such as a phase current in A. ## Example Open the example with the command `file.openExample` and the name `demo:abs`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # ADC (`adc`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/adc/ > Rounds its input to a set number of bits, with optional sampling. ![adc](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/adc.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/adc/) **Group:** Control · **Kind:** `{"block":"adc","kind":"control"}` ## When to use it Use it to see how converter resolution and sample rate affect a current or voltage loop. Use Sample and Hold when only the sampling matters. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal to convert, kept between min and min plus range | | `out` | signal | Rounded value from the last sample | ## Common parameters - `bits`: Number of bits in the conversion (Default: 12) - `range`: Full input span the converter covers (Default: required) - `min`: Input value that gives code zero (Default: 0) - `fs`: How often the input is sampled (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `bits` | — | 12 | 8 – 16 | Number of bits in the conversion | | `range` | — | required | | Full input span the converter covers | | `min` | — | 0 | | Input value that gives code zero | | `fs` | Hz | 0 | | How often the input is sampled | _Parameter descriptions are in English in both languages._ ## Model The step size is lsb = range/2^bits. The output is min + round((in - min)/lsb)*lsb, with the code limited to 0 ... 2^bits - 1, so the largest output is min + range - lsb. With fs = 0 the block converts all the time and has direct feedthrough. With fs above 0 it converts every 1/fs seconds and holds the code in between, and it has no feedthrough. Noise, offset, gain error and conversion delay are not modelled. ## Common mistakes - range has no default and must be positive, so the build stops without it. bits must be a whole number from 1 to 24, and for plus or minus 20 A you use min = -20 and range = 40. - An input beyond the range is cut off without a warning, which looks like a saturated sensor. With fs above 0 the ADC adds a sample delay, so match fs to the controller period and keep the maximum step well below the sample period. Problems rules: `compile.error` ## Datasheet and sources The value of bits comes from the ADC resolution in the MCU datasheet, for example 12. The values of range and min come from the input span of the ADC, and fs is the conversion rate you set in the firmware. ## Example Open the example with the command `file.openExample` and the name `demo:adc`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # AND Gate (`and`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/and/ > Outputs 1 only when every input read is above 0.5. ![and](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/and.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/and/) **Group:** Control · **Kind:** `{"block":"and","kind":"control"}` ## When to use it Use it to combine enable and fault signals, for example to pass a gate command only while no fault is active. Use OR Gate when one input is enough. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in1` | signal | First input; true above 0.5 | | `in2` | signal | Second input; true above 0.5 | | `in3` | signal | Third input, read if n is 3 or 4 | | `in4` | signal | Fourth input, read if n is 4 | | `out` | signal | Output, always 0 or 1 | ## Common parameters - `n`: How many inputs the gate has (Default: 2) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `n` | — | 2 | | How many inputs the gate has | _Parameter descriptions are in English in both languages._ ## Model The first n inputs are read (n = 2 by default, up to 4). An input is true when it is above 0.5. The output is 1 when all n inputs are true and 0 otherwise. The gate is combinational: it has direct feedthrough and follows its inputs at every solver step. ## Common mistakes - With the default n of 2, the pins in3 and in4 are ignored even when wired, so set n to the number of inputs you use. An input that is not wired reads 0, which keeps the output at 0. - The threshold is 0.5, so an analog value such as a 0.4 duty counts as false. A loop made only of gates is refused; use SR Latch or D Flip-Flop to store a state. Problems rules: `compile.error` ## Datasheet and sources There is no datasheet. n is the number of signals you combine. The logic levels come from your protection or enable scheme, such as a fault comparator or a gate-enable signal from the controller. ## Example Open the example with the command `file.openExample` and the name `demo:and`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Angle Generator (`angle`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/angle/ > Turns an electrical speed into an angle that wraps around. ![angle](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/angle.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/angle/) **Group:** Control · **Kind:** `{"block":"angle","kind":"control"}` ## When to use it Use it to make the electrical angle for the Park blocks from a speed, or as the core of a phase-locked loop. ## Pins | Pin | Domain | Meaning | |---|---|---| | `w` | signal | Electrical speed in rad/s | | `theta` | signal | Angle in radians, wrapped to one turn | ## Common parameters - `theta0`: Angle at the start (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `theta0` | rad | 0 | | Angle at the start | _Parameter descriptions are in English in both languages._ ## Model The output is theta = theta0 + integral(w dt), integrated with the trapezoidal rule and wrapped to 0 ... 2*pi. The value theta0 is the angle at t = 0 in radians. The block has no direct feedthrough, so it breaks loops with no delay, and a phase-locked loop closes through it. ## Common mistakes - The input is a speed in rad/s, not a frequency in Hz, so multiply a frequency by 2*pi. For a machine it is the electrical speed, so multiply a mechanical speed by the number of pole pairs first, for example with a Gain. - The angle starts at theta0, so for a machine that starts at rest it must match the machine and sensor start angle, or d and q are misaligned from the first step. The angle is only as accurate as the speed, so drift in the speed makes the angle error grow. - Because it has no direct feedthrough, the solver may read the speed one step late. Keep the maximum step well below the electrical period. ## Datasheet and sources No datasheet applies. The speed comes from a sensor or your slip calculation in electrical rad/s, and theta0 is the starting angle of the d axis, equal to theta0 of the machine and the sensor. ## Example Open the example with the command `file.openExample` and the name `demo:angle`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Vector Angle (atan2) (`atan2`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/atan2/ > The angle of the alpha-beta vector, atan2(beta, alpha), wrapped to 0 ... 2*pi. ![atan2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/atan2.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/atan2/) **Group:** Control · **Kind:** `{"block":"atan2","kind":"control"}` ## When to use it Use it to get the angle of a measured voltage or flux vector, for example a grid angle without a phase-locked loop or the rotor angle from an estimated flux. Use `pll` or `srfPll` when the signal is noisy or distorted, since this block follows every ripple at once. ## Pins | Pin | Domain | Meaning | |---|---|---| | `alpha` | signal | Alpha component input, on the axis of phase a. | | `beta` | signal | Beta component input, 90 degrees ahead of alpha. | | `theta` | signal | Angle output in radians, from 0 up to (not including) 2*pi. | ## Model The output is `atan2(beta, alpha)` moved into 0 ... 2*pi by adding 2*pi to a negative angle, the same wrap as the `angle` block, so it plugs into `park` and `invPark`. A zero vector gives 0. The block has direct feedthrough and no state. ## Common mistakes - The angle jumps from just below 2*pi to 0 once per turn. Filtering it or taking its difference gives a spike at each wrap; differentiate the unwrapped angle or use the speed from a `pll` instead. - With amplitude-invariant `clarke` the angle of a balanced cosine set is the angle of phase a. A sine set (a = sin) is 90 degrees behind: subtract pi/2 or feed the cosine to get the frame `park` expects. ## Datasheet and sources There is no datasheet and no parameter. ## Example Open the example with the command `file.openExample` and the name `demo:atan2`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Second-Order Band-Pass (`bandpass`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/bandpass/ > Passes one band of frequencies around a centre frequency. ![bandpass](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/bandpass.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/bandpass/) **Group:** Control · **Kind:** `{"block":"bandpass","kind":"control"}` ## When to use it Use it to pick out one harmonic or resonance, such as a ripple component. Use Second-Order Low-Pass to keep everything below a corner. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal to filter | | `out` | signal | Band-passed signal | ## Common parameters - `f0`: Frequency the filter passes best (Default: required) - `q`: How narrow the passed band is (Default: 1) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `f0` | Hz | required | | Frequency the filter passes best | | `q` | — | 1 | | How narrow the passed band is | _Parameter descriptions are in English in both languages._ ## Model H(s) = (w0/Q)·s / (s² + (w0/Q)·s + w0²) with w0 = 2·pi·f0. The gain is 1 at f0 and 0 at DC and at very high frequency. The -3 dB band is f0/q wide. The block has no direct feedthrough and is integrated with the trapezoidal rule, like Transfer Function. ## Common mistakes - q sets how sharp the band is, and the width in hertz is f0 divided by q. A high q keeps ringing for a while, so run the simulation long enough for the output to settle. - f0 is in hertz. A band-pass has zero gain at DC, so use it only on the AC part of a signal. ## Datasheet and sources There is no datasheet. f0 is the frequency you want to extract, such as a line harmonic, a ripple frequency or a resonance of your plant. q is f0 divided by the bandwidth you need. ## Example Open the example with the command `file.openExample` and the name `demo:bandpass`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Bus Demux (`busDemux`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/busDemux/ > Splits a bus into its elements, one scalar signal per output. ![busDemux](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/busDemux.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/busDemux/) **Group:** Control · **Kind:** `{"block":"busDemux","kind":"control"}` ## When to use it Use it where the elements of a bus go separate ways, for example to give each inverter leg its own gate signal from a gate bus, or to feed a block that does not work element by element. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | The bus to split; its width must be n. | | `out1` | signal | First element. | | `out2` | signal | Second element. | | `out3` | signal | Third element (when n is 3 or more). | | `out4` | signal | Fourth element (when n is 4 or more). | | `out5` | signal | Fifth element (when n is 5 or more). | | `out6` | signal | Sixth element (when n is 6 or more). | | `out7` | signal | Seventh element (when n is 7 or more). | | `out8` | signal | Eighth element (when n is 8). | ## Common parameters - `n`: Number of elements the bus on `in` splits into, 2 to 8 (out1 … out8); it must be the bus's width (Default: 2) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `n` | — | 2 | | Number of elements the bus on `in` splits into, 2 to 8 (out1 … out8); it must be the bus's width | _Parameter descriptions are in English in both languages._ ## Model Each output is the same net as its element of the bus, so the block adds nothing to the simulation; the net keeps the output's name. ## Common mistakes - `n` must equal the width of the bus on `in`; a different count is an error that names both. An input that is not a bus is an error too. - The outputs keep the names you give their nets, and a bus element nobody names is called after the bus (`g_1`, `g_2`). Probe and plot those names after a run; the bus itself is not recorded. ## Datasheet and sources There is no datasheet. Set `n` to the width of the bus, 2 to 8. ## Example Open the example with the command `file.openExample` and the name `demo:busDemux`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Bus Mux (`busMux`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/busMux/ > Joins up to eight signals into one bus, a single wire that carries them all. ![busMux](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/busMux.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/busMux/) **Group:** Control · **Kind:** `{"block":"busMux","kind":"control"}` ## When to use it Use it to carry the three phases (abc), the dq pair or a set of gate signals on one wire instead of several, so a control drawing stays readable. Element-wise blocks (gain, sum, PI, logic, dead time) act on every element of a bus at once, and Clarke, Park and the three-phase PWM take a bus on their first pin. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in1` | signal | First element of the bus (or the first elements, when a bus arrives here). | | `in2` | signal | The next element. | | `in3` | signal | The next element (joined when n is 3 or more). | | `in4` | signal | The next element (joined when n is 4 or more). | | `in5` | signal | The next element (joined when n is 5 or more). | | `in6` | signal | The next element (joined when n is 6 or more). | | `in7` | signal | The next element (joined when n is 7 or more). | | `in8` | signal | The last element (joined when n is 8). | | `out` | signal | The bus: in1 first, then in2 and so on. | ## Common parameters - `n`: Number of inputs joined into the bus, 2 to 8 (in1 … in8); a bus on an input adds all its elements (Default: 2) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `n` | — | 2 | | Number of inputs joined into the bus, 2 to 8 (in1 … in8); a bus on an input adds all its elements | _Parameter descriptions are in English in both languages._ ## Model The block is wiring, not computation: before a run every bus is taken apart into its elements, each element is its own net, and an element-wise block on a bus becomes one copy per element. A circuit drawn with buses therefore simulates exactly as the same circuit drawn with separate wires. A bus on an input adds all its elements, so two buses of three make one of six. A bus is drawn thicker than a wire, with its width beside a slash. ## Common mistakes - Only element-wise blocks and the first pin of a pin group (the a, b, c of Clarke, Park and the three-phase PWM, with b and c left open) take a bus. Any other block, and every electrical pin, reports the bus as an error; split it with a Bus Demux first. - A bus fed back into its own mux never settles and is an error. Feed a signal back through the element-wise block that computes it, not through the mux that builds the bus. ## Datasheet and sources There is no datasheet. Set `n` to the number of inputs you wire, 2 to 8; inputs past `n` are hidden while open. ## Example Open the example with the command `file.openExample` and the name `demo:busMux`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Bus Selector (`busSelect`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/busSelect/ > Picks some elements of a bus, in any order, as a smaller bus or a single signal. ![busSelect](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/busSelect.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/busSelect/) **Group:** Control · **Kind:** `{"block":"busSelect","kind":"control"}` ## When to use it Use it to take the d axis out of a dq bus, reorder phases (`3, 2, 1`), or pass two of six gate signals on, without splitting the whole bus. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | The bus to pick from. | | `out` | signal | The picked elements as a bus, or the element itself when one is picked. | ## Common parameters - `index`: Elements of the bus to pick, 1-based and comma separated: `1, 3` gives a bus of two, `2` a scalar (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `index` | — | optional (off) | | Elements of the bus to pick, 1-based and comma separated: `1, 3` gives a bus of two, `2` a scalar | _Parameter descriptions are in English in both languages._ ## Model Element k of the output is element index(k) of the input, counted from 1. The block is wiring and adds nothing to the simulation. ## Common mistakes - Indices count from 1, not from 0, and must not pass the width of the bus; an index past it is an error that names the block. - Picking one element gives a scalar, which an ordinary block can read; picking several gives a bus, which only element-wise blocks and pin groups take. ## Datasheet and sources There is no datasheet. `index` lists the element numbers, for example `1, 3`. ## Example Open the example with the command `file.openExample` and the name `demo:busSelect`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Carrier (`carrier`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/carrier/ > A triangle or sawtooth wave between 0 and 1 for PWM. ![carrier](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/carrier.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/carrier/) **Group:** Control · **Kind:** `{"block":"carrier","kind":"control"}` ## When to use it Use it to compare a reference with a carrier in your own Comparator, or to share one carrier among gates. PWM Generator already has one. ## Pins | Pin | Domain | Meaning | |---|---|---| | `phase` | signal | Optional phase input in degrees; while wired it replaces the `phase` parameter (phase-shifted bridges). | | `freq` | signal | Optional frequency input in Hz; while wired it replaces `freq` and the carrier integrates it, so the frequency may change without a jump. | | `out` | signal | Carrier wave between 0 and 1 | ## Common parameters - `freq`: Carrier frequency; a wired freq input replaces it (Default: required) - `shape`: Triangle or sawtooth wave shape: `triangle` or `sawtooth` (Default: triangle) - `phase`: How far the wave is shifted, as a fraction of one period; a wired phase input (degrees) replaces it (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `freq` | Hz | required | | Carrier frequency; a wired freq input replaces it | | `shape` | — | triangle | | Triangle or sawtooth wave shape: `triangle` or `sawtooth` | | `phase` | — | 0 | | How far the wave is shifted, as a fraction of one period; a wired phase input (degrees) replaces it | _Parameter descriptions are in English in both languages._ ## Model With `x` the position in the present period (0 to 1, shifted by `phase`), a `triangle` carrier is `2*x` for `x < 0.5` and `2 - 2*x` after, so it starts at 0, peaks at 1 at half a period and returns to 0. A `sawtooth` ramps from 0 to 1 and falls back at each period. The frequency is `freq` in Hz and `phase` is a fraction of one period. A wired `phase` input (degrees, divided by 360) and a wired `freq` input replace the parameters; with `freq` wired the position in the period is the integral of the frequency. ## Common mistakes - A carrier much faster than the step cannot be resolved. Keep the maximum step at or below one fiftieth of the carrier period, which is 1 us at 20 kHz. - Write the frequency with its prefix, 20k and not 20. The carrier runs from 0 to 1, so a reference between -1 and 1 must first become a duty, for example with Space-Vector Modulator set to duty. Problems rules: `step.too_large`, `param.out_of_range` ## Datasheet and sources No datasheet applies. The value of freq is the switching frequency you chose, usually limited by device switching loss and the MCU timer, and phase lets you interleave several carriers. ## Example Open the example with the command `file.openExample` and the name `demo:carrier`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # C Block (`cblock`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/cblock/ > Runs C code you write, a PSIM C Block or a PLECS C-Script, as a control block, in a sandbox that cannot crash or hang the simulation. ![cblock](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/cblock.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/cblock/) **Group:** Control · **Kind:** `{"block":"cblock","kind":"control"}` ## When to use it Use it for control logic that is easier to write as code than to draw: a state machine, a protection sequence, a lookup with branches, a controller copied from firmware. Use the built-in blocks (`pi`, `dpi`, `ztf`, `svpwm`) when one does the job: they are faster and code generation writes them as fixed-point C. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in1` | signal | First input: x1 or in[0] (PSIM), InputSignal(0, 0) (PLECS). | | `in2` | signal | Second input, read when inputs is 2 or more. | | `in3` | signal | Third input, read when inputs is 3 or more. | | `in4` | signal | Fourth input, read when inputs is 4 or more. | | `in5` | signal | Fifth input, read when inputs is 5 or more. | | `in6` | signal | Sixth input, read when inputs is 6 or more. | | `in7` | signal | Seventh input, read when inputs is 7 or more. | | `in8` | signal | Eighth input, read when inputs is 8. | | `out1` | signal | First output: y1 or out[0] (PSIM), OutputSignal(0, 0) (PLECS). | | `out2` | signal | Second output, written when outputs is 2 or more. | | `out3` | signal | Third output, written when outputs is 3 or more. | | `out4` | signal | Fourth output, written when outputs is 4 or more. | | `out5` | signal | Fifth output, written when outputs is 5 or more. | | `out6` | signal | Sixth output, written when outputs is 6 or more. | | `out7` | signal | Seventh output, written when outputs is 7 or more. | | `out8` | signal | Eighth output, written when outputs is 8. | ## Common parameters - `dialect`: Whose C block the code is written for: `psim` (C Block: t, delt, x1…, y1…) or `plecs` (C-Script: sections and the PLECS macros) (Default: psim) - `inputs`: Inputs the code reads, 0 to 64 (in1 … in64) (Default: 1) - `outputs`: Outputs the code writes, 0 to 64 (out1 … out64) (Default: 1) - `ts`: Sample time: the code runs at 0, ts, 2·ts, … and the outputs hold between; 0 runs it at every solver step. Imported blocks may set `sampleTime` instead (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `dialect` | — | psim | | Whose C block the code is written for: `psim` (C Block: t, delt, x1…, y1…) or `plecs` (C-Script: sections and the PLECS macros) | | `inputs` | — | 1 | | Inputs the code reads, 0 to 64 (in1 … in64) | | `outputs` | — | 1 | | Outputs the code writes, 0 to 64 (out1 … out64) | | `ts` | s | 0 | | Sample time: the code runs at 0, ts, 2·ts, … and the outputs hold between; 0 runs it at every solver step. Imported blocks may set `sampleTime` instead | | `feedthrough` | — | 1 | | 1 when the outputs depend on the present inputs; 0 lets the block break an algebraic loop (it may read the previous step's inputs) | | `params` | — | optional (off) | | PLECS parameters, read by ParamRealData(i, 0): a comma-separated list. Imported blocks may set `param1`, `param2`, … instead | | `discStates` | — | 0 | | PLECS discrete states, DiscState(i) | | `contStates` | — | 0 | | PLECS continuous states, ContState(i), whose ContDeriv(i) the derivative section sets; integrated with Heun's method over each solver step | | `inputWidths` | — | optional (off) | | PLECS input terminal widths, one per terminal, adding up to `inputs`: `1, 1, 1` is three terminals read as InputSignal(k, 0); unset is one terminal of all inputs | | `outputWidths` | — | optional (off) | | PLECS output terminal widths, one per terminal, adding up to `outputs`: `1, 1, 1` is three terminals written as OutputSignal(k, 0); unset is one terminal of all outputs | _Parameter descriptions are in English in both languages._ ## Model The code is kept with the circuit under the block's name (C Code window, or circuit.setCode). It is compiled when the simulation starts; a compile error stops the run and names the block, the line and the column. The start-up code runs once at t = 0, then the step code runs once per accepted solver step (or at 0, ts, 2*ts, ... when ts > 0, with the outputs held between), with `t` the time and `delt` the time since the previous run. `static` variables and PLECS states keep their values between steps. PLECS continuous states are integrated with Heun's method over that step, from the derivative section. PLECS sections are kept in one text, each after a `//@section ` line (declarations, start, output, update, derivative, terminate), as the PLECS import writes them. An output the code does not assign keeps its previous value. Every run has an operation budget, so an endless loop stops the simulation with an error instead of hanging it. ## Common mistakes - With feedthrough = 1 a C block inside a loop of control blocks with no delay is an algebraic loop. Set feedthrough = 0 when the outputs depend only on the state (then the block reads the previous step's inputs inside the loop), or put a `zDelay` in the loop. - With ts = 0, `delt` is the solver step, which a variable-step run changes from step to step: an integrator written as `x += k*u*delt` stays right, one written as `x += k*u` does not. Set ts to the controller's sample time to get a fixed `delt`. - `#include` takes only the C standard headers and `Psim.h`; a header of your own (or a path) is refused, so copy the code it holds into the block. Each block's variables, and those of all C blocks in a circuit together, have a memory limit (2097152 and 4194304 values), and every function call costs one operation per local value, so size arrays to what the controller needs. ## Datasheet and sources There is no datasheet. Take ts from the firmware's interrupt rate and the counts of inputs, outputs, parameters and states from the block you copy the code from. ## Example Open the example with the command `file.openExample` and the name `demo:cblock`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Clarke Transform (`clarke`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/clarke/ > Turns three phase quantities into two fixed components, alpha and beta. ![clarke](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/clarke.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/clarke/) **Group:** Control · **Kind:** `{"block":"clarke","kind":"control"}` ## When to use it Use it to see three phase quantities as one fixed vector, for example before Park Transform. Use abc to dq Transform for both steps in one block. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | signal | Phase a input | | `b` | signal | Phase b input | | `c` | signal | Phase c input | | `alpha` | signal | Component along the axis of phase a | | `beta` | signal | Component 90 degrees ahead of alpha | | `zero` | signal | Zero-sequence output, (a + b + c)/3; 0 for a balanced set. | ## Model The outputs are `alpha = (2*a - b - c)/3` and `beta = (b - c)/sqrt(3)`. The scaling is amplitude-invariant: a balanced set `a = A*cos(th)`, `b = A*cos(th - 120 deg)`, `c = A*cos(th + 120 deg)` gives `alpha = A*cos(th)` and `beta = A*sin(th)`. The zero-sequence part `(a + b + c)/3` is not in alpha and beta; it comes out on `zero`. Three-phase power is then 1.5 times (vd*id + vq*iq). ## Common mistakes - In a three-wire machine the three phases add up to zero, so the dropped zero-sequence part does no harm. With four wires or an unbalanced fault that current is lost, and this block cannot show it. - With this scaling, three-phase power is 1.5 times (vd times id plus vq times iq), so leaving out the 1.5 gives a wrong result. An input left open reads 0. Problems rules: `pin.unconnected` ## Datasheet and sources No datasheet applies. The inputs are the three phase quantities you measure with ammeters or voltmeters, in A or V, and the outputs keep that unit. ## Example Open the example with the command `file.openExample` and the name `demo:clarke`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Communication Link (`commLink`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/commLink/ > Carries up to four values from one controller to another with the timing of a bus: a rate, a latency, a seeded jitter and a seeded loss. ![commLink](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/commLink.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/commLink/) **Group:** Control · **Kind:** `{"block":"commLink","kind":"control"}` ## When to use it Use it where a supervisor talks to a converter over PMBus, CAN or a UART: a set point that arrives late, a status report that takes some milliseconds, a message that is lost. It models only the timing, not a protocol stack: no addressing, arbitration, checksums or retries. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in1` | signal | First value of the message | | `in2` | signal | Second value (sent when width is 2 or more) | | `in3` | signal | Third value (sent when width is 3 or more) | | `in4` | signal | Fourth value (sent when width is 4) | | `out1` | signal | First value of the last message delivered, held | | `out2` | signal | Second value delivered | | `out3` | signal | Third value delivered | | `out4` | signal | Fourth value delivered | | `fresh` | signal | 1 for pulse seconds after each arrival, else 0 | | `lost` | signal | Messages lost so far | ## Common parameters - `rate`: Messages per second, sent at t = k/rate; 0 sends a message whenever an input moves past deadband (Default: 1k) - `latency`: Fixed delay from sending to arrival (Default: 1m) - `jitter`: Most extra delay per message, drawn from 0 to jitter with the seed; every message arrives within latency + jitter (Default: 0) - `loss`: Probability that a message is lost, 0 to 1, drawn with the seed; the lost output counts them (Default: 0) - `width`: Values per message, 1 to 4: inputs in1 … in, outputs out1 … out (Default: 1) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `rate` | Hz | 1k | | Messages per second, sent at t = k/rate; 0 sends a message whenever an input moves past deadband | | `latency` | s | 1m | | Fixed delay from sending to arrival | | `jitter` | s | 0 | | Most extra delay per message, drawn from 0 to jitter with the seed; every message arrives within latency + jitter | | `loss` | — | 0 | | Probability that a message is lost, 0 to 1, drawn with the seed; the lost output counts them | | `width` | — | 1 | | Values per message, 1 to 4: inputs in1 … in, outputs out1 … out | | `seed` | — | 1 | | Number that picks the jitter and loss pattern; the same seed gives the same run | | `deadband` | — | 0 | | Send on change only: how far an input must move from the last message before a new one is sent | | `y0` | — | 0 | | Outputs until the first message arrives | | `pulse` | s | 100u | | How long fresh stays 1 after each arrival; keep it above maxStep to see it in a fixed-step recording | _Parameter descriptions are in English in both languages._ ## Model With rate above 0 the sender reads in1 … in at t = k/rate from t = 0; with rate 0 it sends whenever an input moves more than deadband from the last message sent. Each message is lost with the probability loss and counted on lost when it is sent. Otherwise it arrives latency + jitter·u after it was sent, u uniform from 0 to 1, and never before the message ahead of it, so the bus keeps the order and every message arrives within latency + jitter. The outputs hold the last message delivered, y0 before the first, and fresh is 1 for pulse seconds from each arrival. The draws depend only on seed and the message number, so the same seed gives the same jitter and losses in every run and in both solvers. Send instants, arrivals and the ends of the pulses are events, so the solver lands on them. A message sent while 4096 are on the way is dropped and counted as lost. ## Common mistakes - With rate 0 and a continuous input, every solver step sends a message. Give deadband a value, or use a rate, so the bus carries what a real one would. - A fixed-step recording keeps only the grid points, so a pulse shorter than maxStep can fall between them. Keep pulse above maxStep, and below the time between messages, or fresh stays at 1. - Code generation leaves this block out as simulation-only. On the target the bus driver carries the message, so generate each side on its own. ## Datasheet and sources There is no datasheet. Typical numbers, worked out from the bit rates and not taken from a standard: PMBus at 100 kHz needs about 0.5 ms for a word read or write and a host polls at 10 to 100 Hz (rate 10 to 100, latency 0.5m, jitter up to 1m). CAN at 500 kbit/s sends an 8-byte frame in about 0.27 ms and a lower-priority frame waits for the ones ahead (latency 0.3m, jitter 0.3m to 1m). A UART at 115200 baud takes 87 µs per byte, about 0.7 ms for 8 bytes (latency 0.7m). loss stands for a message the application never gets, after any retries the bus makes. ## Example Open the example with the command `file.openExample` and the name `demo:commLink`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Comparator (`comparator`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/comparator/ > Outputs 1 while in1 is above in2, otherwise 0. ![comparator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/comparator.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/comparator/) **Group:** Control · **Kind:** `{"block":"comparator","kind":"control"}` ## When to use it Use it for a trip level, a threshold, or a PWM gate made from a reference and a Carrier. Use PWM Generator for the standard gate. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in1` | signal | Larger side: reference or modulation | | `in2` | signal | Smaller side: carrier or threshold | | `out` | signal | 1 while in1 is above in2 | ## Common parameters - `hys`: Hysteresis: out turns 1 above in2 + hys and 0 below in2 − hys and holds in between; 0 = plain in1 > in2 (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `hys` | — | 0 | | Hysteresis: out turns 1 above in2 + hys and 0 below in2 − hys and holds in between; 0 = plain in1 > in2 | _Parameter descriptions are in English in both languages._ **Use for:** Overcurrent trips · Carrier-based PWM · Level detection **Not for:** Custom on and off levels → [`hysteresis`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/hysteresis/) · Exact PWM edges → [`pwm`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/pwm/) ## Formulas | Formula | Equation | Source | |---|---|---| | Turn-on level | von = in2 + hys | Sedra & Smith, Microelectronic Circuits, 7th ed. (2015), bistable multivibrator (Schmitt trigger) section | | Turn-off level | voff = in2 - hys | Sedra & Smith, Microelectronic Circuits, 7th ed. (2015), bistable multivibrator (Schmitt trigger) section | | Carrier comparison | out = 1 when in1 > in2 + hys (from off) | Holmes & Lipo, Pulse Width Modulation for Power Converters (2003), ch. 3 | ## Quick check Inputs: - `in1`: Signal = 10.5 — - `in2`: Threshold = 10 — - `hys`: Hysteresis half-width = 200m —, `hys` Outputs: - `von`: Turn-on level = `in2 + hys` — - `voff`: Turn-off level = `in2 - hys` — - `out`: Output from the off state = `if(in1 > in2 + hys, 1, 0)` — ## Model logic - With hys = 0 the output is 1 while in1 > in2 and 0 otherwise, so equal inputs give 0; it has no state and no delay. - With hys > 0 it turns 1 above in2 + hys, turns 0 below in2 - hys and holds in between, starting at 0; the band is 2·hys wide. - The solver does not land a step on a crossing, so the flip shows at the end of the step; only a Transport Delay reading it gets the interpolated crossing time. - The output levels are only 0 and 1, propagation delay is not modelled, and a negative or non-finite hys is refused. ## Model The output is `out = 1` if `in1 > in2`, else 0. There is no delay. With `hys` = 0 (the default) there is no hysteresis and equal inputs give 0. With `hys` > 0 the output keeps a state: it turns 1 when `in1 > in2 + hys`, turns 0 when `in1 < in2 - hys` and holds in between, starting at 0. The block does not predict crossing times, so the solver does not land a step exactly on a crossing. ## Common mistakes - With a noisy or slow input the output can chatter near the threshold, and the switching time is only as exact as the step. Use a small maximum step, or PWM Generator, which places its edges exactly. - An output of Space-Vector Modulator between -1 and 1 must not be compared with the Carrier, which runs from 0 to 1. Set output of the Space-Vector Modulator to duty, or its lower half never turns the switch on. ## Datasheet and sources No datasheet applies. The threshold comes from your design, for example an overcurrent trip level set from the device current rating with a margin. ## Example Open the example with the command `file.openExample` and the name `demo:comparator`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Type II / Type III Compensator (`compensator`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/compensator/ > The error-amplifier compensator of a switch-mode power supply: an integrator with one or two zero-pole pairs, output limits and anti-windup. ![compensator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/compensator.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/compensator/) **Group:** Control · **Kind:** `{"block":"compensator","kind":"control"}` ## When to use it Use it for the voltage loop of a converter designed in the frequency domain, with the zero and pole frequencies from a K-factor or crossover design. Type II suits a current-mode plant; Type III a voltage-mode buck with its LC double pole. Use `pi` or `pid` for gains given in the time domain, and `ztf` or `dpi` for a sampled controller. ## Pins | Pin | Domain | Meaning | |---|---|---| | `fb` | signal | Feedback input (the divided output voltage). | | `ref` | signal | Reference input; the block acts on the error ref - fb. | | `out` | signal | Compensator output (the duty or the current command), limited to vl ... vh. | ## Common parameters - `type`: Compensator type: `2` (Type II: one zero, one pole) or `3` (Type III: a second zero and pole) (Default: 2) - `g`: Gain g of H(s) = g·(ωz1/s)·(1 + s/ωz1)/(1 + s/ωp1), on the error ref − fb (Default: 1) - `fz1`: First zero: ωz1 = 2π·fz1, also the integrator's unity-gain frequency (Default: required) - `fp1`: First pole frequency (Default: required) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `type` | — | 2 | | Compensator type: `2` (Type II: one zero, one pole) or `3` (Type III: a second zero and pole) | | `g` | — | 1 | | Gain g of H(s) = g·(ωz1/s)·(1 + s/ωz1)/(1 + s/ωp1), on the error ref − fb | | `fz1` | Hz | required | | First zero: ωz1 = 2π·fz1, also the integrator's unity-gain frequency | | `fp1` | Hz | required | | First pole frequency | | `fz2` | Hz | optional (off) | | Second zero frequency (Type III; needed there) | | `fp2` | Hz | optional (off) | | Second pole frequency (Type III; needed there) | | `avol` | — | optional (off) | | DC gain of the integrator, as an op-amp's open-loop gain: ωz1/s becomes ωz1/(s + ωz1/avol); unset = ideal | | `vl` | — | -1e30 | | Lower output limit | | `vh` | — | 1e30 | | Upper output limit | _Parameter descriptions are in English in both languages._ ## Model With e = ref - fb and w = 2*pi*f, the Type II transfer function is `H(s) = g*(wz1/s)*(1 + s/wz1)/(1 + s/wp1)`; Type III multiplies it by `(1 + s/wz2)/(1 + s/wp2)`. A finite `avol` turns `wz1/s` into `wz1/(s + wz1/avol)`, a pole at wz1/avol with DC gain avol. The integrator is clamped so that g times it stays in vl ... vh (the lead-lag sections have unit DC gain), so the output leaves a limit as soon as the error reverses, and the output is limited to vl ... vh. The block is strictly proper (no direct feedthrough), so a loop closes through it, and an AC sweep uses H(jw). ## Common mistakes - The frequencies are in Hz, not rad/s. Entering a crossover design's angular frequencies as `fz1` and `fp1` puts every zero and pole 2*pi times too high. - `g` is the gain at the frequency `fz1` of the integrator alone, not the mid-band gain. For a Type II with fz1 well below fp1 the mid-band gain is about g; for a Type III the gain keeps rising between fz2 and fp1, so the loop gain at crossover may be much higher than g. - A duty output needs `vl` = 0 and `vh` below 1; with the default (no) limits the integrator winds up during start-up and the output overshoots. ## Datasheet and sources For an op-amp error amplifier, `avol` is the open-loop gain from its datasheet (for example 10^4 to 10^5). The zero and pole frequencies follow from the feedback network (fz1 = 1/(2*pi*R2*C1), fp1 = 1/(2*pi*R2*C2) for a Type II) or from the K-factor method. ## Example Open the example with the command `file.openExample` and the name `demo:compensator`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Constant (`constant`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/constant/ > Outputs one fixed value for the whole run. ![constant](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/constant.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/constant/) **Group:** Control · **Kind:** `{"block":"constant","kind":"control"}` ## When to use it Use it for a reference or limit that never changes. Use Step Source when the value must change at a set time. ## Pins | Pin | Domain | Meaning | |---|---|---| | `out` | signal | Fixed value, valid from the start | ## Common parameters - `value`: Output value (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `value` | — | 0 | | Output value | _Parameter descriptions are in English in both languages._ ## Model out = value at every step. The value has no unit of its own, so it takes the unit of the signal it feeds (A, V, rad/s or a duty fraction). It can be an expression of circuit variables. ## Common mistakes - A Constant that feeds the duty input of a PWM Generator must stay between 0 and 1. Writing 50 for 50 percent keeps the switch on all the time. - The default value is 0. A Constant that you place but never edit gives a zero reference without any warning. Problems rules: `duty.out_of_range` ## Datasheet and sources No datasheet applies. The value is a design target, such as a speed reference or a DC-link voltage, in the unit of the signal it feeds. ## Example Open the example with the command `file.openExample` and the name `demo:constant`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Counter (`counter`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/counter/ > Counts rising clock edges and wraps around at a set number. ![counter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/counter.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/counter/) **Group:** Control · **Kind:** `{"block":"counter","kind":"control"}` ## When to use it Use it to count PWM periods, divide a clock by N, or make a slow time base from a fast clock. Use D Flip-Flop to divide by two. ## Pins | Pin | Domain | Meaning | |---|---|---| | `clk` | signal | Clock input; counts each rising edge | | `rst` | signal | Reset input; holds the count at init | | `down` | signal | Direction input; above 0.5 counts down | | `count` | signal | The count, a whole number | ## Common parameters - `mod`: Count where it wraps back to zero (Default: 256) - `init`: Count at the start and after reset (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `mod` | — | 256 | | Count where it wraps back to zero | | `init` | — | 0 | | Count at the start and after reset | _Parameter descriptions are in English in both languages._ ## Model On each rising edge of clk the count goes up by one, or down by one when down is above 0.5, and wraps from mod - 1 to 0 (or from 0 to mod - 1). While rst is above 0.5 the count is held at init, and it wins over clk. mod is a whole number from 1 up to 2^32 and init a whole number below it. The block has no direct feedthrough. A clk that is already high at t = 0 does not count. ## Common mistakes - The output is the count itself, not a logic level, so a gate reads every count above 0 as true. Compare it first, or use a mod of 2 for a 0 and 1 output; an init that is not below mod is refused. - rst works on a level, so a reset that stays high keeps the count at init and ignores clk edges. Use a short pulse, and drive clk from a PWM Generator output or another source the solver lands on, because edges between two solver steps are missed. Problems rules: `compile.error` ## Datasheet and sources There is no datasheet. mod comes from the timer or divider you are modelling, either its overflow value plus one or its division ratio N. init is the value the register is reset to. ## Example Open the example with the command `file.openExample` and the name `demo:counter`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Discrete Integrator (`dIntegrator`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/dIntegrator/ > Adds up its input over time, one sample at a time. ![dIntegrator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/dIntegrator.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/dIntegrator/) **Group:** Control · **Kind:** `{"block":"dIntegrator","kind":"control"}` ## When to use it Use it for a sampled integral, such as an angle from speed. Use Integrator for a continuous design. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal to integrate | | `out` | signal | Integral, limited to lo and hi | ## Common parameters - `ts`: Time between samples (Default: required) - `k`: How fast the output builds up (Default: 1) - `lo`: Lowest value the output can reach (Default: -1e30) - `hi`: Highest value the output can reach (Default: 1e30) - `x0`: Initial output (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `ts` | s | required | | Time between samples | | `offset` | s | 0 | | Time of the first sample | | `k` | 1/s | 1 | | How fast the output builds up | | `method` | — | forward | | Calculation method for the integral: `forward`, `backward` or `tustin` | | `lo` | — | -1e30 | | Lowest value the output can reach | | `hi` | — | 1e30 | | Highest value the output can reach | | `x0` | — | 0 | | Initial output | _Parameter descriptions are in English in both languages._ ## Model With area = k·ts, forward gives x[k] = x[k-1] + area·u[k-1] with the output x[k-1], so it has no direct feedthrough. backward gives x[k] = x[k-1] + area·u[k] and tustin uses the average of u[k] and u[k-1]; both have feedthrough. The state is clamped to lo ... hi at each step, which is also the anti-windup. The output is x0 (clamped) before the first instant. ## Common mistakes - Here method starts at forward, but in Discrete PI Controller and Discrete PID Controller it starts at backward. Forward lags the input by one sample, so choose backward or tustin when that matters and no loop closes through this block. - k is per second. lo and hi start at plus and minus 1e30, so a constant offset in the input makes the output drift without limit; set the limits or remove the offset. ## Datasheet and sources ts is the firmware loop period, 1/fs. k is the integral gain from your design, and it is 1 for a speed-to-angle integrator. lo and hi are the register range or the physical limit, and x0 is the value the firmware starts with. ## Example Open the example with the command `file.openExample` and the name `demo:dIntegrator`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Dead Time (`deadtime`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/deadtime/ > Delays the rising edge of a gate signal and passes the falling edge at once. ![deadtime](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/deadtime.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/deadtime/) **Group:** Control · **Kind:** `{"block":"deadtime","kind":"control"}` ## When to use it Use it on each gate of a half bridge so that one switch turns off before the other turns on. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Gate signal; above 0.5 counts as on | | `out` | signal | Gate signal with the rising edge delayed by td | | `outn` | signal | Complementary gate output: on while the input is off and `td` has passed since its falling edge, so one block drives both switches of a half bridge. | ## Common parameters - `td`: Delay added to every rising edge of out, and of the complementary output outn (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `td` | s | 0 | | Delay added to every rising edge of out, and of the complementary output outn | | `tdn` | s | optional (off) | | Delay added to every rising edge of outn instead of td, when the two switches need different dead times | _Parameter descriptions are in English in both languages._ ## Model The block turns the input into a logic level (above 0.5 is true). A rising edge appears at the output `td` seconds later, while a falling edge appears at once. The output is on only while the input is on and `td` has passed since its rise. A pulse shorter than `td` never reaches the output. The second output `outn` is the complement with the same delay on its own rising edge (the input's falling edge); an input that starts low turns `outn` on at `td`. The solver lands a step on the delayed edge. ## Common mistakes - The unit of td is seconds, so write 500n for 500 ns. A dead time longer than the shortest on-time deletes the pulse completely. - One block handles one gate. A half bridge needs a Dead Time on both gates, the second one after a Logic NOT, or the switches can still overlap. Problems rules: `param.out_of_range`, `shoot-through` ## Datasheet and sources Choose td from the switch datasheet: it must be longer than the turn-off delay plus the fall time with a margin, and short against the on-time. A few hundred nanoseconds is typical for MOSFETs. ## Example Open the example with the command `file.openExample` and the name `demo:deadtime`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Sample Delay (`delay`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/delay/ > Delays its input by one sample period. ![delay](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/delay.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/delay/) **Group:** Control · **Kind:** `{"block":"delay","kind":"control"}` ## When to use it Use it for the computation delay of a digital controller or to break a loop. Use Sample and Hold for no extra delay. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal to delay | | `out` | signal | Input from one period earlier | ## Common parameters - `period`: Sample period (Default: required) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `period` | s | required | | Sample period | _Parameter descriptions are in English in both languages._ ## Model At every multiple of period the block outputs the value it stored at the previous instant and stores its present input: out(k) = in(k-1). The output is 0 during the first period. The solver lands a step on each sample instant. The block has no direct feedthrough, so it breaks loops with no delay. ## Common mistakes - The delay is a whole period, not any time you like. The period is in seconds, so write 100u for 10 kHz. - The output is 0 for the first period, which can start a loop with a wrong command. Allow for it at start-up, and keep the maximum step well below the period. Problems rules: `param.out_of_range` ## Datasheet and sources No datasheet applies. The value of period is the controller sample period (the inverse of the interrupt rate), and one delay of that length models the usual one-sample computation delay. ## Example Open the example with the command `file.openExample` and the name `demo:delay`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Filtered Derivative (`derivative`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/derivative/ > The rate of change of its input, times a gain, with a first-order filter so it does not amplify noise without bound. ![derivative](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/derivative.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/derivative/) **Group:** Control · **Kind:** `{"block":"derivative","kind":"control"}` ## When to use it Use it for a rate of change: di/dt of a measured current, the derivative path of a hand-built controller, or the speed from a position. Use PID Controller for a whole PID. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal input | | `out` | signal | k times the filtered rate of change | ## Common parameters - `k`: Gain on the rate of change (Default: 1) - `fc`: Corner of the derivative filter; above it the gain levels off at k·2π·fc (Default: 1k) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `k` | s | 1 | | Gain on the rate of change | | `fc` | Hz | 1k | | Corner of the derivative filter; above it the gain levels off at k·2π·fc | _Parameter descriptions are in English in both languages._ ## Model H(s) = k·ωc·s/(s + ωc) with ωc = 2π·fc: below fc it is k·s, a derivative; above fc its gain levels off at k·ωc. A ramp of slope m gives k·m after a few time constants 1/ωc. It runs as Transfer Function, so the output follows the present input (direct feedthrough). ## Common mistakes - A switching ripple at the input comes out multiplied by up to k·ωc. Keep fc below the switching frequency, or filter the input first. - fc must be positive. A very high fc against maxStep makes the trapezoidal rule ring; keep 1/(2π·fc) several steps long. Problems rules: `compile.error`, `solver.control` ## Datasheet and sources There is no datasheet. ## Example Open the example with the command `file.openExample` and the name `demo:derivative`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # D Flip-Flop (`dff`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/dff/ > Copies its data input to the output on each rising clock edge. ![dff](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/dff.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/dff/) **Group:** Control · **Kind:** `{"block":"dff","kind":"control"}` ## When to use it Use it to sample a logic signal on a clock, divide a clock by two, or build a shift register. Use SR Latch for a latch that follows levels, and Counter to count edges. ## Pins | Pin | Domain | Meaning | |---|---|---| | `d` | signal | Data input; true above 0.5 | | `clk` | signal | Clock input; rising edge crosses 0.5 | | `s` | signal | Optional asynchronous set; makes q 1 at once while above 0.5 | | `r` | signal | Optional asynchronous reset; makes q 0 at once while above 0.5 and wins over s | | `q` | signal | Output, always 0 or 1 | | `qn` | signal | Opposite of q | ## Common parameters - `q0`: Output at the start (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `q0` | — | 0 | | Output at the start | _Parameter descriptions are in English in both languages._ ## Model An edge is a step at which clk is above 0.5 after being at or below 0.5 at the step before. At that step q takes the value d had at the previous step, that is the value just before the clock moved. This makes two flip-flops on one clock a proper shift register. The block has no direct feedthrough, so qn may feed d directly. A clk that is already high at t = 0 does not fire. While r is above 0.5, q is 0; otherwise, while s is above 0.5, q is 1; either one overrides the clock. An unwired s or r reads 0 and never forces q. ## Common mistakes - A clock that changes between two solver steps is only seen at the next step, so drive it from a PWM Generator output or another source the solver lands on. Data that changes at the same moment as the clock is captured at its old value, like a hold time in hardware. - A reset held high keeps q at 0 through every clock edge, and reset wins when s and r are both high. For peak-current-mode control, tie d high, clock it from the oscillator and drive r from the current comparator. q0 sets the starting value; the default 0 suits most designs, and 1 is for an output that must start high. ## Datasheet and sources There is no datasheet. q0 is the power-up state of the register in your design. The clock frequency and phase come from the signal that drives clk, such as the PWM carrier or a timer output in your MCU setup. ## Example Open the example with the command `file.openExample` and the name `demo:dff`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Discrete PI Controller (`dpi`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/dpi/ > A PI controller that runs once every sample time. ![dpi](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/dpi.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/dpi/) **Group:** Control · **Kind:** `{"block":"dpi","kind":"control"}` ## When to use it Use it for a current or voltage loop that runs in an MCU interrupt. Use PI Controller for a continuous design. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Error: reference minus feedback | | `clk` | signal | Optional clock; while wired the controller samples at each of its rising edges, and `ts` is the nominal period its discrete gains use. | | `out` | signal | Controller output, limited to lo and hi | ## Common parameters - `ts`: Time between samples; with the clk input wired, its rising edges, and ts is the period the gains use (Default: required) - `kp`: Strength of the reaction to error (Default: 1) - `ki`: Strength of the reaction to past error (Default: 0) - `lo`: Lowest value the output can reach (Default: -1e30) - `hi`: Highest value the output can reach (Default: 1e30) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `ts` | s | required | | Time between samples; with the clk input wired, its rising edges, and ts is the period the gains use | | `offset` | s | 0 | | Time of the first sample | | `kp` | — | 1 | | Strength of the reaction to error | | `ki` | 1/s | 0 | | Strength of the reaction to past error | | `method` | — | backward | | Calculation method for the integral: `forward`, `backward` or `tustin` | | `lo` | — | -1e30 | | Lowest value the output can reach | | `hi` | — | 1e30 | | Highest value the output can reach | | `kb` | 1/s | optional (off) | | Strength of the anti-windup correction | _Parameter descriptions are in English in both languages._ ## Model out = kp·e + I, where the integral I follows the rule in `method`: forward I[k] = I[k-1] + ki·ts·e[k-1], backward I[k] = I[k-1] + ki·ts·e[k], tustin uses the average of e[k] and e[k-1]. The output is clamped to `lo` ... `hi` and the integrator receives kb·(clamped - unclamped) back; an unset `kb` takes |ki/kp|. `kd` and `n` are ignored. There is direct feedthrough when kp is not 0 or the method is not `forward`. ## Common mistakes - ki is per second, not per sample. Set ts to 1/fs of the MCU Output Stage and use the same offset, or the controller runs at a different moment than the PWM stage expects. - A loop made only of control blocks that goes through this block is refused, unless kp is 0 and method is forward, so add a Unit Delay. lo and hi start at plus and minus 1e30, so set them to the modulator range. Problems rules: `compile.error` ## Datasheet and sources ts is the MCU control period, 1/fs. kp and ki come from your loop design: for a current loop with crossover frequency fc, kp is 2·pi·fc times L and ki is 2·pi·fc times R. lo and hi come from the voltage or duty range the modulator can produce. ## Example Open the example with the command `file.openExample` and the name `demo:dpi`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Discrete PID Controller (`dpid`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/dpid/ > A PID controller that runs once every sample time. ![dpid](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/dpid.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/dpid/) **Group:** Control · **Kind:** `{"block":"dpid","kind":"control"}` ## When to use it Use it when a digital loop needs a derivative term, such as a speed loop in firmware. Use Discrete PI Controller when it does not. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Error: reference minus feedback | | `clk` | signal | Optional clock; while wired the controller samples at each of its rising edges, and `ts` is the nominal period its discrete gains use. | | `out` | signal | Controller output, limited to lo and hi | ## Common parameters - `ts`: Time between samples; with the clk input wired, its rising edges, and ts is the period the gains use (Default: required) - `kp`: Strength of the reaction to error (Default: 1) - `ki`: Strength of the reaction to past error (Default: 0) - `kd`: Strength of the reaction to change (Default: 0) - `n`: How fast the derivative filter reacts (Default: 100) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `ts` | s | required | | Time between samples; with the clk input wired, its rising edges, and ts is the period the gains use | | `offset` | s | 0 | | Time of the first sample | | `kp` | — | 1 | | Strength of the reaction to error | | `ki` | 1/s | 0 | | Strength of the reaction to past error | | `kd` | s | 0 | | Strength of the reaction to change | | `n` | rad/s | 100 | | How fast the derivative filter reacts | | `method` | — | backward | | Calculation method for the integral and filter: `forward`, `backward` or `tustin` | | `lo` | — | -1e30 | | Lowest value the output can reach | | `hi` | — | 1e30 | | Highest value the output can reach | | `kb` | 1/s | optional (off) | | Strength of the anti-windup correction | _Parameter descriptions are in English in both languages._ ## Model out = kp·e + I + kd·N·(e - xf), where xf is the input after a first-order lag with pole `n` (rad/s), so the derivative acts on the error. The integral I and the filter state xf are both advanced with `method` (`forward`, `backward` or `tustin`). The output is clamped to `lo` ... `hi` with back-calculation anti-windup through `kb`. There is direct feedthrough when kp or kd is not 0 or the method is not `forward`. ## Common mistakes - With forward, n times ts must stay below 2, or the block is refused. With backward and n times ts well above 1, the filter stops filtering and the derivative amplifies noise. - kd is in seconds, ki is per second, and lo and hi start at plus and minus 1e30, so set them. A loop made only of control blocks needs a Unit Delay unless kp and kd are 0 and method is forward. Problems rules: `compile.error` ## Datasheet and sources ts is the MCU control period, 1/fs. kp, ki and kd come from your loop design at that sample rate. n is the derivative bandwidth you want, a few times the crossover and below about 1/ts, and lo and hi come from the actuator range. ## Example Open the example with the command `file.openExample` and the name `demo:dpid`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # dq to abc Transform (`dq2abc`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/dq2abc/ > Turns rotating d and q components back into three phase quantities in one block. ![dq2abc](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/dq2abc.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/dq2abc/) **Group:** Control · **Kind:** `{"block":"dq2abc","kind":"control"}` ## When to use it Use it after the current controllers to turn vd and vq into three phase voltage references for Space-Vector Modulator. ## Pins | Pin | Domain | Meaning | |---|---|---| | `d` | signal | Direct-axis component input | | `q` | signal | Quadrature-axis component input | | `theta` | signal | Frame angle in radians, electrical | | `zero` | signal | Optional zero-sequence input added to every phase; unwired it is 0. | | `a` | signal | Phase a output | | `b` | signal | Phase b output, 120 degrees behind a | | `c` | signal | Phase c output, 120 degrees ahead of a | ## Model The block applies `invPark` (`alpha = d*cos(theta) - q*sin(theta)`, `beta = d*sin(theta) + q*cos(theta)`) and then `invClarke` (`a = alpha`, `b = -alpha/2 + (sqrt(3)/2)*beta`, `c = -alpha/2 - (sqrt(3)/2)*beta`). The `zero` input is added to every phase (0 when unwired). With `q = 0` and `d = A` the outputs are `A*cos(theta)`, `A*cos(theta - 120 deg)` and `A*cos(theta + 120 deg)`. ## Common mistakes - The outputs are phase voltage references in V, not duties, so send them to Space-Vector Modulator (with the DC-link voltage on vdc) and not straight to Three-Phase PWM. Limit vd and vq with lo and hi of the PI Controller blocks so the vector stays inside the DC-link voltage divided by the square root of 3. - Use the same theta as the forward abc to dq Transform, in radians and electrical. An open theta reads 0. Problems rules: `duty.out_of_range`, `pin.unconnected` ## Datasheet and sources No datasheet applies. The vd and vq inputs are the outputs of your current controllers in V, and theta is the same electrical angle the forward transform uses. ## Example Open the example with the command `file.openExample` and the name `demo:dq2abc`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Droop Control (Grid-Forming) (`droop`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/droop/ > Sets an inverter's frequency and voltage amplitude from the power it delivers, so inverters in parallel share a load. ![droop](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/droop.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/droop/) **Group:** Control · **Kind:** `{"block":"droop","kind":"control"}` ## When to use it Use it for a grid-forming inverter that runs alone or in parallel with others on an island or microgrid: each inverter sets its own voltage and the droops share the load without a link between them. Use Three-Phase SRF-PLL for a grid-following inverter that injects current into a stiff grid. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | signal | Measured active power the inverter delivers, in W | | `q` | signal | Measured reactive power, in var, positive for an inductive load | | `theta` | signal | Angle of the voltage reference, in radians | | `w` | signal | Angular frequency of the voltage, in rad/s | | `e` | signal | Amplitude of the voltage reference, peak per phase, in V | ## Common parameters - `e0`: Voltage amplitude (peak, per phase) at the reactive power qset (Default: required) - `prated`: Rated active power: the base of kp (Default: required) - `kp`: Frequency droop per unit: the frequency falls by kp·f0 at the rated power (Default: required) - `kq`: Voltage droop per unit: the amplitude falls by kq·e0 at the rated reactive power (Default: required) - `fc`: Cutoff of the filter on the measured powers (Default: required) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `f0` | Hz | 50 | | Nominal frequency, at the power pset (50 Hz mains, IEC 60038:2009 Table 1) | | `e0` | V | required | | Voltage amplitude (peak, per phase) at the reactive power qset | | `prated` | W | required | | Rated active power: the base of kp | | `qrated` | var | optional (off) | | Rated reactive power: the base of kq (prated when absent) | | `kp` | — | required | | Frequency droop per unit: the frequency falls by kp·f0 at the rated power | | `kq` | — | required | | Voltage droop per unit: the amplitude falls by kq·e0 at the rated reactive power | | `fc` | Hz | required | | Cutoff of the filter on the measured powers | | `pset` | W | 0 | | Active power at which the frequency is f0 | | `qset` | var | 0 | | Reactive power at which the amplitude is e0 | | `theta0` | rad | 0 | | Angle at the start | _Parameter descriptions are in English in both languages._ ## Model The measured powers pass a first-order low-pass of cutoff fc, Pf and Qf. The frequency is w = 2*pi*f0*(1 - kp*(Pf - pset)/prated) and the amplitude e = e0*(1 - kq*(Qf - qset)/qrated); theta is the integral of w, kept between 0 and 2*pi. kp and kq are per-unit droops: with kp = 0.01 the frequency falls by 1 % of f0 when the power rises by prated. In steady state every inverter on one island runs at the same frequency, so kp1*P1/prated1 = kp2*P2/prated2: inverters with the same per-unit droop share active power by their ratings, whatever the lines between them. w stays between 0 and twice the nominal speed and e between 0 and 2*e0. The filters start at the set points, so the run starts at f0 and e0. The block has no direct feedthrough, so it can sit in the loop it feeds; it then reads the power of the previous step. Feed theta and e to Inverse Park (dq2abc) with d = e and q = 0 to get the three phase voltage references. ## Common mistakes - The droops assume a mainly inductive output impedance, where active power follows the angle and reactive power the amplitude. With a resistive line (low-voltage cables) the two couple and the sharing drifts; add series inductance or a virtual impedance. - Reactive power shares by the ratings only when the output impedances are in inverse proportion to the ratings, because the voltages at the inverters differ by the drops along their lines. Expect an error in the reactive share with unequal lines; active power still shares exactly. - q must be positive for an inductive load (current lagging the voltage), as Instantaneous Power (pq) gives it from the inverter's own voltage and current. A reversed current direction flips both powers and the droops push the wrong way. - A larger droop or a higher fc makes the sharing faster but less damped; with a few percent of droop keep fc at a few hertz, well below the line frequency, so the filter also removes the ripple at twice the line frequency of an unbalanced load. Problems rules: `pin.unconnected` ## Datasheet and sources There is no datasheet. e0 is the phase voltage peak of the grid the inverter forms (230 V rms is 325 V peak), prated and qrated are the inverter's ratings, and kp and kq come from the grid's rules or the microgrid's design: a few percent of frequency droop and a few percent of voltage droop at rated power. fc is a few hertz. ## Example Open the example with the command `file.openExample` and the name `demo:droop`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Expression (Fcn) (`expr`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/expr/ > Computes its output from a formula of up to eight inputs, the time and the circuit variables. ![expr](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/expr.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/expr/) **Group:** Control · **Kind:** `{"block":"expr","kind":"control"}` ## When to use it Use it for a formula no other block gives: a power p = in1*in2, a square root, a sensor's equation or a piecewise function. Importers make it for behavioural sources. Use Gain, Sum or Product for one plain operation. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in1` | signal | First input, in1 in the formula | | `in2` | signal | Second input | | `in3` | signal | Third input | | `in4` | signal | Fourth input | | `in5` | signal | Fifth input | | `in6` | signal | Sixth input | | `in7` | signal | Seventh input | | `in8` | signal | Eighth input | | `out` | signal | Value of the formula | ## Common parameters - `f`: Formula of in1 … in8, time and the circuit variables, for example in1*in2 (Default: required) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `f` | — | required | | Formula of in1 … in8, time and the circuit variables, for example in1*in2 | _Parameter descriptions are in English in both languages._ ## Model out = f(in1 … in8, time, circuit variables), evaluated once per accepted solver step with the same expression language as parameters (+ − * / ^, sqrt, exp, log, sin, cos, abs, min, max, if and the rest). An unconnected input reads 0. The expression is checked when the circuit is built, so a syntax error or an unknown name stops the build; a value that is not finite during the run stops it with the block's name. The block has direct feedthrough. ## Common mistakes - The formula runs once per step after the meters read the solution, so a source it drives follows one step late. Inside a tight loop keep maxStep small against the loop's time constants. - Code generation leaves this block out. A division by an input that reaches 0 stops the run; guard it, for example in1/max(in2, 1e-9). Problems rules: `compile.error`, `solver.control` ## Datasheet and sources There is no datasheet. ## Example Open the example with the command `file.openExample` and the name `demo:expr`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # FFT Block (`fft`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/fft/ > Samples a signal and outputs one bin of its discrete Fourier transform once a period. ![fft](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/fft.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/fft/) **Group:** Control · **Kind:** `{"block":"fft","kind":"control"}` ## When to use it Use it to model the harmonic analysis a digital controller runs on its samples, aliasing included. Use Harmonic Meter for a continuous measurement and analysis.fft for the spectrum after the run. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal to sample | | `amp` | signal | Peak amplitude of the bin | | `phase` | signal | Phase in degrees, as the phase of a Sine Source | ## Common parameters - `f`: Fundamental frequency: one transform per period (50 Hz mains, IEC 60038:2009 Table 1) (Default: 50) - `samples`: Samples per period; harmonics up to samples/2 − 1 are resolved, higher ones alias (Default: 64) - `order`: Bin read out: the harmonic order, below samples/2 (Default: 1) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `f` | Hz | 50 | | Fundamental frequency: one transform per period (50 Hz mains, IEC 60038:2009 Table 1) | | `samples` | — | 64 | | Samples per period; harmonics up to samples/2 − 1 are resolved, higher ones alias | | `order` | — | 1 | | Bin read out: the harmonic order, below samples/2 | _Parameter descriptions are in English in both languages._ ## Model The input is sampled at t = k/(samples*f); the instants are events, so the solver lands a step on each. At the last sample of every period the block takes bin order of the DFT of that period's samples, the bin a radix-2 FFT gives: a = (2/N)*sum(x_j*sin(2*pi*order*j/N)) and b the same with cos, amp = sqrt(a^2 + b^2) and phase = atan2(b, a) in degrees. The outputs hold until the next period ends and are 0 before the first one does. ## Common mistakes - Harmonics above samples/2 fold back onto lower bins, as in a real ADC without an anti-aliasing filter. Raise samples, or filter the input, when the signal has switching ripple. - The output changes only once a period, so a loop closed through it sees a delay of up to two periods. Problems rules: `pin.unconnected` ## Datasheet and sources In a microcontroller the samples per period is the ADC trigger rate divided by the line frequency; a DSP library FFT of N points matches this block with samples set to N. ## Example Open the example with the command `file.openExample` and the name `demo:fft`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # FIR Filter (`fir`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/fir/ > Filters a sampled signal with a fixed list of weights. ![fir](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/fir.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/fir/) **Group:** Control · **Kind:** `{"block":"fir","kind":"control"}` ## When to use it Use it for a moving average or any linear-phase filter in firmware. Use IIR Filter for a sharper response with fewer coefficients. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal to filter, sampled every ts | | `out` | signal | Filtered output, held between samples | ## Common parameters - `ts`: Time between samples (Default: required) - `coeffs`: Filter weights, separated by commas (Default: required) - `offset`: Time of the first sample (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `ts` | s | required | | Time between samples | | `offset` | s | 0 | | Time of the first sample | | `coeffs` | — | required | | Filter weights, separated by commas | _Parameter descriptions are in English in both languages._ ## Model coeffs lists the taps h0, h1, ..., and y[k] = h0·u[k] + h1·u[k-1] + .... At most 4096 taps are allowed. There is no feedback, so the filter is always stable, and its DC gain is the sum of the taps. The history starts at zero. The block has direct feedthrough only when h0 is not 0. ## Common mistakes - The coefficients are not scaled for you. A moving average of N samples needs N coefficients of 1/N, and coefficients that add up to 1.2 give a DC gain of 1.2. - The first outputs start from zero history, so there is a short start-up transient. A symmetric filter also delays the signal by half its length, which costs phase inside a control loop, so keep it short there. ## Datasheet and sources ts is the sample time of the data the filter runs on, the 1/fs of your interrupt. The coefficients come from a filter design tool for that sample rate, or are 1/N for a moving average. ## Example Open the example with the command `file.openExample` and the name `demo:fir`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Gain (`gain`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/gain/ > Multiplies the input by a fixed factor k. ![gain](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/gain.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/gain/) **Group:** Control · **Kind:** `{"block":"gain","kind":"control"}` ## When to use it Use it to change units or scale a signal. Use Product to multiply two signals and Lookup Table for a curve. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal to scale | | `out` | signal | Input times k | ## Common parameters - `k`: How much the input is multiplied (Default: 1) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `k` | — | 1 | | How much the input is multiplied | _Parameter descriptions are in English in both languages._ **Use for:** Unit scaling · Sensor scales · Per-unit conversion **Not for:** Multiplying two signals → [`product`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/product/) · Nonlinear curves → [`lookup`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/lookup/) ## Formulas | Formula | Equation | Source | |---|---|---| | Gain | out = k·in | Ogata, Modern Control Engineering, 5th ed. (2010), ch. 2 (block diagrams) | | Gain in decibels | G = 20·log10(abs(k)) | Franklin, Powell & Emami-Naeini, Feedback Control of Dynamic Systems, 8th ed. (2019), ch. 6 | ## Quick check Inputs: - `k`: Gain = 10m —, `k` - `u`: Input value = 400 — Outputs: - `y`: Output = `k*u` — - `gdb`: Gain in dB = `20*log10(abs(k))` — ## Model logic - The output is k times the input at every step, with no state and no dynamics, so it follows the input in the same step (direct feedthrough). - Any finite k is accepted, including 0 and negative values, which flip the sign; an unconnected input reads 0. - A loop made only of blocks with direct feedthrough is an algebraic loop: the build stops and names the blocks in the loop. ## Model out = k*in, with no dynamics. The block has direct feedthrough, so the output follows the input within the same step. A negative k flips the sign. ## Common mistakes - A loop made only of blocks with no delay, such as Gain, Sum and Product, stops the run. Put an Integrator, Sample Delay or Sample and Hold in the loop. - Gain does not check units, so a factor that mixes per-unit and SI values passes without a warning. Write k as an expression such as 1/Vdc so that it follows design changes. Problems rules: `solver.control` ## Datasheet and sources No datasheet applies. The value of k comes from your design, such as a unit factor, a pole-pair count or a sensor scale. ## Example Open the example with the command `file.openExample` and the name `demo:gain`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Harmonic Meter (`harmonic`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/harmonic/ > The amplitude and phase of one harmonic of a signal, while the circuit runs. ![harmonic](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/harmonic.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/harmonic/) **Group:** Control · **Kind:** `{"block":"harmonic","kind":"control"}` ## When to use it Use it to act on one harmonic during the run, such as a selective harmonic compensator, or to check a filter against a limit on one order. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal to measure | | `freq` | signal | Optional fundamental frequency in hertz, such as a PLL output | | `amp` | signal | Peak amplitude of the harmonic | | `phase` | signal | Phase in degrees, as the phase of a Sine Source | ## Common parameters - `f`: Fundamental frequency: the window is cycles/f seconds; a wired freq input replaces it (50 Hz mains, IEC 60038:2009 Table 1) (Default: 50) - `order`: Harmonic order measured: 1 is the fundamental, 3 the third harmonic (Default: 1) - `cycles`: Window length in periods of the fundamental; the harmonic window of IEC 61000-4-7:2002+A1:2008 is 10 at 50 Hz and 12 at 60 Hz (Default: 1) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `f` | Hz | 50 | | Fundamental frequency: the window is cycles/f seconds; a wired freq input replaces it (50 Hz mains, IEC 60038:2009 Table 1) | | `order` | — | 1 | | Harmonic order measured: 1 is the fundamental, 3 the third harmonic | | `cycles` | — | 1 | | Window length in periods of the fundamental; the harmonic window of IEC 61000-4-7:2002+A1:2008 is 10 at 50 Hz and 12 at 60 Hz | _Parameter descriptions are in English in both languages._ ## Model The harmonic of order n is amp*sin(n*theta + phase), where theta is the fundamental angle 2*pi*f*t, or the integral of 2*pi*freq while freq is wired. Over the sliding window a = 2*mean(in*sin(n*theta)) and b = 2*mean(in*cos(n*theta)); amp = sqrt(a^2 + b^2) and phase = atan2(b, a) in degrees. A Sine Source with phase 30 reads phase 30 at order 1. ## Common mistakes - The phase is measured against the fundamental angle from t = 0, not against the signal's own zero crossing. Compare two Harmonic Meters with the same f to get the phase between two signals. - An order above half the samples per period of a coarse step is not resolved. Keep at least 20 steps in one period of the harmonic. Problems rules: `pin.unconnected` ## Datasheet and sources Harmonic limits, such as IEC 61000-3-2 for equipment up to 16 A, are given per order in amperes RMS; the RMS of the harmonic is amp divided by sqrt(2). ## Example Open the example with the command `file.openExample` and the name `demo:harmonic`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Relay with Hysteresis (`hysteresis`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/hysteresis/ > Switches its output to one level when the input rises above a threshold and back when it falls below a lower one. ![hysteresis](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/hysteresis.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/hysteresis/) **Group:** Control · **Kind:** `{"block":"hysteresis","kind":"control"}` ## When to use it Use it for a bang-bang (hysteresis) current controller, a thermostat, an under-voltage lockout or a Schmitt trigger. Use Comparator to compare two signals. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal input | | `out` | signal | yon or yoff | ## Common parameters - `on`: Input above which the output switches to yon (Default: 0.5) - `off`: Input below which the output switches to yoff; not above on (Default: -0.5) - `yon`: Output after the input rises above on (Default: 1) - `yoff`: Output after the input falls below off, and at the start (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `on` | — | 0.5 | | Input above which the output switches to yon | | `off` | — | -0.5 | | Input below which the output switches to yoff; not above on | | `yon` | — | 1 | | Output after the input rises above on | | `yoff` | — | 0 | | Output after the input falls below off, and at the start | _Parameter descriptions are in English in both languages._ ## Model The output is yon while the input is above on, yoff while it is below off, and keeps its last value in between, so the band from off to on is the hysteresis. It starts at yoff unless the input starts above on. on must not be below off; with on = off it is a comparator against that threshold. Code generation writes it with the held level in the state struct. ## Common mistakes - The output changes only at a solver step, so the input can overshoot a threshold by up to one step's change. Keep maxStep small against how fast the input crosses the band. - off above on is refused. A noisy input needs a band wider than its noise, or the output chatters at every crossing. Problems rules: `compile.error` ## Datasheet and sources There is no datasheet. For an under-voltage lockout, on and off are the rising and falling thresholds in the controller's data sheet. ## Example Open the example with the command `file.openExample` and the name `demo:hysteresis`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # IIR Filter (Biquad Cascade) (`iir`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/iir/ > Filters a sampled signal with a chain of second-order sections. ![iir](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/iir.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/iir/) **Group:** Control · **Kind:** `{"block":"iir","kind":"control"}` ## When to use it Use it for Butterworth, Chebyshev or elliptic filters exported from a filter design tool. Use FIR Filter when you need linear phase. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal to filter, sampled every ts | | `out` | signal | Filtered output, held between samples | ## Common parameters - `ts`: Time between samples (Default: required) - `sections`: Filter sections, six numbers each (Default: required) - `gain`: Overall gain applied to the input (Default: 1) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `ts` | s | required | | Time between samples | | `offset` | s | 0 | | Time of the first sample | | `sections` | — | required | | Filter sections, six numbers each | | `gain` | — | 1 | | Overall gain applied to the input | | `lo` | — | -1e30 | | Lowest value the output can reach; the limited output is what the filter remembers | | `hi` | — | 1e30 | | Highest value the output can reach; the limited output is what the filter remembers | | `y0` | — | 0 | | Output at the start while the input is zero (needs a pole at z = 1) | _Parameter descriptions are in English in both languages._ ## Model sections holds six numbers per section, b0, b1, b2, a0, a1, a2, one section after the other, at most 64 sections. Each section is (b0 + b1·z^-1 + b2·z^-2) / (a0 + a1·z^-1 + a2·z^-2) with a0 not 0. The input is first multiplied by gain, then passes through the sections in order. The block has direct feedthrough only when gain and every b0 are not 0. ## Common mistakes - Each section lists the top part first: b0, b1, b2, a0, a1, a2. Swapping the two halves gives a different filter with no warning, and a list whose length is not a multiple of 6 is refused. - Design the sections for the same ts the block uses. If your design tool gives the overall gain as a separate number, enter it as gain; if the gain is already inside the b coefficients, leave gain at 1. Problems rules: `compile.error` ## Datasheet and sources ts is the sample time of the data, 1/fs. The sections and the gain come from a filter design tool, using your cutoff, order and filter family at that sample rate, exported as second-order sections. ## Example Open the example with the command `file.openExample` and the name `demo:iir`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Integrator (`integrator`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/integrator/ > Adds up its input over time, with optional output limits. ![integrator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/integrator.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/integrator/) **Group:** Control · **Kind:** `{"block":"integrator","kind":"control"}` ## When to use it Use it for a plant model or a flux estimate. Use PI Controller for a ready controller and Angle Generator for an angle. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal to add up over time | | `out` | signal | Running total, kept between lo and hi | ## Common parameters - `k`: How fast the output builds up (Default: 1) - `lo`: Lowest value the output can reach (Default: -1e30) - `hi`: Highest value the output can reach (Default: 1e30) - `x0`: Initial output (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `k` | 1/s | 1 | | How fast the output builds up | | `lo` | — | -1e30 | | Lowest value the output can reach | | `hi` | — | 1e30 | | Highest value the output can reach | | `x0` | — | 0 | | Initial output | _Parameter descriptions are in English in both languages._ **Use for:** Plant models · Flux estimates · Ramps from a constant **Not for:** Ready-made controllers → [`pi`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/pi/) · Rotor and grid angles → [`angle`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/angle/) ## Formulas | Formula | Equation | Source | |---|---|---| | Integrator | y = x0 + k·∫u dt | Ogata, Modern Control Engineering, 5th ed. (2010), ch. 2 | | Output for a constant input | y = min(x0 + k·u·t, hi) | Ogata, Modern Control Engineering, 5th ed. (2010), ch. 2 | | Time to reach hi | t = (hi - x0)/(k·u) | Ogata, Modern Control Engineering, 5th ed. (2010), ch. 2 | ## Quick check Inputs: - `k`: Integration gain = 1k 1/s, `k` - `u`: Constant input = 500m — - `x0`: Initial output = 0 —, `x0` - `t`: Time = 2m s - `hi`: Upper limit = 10 —, `hi` Outputs: - `y`: Output after t = `min(x0 + k*u*t, hi)` — - `thi`: Time to reach hi = `(hi - x0)/(k*u)` s ## Model logic - Once per accepted step the stored value grows by k·h·(in + previous in)/2 (trapezoid); a step that starts on a switching edge uses the input at its end. - The stored value itself is clamped to lo and hi after each step, so it comes off a limit as soon as the input reverses (anti-windup). - The output starts at x0, and the defaults of -1e30 and 1e30 leave it unlimited. - The block has no direct feedthrough, so it breaks loops; an input that is not finite stops the run and names the block. ## Model out = x0 + integral(k*in dt), held between lo and hi. The solver uses the trapezoidal rule over each accepted step. The limit is applied to the stored value itself, so the total comes off a limit as soon as the input reverses (anti-windup). The block has no direct feedthrough, so it breaks loops with no delay. ## Common mistakes - The unit of k is 1/s. A value of 100 adds up 100 units per second for each unit of input, so a time constant of 10 ms means k = 100, not 0.01. - With the default limits, a constant offset on the input makes the output grow without bound. Set lo and hi when the Integrator is part of a controller. - Because it has no direct feedthrough, the solver may read the signal that drives it one step late. Keep the maximum step well below the fastest time constant of the loop. Problems rules: `control.saturated` ## Datasheet and sources No datasheet applies. The value of k is the inverse of your integration time, x0 is the starting value, and lo and hi follow the range of the signal the integral feeds. ## Example Open the example with the command `file.openExample` and the name `demo:integrator`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Inverse Clarke Transform (`invClarke`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/invClarke/ > Turns alpha and beta back into three phase quantities. ![invClarke](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/invClarke.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/invClarke/) **Group:** Control · **Kind:** `{"block":"invClarke","kind":"control"}` ## When to use it Use it to make three-phase references from a vector in the fixed frame. Use dq to abc Transform when the command is in the rotating frame. ## Pins | Pin | Domain | Meaning | |---|---|---| | `alpha` | signal | Component along the axis of phase a | | `beta` | signal | Component 90 degrees ahead of alpha | | `zero` | signal | Optional zero-sequence input added to every phase; unwired it is 0. | | `a` | signal | Phase a output, same as alpha | | `b` | signal | Phase b output | | `c` | signal | Phase c output | ## Model The outputs are `a = alpha`, `b = -alpha/2 + (sqrt(3)/2)*beta` and `c = -alpha/2 - (sqrt(3)/2)*beta`. The `zero` input is added to every phase; unwired it is 0, and then `a + b + c` = 0 always. Fed with the `zero` output of `clarke` it is the exact inverse of `clarke` for any input. ## Common mistakes - If the references go to Space-Vector Modulator, that block adds the zero-sequence part itself, so do not add one here. - The outputs are voltage or current references, not duties. Feeding them straight to Three-Phase PWM pushes the duty outside 0 to 1, so go through Space-Vector Modulator set to duty. Problems rules: `duty.out_of_range` ## Datasheet and sources No datasheet applies. The inputs are commands in the fixed frame from your controller, in V or A, and the three outputs keep that unit. ## Example Open the example with the command `file.openExample` and the name `demo:invClarke`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Inverse Park Transform (`invPark`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/invPark/ > Rotates a d-q vector back into the fixed alpha-beta frame. ![invPark](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/invPark.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/invPark/) **Group:** Control · **Kind:** `{"block":"invPark","kind":"control"}` ## When to use it Use it after the current controllers to turn vd and vq into a fixed voltage vector. Use dq to abc Transform for both steps. ## Pins | Pin | Domain | Meaning | |---|---|---| | `d` | signal | Direct-axis component input | | `q` | signal | Quadrature-axis component input | | `theta` | signal | Frame angle in radians, electrical | | `alpha` | signal | Component along the axis of phase a | | `beta` | signal | Component 90 degrees ahead of alpha | ## Model The outputs are alpha = d*cos(theta) - q*sin(theta) and beta = d*sin(theta) + q*cos(theta). At the same theta it is the exact inverse of Park Transform. The angle is in radians and can be any value. ## Common mistakes - Use the same theta signal as the forward Park Transform or abc to dq Transform in the loop. Otherwise the two transforms turn to different frames and the controller sees a rotating error, and a sampled angle on one side with a continuous angle on the other does the same. - An open theta reads 0 and the vector stays fixed. This transform does not limit, so limit vd and vq with lo and hi of the PI Controller blocks in front of it. Problems rules: `pin.unconnected` ## Datasheet and sources No datasheet applies. The d and q inputs are voltage or current commands from your controllers, and theta is the same electrical angle the forward transform uses. ## Example Open the example with the command `file.openExample` and the name `demo:invPark`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Limiter (`limiter`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/limiter/ > Keeps the input between a lower limit lo and an upper limit hi. ![limiter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/limiter.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/limiter/) **Group:** Control · **Kind:** `{"block":"limiter","kind":"control"}` ## When to use it Use it to bound a reference, command or duty from a block with no limits. Inside a controller, use the limits of PI Controller. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal to limit | | `out` | signal | Input held between lo and hi | ## Common parameters - `lo`: Lower limit (Default: -1e30) - `hi`: Upper limit (Default: 1e30) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `lo` | — | -1e30 | | Lower limit | | `hi` | — | 1e30 | | Upper limit | _Parameter descriptions are in English in both languages._ **Use for:** Duty limits · Current reference limits · Voltage commands **Not for:** Slew-rate limits → [`rateLimiter`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/rateLimiter/) · Limits inside a controller → [`pi`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/pi/) ## Formulas | Formula | Equation | Source | |---|---|---| | Saturation | y = min(max(u, lo), hi) | Åström & Murray, Feedback Systems, 2nd ed. (2021), ch. 11 (actuator saturation and windup) | | Amount removed | Δ = u - y | Åström & Murray, Feedback Systems, 2nd ed. (2021), ch. 11 | ## Quick check Inputs: - `u`: Input value = 1.2 — - `lo`: Lower limit = 0 —, `lo` - `hi`: Upper limit = 950m —, `hi` Outputs: - `y`: Output = `limit(u, lo, hi)` — - `cut`: Amount removed = `u - limit(u, lo, hi)` — ## Model logic - The output is min(max(in, lo), hi) at every step, with no state and direct feedthrough. - The defaults of -1e30 and 1e30 pass every value; lo equal to hi gives a constant, and lo above hi stops the build. - The block only limits its own output and tells nothing to the blocks before it, so an Integrator or PI Controller in front keeps winding up. ## Model out = min(max(in, lo), hi), with direct feedthrough and no state. With the defaults of -1e30 and 1e30 the block passes every value. ## Common mistakes - A Limiter does not stop an Integrator or PI Controller in front of it from winding up. If they have no limits, set lo and hi on them too. - A Limiter that sits at one bound for most of the run means the loop is not regulating. Widen the limit or lower the reference. - lo must not be above hi. Swapped limits stop the build. Problems rules: `control.saturated`, `compile.error` ## Datasheet and sources No datasheet applies. The limits come from the hardware you protect, such as the rated device current, the DC-link voltage, or 0 and 1 for a duty. ## Example Open the example with the command `file.openExample` and the name `demo:limiter`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Lookup Table (`lookup`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/lookup/ > Looks up an output from a table of points, with straight lines between them. ![lookup](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/lookup.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/lookup/) **Group:** Control · **Kind:** `{"block":"lookup","kind":"control"}` ## When to use it Use it for a measured curve, a nonlinear sensor or a torque-speed profile. Use Gain for a straight line and Limiter for a plain cutoff. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Value to look up in xs | | `out` | signal | Matching value from ys | ## Common parameters - `xs`: Input points, smallest first, with commas (Default: required) - `ys`: Output values for those points, with commas (Default: required) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `xs` | — | required | | Input points, smallest first, with commas | | `ys` | — | required | | Output values for those points, with commas | _Parameter descriptions are in English in both languages._ ## Model Between two points the output is the straight line through them, y = y0 + (y1 - y0)*(x - x0)/(x1 - x0). Below the first point it holds the first ys value, and above the last point it holds the last one (no extrapolation). The block has direct feedthrough and no state. Both lists are comma separated and can use expressions. ## Common mistakes - xs must rise strictly, and xs and ys must have the same length and not be empty, or the build stops. A repeated x value is not allowed, so for a vertical step use two points very close together. - Outside the table the output stays flat and is not extended. A signal that leaves the range looks like saturation without a warning, so cover the full range of the input. Problems rules: `compile.error` ## Datasheet and sources The table comes from your own data or a datasheet graph, such as an NTC resistance against temperature or a saturation curve read at several points. Both columns use the units of the signals around the block. ## Example Open the example with the command `file.openExample` and the name `demo:lookup`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # 2-D Lookup Table (`lookup2d`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/lookup2d/ > Looks up an output from a table over two inputs, with bilinear interpolation between the grid points. ![lookup2d](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/lookup2d.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/lookup2d/) **Group:** Control · **Kind:** `{"block":"lookup2d","kind":"control"}` ## When to use it Use it for a value that depends on two signals: a switching-loss map against current and temperature, a flux map Ld or Lq against id and iq, or an MTPA table. Use Lookup Table for one input. ## Pins | Pin | Domain | Meaning | |---|---|---| | `x` | signal | First input, looked up in xs | | `y` | signal | Second input, looked up in ys | | `out` | signal | Interpolated value from zs | ## Common parameters - `xs`: Grid points of input x, smallest first, with commas (Default: required) - `ys`: Grid points of input y, smallest first, with commas (Default: required) - `zs`: Table values: one row per xs value separated by semicolons, one value per ys value in each row (Default: required) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `xs` | — | required | | Grid points of input x, smallest first, with commas | | `ys` | — | required | | Grid points of input y, smallest first, with commas | | `zs` | — | required | | Table values: one row per xs value separated by semicolons, one value per ys value in each row | _Parameter descriptions are in English in both languages._ ## Model zs holds one row per xs value, rows separated by semicolons, and each row one value per ys value, so the value in row i and column j belongs to the point (xs i, ys j). Inside a grid cell the output is the bilinear interpolation of the four corners: first along y in the two rows around x, then along x between those two results. It is exact at the grid points and for any function a + b·x + c·y + d·x·y. Outside the grid each input is held at the nearest edge (no extrapolation). The block has direct feedthrough and no state. ## Common mistakes - xs and ys must rise strictly, zs must have exactly one row per xs value and one value per ys value in every row, or the build stops and names the row. The table is at most 65536 values. - Outside the grid the output stays flat. An operating point that leaves the table looks like saturation without a warning, so cover the full range of both inputs. Problems rules: `compile.error` ## Datasheet and sources The table comes from your own data or from a data sheet's family of curves, such as the turn-on energy against current at two or three temperatures; each curve read at the same currents is one column. Code generation writes the interpolation as a chain of comparisons for a grid of up to 64 points per axis and 256 values; a larger table is left out with the reason. ## Example Open the example with the command `file.openExample` and the name `demo:lookup2d`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Second-Order Low-Pass (`lowpass2`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/lowpass2/ > Smooths a signal by removing changes faster than a corner frequency. ![lowpass2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/lowpass2.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/lowpass2/) **Group:** Control · **Kind:** `{"block":"lowpass2","kind":"control"}` ## When to use it Use it to smooth a measurement or model a sensor or an LC filter. Use Notch Filter to remove one frequency. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal to filter | | `out` | signal | Filtered signal | ## Common parameters - `f0`: Corner frequency (Default: required) - `q`: How sharp the filter is at the corner (Default: 0.7071) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `f0` | Hz | required | | Corner frequency | | `q` | — | 0.7071 | | How sharp the filter is at the corner | _Parameter descriptions are in English in both languages._ **Use for:** Measurement filters · Sensor models · LC filter models **Not for:** Removing one frequency → [`notch`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/notch/) · Passing one band → [`bandpass`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/bandpass/) ## Formulas | Formula | Equation | Source | |---|---|---| | Second-order low-pass | H(s) = ω0²/(s² + (ω0/q)·s + ω0²), ω0 = 2π·f0 | Franklin, Powell & Emami-Naeini, Feedback Control of Dynamic Systems, 8th ed. (2019), ch. 6 | | Damping ratio | ζ = 1/(2·q) | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), ch. 8 (quadratic pole response) | | -3 dB frequency | f3 = f0·√(1 - 2ζ² + √((1 - 2ζ²)² + 1)) | Ogata, Modern Control Engineering, 5th ed. (2010), ch. 7 | | Gain at f | G = -10·log10((1 - (f/f0)²)² + (f/(f0·q))²) | Franklin, Powell & Emami-Naeini, Feedback Control of Dynamic Systems, 8th ed. (2019), ch. 6 | ## Quick check Inputs: - `f0`: Corner frequency = 1k Hz, `f0` - `q`: Quality factor = 707.1m —, `q` - `f`: Frequency = 5k Hz Outputs: - `zeta`: Damping ratio = `1/(2*q)` — - `f3db`: -3 dB frequency = `f0*sqrt(1 - 2*zeta^2 + sqrt((1 - 2*zeta^2)^2 + 1))` Hz - `gdb`: Gain at f in dB = `-10*log10((1 - (f/f0)^2)^2 + (f/(f0*q))^2)` — ## Model logic - The block is a Transfer Function with num ω0² and den 1, ω0/q, ω0², ω0 = 2π·f0: the DC gain is 1 and the gain at f0 is q. - It advances by the trapezoid (Tustin) once per accepted step, which moves the corner slightly down as the step grows. - The state starts at zero, so the output starts at 0 even when the input does not, and there is no initial-output parameter. - The block has no direct feedthrough, and an f0 or q that is not above zero and finite is refused. ## Model H(s) = w0² / (s² + (w0/Q)·s + w0²) with w0 = 2·pi·f0. The DC gain is 1, the gain at f0 is Q, and the response falls at 40 dB per decade above f0. The default q of 0.7071 is a Butterworth response (-3 dB at f0); a larger q peaks near f0. The block has no direct feedthrough and is integrated with the trapezoidal rule, like Transfer Function. ## Common mistakes - f0 is in hertz, not rad/s, so a rad/s value puts the corner 6.28 times too high. Both f0 and q must be above zero. - The solver moves the corner down a little, so keep maxStep below one twentieth of the period of f0 for about 1 percent error. Inside a feedback loop the filter adds phase lag, so count it in the loop design. Problems rules: `compile.error` ## Datasheet and sources There is no datasheet. f0 comes from your filter design: a measurement filter usually sits a decade above the loop crossover and below the switching ripple, and an LC filter takes it from its L and C values. Use q of 0.7071 unless you need a specific damping. ## Example Open the example with the command `file.openExample` and the name `demo:lowpass2`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Maximum (`max`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/max/ > Outputs the larger of two signals. ![max](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/max.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/max/) **Group:** Control · **Kind:** `{"block":"max","kind":"control"}` ## When to use it Use it for a lower bound that is itself a signal, such as a minimum duty from another block. Use Limiter for fixed bounds. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in1` | signal | First input | | `in2` | signal | Second input | | `out` | signal | The larger of the two inputs | ## Model out = max(in1, in2), with direct feedthrough and no state. For three signals, chain two Maximum blocks. An unconnected input reads 0, so a negative signal against an open pin returns 0. ## Common mistakes - An input left open reads 0, so a negative signal never shows through. Wire both inputs. - The output has a corner where the two inputs cross, so a loop that depends on the slope can chatter there. For a plain fixed bound, use Limiter instead. Problems rules: `pin.unconnected` ## Datasheet and sources No datasheet applies. Both inputs come from your control design, and the output has their common unit. ## Example Open the example with the command `file.openExample` and the name `demo:max`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # MCU Output Stage (`mcu`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/mcu/ > Adds the timing of a digital controller to a duty command before the PWM. ![mcu](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/mcu.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/mcu/) **Group:** Control · **Kind:** `{"block":"mcu","kind":"control"}` ## When to use it Use it between a duty calculation and a PWM block to see what a digital controller does to your loop. Leave it out for an ideal controller. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | signal | Duty command for phase a, 0 to 1 | | `b` | signal | Duty command for phase b, 0 to 1 | | `c` | signal | Duty command for phase c, 0 to 1 | | `da` | signal | Duty for phase a; goes to Three-Phase PWM | | `db` | signal | Duty for phase b; goes to Three-Phase PWM | | `dc` | signal | Duty for phase c; goes to Three-Phase PWM | | `overrun` | signal | 1 when the code takes the whole period or more, else 0 | | `load` | signal | CPU load of the code, tIsr times fs (0 without tIsr) | ## Common parameters - `fs`: How often the controller code runs (Default: required) - `fpwm`: Carrier frequency of the PWM it drives (Default: required) - `delay`: Computing delay, counted in samples (Default: 1) - `align`: Where in the carrier the code runs: `start` or `peak` (Default: start) - `update`: When a new duty takes effect: `period` or `immediate` (`end`) (Default: period) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `fs` | Hz | required | | How often the controller code runs | | `fpwm` | Hz | required | | Carrier frequency of the PWM it drives | | `delay` | — | 1 | | Computing delay, counted in samples | | `align` | — | start | | Where in the carrier the code runs: `start` or `peak` | | `update` | — | period | | When a new duty takes effect: `period` or `immediate` (`end`) | | `counts` | — | optional (off) | | Timer counts that set duty resolution | | `bits` | — | optional (off) | | Duty resolution in bits | | `tIsr` | s | optional (off) | | Time the code takes each run (replaces delay) | | `cycles` | — | optional (off) | | CPU cycles the code takes each run | | `fclk` | Hz | optional (off) | | CPU clock that counts the cycles | _Parameter descriptions are in English in both languages._ ## Model The ISR fires every 1/fs at the carrier valley t = k/fpwm (align = start) or the peak t = (k + 1/2)/fpwm (peak). At each instant the three commands are clamped to 0..1 and ready after delay samples. With update = period they reach the registers at the next carrier valley, with immediate (or end) as soon as they are ready, and they are rounded to a multiple of 1/counts (bits gives counts = 2^bits). The registers are 0 until the first update. With an execution time (tIsr, or cycles of the clock fclk) in place of delay, each ISR starts at its instant, or when the previous one returns if that is later, and its duty is ready tIsr after it starts. An ISR that cannot start before the next instant is lost, and its duty is never written. The output load is tIsr times fs, and overrun is 1 when load is 1 or more. Only the timing is modelled, not the controller arithmetic. ## Common mistakes - The block captures whatever its inputs hold at the interrupt time. Give the Zero-Order Hold and Discrete PI Controller ahead of it ts = 1/fs and the matching offset (0 for start, half a PWM period for peak), or the controller runs at a different moment than the PWM stage expects. - delay counts from the block's own interrupt instant, not from the ADC sample. With the sample at that instant (zoh offset 0 for start), delay 1 and update period load the duty of the sample at k/fs into the register at (k + 1)/fs, the classic one-period latency. If the ADC is triggered later than the interrupt instant (an offset after the valley, such as a trigger delay that cancels a sensor's group delay), the block captures the duty computed from the previous sample, which already costs one period: use delay 0 for the classic latency, since delay 1 then gives two periods. - fpwm must equal the freq of the Three-Phase PWM it feeds. The valley timing assumes a triangle carrier with phase 0, so a sawtooth shape or a phase setting does not match. - The inputs must be duty values from 0 to 1. A modulation index from Space-Vector Modulator in its default output m (-1 to 1) loses its negative half, so set that output to duty; delay counts interrupt samples, not seconds. - With the fixed-step solver the interrupt and register instants must fall on the step grid, so maxStep should divide 1/fs and 1/fpwm evenly. A maxStep above 1/fs skips interrupt instants. ## Datasheet and sources There is no datasheet. fs is the interrupt or ADC trigger rate of your timer setup, and fpwm follows from the timer clock and period register (f_timer divided by 2 times the period for an up-down counter). delay is the measured interrupt run time divided by 1/fs, and counts is the period register value, or bits its width. tIsr is the measured interrupt run time; cycles is a cycle count, such as the estimate cargo xtask armgcc prints for the generated STM32G474 code, with fclk the CPU clock (170 MHz on that part). ## Example Open the example with the command `file.openExample` and the name `demo:mcu`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Memory (one-step delay) (`memory`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/memory/ > Outputs its input as it was at the previous solver step. ![memory](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/memory.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/memory/) **Group:** Control · **Kind:** `{"block":"memory","kind":"control"}` ## When to use it Use it for a difference equation over the solver's steps: a counter, an edge detector (the input and its value one step ago), or a loop that needs a delay to have no algebraic loop. It is what a PLECS Memory block imports as. Use Sample Delay or zDelay for a delay of one sample period. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal to delay | | `out` | signal | The input at the previous solver step | ## Common parameters - `x0`: Initial output (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `x0` | — | 0 | | Initial output | _Parameter descriptions are in English in both languages._ ## Model out(k) = in(k-1), where k counts the accepted solver steps; before the first step the output is x0. The input is taken after every other block has run at a step, so the delay is one step whether or not the block sits in a loop, and the block has no direct feedthrough, so a loop through it is not an algebraic loop. ## Common mistakes - The delay is one solver step, not a fixed time: with a variable step it changes with the step, and a smaller maxStep makes it shorter. For a delay in seconds use Transport Delay, and for one sample period Sample Delay. - Code generation leaves it out: firmware has no solver step. At a sample time use zDelay. Problems rules: `compile.error` ## Datasheet and sources There is no datasheet. ## Example Open the example with the command `file.openExample` and the name `demo:memory`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Minimum (`min`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/min/ > Outputs the smaller of two signals. ![min](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/min.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/min/) **Group:** Control · **Kind:** `{"block":"min","kind":"control"}` ## When to use it Use it for an upper bound that is itself a signal, such as a current limit that depends on temperature. Use Limiter for fixed bounds. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in1` | signal | First input | | `in2` | signal | Second input | | `out` | signal | The smaller of the two inputs | ## Model out = min(in1, in2), with direct feedthrough and no state. For three signals, chain two Minimum blocks. An unconnected input reads 0, so a positive signal against an open pin returns 0. ## Common mistakes - An input left open reads 0, so a positive signal is cut to 0. Wire both inputs. - The output has a corner where the two inputs cross, so a loop that depends on the slope can chatter there. If the bound drops below the other path, the loop loses control without a warning. Problems rules: `pin.unconnected` ## Datasheet and sources No datasheet applies. Both inputs come from your control design, and the output has their common unit. ## Example Open the example with the command `file.openExample` and the name `demo:min`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # MMC Submodule Selection (`mmcBalance`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/mmcBalance/ > Picks which submodules of an MMC arm to insert: how many from the insertion index m, which ones by sorting the capacitor voltages. ![mmcBalance](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/mmcBalance.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/mmcBalance/) **Group:** Control · **Kind:** `{"block":"mmcBalance","kind":"control"}` ## When to use it The MMC Arm part already holds one. Use this block on its own when you build the submodules by hand, for example with MOSFETs or IGBTs and their losses, and need the nearest-level or phase-shifted modulation and the capacitor balance for them. ## Pins | Pin | Domain | Meaning | |---|---|---| | `m` | signal | Insertion index: 0 … 1, or −1 … 1 with bipolar 1 | | `i` | signal | Arm current, positive when it charges an inserted capacitor | | `v1` | signal | Capacitor voltage of submodule 1 | | `v2` | signal | Capacitor voltage of submodule 2 (read when n is 2 or more) | | `v3` | signal | Capacitor voltage of submodule 3 (read when n is 3 or more) | | `v4` | signal | Capacitor voltage of submodule 4 (read when n is 4 or more) | | `v5` | signal | Capacitor voltage of submodule 5 (read when n is 5 or more) | | `v6` | signal | Capacitor voltage of submodule 6 (read when n is 6 or more) | | `v7` | signal | Capacitor voltage of submodule 7 (read when n is 7 or more) | | `v8` | signal | Capacitor voltage of submodule 8 (read when n is 8) | | `g1` | signal | Submodule 1: 1 inserted, 0 bypassed, −1 inserted reversed | | `g2` | signal | Submodule 2 | | `g3` | signal | Submodule 3 | | `g4` | signal | Submodule 4 | | `g5` | signal | Submodule 5 | | `g6` | signal | Submodule 6 | | `g7` | signal | Submodule 7 | | `g8` | signal | Submodule 8 | ## Common parameters - `n`: Submodules selected, 1 to 8: inputs v1 … v, outputs g1 … g (Default: 4) - `fc`: Carrier frequency of the phase-shifted PWM (n carriers shifted by 1/n of a period); 0 inserts the nearest level, round(m·n) (Default: 0) - `bipolar`: Set to 1 for full-bridge submodules: m from −1 to 1, and a negative m inserts submodules reversed (g = −1) (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `n` | — | 4 | | Submodules selected, 1 to 8: inputs v1 … v, outputs g1 … g | | `fc` | Hz | 0 | | Carrier frequency of the phase-shifted PWM (n carriers shifted by 1/n of a period); 0 inserts the nearest level, round(m·n) | | `bipolar` | — | 0 | | Set to 1 for full-bridge submodules: m from −1 to 1, and a negative m inserts submodules reversed (g = −1) | | `sorting` | — | 1 | | Set to 0 to switch the sorting balance off: submodules go in by index, lowest first, and leave highest first | _Parameter descriptions are in English in both languages._ ## Model How many: round(m·n) with fc = 0 (nearest level); with fc above 0, n triangle carriers from 0 to 1, carrier k shifted by k/n of a period, and the count is the number of carriers below |m|, which averages |m|·n over a carrier period. Which ones: while s·i is positive (s the insertion polarity) the capacitors charge, so the lowest are inserted; otherwise the highest. When the count rises only the new submodules are picked from the bypassed ones, and when it falls only the leaving ones from the inserted ones, so a submodule switches only when the level changes. Voltages within a billionth of the arm's largest count as equal and go to the lower index, so the solver's rounding never picks the submodule. With sorting 0 the order is fixed instead: the lowest index goes in first and leaves last, so the capacitor voltages drift apart; it shows what the sorting does. With bipolar 1 a negative count inserts submodules reversed, and a change of polarity sorts again from scratch. The block reports the carrier crossings so the solver lands on them. ## Common mistakes - The arm current must be measured in the direction that charges an inserted capacitor. With the sign reversed the sorting inserts the wrong submodules and the capacitor voltages drift apart. - The selection changes only at a change of level. With m held still, the capacitors drift apart until the level moves again; that is the price of fewer switchings. ## Datasheet and sources There is no datasheet. Set n to the submodules in the arm and fc to the carrier frequency of each submodule. ## Example Open the example with the command `file.openExample` and the name `demo:mmcBalance`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Monostable (One-Shot) (`monostable`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/monostable/ > Makes one pulse of a fixed length after a rising edge. ![monostable](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/monostable.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/monostable/) **Group:** Control · **Kind:** `{"block":"monostable","kind":"control"}` ## When to use it Use it for a blanking time, a fixed-length reset pulse or a timeout after an event. Use SR Latch for a state that stays until cleared. ## Pins | Pin | Domain | Meaning | |---|---|---| | `trig` | signal | Trigger input; rising edge starts the pulse | | `ton` | signal | Optional pulse width in seconds; while wired, its value at each trigger sets the width and `width` is not needed. | | `out` | signal | Pulse output, 0 or 1 | ## Common parameters - `width`: Length of the output pulse; not needed while the ton input is wired (Default: required) - `retrigger`: Whether a new edge restarts the pulse (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `width` | s | required | | Length of the output pulse; not needed while the ton input is wired | | `retrigger` | — | 0 | | Whether a new edge restarts the pulse | _Parameter descriptions are in English in both languages._ ## Model A rising edge on trig (above 0.5 after being at or below it) sets out to 1 until `width` seconds have passed (with `ton` wired: the value of `ton` at the trigger; a value that is not positive gives no pulse). With `retrigger` = 1 an edge during the pulse restarts the timing; with 0 such an edge is ignored. The end of the pulse is reported to the solver as an event, so fastsolve lands a step exactly on it. A trig that is already high at t = 0 does not fire, and a trig that stays high fires only once. ## Common mistakes - width has no default and must be above zero. With the fixed-step solver the pulse ends at the first step at or after the end time, so a width shorter than a few maxStep values is rounded coarsely. - A trigger that is held high does not make a second pulse; the edge must go low and high again. During the pulse a new edge is ignored unless retrigger is 1, so a fast pulse train shorter than width can look like one long pulse. ## Datasheet and sources There is no datasheet. width is the time your design needs, such as a blanking time after a switching edge, a reset pulse length or a watchdog timeout. Take it from the requirement or from the timer period you are modelling. ## Example Open the example with the command `file.openExample` and the name `demo:monostable`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Multiplexer (`mux`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/mux/ > Passes one of up to eight inputs to its output, picked by the `sel` signal. ![mux](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/mux.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/mux/) **Group:** Control · **Kind:** `{"block":"mux","kind":"control"}` ## When to use it Use it to switch a controller between references, gains or modes (soft start then regulation, a fault value, a test signal) without rewiring. Use `limiter` or `max`/`min` when you want a smooth combination rather than a choice. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in1` | signal | Data input picked by sel = 0. | | `in2` | signal | Data input picked by sel = 1. | | `in3` | signal | Data input picked by sel = 2 (read when n is 3 or more). | | `in4` | signal | Data input picked by sel = 3 (read when n is 4 or more). | | `in5` | signal | Data input picked by sel = 4 (read when n is 5 or more). | | `in6` | signal | Data input picked by sel = 5 (read when n is 6 or more). | | `in7` | signal | Data input picked by sel = 6 (read when n is 7 or more). | | `in8` | signal | Data input picked by sel = 7 (read when n is 8). | | `sel` | signal | Selector, counted from 0; rounded to the nearest whole number and limited to 0 ... n - 1. | | `out` | signal | The selected input. | ## Common parameters - `n`: Number of data inputs read, 2 to 8 (in1 … in8); sel = 0 picks in1, 1 picks in2, …, rounded and limited to n − 1 (Default: 2) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `n` | — | 2 | | Number of data inputs read, 2 to 8 (in1 … in8); sel = 0 picks in1, 1 picks in2, …, rounded and limited to n − 1 | _Parameter descriptions are in English in both languages._ ## Model The output is input number `round(sel)` counted from 0, with the index limited to 0 ... `n` - 1, so `sel` = 0 gives `in1` and a logic level (0 or 1) switches between `in1` and `in2`. A `sel` that is not a number picks `in1`. The block has direct feedthrough and no state; the switch happens at the step where `sel` crosses a half. ## Common mistakes - The selector counts from 0, not from 1: `sel` = 1 picks `in2`. A selector that comes from a comparator or a logic gate is 0 or 1 and therefore picks `in1` or `in2`. - Switching between two controller outputs jumps the output. When the inputs are the outputs of integrating controllers, the one that is not selected keeps integrating and winds up; reset it or limit it so the switch-over does not kick the plant. ## Datasheet and sources There is no datasheet. Set `n` to the number of inputs you wire; inputs past `n` are not read. ## Example Open the example with the command `file.openExample` and the name `demo:mux`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # NAND Gate (`nand`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/nand/ > Outputs 0 only when every input read is above 0.5. ![nand](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/nand.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/nand/) **Group:** Control · **Kind:** `{"block":"nand","kind":"control"}` ## When to use it Use it for an active-low enable or interlock, such as a fault output that goes low only when every condition holds. Use AND Gate for a true output instead. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in1` | signal | First input; true above 0.5 | | `in2` | signal | Second input; true above 0.5 | | `in3` | signal | Third input, read if n is 3 or 4 | | `in4` | signal | Fourth input, read if n is 4 | | `out` | signal | Output, always 0 or 1 | ## Common parameters - `n`: How many inputs the gate has (Default: 2) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `n` | — | 2 | | How many inputs the gate has | _Parameter descriptions are in English in both languages._ ## Model The first n inputs are read (n = 2 by default, up to 4). An input is true when it is above 0.5. The output is the inverse of AND: 0 when all n inputs are true and 1 otherwise. The gate is combinational: it has direct feedthrough and follows its inputs at every solver step. ## Common mistakes - An input that is not wired reads 0, so the output stays at 1 and never goes low. Wire every input up to n, and set n to the number of inputs you use, because the default is 2. - If all inputs are 0, the output is 1 from the start, so a latch or counter fed from it sees a high level from time 0 and does not count that as an edge. A loop made only of gates is refused. Problems rules: `compile.error` ## Datasheet and sources There is no datasheet. n is the number of conditions combined. The logic levels come from your interlock or enable logic. ## Example Open the example with the command `file.openExample` and the name `demo:nand`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # NOR Gate (`nor`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/nor/ > Outputs 1 only when every input read is at or below 0.5. ![nor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/nor.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/nor/) **Group:** Control · **Kind:** `{"block":"nor","kind":"control"}` ## When to use it Use it for an all-clear signal, such as allowing the gate drive only when no fault is active. Use OR Gate when the fault itself should be the true output. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in1` | signal | First input; true above 0.5 | | `in2` | signal | Second input; true above 0.5 | | `in3` | signal | Third input, read if n is 3 or 4 | | `in4` | signal | Fourth input, read if n is 4 | | `out` | signal | Output, always 0 or 1 | ## Common parameters - `n`: How many inputs the gate has (Default: 2) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `n` | — | 2 | | How many inputs the gate has | _Parameter descriptions are in English in both languages._ ## Model The first n inputs are read (n = 2 by default, up to 4). An input is true when it is above 0.5. The output is the inverse of OR: 1 when all n inputs are false and 0 when at least one is true. The gate is combinational: it has direct feedthrough and follows its inputs at every solver step. ## Common mistakes - An input that is not wired reads 0, which this gate ignores, so a fault source you forgot to wire never trips the output. Wire every input up to n, and set n to the number you use, because the default is 2. - With every input at 0 the output is 1 from time 0, so the all-clear signal is true before any fault logic has run. A loop made only of gates is refused; build a latch with SR Latch. Problems rules: `compile.error` ## Datasheet and sources There is no datasheet. n is the number of fault or enable sources combined. The logic levels come from your protection logic. ## Example Open the example with the command `file.openExample` and the name `demo:nor`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Logic NOT (`not`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/not/ > Turns a high logic signal low and a low one high. ![not](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/not.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/not/) **Group:** Control · **Kind:** `{"block":"not","kind":"control"}` ## When to use it Use it to make the opposite gate of a half bridge from one PWM Generator output. Put a Dead Time block after each gate. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Logic input; above 0.5 counts as high | | `out` | signal | Opposite logic level | ## Model out = 1 if in <= 0.5, otherwise 0. The block has direct feedthrough and no delay, so the opposite gate changes at the same instant as the original. An unconnected input reads 0 and gives 1. ## Common mistakes - A plain opposite signal has no dead time, so both switches of a half bridge can conduct together. Add a Dead Time after the gate and after the opposite gate. - An input left open reads 0, so the output sticks at 1 and the switch it drives stays on. Look for an open pin. Problems rules: `shoot-through`, `pin.unconnected` ## Datasheet and sources No datasheet applies. The threshold is fixed at 0.5, and the polarity of your gate driver decides whether you need the inversion at all. ## Example Open the example with the command `file.openExample` and the name `demo:not`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Notch Filter (`notch`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/notch/ > Removes one frequency and lets the rest pass. ![notch](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/notch.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/notch/) **Group:** Control · **Kind:** `{"block":"notch","kind":"control"}` ## When to use it Use it to remove one known frequency, such as a mains harmonic or a mechanical resonance. Use Second-Order Low-Pass to reduce everything above a corner. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal to filter | | `out` | signal | Signal with one frequency removed | ## Common parameters - `f0`: Frequency the filter blocks (Default: required) - `q`: How narrow the blocked band is (Default: 1) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `f0` | Hz | required | | Frequency the filter blocks | | `q` | — | 1 | | How narrow the blocked band is | _Parameter descriptions are in English in both languages._ ## Model H(s) = (s² + w0²) / (s² + (w0/Q)·s + w0²) with w0 = 2·pi·f0. The gain is exactly 0 at f0 and approaches 1 at DC and at high frequency. The notch is about f0/q wide. The numerator and denominator have the same degree, so the block has direct feedthrough. It is integrated with the trapezoidal rule, like Transfer Function. ## Common mistakes - This block passes its input straight to the output, so a loop made only of such blocks is refused. Put an Integrator or a Unit Delay in the loop. - The solver moves the notch slightly below f0, so use a small maxStep when it must hit the target exactly. Inside a loop the notch adds phase lag below f0 and phase lead above it. Problems rules: `compile.error` ## Datasheet and sources There is no datasheet. f0 is the frequency to remove, measured from the waveform or taken from the plant model. A smaller q gives a wider notch, which disturbs the phase more away from f0. ## Example Open the example with the command `file.openExample` and the name `demo:notch`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # OR Gate (`or`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/or/ > Outputs 1 when any input read is above 0.5. ![or](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/or.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/or/) **Group:** Control · **Kind:** `{"block":"or","kind":"control"}` ## When to use it Use it to merge several fault sources into one signal. Use AND Gate when all inputs must agree. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in1` | signal | First input; true above 0.5 | | `in2` | signal | Second input; true above 0.5 | | `in3` | signal | Third input, read if n is 3 or 4 | | `in4` | signal | Fourth input, read if n is 4 | | `out` | signal | Output, always 0 or 1 | ## Common parameters - `n`: How many inputs the gate has (Default: 2) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `n` | — | 2 | | How many inputs the gate has | _Parameter descriptions are in English in both languages._ ## Model The first n inputs are read (n = 2 by default, up to 4). An input is true when it is above 0.5. The output is 1 when at least one of the n inputs is true and 0 when all are false. The gate is combinational: it has direct feedthrough and follows its inputs at every solver step. ## Common mistakes - With the default n of 2, the pins in3 and in4 are ignored even when wired, so a third fault source is silently missed. Set n to the number of inputs you use; an input that is not wired reads 0 and does not affect the result. - A pulse shorter than one solver step can be missed, so feed the gate from PWM Generator outputs or comparator signals that change at solver steps. A loop made only of gates is refused. Problems rules: `compile.error` ## Datasheet and sources There is no datasheet. n is the number of fault or enable signals you merge. The logic levels come from your protection scheme, with one signal for each trip source. ## Example Open the example with the command `file.openExample` and the name `demo:or`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Park Transform (`park`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/park/ > Rotates a fixed alpha-beta vector into the rotating d-q frame. ![park](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/park.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/park/) **Group:** Control · **Kind:** `{"block":"park","kind":"control"}` ## When to use it Use it after Clarke Transform to see the vector in a frame that turns with the rotor or flux. Use abc to dq Transform for both steps. ## Pins | Pin | Domain | Meaning | |---|---|---| | `alpha` | signal | Alpha component input | | `beta` | signal | Beta component input | | `theta` | signal | Frame angle in radians, electrical | | `d` | signal | Direct-axis component, along the frame | | `q` | signal | Quadrature-axis component, 90 degrees ahead of d | ## Model The outputs are d = alpha*cos(theta) + beta*sin(theta) and q = -alpha*sin(theta) + beta*cos(theta). The frame turns counter-clockwise with theta, which can be any value and needs no wrapping. A cosine on phase a at the angle theta gives d = A and q = 0, and a vector leading the frame by phi gives d = A*cos(phi) and q = A*sin(phi). ## Common mistakes - theta is in radians, so degrees or turns make the frame rotate at the wrong rate. It must be the electrical angle (pole pairs times the mechanical angle), for example from Angle Generator or the elec output of a position sensor. - An open theta reads 0, which freezes the frame. A wrong angle offset mixes d and q, so compare the sensor offset with theta0 of the machine. Problems rules: `pin.unconnected` ## Datasheet and sources No datasheet applies. The alpha and beta inputs come from Clarke Transform, and theta comes from the sensor or estimator: pole pairs times the mechanical angle plus any sensor offset. ## Example Open the example with the command `file.openExample` and the name `demo:park`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Phase Detector (`phaseDetector`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/phaseDetector/ > Compares the phase of two signals and outputs the difference. ![phaseDetector](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/phaseDetector.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/phaseDetector/) **Group:** Control · **Kind:** `{"block":"phaseDetector","kind":"control"}` ## When to use it Use it to build a phase-locked loop from separate blocks. Use Phase-Locked Loop (single-phase) when a ready-made loop is enough. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | signal | Reference signal | | `b` | signal | Signal to compare, usually the oscillator output | | `out` | signal | Detector output, to the loop filter | | `up` | signal | 1 while a leads, 0 in multiplier mode | | `down` | signal | 1 while b leads, 0 in multiplier mode | ## Common parameters - `type`: How the two inputs are compared: `multiplier`, `xor` or `pfd` (Default: multiplier) - `gain`: Scale factor of the detector output (Default: 1) - `threshold`: Level above which an input is high (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `type` | — | multiplier | | How the two inputs are compared: `multiplier`, `xor` or `pfd` | | `gain` | — | 1 | | Scale factor of the detector output | | `threshold` | — | 0 | | Level above which an input is high | _Parameter descriptions are in English in both languages._ ## Model Multiplier gives out = gain*a*b. For two unit sines the mean is gain*cos(phase difference)/2, so a loop locks with the two signals 90 degrees apart, and the product also carries a ripple at twice the input frequency. XOR gives out = gain while exactly one input is above threshold. For two square waves the mean is gain*|phase difference|/pi. PFD uses two flip-flops. A rising edge of a sets up, a rising edge of b sets down, and when both are set they both clear, and out = gain*(up - down). Its mean follows the phase difference over plus or minus 2*pi and keeps its sign when the frequencies differ, so it can pull a loop in from far away. Edges are seen at solver steps. ## Common mistakes - The multiplier output has a large part at twice the input frequency. Put a Second-Order Low-Pass well below that frequency and well above the loop bandwidth, or the oscillator is modulated and the loop may never settle. - XOR and PFD read a level, not a wave, and an input counts as high above threshold. A 0 to 1 logic signal needs a threshold of 0.5, or every sample counts as high and no edge is ever seen. - The multiplier locks with b 90 degrees away from a, not in phase. Use Phase-Locked Loop (single-phase), or shift the signal by 90 degrees, when the phase itself matters. ## Datasheet and sources The phase comparators of a PLL IC such as the 4046 match the XOR type, the PFD type and an edge-triggered latch. For the XOR type set gain to the supply voltage, which gives a detector gain of about the supply voltage divided by pi in volts per radian, and a charge-pump PFD has the supply voltage divided by four pi. ## Example Open the example with the command `file.openExample` and the name `demo:phaseDetector`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # PI Controller (`pi`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/pi/ > Corrects an error with proportional and integral action, and limits its output. ![pi](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/pi.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/pi/) **Group:** Control · **Kind:** `{"block":"pi","kind":"control"}` ## When to use it Use it for the current, speed or voltage loop of a converter or drive. Use PID Controller when you need a derivative term. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Error: reference minus feedback | | `out` | signal | Controller output, kept between lo and hi | ## Common parameters - `kp`: Strength of the reaction to error (Default: 1) - `ki`: Strength of the reaction to past error (Default: 0) - `lo`: Lowest value the output can reach (Default: -1e30) - `hi`: Highest value the output can reach (Default: 1e30) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `kp` | — | 1 | | Strength of the reaction to error | | `ki` | 1/s | 0 | | Strength of the reaction to past error | | `lo` | — | -1e30 | | Lowest value the output can reach | | `hi` | — | 1e30 | | Highest value the output can reach | | `y0` | — | 0 | | Output at the start while the error is zero | _Parameter descriptions are in English in both languages._ **Use for:** Current loops · Voltage loops · Speed loops **Not for:** Firmware loops at a sample rate → [`dpi`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/dpi/) · Loops that need a derivative → [`pid`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/pid/) ## Formulas | Formula | Equation | Source | |---|---|---| | PI controller | C(s) = kp + ki/s | Åström & Murray, Feedback Systems, 2nd ed. (2021), ch. 11 (PID control) | | Controller zero | fz = ki/(2π·kp) | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), ch. 9 (PI compensator) | | Integral time | Ti = kp/ki | Åström & Hägglund, Advanced PID Control (2006), ch. 3 | | Response to a constant error | y = min(kp·err + ki·err·t, hi) | Åström & Murray, Feedback Systems, 2nd ed. (2021), ch. 11 (PID control) | ## Quick check Inputs: - `kp`: Proportional gain = 500m —, `kp` - `ki`: Integral gain = 500 1/s, `ki` - `err`: Constant error = 100m — - `t`: Time since the error appeared = 1m s - `hi`: Upper output limit = 1 —, `hi` Outputs: - `fz`: Zero frequency = `ki/(2*pi*kp)` Hz - `ti`: Integral time = `kp/ki` s - `y`: Output after t = `min(kp*err + ki*err*t, hi)` — ## Model logic - The block runs once per accepted solver step and adds ki·h·(in + previous in)/2 to its integral (trapezoid); a step that starts on a switching edge uses the input at its end. - Anti-windup is by clamping: the integral is kept between lo - kp·in and hi - kp·in and the output between lo and hi, so it leaves a limit as soon as the error reverses. - The integral starts at y0 clamped to lo and hi; the evaluations at t = 0 with no time step do not change it, so a loop starts at its operating point. - The output follows the input in the same step through kp (direct feedthrough); an input that is not a finite number stops the run and names the block. ## Model out = kp*e + ki*integral(e dt), held between lo and hi, where e is the input. The integral is kept inside lo - kp*e ... hi - kp*e, so the controller leaves a limit at once when the error reverses (anti-windup). The block has direct feedthrough through kp. The integral starts at y0, so a loop can start at its operating point. ## Common mistakes - The defaults are ki = 0 and no limits, so an unedited PI Controller is only a gain with no windup protection. Set ki, lo and hi. - If the input depends on the output only through blocks with no delay, such as a plant modelled as a plain Gain, the run stops. Put an Integrator or a lag in the plant path. - The unit of ki is the unit of kp per second. For a current loop a common rule is kp = L times the bandwidth and ki = R times the bandwidth, with the bandwidth in rad/s; using Hz makes the loop about six times too slow. Problems rules: `control.saturated`, `solver.control` ## Datasheet and sources No datasheet applies. The gains come from the plant (L and R, or J and the torque constant) and your target bandwidth, and the limits from the actuator range, such as the current limit or 0 to 1 for a duty. ## Example Open the example with the command `file.openExample` and the name `demo:pi`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # PID Controller (`pid`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/pid/ > Adds up proportional, integral and derivative action on an error signal. ![pid](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/pid.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/pid/) **Group:** Control · **Kind:** `{"block":"pid","kind":"control"}` ## When to use it Use it for an analog loop design. Use PI Controller when there is no derivative, and Discrete PID Controller for firmware. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Error: reference minus feedback | | `out` | signal | Controller output, limited to lo and hi | ## Common parameters - `kp`: Strength of the reaction to error (Default: 1) - `ki`: Strength of the reaction to past error (Default: 0) - `kd`: Strength of the reaction to change (Default: 0) - `lo`: Lowest value the output can reach (Default: -1e30) - `hi`: Highest value the output can reach (Default: 1e30) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `kp` | — | 1 | | Strength of the reaction to error | | `ki` | 1/s | 0 | | Strength of the reaction to past error | | `kd` | s | 0 | | Strength of the reaction to change | | `n` | rad/s | 100 | | How fast the derivative filter reacts | | `lo` | — | -1e30 | | Lowest value the output can reach | | `hi` | — | 1e30 | | Highest value the output can reach | | `kb` | 1/s | optional (off) | | Strength of the anti-windup correction | _Parameter descriptions are in English in both languages._ **Use for:** Analog loop design · Position loops · Voltage loops **Not for:** Firmware PID at a sample rate → [`dpid`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/dpid/) · Type II or III error amplifiers → [`compensator`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/compensator/) ## Formulas | Formula | Equation | Source | |---|---|---| | PID with derivative filter | C(s) = kp + ki/s + kd·n·s/(s + n) | Åström & Hägglund, Advanced PID Control (2006), ch. 3 | | High-frequency derivative gain | Kd∞ = kd·n | Åström & Hägglund, Advanced PID Control (2006), ch. 3 | | Derivative filter corner | fn = n/(2π) | Åström & Hägglund, Advanced PID Control (2006), ch. 3 | | Default tracking gain | kb = abs(ki/kp) | Åström & Hägglund, Advanced PID Control (2006), ch. 3 (back-calculation anti-windup) | ## Quick check Inputs: - `kp`: Proportional gain = 1 —, `kp` - `ki`: Integral gain = 200 1/s, `ki` - `kd`: Derivative gain = 1m s, `kd` - `n`: Derivative filter pole = 10k rad/s, `n` Outputs: - `kdhf`: High-frequency derivative gain = `kd*n` — - `fn`: Filter corner = `n/(2*pi)` Hz - `kb`: Default anti-windup gain = `if(kp != 0, abs(ki/kp), 1)` 1/s ## Model logic - Once per accepted step the integral and the derivative filter dx/dt = n·(in - x) advance by the trapezoid; the derivative term kd·n·(in - x) acts on the error. - The sum is clamped to lo and hi, and the integral receives kb·(clamped - unclamped output) of the previous step; unset kb takes abs(ki/kp), or 1 when kp is 0. - The integral and the filter start at 0 and there is no y0, so an error at t = 0 gives a derivative kick kd·n·in that decays at the rate n. - The block has direct feedthrough when kp or kd is not 0; kd not 0 with n at or below 0, a negative kb or lo above hi is refused. ## Model out = kp·e + ki·integral(e) + kd·N·s/(s + N)·e with N = n, so the derivative passes through a first-order lag and acts on the error, not on the measurement. The output is clamped to lo ... hi. While it is clamped, the integrator receives kb·(clamped output − unclamped output). An unset kb takes |ki/kp|, or 1 when kp is 0, and kb = 0 turns anti-windup off. The block has direct feedthrough when kp or kd is not 0. ## Common mistakes - ki is per second and kd is in seconds, so enter ki as kp divided by Ti and kd as kp times Td. When kd is not 0, n must be above zero and well above the loop crossover, but far below 1/maxStep. - lo and hi start at plus and minus 1e30, so nothing is limited until you set them to the actuator range, such as 0 to 1 for a duty command. A lo above hi is refused. Problems rules: `compile.error` ## Datasheet and sources There is no datasheet. kp, ki and kd come from your loop design, lo and hi from the actuator range, and n from the derivative filter you want, usually a few times the crossover frequency in rad/s. ## Example Open the example with the command `file.openExample` and the name `demo:pid`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Phase-Locked Loop (single-phase) (`pll`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/pll/ > Locks onto a single-phase signal and reports its frequency and phase. ![pll](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/pll.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/pll/) **Group:** Control · **Kind:** `{"block":"pll","kind":"control"}` ## When to use it Use it to sync an inverter or rectifier with the grid voltage, or to measure a frequency. Use Three-Phase SRF-PLL for a three-phase grid. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal to lock to, such as grid voltage | | `f` | signal | Estimated frequency in hertz | | `theta` | signal | Estimated phase in radians | | `locked` | signal | 1 when locked, otherwise 0 | ## Common parameters - `f0`: Normal frequency the loop starts at (Default: 50) - `kp`: Reaction to the phase error (Default: optional (off)) - `ki`: Reaction to the phase error over time (Default: optional (off)) - `lockTol`: Phase error that counts as locked (Default: 0.02) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `f0` | Hz | 50 | | Normal frequency the loop starts at | | `kp` | rad/s | optional (off) | | Reaction to the phase error | | `ki` | rad/s² | optional (off) | | Reaction to the phase error over time | | `fmin` | Hz | optional (off) | | Lowest frequency the loop can follow | | `fmax` | Hz | optional (off) | | Highest frequency the loop can follow | | `lockTol` | rad | 0.02 | | Phase error that counts as locked | _Parameter descriptions are in English in both languages._ ## Model A second-order generalised integrator (SOGI, gain sqrt(2)), tuned to the tracked frequency, splits the input into an in-phase part v_alpha = A*sin(phi) and a quadrature part v_beta = -A*cos(phi). The phase error is e = (v_alpha*cos(theta) + v_beta*sin(theta))/A = sin(phi - theta), so the input amplitude does not matter. A PI controller drives the error to zero. The speed is w = wi + kp*e, the integral part is d(wi)/dt = ki*e, both are held to the range 2*pi*fmin to 2*pi*fmax, and d(theta)/dt = w. The linearised loop is s^2 + kp*s + ki, with natural frequency sqrt(ki) and damping kp/(2*sqrt(ki)). With the gains unset, wn = 2*pi*0.3*f0 and the damping is 0.707, which settles a phase step in about six periods. The output f is the integral part, so a phase step does not kick it. The lock range is about kp rad/s, and from further away the loop pulls in slowly, up to fmin and fmax, which are f0/2 and 2*f0 when unset. Locked becomes 1 once the phase error has stayed below lockTol for two periods. The SOGI uses the trapezoidal rule and is stable at any step. ## Common mistakes - Keep the step well below one period and below 1/kp. At 50 Hz with the default gains, a step up to about 1 millisecond works, and a longer step makes the loop ring or lose lock. - A frequency outside fmin and fmax can never be reached, so the loop sits on the limit and locked stays 0. Set f0 near the expected frequency, and widen fmin and fmax for a source whose frequency varies, such as a generator during start-up. - Harmonics and a DC offset on the input show up as ripple on theta and f, because the SOGI reduces them but does not remove them. When the input is distorted, lower kp and ki, and accept a slower response. ## Datasheet and sources There is no datasheet. Set f0 to the nominal grid frequency, 50 or 60 Hz. The default gains follow phase jumps and frequency changes within a few cycles, as grid codes ask, and a lockTol of 0.02 radians, about 1 degree, suits grid synchronisation. ## Example Open the example with the command `file.openExample` and the name `demo:pll`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Power Factor Meter (`powerFactor`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/powerFactor/ > The power factor and displacement factor of a voltage and current, while the circuit runs. ![powerFactor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/powerFactor.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/powerFactor/) **Group:** Control · **Kind:** `{"block":"powerFactor","kind":"control"}` ## When to use it Use it to watch or regulate the power factor of a PFC stage or a grid inverter during the run. Use Power Meter for the efficiency of a converter. ## Pins | Pin | Domain | Meaning | |---|---|---| | `v` | signal | Voltage, from a voltmeter | | `i` | signal | Current, from an ammeter | | `freq` | signal | Optional fundamental frequency in hertz, such as a PLL output | | `pf` | signal | Power factor p/s | | `dpf` | signal | Displacement factor: the cosine of the angle between the fundamentals of v and i | | `p` | signal | Real power, mean of v*i | | `s` | signal | Apparent power, RMS of v times RMS of i | ## Common parameters - `f`: Fundamental frequency: the window is cycles/f seconds; a wired freq input replaces it (50 Hz mains, IEC 60038:2009 Table 1) (Default: 50) - `cycles`: Window length in periods of the fundamental; whole periods give exact figures (Default: 1) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `f` | Hz | 50 | | Fundamental frequency: the window is cycles/f seconds; a wired freq input replaces it (50 Hz mains, IEC 60038:2009 Table 1) | | `cycles` | — | 1 | | Window length in periods of the fundamental; whole periods give exact figures | _Parameter descriptions are in English in both languages._ ## Model Over the sliding window p = mean(v*i), s = sqrt(mean(v^2))*sqrt(mean(i^2)) and pf = p/s. The fundamentals of v and i are found as in Harmonic Meter, and dpf is the cosine of the angle between them. For a sine voltage the power factor is the displacement factor times the distortion factor I1/I, so a distorted current lowers pf but not dpf. Both are 0 while what they divide by is zero. ## Common mistakes - The sign of p follows the current direction of the ammeter. A current measured into the load gives a positive power; turn the ammeter around and pf and dpf turn negative. - dpf does not say whether the current leads or lags. Read the phase of two Harmonic Meters when the sign matters. Problems rules: `pin.unconnected` ## Datasheet and sources A PFC controller data sheet gives the power factor at a stated line voltage and load, measured with a power analyser over whole line cycles; set f to that line frequency and cycles to the analyser's window to compare. ## Example Open the example with the command `file.openExample` and the name `demo:powerFactor`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Power Meter (`powerMeter`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/powerMeter/ > The average input and output power and the efficiency of a converter, while the circuit runs. ![powerMeter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/powerMeter.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/powerMeter/) **Group:** Control · **Kind:** `{"block":"powerMeter","kind":"control"}` ## When to use it Use it to see a converter's efficiency settle during the run, or to stop a sweep point once it has. Use Power Factor Meter for one AC port. ## Pins | Pin | Domain | Meaning | |---|---|---| | `vin` | signal | Input voltage, from a voltmeter | | `iin` | signal | Input current, from an ammeter, into the converter | | `vout` | signal | Output voltage, from a voltmeter | | `iout` | signal | Output current, from an ammeter, into the load | | `freq` | signal | Optional frequency in hertz that sets the window | | `pin` | signal | Average input power | | `pout` | signal | Average output power | | `eff` | signal | Efficiency pout/pin, 0 while pin is not positive | ## Common parameters - `f`: Frequency the powers are averaged over: the switching frequency of a DC-DC converter, the line frequency of an inverter (Default: required) - `cycles`: Window length in periods of f; whole periods give exact figures (Default: 1) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `f` | Hz | required | | Frequency the powers are averaged over: the switching frequency of a DC-DC converter, the line frequency of an inverter | | `cycles` | — | 1 | | Window length in periods of f; whole periods give exact figures | _Parameter descriptions are in English in both languages._ ## Model Over the last cycles/f seconds pin = mean(vin*iin) and pout = mean(vout*iout), each integrated with the trapezoidal rule, and eff = pout/pin. A window of whole switching periods removes the switching ripple from both, so the efficiency is exact once the converter has settled. ## Common mistakes - The efficiency reads high or low while the output capacitor is still charging, because part of pin goes into stored energy. Read it after the output has settled, or use a window of many cycles. - f has no default: set it to the switching frequency of a DC-DC converter, or to the line frequency for an inverter or a rectifier, whose power pulses at twice that frequency. Problems rules: `pin.unconnected` ## Datasheet and sources A converter data sheet gives efficiency curves against load at a stated input voltage; set the load and input to one point of the curve and compare eff with it once the run has settled. ## Example Open the example with the command `file.openExample` and the name `demo:powerMeter`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Instantaneous Power (p, q) (`pq`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/pq/ > The instantaneous active and reactive power from the alpha-beta voltage and current. ![pq](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/pq.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/pq/) **Group:** Control · **Kind:** `{"block":"pq","kind":"control"}` ## When to use it Use it for power control of a grid inverter or an active rectifier, and to measure the power a drive draws. Use a `product` of voltage and current for a single phase. ## Pins | Pin | Domain | Meaning | |---|---|---| | `ealpha` | signal | Voltage alpha component input. | | `ebeta` | signal | Voltage beta component input. | | `ialpha` | signal | Current alpha component input. | | `ibeta` | signal | Current beta component input. | | `p` | signal | Active power output, k*(ealpha*ialpha + ebeta*ibeta). | | `q` | signal | Reactive power output, k*(ebeta*ialpha - ealpha*ibeta); positive for a lagging current. | ## Common parameters - `k`: Scale of p and q: 1.5 for amplitude-invariant αβ quantities (then p is the three-phase power), 1 for power-invariant ones (Default: 1.5) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `k` | — | 1.5 | | Scale of p and q: 1.5 for amplitude-invariant αβ quantities (then p is the three-phase power), 1 for power-invariant ones | _Parameter descriptions are in English in both languages._ ## Model The outputs are `p = k*(ealpha*ialpha + ebeta*ibeta)` and `q = k*(ebeta*ialpha - ealpha*ibeta)` (the instantaneous power theory of Akagi, Kanazawa and Nabae, 1984). With the amplitude-invariant `clarke` used by every block here `k` = 1.5 makes `p` the three-phase power. The block has direct feedthrough and no state; ripple on the inputs shows up on `p` and `q` at once. ## Common mistakes - The sign of `q` depends on the convention: here a current that lags the voltage gives a positive `q` (an inductive load absorbs reactive power). Some texts use the opposite sign; check it against a known inductive load before closing a loop on it. - Use `k` = 1 only with power-invariant (sqrt(2/3)) alpha-beta quantities. With the amplitude-invariant ones of `clarke` and `k` = 1 the power reads two thirds of the real value. ## Datasheet and sources There is no datasheet. Feed it the voltage and current through `clarke` blocks from the meters at the point of connection. ## Example Open the example with the command `file.openExample` and the name `demo:pq`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Product (`product`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/product/ > Multiplies two signals. ![product](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/product.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/product/) **Group:** Control · **Kind:** `{"block":"product","kind":"control"}` ## When to use it Use it for a power calculation (voltage times current), an enable mask or a variable gain. Use Gain when one factor is fixed. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in1` | signal | First factor | | `in2` | signal | Second factor | | `out` | signal | Product of the two inputs | ## Model out = in1*in2, with no dynamics and direct feedthrough. The unit of the output is the product of the two input units. An unconnected input reads 0, so the output is 0. ## Common mistakes - An input left open reads 0, so the output stays at 0 and hides the other signal. Look for an open pin when the output stays at zero. - Feeding the output back to its own input through blocks with no delay stops the run. Put an Integrator, Sample Delay or Sample and Hold in the path. Problems rules: `pin.unconnected`, `solver.control` ## Datasheet and sources No datasheet applies. The two factors are signals from your own loop, such as a measured voltage and a measured current. ## Example Open the example with the command `file.openExample` and the name `demo:product`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # PWM Generator (`pwm`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/pwm/ > Turns a duty from 0 to 1 into a gate signal. ![pwm](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/pwm.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/pwm/) **Group:** Control · **Kind:** `{"block":"pwm","kind":"control"}` ## When to use it Use it for one switch or one half-bridge leg driven by a duty. Use Three-Phase PWM for three phases. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Duty: 0 always off, 1 always on | | `phase` | signal | Optional carrier phase in degrees; while wired it replaces the `phase` parameter, so a controller can shift one leg against another (phase-shifted full bridge, DAB). | | `freq` | signal | Optional carrier frequency in Hz; while wired it replaces `freq` and the carrier integrates it. | | `out` | signal | Gate signal: 1 while duty is above the carrier | ## Common parameters - `freq`: Carrier frequency; a wired freq input replaces it (Default: required) - `shape`: Triangle or sawtooth wave shape: `triangle` or `sawtooth` (Default: triangle) - `phase`: How far the wave is shifted, as a fraction of one period; a wired phase input (degrees) replaces it (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `freq` | Hz | required | | Carrier frequency; a wired freq input replaces it | | `shape` | — | triangle | | Triangle or sawtooth wave shape: `triangle` or `sawtooth` | | `phase` | — | 0 | | How far the wave is shifted, as a fraction of one period; a wired phase input (degrees) replaces it | | `counts` | — | optional (off) | | Timer counts in one PWM period; the duty rounds to 1/counts (none = exact) | | `hrpwm` | s | optional (off) | | High-resolution PWM edge step, or `f28379d` (150 ps) or `stm32g474` (184 ps); the duty rounds to step × freq | | `offset` | — | 0 | | Carrier's lowest value, in the input's units: an input at or below it gives a duty of 0 | | `vpp` | — | 1 | | Carrier's peak-to-peak value, in the input's units: the duty is (in − offset)/vpp | _Parameter descriptions are in English in both languages._ **Use for:** Single-switch gates · Half-bridge legs · Phase-shifted bridges **Not for:** Three-phase inverters → [`pwm3`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/pwm3/) · Firmware timing and update delay → [`mcu`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/mcu/) ## Formulas | Formula | Equation | Source | |---|---|---| | Duty from a control voltage | D = vc/vpk | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), ch. 7 (modelling the pulse-width modulator) | | Modulator gain | Gm = 1/vpk | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), ch. 7 (modelling the pulse-width modulator) | | On-time per period | ton = D/freq | Holmes & Lipo, Pulse Width Modulation for Power Converters (2003), ch. 3 | | Average switched output | Vavg = D·vdc | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), ch. 2 | ## Quick check Inputs: - `vc`: Control signal = 400m — - `vpk`: Carrier peak (1 in this block) = 1 — - `vdc`: DC-link voltage = 48 V - `freq`: Switching frequency = 20k Hz, `freq` Outputs: - `d`: Duty = `limit(vc/vpk, 0, 1)` — - `ton`: On-time = `d/freq` s - `vavg`: Average output = `d*vdc` V ## Model logic - The carrier runs from 0 to 1 at freq: a triangle rises over the first half period and falls over the second, a sawtooth rises over the whole period; phase shifts it by a fraction of a period. - The gate is 1 while duty > carrier: with a triangle the on-time is centred on the period start, with a sawtooth it starts there; a wired phase input in degrees replaces phase. - The duty is clamped to 0 and 1, where the gate stays off or on with no edges; counts or hrpwm round it to the nearest multiple of 1/counts or step·freq. - The duty is read at every step, not sampled once per period, and the next edge for the present duty is reported so the solver lands a step just after it. ## Model The output is 1 while `duty > carrier`, with the carrier between 0 and 1 at `freq` Hz (`triangle` by default, or `sawtooth`, shifted by `phase`). With a triangle the on-time is centred on the start of each period; with a sawtooth it starts at the period start. The duty is clamped to 0 ... 1, and the solver lands a step exactly on every edge for a constant duty. Wired `phase` (degrees) and `freq` inputs replace the parameters; unwired, the block is exactly the fixed carrier. A digital PWM can only place an edge on its timer: with `counts` (timer counts per period, TBPRD or ARR) the duty rounds to a multiple of 1/counts, and with `hrpwm` (a high-resolution edge step in seconds, or `f28379d` or `stm32g474`) to a multiple of step × freq. Without them the duty is not rounded, as before. ## Common mistakes - A duty outside 0 to 1 does not make a wider or negative pulse, so the switch just stays on or off. Keep a Constant or Sine Source reference inside 0 to 1, and centre a sine on 0.5 with an amplitude of at most 0.5. - A carrier much faster than the step is not resolved, so keep the maximum step at or below one fiftieth of the period. Write freq with its prefix, such as 20k. - Both switches of a half bridge need a dead time. Make the opposite gate with Logic NOT and put a Dead Time after each gate. Problems rules: `duty.out_of_range`, `step.too_large`, `param.out_of_range`, `shoot-through` ## Datasheet and sources The value of freq is the switching frequency you design for, and the duty comes from your controller, for example a PI Controller output limited to 0 to 1. The hrpwm presets: `f28379d` is 150 ps, the typical MEP step size of TI SPRS880P (TMS320F2837xD data sheet) section 6.11.4.1.2 (310 ps maximum); `stm32g474` is 184 ps, from ST DS12288 Rev 4 section 3.24.1 and RM0440 Rev 9 section 28.3.3, Table 231 (prescaler CKPSC = 000, PWM from 83.0 kHz up). ## Example Open the example with the command `file.openExample` and the name `demo:pwm`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Three-Phase PWM (`pwm3`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/pwm3/ > Turns three duties into three gate signals with one shared carrier. ![pwm3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/pwm3.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/pwm3/) **Group:** Control · **Kind:** `{"block":"pwm3","kind":"control"}` ## When to use it Use it for a three-phase inverter, usually after Space-Vector Modulator set to duty. Use PWM Generator for a single gate. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | signal | Duty for phase a, 0 to 1 | | `b` | signal | Duty for phase b, 0 to 1 | | `c` | signal | Duty for phase c, 0 to 1 | | `ga` | signal | Gate signal for phase a | | `gb` | signal | Gate signal for phase b | | `gc` | signal | Gate signal for phase c | ## Common parameters - `freq`: Carrier frequency shared by all three phases (Default: required) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `freq` | Hz | required | | Carrier frequency shared by all three phases | | `counts` | — | optional (off) | | Timer counts in one PWM period; the duty rounds to 1/counts (none = exact) | | `hrpwm` | s | optional (off) | | High-resolution PWM edge step, or `f28379d` (150 ps) or `stm32g474` (184 ps); the duty rounds to step × freq | _Parameter descriptions are in English in both languages._ ## Model Each gate follows duty > carrier, with the same triangle carrier of frequency freq (0 at the start of each period, 1 at half a period). The three phases are aligned and their edges are symmetric around the carrier valley. Each duty is clamped to 0 ... 1, and the solver lands a step on every edge. There is no dead time and no opposite output. With `counts` or `hrpwm` each duty first rounds to the timer's resolution, as in PWM Generator. ## Common mistakes - The inputs are duties, not modulation signals. With the default output m of Space-Vector Modulator, which runs from -1 to 1, the negative half is cut off and the inverter output distorts, so set output to duty. - A bridge with no dead time can shoot through. For both switches of a leg, make the opposite gate with Logic NOT and add a Dead Time to each gate, and keep the maximum step below one fiftieth of the carrier period. Problems rules: `duty.out_of_range`, `step.too_large`, `shoot-through` ## Datasheet and sources No datasheet applies. The value of freq is the inverter switching frequency you design for, for example 10 kHz in the drive examples, and the duties come from Space-Vector Modulator or a sine reference centred on 0.5. ## Example Open the example with the command `file.openExample` and the name `demo:pwm3`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Ramp (`ramp`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/ramp/ > A ramp that rises while a gate is on (slope compensation) or restarts at each clock edge (a clock-synced sawtooth). ![ramp](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/ramp.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/ramp/) **Group:** Control · **Kind:** `{"block":"ramp","kind":"control"}` ## When to use it Use the `gate` mode for the slope compensation of a peak-current-mode converter: feed it the switch gate and add its output to the sensed current. Use the `saw` mode for a carrier that follows an external clock. Use `carrier` for a free-running carrier at a fixed frequency. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Gate input for the gate mode; the ramp runs while it is above 0.5. | | `clk` | signal | Clock input for the saw mode; each rising edge across 0.5 restarts the ramp at 0. | | `out` | signal | Ramp output. | ## Common parameters - `mode`: Ramp mode: `gate` (out = se·(t − t_rise) while in is high and 0 while it is low) or `saw` (from 0 at each rising edge of clk, reaching vh after 1/f) (Default: gate) - `se`: Slope of the gate-mode ramp (output units per second) (Default: 1) - `f`: Saw mode: the ramp rises at vh·f, so it reaches vh after 1/f (needed in saw mode) (Default: optional (off)) - `vh`: Upper limit of the output; the peak in saw mode (needed there), no limit in gate mode while unset (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `mode` | — | gate | | Ramp mode: `gate` (out = se·(t − t_rise) while in is high and 0 while it is low) or `saw` (from 0 at each rising edge of clk, reaching vh after 1/f) | | `se` | 1/s | 1 | | Slope of the gate-mode ramp (output units per second) | | `f` | Hz | optional (off) | | Saw mode: the ramp rises at vh·f, so it reaches vh after 1/f (needed in saw mode) | | `vh` | — | optional (off) | | Upper limit of the output; the peak in saw mode (needed there), no limit in gate mode while unset | _Parameter descriptions are in English in both languages._ ## Model In `gate` mode the output is `se*(t - t_rise)` while `in` is above 0.5, with `t_rise` the step at which it rose, and 0 while it is low; it is limited to `vh` when that is set. In `saw` mode the output starts at 0 at t = 0 and at every rising edge of `clk`, rises at `vh*f` (so it reaches `vh` after 1/f) and stays at `vh` until the next edge. The ramp is computed at each solver step; the edges come from the input, so a `pwm` gate gives exact edge times. The block has no direct feedthrough (its output is 0 at a rising edge whatever it reads), so a latch that gates its own slope, as in peak current mode, closes a loop through it: inside such a loop it reads the previous step, which delays only the reset at the falling edge by one step. ## Common mistakes - The slope `se` is in output units per second. For slope compensation that is the sensed-current slope in V/s (current slope times the sense gain); a value of a few volts is a slope a million times too small. Half the inductor down-slope or more stops subharmonic oscillation above 50 % duty. - In `saw` mode `f` and `vh` are both needed: the run stops with an error naming the block if one is missing. With no clock wired the saw rises once from t = 0 and then holds at `vh`. ## Datasheet and sources For slope compensation take the slope from the controller datasheet (the internal ramp amplitude over the switching period) or from Se >= Rsense*Vout/(2L) for a buck. For the saw mode `f` is the nominal switching frequency. ## Example Open the example with the command `file.openExample` and the name `demo:ramp`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Random Source (`random`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/random/ > A seeded random signal: a new uniform or Gaussian value every 1/fs seconds, held in between. ![random](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/random.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/random/) **Group:** Control · **Kind:** `{"block":"random","kind":"control"}` ## When to use it Use it for sensor noise, a disturbance on a reference or a random load, wherever the same random sequence must come back in every run. For noise on a meter's output, the meter's own noise parameter is simpler. ## Pins | Pin | Domain | Meaning | |---|---|---| | `out` | signal | offset plus the value drawn for the present interval | ## Common parameters - `dist`: Distribution: `uniform` (offset plus a value from −amp to amp) or `gaussian` (offset plus a value of standard deviation amp) (Default: uniform) - `amp`: Half the span of a uniform value, or the standard deviation of a Gaussian one (Default: 1) - `fs`: How often a new value is drawn; the output holds in between (Default: required) - `offset`: Fixed amount added to every drawn value (Default: 0) - `seed`: Number that picks the sequence; the same seed gives the same run (Default: 1) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `dist` | — | uniform | | Distribution: `uniform` (offset plus a value from −amp to amp) or `gaussian` (offset plus a value of standard deviation amp) | | `amp` | — | 1 | | Half the span of a uniform value, or the standard deviation of a Gaussian one | | `offset` | — | 0 | | Fixed amount added to every drawn value | | `fs` | Hz | required | | How often a new value is drawn; the output holds in between | | `seed` | — | 1 | | Number that picks the sequence; the same seed gives the same run | _Parameter descriptions are in English in both languages._ ## Model Time is cut into intervals of 1/fs seconds starting at t = 0, and interval k holds one value: offset + amp·(2u − 1) with u uniform from 0 to 1 for dist = uniform, or offset + amp·z with z standard normal (Box–Muller) for dist = gaussian. The value is a pure function of seed and k (SplitMix64), so the same seed gives the same sequence in every run, in both solvers and after a restart, and a rejected step cannot change it. Each new interval is an event, so the solver lands on it. ## Common mistakes - Every interval is a step the solver must land on, so a high fs over a long run costs many steps. Draw only as fast as the bandwidth you study needs. - A Gaussian value has no bound: about one value in 370 lies beyond 3·amp. Put a Limiter after it when what it drives has a range. ## Datasheet and sources There is no datasheet. For a sensor, amp is the noise the data sheet states (as an rms value with dist = gaussian) and fs is about twice its bandwidth. ## Example Open the example with the command `file.openExample` and the name `demo:random`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Rate Limiter (`rateLimiter`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/rateLimiter/ > Follows its input, but changes no faster than a rising and a falling rate. ![rateLimiter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/rateLimiter.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/rateLimiter/) **Group:** Control · **Kind:** `{"block":"rateLimiter","kind":"control"}` ## When to use it Use it for a soft start of a reference, a ramped speed command, or a slew-rate limit on a duty cycle. Use Limiter to limit the value itself. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal to follow | | `out` | signal | Rate-limited signal | ## Common parameters - `rise`: Fastest rise of the output, in units per second (Default: required) - `fall`: Fastest fall of the output, in units per second; the rising rate when empty (Default: rise) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `rise` | 1/s | required | | Fastest rise of the output, in units per second | | `fall` | 1/s | rise | | Fastest fall of the output, in units per second; the rising rate when empty | _Parameter descriptions are in English in both languages._ ## Model At the start the output equals the input. Over each accepted solver step of length h it moves toward the input by at most rise·h up and fall·h down, from the value the step before left, so a step of the input becomes a ramp of slope rise (or −fall). When the input comes from a step source or a comparator, whose jump falls inside the step (a step source's at the step's end, where the solver lands it), the output moves only for the part of the step after the jump, so the ramp starts at the jump whatever the step size. rise and fall are in units per second; fall defaults to rise. The block has direct feedthrough. ## Common mistakes - The rates are per second of simulated time. Code generation writes the block at the code's sample time ts, moving at most rise·ts up and fall·ts down per sample, when it feeds the duty cycle a PWM reads; anywhere else it is left out, and you build it from a zDelay, a sum and a limiter of rise·ts. - rise and fall must be positive. Inside a loop the limit adds a delay that depends on the step size; keep it out of fast inner loops. Problems rules: `compile.error` ## Datasheet and sources There is no datasheet. ## Example Open the example with the command `file.openExample` and the name `demo:rateLimiter`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # RMS Meter (`rms`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/rms/ > The RMS of a signal over a sliding window, while the circuit runs. ![rms](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/rms.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/rms/) **Group:** Control · **Kind:** `{"block":"rms","kind":"control"}` ## When to use it Use it when a controller acts on an RMS value during the run, such as an output-voltage regulator of an inverter or an overcurrent trip. Use scope.measure when you only need the number after the run. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal to measure | | `freq` | signal | Optional frequency in hertz, such as a PLL output; when wired it sets the window | | `out` | signal | RMS value | ## Common parameters - `f`: Fundamental frequency: the window is cycles/f seconds; a wired freq input replaces it (50 Hz mains, IEC 60038:2009 Table 1) (Default: 50) - `cycles`: Window length in periods of f; whole periods give exact figures (one cycle, as the Urms(1/2) of IEC 61000-4-30:2015) (Default: 1) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `f` | Hz | 50 | | Fundamental frequency: the window is cycles/f seconds; a wired freq input replaces it (50 Hz mains, IEC 60038:2009 Table 1) | | `cycles` | — | 1 | | Window length in periods of f; whole periods give exact figures (one cycle, as the Urms(1/2) of IEC 61000-4-30:2015) | _Parameter descriptions are in English in both languages._ ## Model The output is the square root of the mean of in squared over the last cycles/f seconds. The square is integrated with the trapezoidal rule at every step and the window start is interpolated inside its step, so a window of whole periods gives the exact RMS of a periodic signal at fixed or variable steps. Before a full window has passed, the window is the time elapsed, and at t = 0 the output is the size of the input. When freq is wired and positive it replaces f at every step, so the window stays one period of a signal whose frequency drifts. ## Common mistakes - A window that is not a whole number of periods leaves a ripple at twice the signal frequency on the output. Set f to the signal frequency, or wire freq from a PLL when the frequency changes. - The output lags a change of the input by up to one window. A loop that regulates an RMS value must be slower than the window, or it oscillates. Problems rules: `pin.unconnected` ## Datasheet and sources A true-RMS meter or power analyser reads the same figure; its data sheet gives the averaging window, often one cycle or 10 cycles at 50 Hz. Set cycles to match when you compare with a bench reading. ## Example Open the example with the command `file.openExample` and the name `demo:rms`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Sample and Hold (`sampleHold`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/sampleHold/ > Samples its input once per period and holds the value. ![sampleHold](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/sampleHold.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/sampleHold/) **Group:** Control · **Kind:** `{"block":"sampleHold","kind":"control"}` ## When to use it Use it to model a digital controller that reads a measurement once per period. Use ADC for rounding and Sample Delay for extra delay. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal to sample | | `clk` | signal | Optional clock; while wired the block samples at each of its rising edges (across 0.5) instead of every `period`. | | `out` | signal | Value held from the last sample | ## Common parameters - `period`: Sample period; unused while the clk input is wired (then every rising edge of clk samples) (Default: required) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `period` | s | required | | Sample period; unused while the clk input is wired (then every rising edge of clk samples) | _Parameter descriptions are in English in both languages._ ## Model At every multiple of `period` (starting at t = 0) the block copies its input to the output, then holds it constant until the next instant. The solver lands a step exactly on each sample instant. With `clk` wired the block samples at each rising edge of `clk` instead (not at a pass with no time step, so a clock high at t = 0 does not fire) and reports no instants of its own. The block has no direct feedthrough, so it breaks algebraic loops. ## Common mistakes - The period is in seconds, so write 100u for 10 kHz. A value written without its prefix is probably wrong. - Without direct feedthrough, the solver may read the signal that drives it one step late. Keep the maximum step well below period, and sample signals that change slowly compared with the step. Problems rules: `param.out_of_range` ## Datasheet and sources No datasheet applies. The value of period is the sample period of the controller you model: the inverse of the interrupt or ADC trigger rate, often equal to the PWM period or half of it. ## Example Open the example with the command `file.openExample` and the name `demo:sampleHold`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Sine Source (`sine`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/sine/ > Outputs a sine wave with set amplitude, frequency, phase and offset. ![sine](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/sine.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/sine/) **Group:** Control · **Kind:** `{"block":"sine","kind":"control"}` ## When to use it Use it for a reference, a test disturbance or a modulation wave. Use Three-Phase Sine Source for a three-phase set and Step Source for a one-time change. ## Pins | Pin | Domain | Meaning | |---|---|---| | `out` | signal | Offset plus a sine wave | ## Common parameters - `amp`: Height of the wave peak (Default: 1) - `freq`: Frequency (Default: required) - `phase`: Where the wave starts in its cycle (Default: 0) - `offset`: Fixed amount added to the wave (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `amp` | — | 1 | | Height of the wave peak | | `freq` | Hz | required | | Frequency | | `phase` | ° | 0 | | Where the wave starts in its cycle | | `offset` | — | 0 | | Fixed amount added to the wave | _Parameter descriptions are in English in both languages._ ## Model out = offset + amp*sin(2*pi*freq*t + phase), where phase is in degrees and freq is in Hz. The value has no unit of its own. For a cosine, set phase to 90. ## Common mistakes - As a duty reference for PWM Generator the wave must stay between 0 and 1. Set offset to 0.5 and amp to at most 0.5. - The phase is in degrees, while the angle inputs of the transform blocks use radians. Keep the maximum step at or below one fiftieth of the period, which is 400 us for 50 Hz. Problems rules: `duty.out_of_range`, `step.too_large` ## Datasheet and sources No datasheet applies. The value of freq is the frequency you need, amp is the peak value and offset is the DC level, all in the unit of the signal the wave drives. ## Example Open the example with the command `file.openExample` and the name `demo:sine`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Three-Phase Sine Source (`sine3`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/sine3/ > Outputs a balanced three-phase sine set on three pins. ![sine3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/sine3.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/sine3/) **Group:** Control · **Kind:** `{"block":"sine3","kind":"control"}` ## When to use it Use it for three-phase voltage references or test currents. Use dq to abc Transform when you start from dq values, and Sine Source for one phase. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | signal | Phase a sine wave | | `b` | signal | Phase b, 120 degrees behind a | | `c` | signal | Phase c, 120 degrees ahead of a | ## Common parameters - `amp`: Height of the wave peak (Default: 1) - `freq`: Frequency (Default: required) - `phase`: Where the wave starts in its cycle (Default: 0) - `offset`: Fixed amount added to the wave (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `amp` | — | 1 | | Height of the wave peak | | `freq` | Hz | required | | Frequency | | `phase` | ° | 0 | | Where the wave starts in its cycle | | `offset` | — | 0 | | Fixed amount added to the wave | _Parameter descriptions are in English in both languages._ ## Model With w = 2*pi*freq*t + phase, the outputs are a = offset + amp*sin(w), b = offset + amp*sin(w - 120 deg) and c = offset + amp*sin(w + 120 deg). The sequence is positive (a, b, c). The phase setting is in degrees and applies to phase a. The three outputs add up to 3*offset. ## Common mistakes - The transform blocks treat phase a as a cosine, but this wave is a sine. Set phase to 90 to get d = amp and q = 0, because phase 0 gives d = 0 and q = -amp. - Keep the maximum step at or below one fiftieth of the period. As duty references for Three-Phase PWM, all three outputs must stay between 0 and 1, so use offset 0.5 and amp of at most 0.5. Problems rules: `step.too_large`, `duty.out_of_range` ## Datasheet and sources No datasheet applies. The value of freq is the electrical frequency you want, amp is the phase peak (at most the DC-link voltage divided by the square root of 3 for Space-Vector Modulator), and offset is normally 0. ## Example Open the example with the command `file.openExample` and the name `demo:sine3`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Sliding-Mode Observer (`smo`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/smo/ > Estimates the rotor angle and speed of a permanent-magnet motor without a position sensor. ![smo](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/smo.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/smo/) **Group:** Control · **Kind:** `{"block":"smo","kind":"control"}` ## When to use it Use it to run a permanent-magnet motor without a position sensor. It needs back-EMF, so start open loop and hand over above a speed threshold. ## Pins | Pin | Domain | Meaning | |---|---|---| | `valpha` | signal | Voltage command on the alpha axis, in V | | `vbeta` | signal | Voltage command on the beta axis, in V | | `ialpha` | signal | Measured current on the alpha axis, in A | | `ibeta` | signal | Measured current on the beta axis, in A | | `theta` | signal | Estimated rotor angle, in radians | | `w` | signal | Estimated electrical speed, in rad/s | ## Common parameters - `rs`: Stator resistance of the motor (Default: required) - `ls`: Stator inductance of the motor (Default: required) - `k`: Strength of the sliding correction (Default: required) - `phi`: Width of the smooth zone around zero error (Default: 1) - `fc`: Cutoff of the filter on the estimate (Default: 300) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `rs` | Ω | required | | Stator resistance of the motor | | `ls` | H | required | | Stator inductance of the motor | | `k` | V | required | | Strength of the sliding correction | | `phi` | A | 1 | | Width of the smooth zone around zero error | | `fc` | Hz | 300 | | Cutoff of the filter on the estimate | | `fpll` | Hz | 100 | | Speed of the loop that tracks the angle | _Parameter descriptions are in English in both languages._ ## Model A model of the stator, L*d(ih)/dt = v - Rs*ih - z, runs beside the machine and is forced towards the measured current i by the switching term z = k*sat((ih - i)/phi), where sat is linear for a current error below phi (the boundary layer, which replaces the chattering sign) and ±1 beyond it. With k above the peak back-EMF the error stays in the layer and z settles at the back-EMF e = wr*psi_f*(-sin(theta), cos(theta)). A low-pass of cutoff fc filters z, and a phase-locked loop (PI, damping 1/sqrt(2), bandwidth fpll) on the filtered vector gives the speed and the angle, which avoids an atan2 of noisy signals. The output angle adds the phase lag of the low-pass and of the current observer, atan(w/(2*pi*fc)) + atan(w*L/(Rs + k/phi)), so it is exact at a constant speed. The current observer uses backward Euler and is stable for any step. The block has no direct feedthrough, so it can sit in the loop it feeds; it then reads the voltage of the previous step. The voltage inputs are the voltage the inverter is commanded to apply, for example the alpha output of Inverse Park Transform, and the current inputs come from Clarke Transform. theta is the d axis seen from phase a, and w is the mechanical speed times the pole pairs, negative when the machine turns backwards. ## Common mistakes - k must be larger than the peak back-EMF, and about 1.5 times it is a good choice. Below that the estimate is wrong and the angle may lock late or not at all, while a very large k adds ripple that the low-pass has to remove. - At low speed the back-EMF is lost in the ripple, so the estimate cannot start a motor from standstill. Start open loop up to a speed threshold, let w pass it, then switch the angle to theta; switching below that speed gives a wrong angle and the loop can run away. - The voltage inputs must be the voltage the motor really gets, which is the reference after the inverse Park, not a duty cycle or a modulation index. Voltage lost to the DC link limit, dead time or switch drops shows up as an error in the estimate, and rs and ls must match the motor, which is assumed to have Ld equal to Lq. - An input that is not connected reads 0, so an observer without current inputs sees a motor that draws no current and the angle drifts. Connect all four inputs, and take valpha and vbeta from the same stage that feeds the modulator. Problems rules: `pin.unconnected` ## Datasheet and sources There is no datasheet. rs and ls are the phase resistance and inductance of the motor, the same as in Surface PMSM. k is about 1.5 times psi_f times the highest electrical speed, and phi is a fraction of the rated current, 1 to 2 A for a 5 A motor. fc is a few times the highest electrical frequency and well below the switching frequency, and fpll is 50 to 200 Hz, below fc. ## Example Open the example with the command `file.openExample` and the name `demo:smo`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Three-Phase SRF-PLL (`srfPll`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/srfPll/ > Locks onto a three-phase signal and gives the grid angle and speed. ![srfPll](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/srfPll.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/srfPll/) **Group:** Control · **Kind:** `{"block":"srfPll","kind":"control"}` ## When to use it Use it in a grid-connected three-phase inverter or rectifier to get the angle for the dq transforms. Use Phase-Locked Loop (single-phase) for one phase. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | signal | Phase a, such as the grid voltage | | `b` | signal | Phase b, 120 degrees behind a | | `c` | signal | Phase c, 120 degrees ahead of a | | `theta` | signal | Estimated angle in radians | | `w` | signal | Estimated speed in radians per second | ## Common parameters - `f0`: Normal frequency the loop starts at (Default: 50) - `kp`: Reaction to the phase error (Default: optional (off)) - `ki`: Reaction to the phase error over time (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `f0` | Hz | 50 | | Normal frequency the loop starts at | | `kp` | rad/s | optional (off) | | Reaction to the phase error | | `ki` | rad/s² | optional (off) | | Reaction to the phase error over time | | `fmin` | Hz | optional (off) | | Lowest frequency the loop can follow | | `fmax` | Hz | optional (off) | | Highest frequency the loop can follow | _Parameter descriptions are in English in both languages._ ## Model The input is turned into d and q by the Clarke and Park transforms at the loop's own angle, using the convention of abc to dq Transform. A cosine on phase a at angle theta gives d equal to the amplitude and q equal to 0. For a positive sequence q/|dq| = sin(theta_grid - theta), and a PI controller drives it to zero. The speed is w = wi + kp*e, the integral part is d(wi)/dt = ki*e, both are held to the range 2*pi*fmin to 2*pi*fmax, and d(theta)/dt = w. Dividing by the amplitude makes the loop gain independent of the voltage. The linearised loop is s^2 + kp*s + ki. With the gains unset, wn = 2*pi*0.3*f0 and the damping is 0.707. The output w is the integral part of the loop. ## Common mistakes - The phase order matters. With a negative sequence, where b and c are swapped, the loop locks to a wrong angle that turns backwards, or does not lock at all. Check that b is 120 degrees behind a. - Unbalance and negative sequence on the grid show up as a ripple at twice the grid frequency on theta and w. Lower kp and ki to reduce it, and accept a slower response to phase jumps. - The angle theta is where the cosine of phase a peaks. A source written as sines, such as Three-Phase Sine Source, gives an angle 90 degrees behind the sine phase, so use the same convention in the transforms of the controller. ## Datasheet and sources There is no datasheet. Set f0 to the nominal grid frequency, 50 or 60 Hz, and keep the bandwidth between 10 and 30 Hz, which balances speed against rejection of unbalance and harmonics. The default gains give 15 Hz at 50 Hz. ## Example Open the example with the command `file.openExample` and the name `demo:srfPll`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # SR Latch (`srff`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/srff/ > Remembers a fault or state until it is reset. ![srff](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/srff.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/srff/) **Group:** Control · **Kind:** `{"block":"srff","kind":"control"}` ## When to use it Use it to remember a fault until it is cleared, such as an overcurrent trip. Use D Flip-Flop when the state should change only on a clock edge. ## Pins | Pin | Domain | Meaning | |---|---|---| | `s` | signal | Set input; makes q 1 when above 0.5 | | `r` | signal | Reset input; makes q 0 and wins over s | | `q` | signal | Latch output, 0 or 1 | | `qn` | signal | Opposite of q | ## Common parameters - `q0`: Initial output q, 0 or 1 (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `q0` | — | 0 | | Initial output q, 0 or 1 | | `priority` | — | reset | | Which input wins when s and r are both high: `reset`, or `set` (set-dominant, as peak-current-mode control needs) | _Parameter descriptions are in English in both languages._ ## Model At every solver step, if r is above 0.5 then q becomes 0, otherwise if s is above 0.5 then q becomes 1, otherwise q keeps its value. With `priority` = `set` the latch is set-dominant: s is checked first, and r is ignored while s is high (the clock of a peak-current-mode loop sets the latch even if the current comparator still resets it). qn is always 1 - q. The latch reacts to levels, not edges, and has direct feedthrough, so `q0` (0 or 1) sets only the value before the first input is seen. ## Common mistakes - While r stays high the output stays 0 whatever s does. Use a short reset pulse, for example from Monostable, to clear a fault. - Two latches wired to each other, or a loop through the latch and gates, is refused. One SR Latch already remembers a state, so you do not need to build one from gates. Problems rules: `compile.error` ## Datasheet and sources There is no datasheet. q0 is the state at power-up that your design assumes, usually 0, meaning no fault is held. The set and reset signals come from your protection logic, such as a comparator on a current sense and a reset from the controller. ## Example Open the example with the command `file.openExample` and the name `demo:srff`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # State Machine (`stateMachine`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/stateMachine/ > Runs a sequence of named states; guard expressions over its inputs and the time in the state move it from one state to the next. ![stateMachine](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/stateMachine.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/stateMachine/) **Group:** Control · **Kind:** `{"block":"stateMachine","kind":"control"}` ## When to use it Use it for start-up, precharge, takeover and fault sequences that would otherwise be a tangle of gates, latches, counters and one-shots. Use SR Latch or Monostable for a single flag or a single pulse. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in1` | signal | First input. A definition with more inputs adds in2 to in8; a guard reads an input by its name or as in1, in2 … | | `out1` | signal | First output, the value the active state gives it. A definition with more outputs adds out2 to out7 | | `state` | signal | Index of the active state, counted from 0 in the order the states are listed | ## Common parameters - `definition`: States, transitions and outputs as JSON; edit it with circuit.setStateMachine, and the pins follow it (Default: required) - `fs`: Rate at which the machine is evaluated; 0 evaluates it at every solver step (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `definition` | — | required | | States, transitions and outputs as JSON; edit it with circuit.setStateMachine, and the pins follow it | | `fs` | Hz | 0 | | Rate at which the machine is evaluated; 0 evaluates it at every solver step | _Parameter descriptions are in English in both languages._ ## Model The definition lists the inputs, the outputs, the states with each output's value (an expression; an output a state leaves out is 0), the initial state and the transitions {from, to, guard, priority}. At every sample (every 1/fs seconds from t = 0, or every solver step when fs is 0) the transitions out of the active state are tried, the smallest priority first and, at equal priorities, in the order they are listed; the first guard that is true (above 0.5) fires, and at most one transition fires per sample. A transition resets t_in_state, the time spent in the active state, also when it returns to the same state. The outputs are then set from the new state and held until the next sample. Guards and output values may read the inputs, t_in_state and the circuit variables. With fs above 0 the sample instants are reported to the solver, t_in_state counts whole samples, and code generation writes the machine as a C switch statement. ## Common mistakes - With fs = 0 a timed guard such as t_in_state > 10m fires at the first solver step after 10 ms, so the timing depends on the step. Set fs to the rate of the controller you model, and write a timed guard half a sample early (t_in_state > 9.5m at 1 kHz) so rounding never moves it a whole sample. - A state that no transition reaches, a transition to a state that does not exist, a guard that does not parse or that reads an unknown name are errors before the run; the message names the state, the transition or the guard. Edit the definition with circuit.setStateMachine, which checks it and moves the pins. ## Datasheet and sources There is no datasheet. The states and timings come from the sequence your system needs, such as the contactor order and the precharge time of a battery pack or the takeover rules of a backup unit. ## Example Open the example with the command `file.openExample` and the name `demo:stateMachine`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # State-Space Model (`stateSpace`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/stateSpace/ > A linear plant or filter given by its A, B, C and D matrices, one input and one output. ![stateSpace](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/stateSpace.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/stateSpace/) **Group:** Control · **Kind:** `{"block":"stateSpace","kind":"control"}` ## When to use it Use it when your model of a plant is already in state-space form, such as an averaged converter model written as derivatives of inductor currents and capacitor voltages. Use Transfer Function or Zero-Pole-Gain when you have B(s)/A(s) or its roots. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Input u | | `out` | signal | Output y | ## Common parameters - `a`: State matrix A, rows separated by semicolons (Default: required) - `b`: Input column B, one value per state (Default: required) - `c`: Output row C, one value per state (Default: required) - `d`: Feedthrough D from the input to the output (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `a` | — | required | | State matrix A, rows separated by semicolons | | `b` | — | required | | Input column B, one value per state | | `c` | — | required | | Output row C, one value per state | | `d` | — | 0 | | Feedthrough D from the input to the output | _Parameter descriptions are in English in both languages._ ## Model ẋ = A·x + B·u and y = C·x + D·u. a is the n × n matrix with rows separated by semicolons (-1, 2; 0, -3), b the column of n input gains, c the row of n output gains, and d a number. The block computes the transfer function C·(sI − A)⁻¹·B + D once when the circuit is built (the Faddeev–LeVerrier recursion) and runs it like Transfer Function: controllable canonical form, trapezoidal rule over every accepted step, initial state zero. With d not zero the output follows the present input (direct feedthrough). With a, b and c left empty the block is the gain d. ## Common mistakes - Only the input-to-output behaviour from a zero state is kept: an initial state, and states the input cannot reach or the output cannot see, are dropped. Start the model at its operating point by adding the steady-state output outside the block. - a must be square, b and c must have one value per row of a, and the order is at most 16, or the build stops. One input and one output only; use one block per output for a model with several. Problems rules: `compile.error`, `solver.control` ## Datasheet and sources There is no datasheet. The matrices come from your model. Code generation treats the block like Transfer Function: written as its discrete equivalent when it feeds a PWM, otherwise left out as an s-domain block. ## Example Open the example with the command `file.openExample` and the name `demo:stateSpace`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Step Source (`step`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/step/ > Changes once from a before value to an after value at time t0. ![step](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/step.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/step/) **Group:** Control · **Kind:** `{"block":"step","kind":"control"}` ## When to use it Use it for a reference change, a load switch-on or an enable signal at a known time. Use Constant for a value that never changes. ## Pins | Pin | Domain | Meaning | |---|---|---| | `out` | signal | before until t0, after from t0 on | ## Common parameters - `t0`: Step time (Default: 0) - `before`: Output before the step (Default: 0) - `after`: Output after the step (Default: 1) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `t0` | s | 0 | | Step time | | `before` | — | 0 | | Output before the step | | `after` | — | 1 | | Output after the step | _Parameter descriptions are in English in both languages._ ## Model The output is before for t < t0 and after for t >= t0. The solver lands a step exactly on t0, so the edge is not smeared. The defaults are t0 = 0, before = 0 and after = 1, and the values can be negative or in any unit the loop carries. ## Common mistakes - A step in a reference makes a controller output jump at once. If the jump is larger than the limits of the loop, the controller saturates, so lower after or ramp it through an Integrator. - The defaults 0 and 1 suit a logic enable, not a speed reference, so set before and after in the unit of the loop. For a PWM duty keep both between 0 and 1, and keep t0 inside the run time. Problems rules: `control.saturated`, `duty.out_of_range` ## Datasheet and sources No datasheet applies. The value of t0 is the time of your test event after start-up has settled, and before and after are the references you test, for example 0 and 100 rad/s. ## Example Open the example with the command `file.openExample` and the name `demo:step`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Sum (`sum`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/sum/ > Adds or subtracts two signals, as set by signs. ![sum](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/sum.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/sum/) **Group:** Control · **Kind:** `{"block":"sum","kind":"control"}` ## When to use it Use it to form an error (reference minus feedback) or to add a feed-forward term. Use Gain with a negative k to flip one signal. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in1` | signal | First input, first sign of signs | | `in2` | signal | Second input, second sign of signs | | `out` | signal | Both inputs added with their signs | ## Common parameters - `signs`: Plus or minus sign for each input (Default: ++) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `signs` | — | ++ | | Plus or minus sign for each input | _Parameter descriptions are in English in both languages._ **Use for:** Error signals · Feed-forward terms · Offsets **Not for:** Multiplying signals → [`product`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/product/) · Formulas of several signals → [`expr`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/expr/) ## Formulas | Formula | Equation | Source | |---|---|---| | Signed sum | out = s1·in1 + s2·in2 | Ogata, Modern Control Engineering, 5th ed. (2010), ch. 2 (block diagrams, summing point) | | Result relative to in1 | 100·out/in1 | Ogata, Modern Control Engineering, 5th ed. (2010), ch. 2 | ## Quick check Inputs: - `in1`: First input = 5 — - `in2`: Second input = 4.8 — - `s1`: Sign of in1 (+1 or -1) = 1 — - `s2`: Sign of in2 (+1 or -1) = -1 — Outputs: - `out`: Output = `s1*in1 + s2*in2` — - `errpct`: Output in percent of in1 = `100*out/in1` — ## Model logic - The output is s1·in1 + s2·in2 at every step, with no state and direct feedthrough. - A minus character in signs gives -1 and any other character +1; spaces are ignored, only the first two characters count, and a missing one gives +1. - An unconnected input reads 0, so an open in2 makes the block pass s1·in1. ## Model out = s1*in1 + s2*in2. A minus character in signs gives the weight -1, and any other character gives +1. Only the first two characters count and spaces are ignored. An unconnected input reads 0, and the block has direct feedthrough. ## Common mistakes - The signs follow the pins, not the wiring order. With signs set to -+ the result is in2 minus in1, so put the reference on in2 and the feedback on in1, or the loop gets positive feedback. - Sum has only two inputs, so chain two Sum blocks for three terms. An input left open reads 0. Problems rules: `pin.unconnected` ## Datasheet and sources No datasheet applies. The signs are a design choice, and reference minus feedback is the usual one. ## Example Open the example with the command `file.openExample` and the name `demo:sum`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Space-Vector Modulator (`svpwm`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/svpwm/ > Turns three phase voltages and the DC-link voltage into three modulation signals. ![svpwm](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/svpwm.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/svpwm/) **Group:** Control · **Kind:** `{"block":"svpwm","kind":"control"}` ## When to use it Use it between dq to abc Transform and Three-Phase PWM in a three-phase inverter. A plain sine reference gives up about 15 percent of the voltage range. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | signal | Phase a reference voltage in V | | `b` | signal | Phase b reference voltage in V | | `c` | signal | Phase c reference voltage in V | | `vdc` | signal | DC-link voltage in V; 0 or below gives zero modulation | | `ma` | signal | Phase a output, modulation or duty as set by output | | `mb` | signal | Phase b output, same form as ma | | `mc` | signal | Phase c output, same form as ma | ## Common parameters - `output`: Output as modulation or duty: `m` or `duty` (Default: m) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `output` | — | m | | Output as modulation or duty: `m` or `duty` | _Parameter descriptions are in English in both languages._ ## Model The block adds the zero-sequence part v0 = -(max(a,b,c) + min(a,b,c))/2 to each reference and divides by vdc/2, so m = clamp((v + v0)*2/vdc, -1, 1). Line-to-line voltages stay unchanged. The linear range reaches a phase peak of vdc/sqrt(3), which is 15.5 percent above a sine-triangle comparison (vdc/2). With output set to duty the outputs are (m + 1)/2, between 0 and 1. A vdc of 0 or below gives m = 0 (duty 0.5). ## Common mistakes - The default output m runs from -1 to 1, so set output to duty before Three-Phase PWM or PWM Generator, which expect 0 to 1. Nothing warns you if you forget. - A reference larger than the DC-link voltage divided by the square root of 3 is cut off, so the inverter over-modulates and the voltage distorts. Limit vd and vq in the PI Controller blocks to that value, and note that an open vdc reads 0 and gives zero modulation. Problems rules: `pin.unconnected` ## Datasheet and sources No datasheet applies. The vdc input is the DC-link voltage, measured or from a Constant, the references come from dq to abc Transform in V, and output follows what the PWM block after it expects. ## Example Open the example with the command `file.openExample` and the name `demo:svpwm`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Transfer Function (`tf`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/tf/ > Describes a plant or compensator with two coefficient lists. ![tf](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/tf.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/tf/) **Group:** Control · **Kind:** `{"block":"tf","kind":"control"}` ## When to use it Use it when you already have a plant or filter as a function of s. Use PID Controller for a PID. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal input | | `out` | signal | Signal output | ## Common parameters - `num`: Numerator coefficients, highest power first (Default: required) - `den`: Denominator coefficients, highest power first (Default: required) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `num` | — | required | | Numerator coefficients, highest power first | | `den` | — | required | | Denominator coefficients, highest power first | | `y0` | — | 0 | | Output at the start; needs an integrator (last `den` coefficient 0) | | `lo` | — | -1e30 | | Lowest value the output can reach; an integrator stops there (anti-windup) | | `hi` | — | 1e30 | | Highest value the output can reach; an integrator stops there (anti-windup) | _Parameter descriptions are in English in both languages._ **Use for:** Plant models · Compensators · Sensor lags **Not for:** PID control → [`pid`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/pid/) · Discrete filters at a sample time → [`ztf`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/ztf/) ## Formulas | Formula | Equation | Source | |---|---|---| | Transfer function | H(s) = num(s)/den(s) | Ogata, Modern Control Engineering, 5th ed. (2010), ch. 2 | | First-order corner of k/(tau·s + 1) | fp = 1/(2π·tau) | Franklin, Powell & Emami-Naeini, Feedback Control of Dynamic Systems, 8th ed. (2019), ch. 6 | | Gain at f | abs(H) = k/√(1 + (2π·f·tau)²) | Franklin, Powell & Emami-Naeini, Feedback Control of Dynamic Systems, 8th ed. (2019), ch. 6 | | Phase at f | φ = -atan(2π·f·tau)·180/π | Franklin, Powell & Emami-Naeini, Feedback Control of Dynamic Systems, 8th ed. (2019), ch. 6 | ## Quick check Inputs: - `k`: DC gain = 1 — - `tau`: Time constant = 1m s - `f`: Frequency = 100 Hz Outputs: - `fp`: Corner frequency = `1/(2*pi*tau)` Hz - `mag`: Gain at f = `k/sqrt(1 + (2*pi*f*tau)^2)` — - `ph`: Phase at f = `-atan(2*pi*f*tau)*180/pi` ° ## Model logic - Coefficients are in descending powers of s; leading zeros are dropped, both lists are divided by the first den coefficient, and the block is built in controllable canonical form. - Each accepted step of length h advances the state by the trapezoid (Tustin); the matrices are recomputed only when h changes, and a step with h = 0 only records the input. - The state starts at zero; a non-zero y0 is accepted only with an integrator (last den coefficient 0 and last num coefficient not 0). - A num of the same degree as den gives direct feedthrough; an improper function, a zero den, an order above 16 or an output that is not finite stops the run. ## Model H(s) = B(s)/A(s). num and den hold the coefficients in descending powers of s, so 0.01, 1 means 0.01·s + 1. Leading zeros are dropped and both lists are divided by the first denominator coefficient. The block is realised in controllable canonical form and integrated with the trapezoidal rule over every accepted solver step. The initial state is zero. A numerator of the same degree as the denominator gives direct feedthrough (the output follows the present input), so a loop through such a block needs another block without feedthrough. ## Common mistakes - Write the coefficients from the highest power of s down, so 1, 0.01 means s + 0.01. A numerator of higher degree than the denominator, a zero denominator or an order above 16 is refused. - An unstable denominator makes the output grow until the run stops, and a pole at 2/h (h is the step length) breaks the method. Keep maxStep several times smaller than the fastest time constant. Problems rules: `compile.error`, `solver.control` ## Datasheet and sources There is no datasheet. The coefficients come from your model of the plant, with R, L, C and J turned into time constants in seconds, or from a compensator you designed. ## Example Open the example with the command `file.openExample` and the name `demo:tf`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # THD Meter (`thd`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/thd/ > The total harmonic distortion of a signal and its fundamental, while the circuit runs. ![thd](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/thd.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/thd/) **Group:** Control · **Kind:** `{"block":"thd","kind":"control"}` ## When to use it Use it to watch or act on the distortion of an inverter output or a rectifier input current during the run. Use Harmonic Meter for one harmonic and scope.measure for the spectrum after the run. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal to measure | | `freq` | signal | Optional fundamental frequency in hertz, such as a PLL output | | `thd` | signal | Total harmonic distortion as a ratio, 0.05 is 5 percent | | `amp` | signal | Peak amplitude of the fundamental | ## Common parameters - `f`: Fundamental frequency: the window is cycles/f seconds; a wired freq input replaces it (50 Hz mains, IEC 60038:2009 Table 1) (Default: 50) - `cycles`: Window length in periods of the fundamental; the harmonic window of IEC 61000-4-7:2002+A1:2008 is 10 at 50 Hz and 12 at 60 Hz (Default: 1) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `f` | Hz | 50 | | Fundamental frequency: the window is cycles/f seconds; a wired freq input replaces it (50 Hz mains, IEC 60038:2009 Table 1) | | `cycles` | — | 1 | | Window length in periods of the fundamental; the harmonic window of IEC 61000-4-7:2002+A1:2008 is 10 at 50 Hz and 12 at 60 Hz | _Parameter descriptions are in English in both languages._ ## Model Over the same sliding window as RMS Meter the block integrates in, in squared, and in times the sine and cosine of the fundamental angle. The fundamental amplitude is A1 = 2*sqrt(mean(in*sin)^2 + mean(in*cos)^2). THD = sqrt(mean(in^2) - mean(in)^2 - A1^2/2) / (A1/sqrt(2)), everything in the RMS that is neither DC nor fundamental over the RMS of the fundamental. It counts every harmonic the step resolves, so a square wave gives the analytic 48.3 percent. The output is 0 while the fundamental is zero. ## Common mistakes - scope.measure sums harmonics up to order 50 by default, as IEEE Std 519-2014 defines THD, and this block counts all of them. For a square wave the two differ by a few tenths of a percent; for a switched waveform with a large ripple at the switching frequency the block reads higher. - The window must be whole periods of the fundamental. With f wrong by even a percent, part of the fundamental counts as distortion. Problems rules: `pin.unconnected` ## Datasheet and sources A power-quality analyser reports THD over a window of 10 cycles at 50 Hz or 12 at 60 Hz (IEC 61000-4-7:2002+A1:2008) and usually up to order 40 or 50; check which orders it sums before comparing. ## Example Open the example with the command `file.openExample` and the name `demo:thd`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Transport Delay (`transportDelay`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/transportDelay/ > Delays a signal by a fixed time. ![transportDelay](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/transportDelay.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/transportDelay/) **Group:** Control · **Kind:** `{"block":"transportDelay","kind":"control"}` ## When to use it Use it for a dead time of the plant: a sensor or communication delay, a computation delay, or the transport lag of a fluid. Use Unit Delay or zDelay for a delay of whole samples. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal input | | `out` | signal | The input td seconds ago | ## Common parameters - `td`: Delay from input to output (Default: required) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `td` | s | required | | Delay from input to output | _Parameter descriptions are in English in both languages._ ## Model out(t) = in(t − td), with straight lines between the solver steps it remembers. Until td has passed the output holds the input's value at t = 0. With td = 0 the output is the input. The block keeps the history it needs, at most about one million points. ## Common mistakes - A long delay against a small step needs a long history: a delay of more than about a million steps stops the run with an error naming the block. Raise maxStep or shorten the delay. - The block has direct feedthrough, so a loop through it alone is an algebraic loop even with td above 0; put an integrator or a sample-and-hold in the loop. Code generation leaves it out; at a sample time a delay of n samples is n zDelay blocks. Problems rules: `compile.error`, `solver.control` ## Datasheet and sources There is no datasheet. A sensor's delay is often given as a propagation delay or a group delay in its data sheet; use that as td. ## Example Open the example with the command `file.openExample` and the name `demo:transportDelay`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Voltage-Controlled Oscillator (`vco`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/vco/ > An oscillator whose frequency follows its control input. ![vco](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/vco.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/vco/) **Group:** Control · **Kind:** `{"block":"vco","kind":"control"}` ## When to use it Use it when a wave must change frequency during the run, for example in a phase-locked loop or a frequency sweep. Use Sine Source when the frequency is fixed. ## Pins | Pin | Domain | Meaning | |---|---|---| | `v` | signal | Control input that sets the frequency | | `out` | signal | The output wave | | `theta` | signal | Phase in radians, one full turn | ## Common parameters - `f0`: Output frequency when the control is zero (Default: required) - `kv`: Frequency change per unit of control (Default: required) - `fmin`: Lowest output frequency (Default: 0) - `fmax`: Highest output frequency (Default: 1e9) - `shape`: Wave shape of the output: `sine`, `square`, `triangle` or `sawtooth` (Default: sine) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `f0` | Hz | required | | Output frequency when the control is zero | | `kv` | Hz | required | | Frequency change per unit of control | | `fmin` | Hz | 0 | | Lowest output frequency | | `fmax` | Hz | 1e9 | | Highest output frequency | | `shape` | — | sine | | Wave shape of the output: `sine`, `square`, `triangle` or `sawtooth` | | `amplitude` | — | 1 | | Height of the wave peak | | `offset` | — | 0 | | Fixed amount added to the wave | | `duty` | — | 0.5 | | Part of the period a square wave is high, between 0 and 1 | | `phase` | ° | 0 | | Where the wave starts in its cycle | _Parameter descriptions are in English in both languages._ ## Model The frequency is f = f0 + kv*v, held between fmin and fmax. The phase is the integral of the frequency, theta = 2*pi*integral(f dt), kept in the range 0 to 2*pi. Within each step the control input is treated as a straight line from its old value to its new value, and the frequency is integrated exactly along that line. So the phase stays exact for any step length when the control input is piecewise linear. The output is offset + amplitude*shape(theta), and every shape rises through the offset at a phase of 0. Sine is sin(theta). Square is +1 for the first half of the period. Triangle peaks at a quarter period. Sawtooth rises from -1 to +1 and jumps back at half a period. The block has no direct feedthrough, like an integrator, so a loop can close through it. Inside a loop it reads the control input of the previous step. ## Common mistakes - The solver ends a step on each edge of a square or sawtooth wave, at the time the present frequency predicts. A control input that changes fast within one step moves the edge a little from that time, so keep the step well below the period when the edges drive switches. - The gain kv is in hertz per unit of input, not radians per second. A loop designed with a gain in radians per second must be divided by 6.28 first, and the frequency never goes below fmin, so a large negative input stops the phase instead of turning it back. - An unconnected control input reads 0, so the oscillator runs at f0 and looks fine. The loop it belongs to is still open. Problems rules: `pin.unconnected` ## Datasheet and sources For an IC oscillator such as the 4046, f0 is the centre frequency set by its timing parts at the middle control voltage. The gain kv is the slope of frequency against control voltage, often called VCO gain and given in MHz or kHz per volt, and fmin and fmax are the two ends of that curve. ## Example Open the example with the command `file.openExample` and the name `demo:vco`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Virtual Synchronous Machine (Grid-Forming) (`vsm`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/vsm/ > Makes an inverter behave like a synchronous generator: its frequency follows the power through a virtual inertia and a droop damping. ![vsm](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/vsm.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/vsm/) **Group:** Control · **Kind:** `{"block":"vsm","kind":"control"}` ## When to use it Use it for a grid-forming inverter that should resist fast frequency changes on an island or weak grid, giving inertia as well as load sharing. Use Droop Control when only the sharing matters; with the same kp both share a load the same way in steady state. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | signal | Measured active power the inverter delivers, in W | | `q` | signal | Measured reactive power, in var, positive for an inductive load | | `theta` | signal | Angle of the voltage reference, in radians | | `w` | signal | Angular frequency of the voltage, in rad/s | | `e` | signal | Amplitude of the voltage reference, peak per phase, in V | ## Common parameters - `e0`: Voltage amplitude (peak, per phase) at the reactive power qset (Default: required) - `prated`: Rated active power: the base of h and kp (Default: required) - `h`: Inertia constant: stored energy at the nominal speed over the rated power (Default: required) - `kp`: Frequency droop per unit, the inverse of the damping: the frequency settles kp·f0 lower at the rated power (Default: required) - `kq`: Voltage droop per unit: the amplitude falls by kq·e0 at the rated reactive power (Default: required) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `f0` | Hz | 50 | | Nominal frequency, at the power pset (50 Hz mains, IEC 60038:2009 Table 1) | | `e0` | V | required | | Voltage amplitude (peak, per phase) at the reactive power qset | | `prated` | W | required | | Rated active power: the base of h and kp | | `qrated` | var | optional (off) | | Rated reactive power: the base of kq (prated when absent) | | `h` | s | required | | Inertia constant: stored energy at the nominal speed over the rated power | | `kp` | — | required | | Frequency droop per unit, the inverse of the damping: the frequency settles kp·f0 lower at the rated power | | `kq` | — | required | | Voltage droop per unit: the amplitude falls by kq·e0 at the rated reactive power | | `fc` | Hz | required | | Cutoff of the filter on the measured reactive power | | `pset` | W | 0 | | Active power at which the frequency is f0 | | `qset` | var | 0 | | Reactive power at which the amplitude is e0 | | `theta0` | rad | 0 | | Angle at the start | _Parameter descriptions are in English in both languages._ ## Model The per-unit speed follows the swing equation 2*h*d(w/w0)/dt = (pset - p)/prated - (w/w0 - 1)/kp, with w0 = 2*pi*f0: h is the inertia constant in seconds on the base prated, and the damping 1/kp makes the frequency settle on the droop line w = w0*(1 - kp*(p - pset)/prated). Right after a power step dP the frequency moves at f0*dP/(2*h*prated) Hz/s, then settles with the time constant 2*h*kp. theta is the integral of w, kept between 0 and 2*pi. The amplitude follows the Q-V droop e = e0*(1 - kq*(Qf - qset)/qrated), with q filtered at fc. With the same kp, inverters share active power by their ratings like Droop Control; the machine equals a droop whose power filter has the cutoff 1/(2*pi*2*h*kp). h = 0 leaves no inertia and kp = 0 holds the frequency at f0. w stays between 0 and twice the nominal speed and e between 0 and 2*e0. The block has no direct feedthrough, so it can sit in the loop it feeds. Feed theta and e to Inverse Park (dq2abc) with d = e and q = 0. ## Common mistakes - A large inertia with a small droop is a slow, lightly damped swing against the line inductance: the power oscillates at the electromechanical frequency after a load step. Raise kp or lower h, or check the step response before adding inertia. - The inertia is virtual: the energy for it comes from the DC link. A step of rated power for the time constant 2*h*kp has to be covered by the source or the link capacitor, or the link voltage sags. - The droops assume a mainly inductive output impedance, as for Droop Control; with a resistive line add series inductance or a virtual impedance. Problems rules: `pin.unconnected` ## Datasheet and sources There is no datasheet. e0 is the phase voltage peak of the grid the inverter forms, prated and qrated are the inverter's ratings, h is a design choice (synchronous generators have a few seconds), and kp and kq come from the grid's rules or the microgrid's design. fc is a few hertz. ## Example Open the example with the command `file.openExample` and the name `demo:vsm`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # XOR Gate (`xor`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/xor/ > Outputs 1 when an odd number of inputs are above 0.5. ![xor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/xor.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/xor/) **Group:** Control · **Kind:** `{"block":"xor","kind":"control"}` ## When to use it Use it to detect that two signals differ, such as a commanded and a measured gate state. Use OR Gate when several true inputs should still give 1. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in1` | signal | First input; true above 0.5 | | `in2` | signal | Second input; true above 0.5 | | `in3` | signal | Third input, read if n is 3 or 4 | | `in4` | signal | Fourth input, read if n is 4 | | `out` | signal | Output, always 0 or 1 | ## Common parameters - `n`: How many inputs the gate has (Default: 2) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `n` | — | 2 | | How many inputs the gate has | _Parameter descriptions are in English in both languages._ ## Model The first n inputs are read (n = 2 by default, up to 4). An input is true when it is above 0.5. The output is 1 when an odd number of the n inputs are true and 0 when the count is even. For two inputs this is true when they differ. The gate is combinational and has direct feedthrough. ## Common mistakes - With three or four inputs this is a parity check, not exactly one: three true inputs give 1. The default n of 2 ignores in3 and in4, so set n to the number of inputs you use. - Two signals that change at slightly different solver steps make the output flash for one step, and a counter or latch may count it. Compare signals that come from the same clock; a loop made only of gates is refused. Problems rules: `compile.error` ## Datasheet and sources There is no datasheet. n is the number of signals compared. The logic levels come from your design, for example a command signal against its feedback. ## Example Open the example with the command `file.openExample` and the name `demo:xor`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Unit Delay (z^-n) (`zDelay`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/zDelay/ > Delays its input by a whole number of samples. ![zDelay](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/zDelay.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/zDelay/) **Group:** Control · **Kind:** `{"block":"zDelay","kind":"control"}` ## When to use it Use it for the computation delay of a digital controller, or to break a loop between sampled blocks. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal to delay | | `out` | signal | Input from n samples ago | ## Common parameters - `ts`: Time between samples (Default: required) - `n`: Delay, counted in whole samples (Default: 1) - `offset`: Time of the first sample (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `ts` | s | required | | Time between samples | | `offset` | s | 0 | | Time of the first sample | | `n` | — | 1 | | Delay, counted in whole samples | _Parameter descriptions are in English in both languages._ ## Model At each instant offset + k·ts the block pushes the present input into a first-in first-out queue of length n and outputs the value that falls out, so y[k] = u[k-n]. The queue starts at zero, so the first n outputs are 0. The block has no direct feedthrough, which is why it can close a loop. The delay in seconds is n·ts. ## Common mistakes - n counts samples, not seconds, and must be a whole number from 1 to 4096. For a delay of part of a sample, use the delay setting of MCU Output Stage. - The first n outputs are 0 whatever the input is. Give this block the same ts and offset as the controller blocks around it, or the delay is not a whole number of controller samples. ## Datasheet and sources ts is the controller sample time, 1/fs. n is the delay of your firmware in samples: the measured interrupt run time divided by ts, rounded up. Use 1 when the code computes in one sample and applies the result in the next. ## Example Open the example with the command `file.openExample` and the name `demo:zDelay`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Zero-Order Hold (`zoh`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/zoh/ > Samples its input at fixed times and holds the value. ![zoh](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/zoh.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/zoh/) **Group:** Control · **Kind:** `{"block":"zoh","kind":"control"}` ## When to use it Use it as the ADC stage that feeds a digital controller. Use Sample and Hold when no start offset is needed. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal to sample | | `clk` | signal | Optional clock; while wired the block samples at each of its rising edges instead of every `ts`. | | `out` | signal | Held value; changes only at sample times | ## Common parameters - `ts`: Time between samples; with the clk input wired, every rising edge of clk instead (Default: required) - `offset`: Time of the first sample (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `ts` | s | required | | Time between samples; with the clk input wired, every rising edge of clk instead | | `offset` | s | 0 | | Time of the first sample | _Parameter descriptions are in English in both languages._ ## Model At each instant t = `offset` + k·`ts` (k = 0, 1, 2, ...) the output takes the value of the input at that moment and keeps it until the next instant. Before the first instant the output is 0. With `clk` wired the instants are the rising edges of `clk` (across 0.5) instead, and the block reports none of its own. The block reports its instants to the solver, so fastsolve ends a step exactly on each of them. It has direct feedthrough at the instant, so it cannot close a loop by itself. ## Common mistakes - Keep maxStep at or below ts, and for the fixed-step solver make it divide ts evenly, or sample times are skipped. A meter has no value yet at time 0, so the first sample reads 0. - A loop that passes only through this block and other direct-pass blocks is refused. Add a Unit Delay to stand for the one-sample delay of the real firmware. Problems rules: `compile.error` ## Datasheet and sources ts is the ADC trigger period of your MCU, which is 1/fs and matches the MCU Output Stage. offset is where the trigger falls inside the PWM period: 0 at the carrier valley, half a PWM period at the peak. ## Example Open the example with the command `file.openExample` and the name `demo:zoh`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Zero-Pole-Gain (`zpk`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/zpk/ > A transfer function given by its zeros, its poles and a gain. ![zpk](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/zpk.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/zpk/) **Group:** Control · **Kind:** `{"block":"zpk","kind":"control"}` ## When to use it Use it when a data sheet, a paper or your design gives a filter or a compensator as poles and zeros, such as a Type II compensator with a zero at 1 kHz and a pole at 20 kHz. Use Transfer Function for polynomial coefficients. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal input | | `out` | signal | Signal output | ## Common parameters - `zeros`: Zeros on the s-plane, with commas; a+bj stands for the pair a ± bj; empty for none (Default: optional (off)) - `poles`: Poles on the s-plane, with commas; a+bj stands for the pair a ± bj (Default: required) - `k`: Gain in front of the factored form (not the DC gain) (Default: required) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `zeros` | rad/s | optional (off) | | Zeros on the s-plane, with commas; a+bj stands for the pair a ± bj; empty for none | | `poles` | rad/s | required | | Poles on the s-plane, with commas; a+bj stands for the pair a ± bj | | `k` | — | required | | Gain in front of the factored form (not the DC gain) | _Parameter descriptions are in English in both languages._ ## Model H(s) = k·(s − z1)(s − z2)…/((s − p1)(s − p2)…), roots in rad/s on the s-plane, so a pole at 1 kHz is -2*pi*1k. A complex root is written a+bj (no spaces) and stands for the pair a ± bj, so the polynomial has real coefficients. The block multiplies the factors out once and runs as Transfer Function. k multiplies the factored form, it is not the DC gain: k/(s + 1000) has a DC gain of k/1000. ## Common mistakes - More zeros than poles is refused (the block must be proper), as is an order above 16; a complex root counts twice. - Write the roots as negative numbers for a stable block: a pole at +1000 grows without bound. Enter roots in rad/s, not Hz. Problems rules: `compile.error`, `solver.control` ## Datasheet and sources There is no datasheet. The roots come from your design. Code generation treats the block like Transfer Function. ## Example Open the example with the command `file.openExample` and the name `demo:zpk`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Discrete Transfer Function (`ztf`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/ztf/ > Filters or controls a sampled signal with two coefficient lists. ![ztf](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/ztf.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/control/ztf/) **Group:** Control · **Kind:** `{"block":"ztf","kind":"control"}` ## When to use it Use it for a digital compensator or filter when you already have its difference equation. Use Transfer Function for a continuous design. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in` | signal | Signal input, sampled every ts | | `out` | signal | Output, held between sample times | ## Common parameters - `ts`: Time between samples (Default: required) - `num`: Numerator coefficients, no delay first (Default: required) - `den`: Denominator coefficients, no delay first (Default: required) - `offset`: Time of the first sample (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `ts` | s | required | | Time between samples | | `offset` | s | 0 | | Time of the first sample | | `num` | — | required | | Numerator coefficients, no delay first | | `den` | — | required | | Denominator coefficients, no delay first | | `lo` | — | -1e30 | | Lowest value the output can reach; the limited output is what the filter remembers | | `hi` | — | 1e30 | | Highest value the output can reach; the limited output is what the filter remembers | | `y0` | — | 0 | | Output at the start while the input is zero (needs a pole at z = 1) | _Parameter descriptions are in English in both languages._ ## Model H(z) = (b0 + b1·z^-1 + ...) / (1 + a1·z^-1 + ...), so y[k] = b0·u[k] + b1·u[k-1] + ... - a1·y[k-1] - .... num is b0, b1, ... and den is 1, a1, ...; both lists are divided by the first den coefficient, which must not be 0. At most 64 coefficients are allowed. The block has direct feedthrough only when b0 is not 0, so 0, 0.1 is a delay of one sample and can close a loop. ## Common mistakes - The order is the opposite of Transfer Function: start with the constant term and go up in powers of z^-1, not down in powers of s. A first-order lag with a = exp(-ts/tau) is num 0, 1-a and den 1, -a. - A pole outside the unit circle makes the output grow until the run stops. Design the coefficients for the same ts the block uses, or the response is wrong. Problems rules: `solver.control` ## Datasheet and sources ts is the controller sample time, 1/fs. The coefficients come from converting your continuous design to that ts with a design tool or by hand, or straight from the difference equation in the firmware. ## Example Open the example with the command `file.openExample` and the name `demo:ztf`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Plug-in Block (`plugin`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/custom/plugin/ > A custom block you write as a sandboxed WebAssembly module. ![plugin](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/plugin.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/custom/plugin/) **Group:** Custom blocks · **Kind:** `{"kind":"plugin","module":"gainOffset"}` ## When to use it Use it for control logic that no library block provides. Prefer a library control block when one exists, because it is faster. ## Pins | Pin | Domain | Meaning | |---|---|---| | `in1` | signal | Signal input 1; reads 0 when unconnected | | `in2` | signal | Signal input 2; reads 0 when unconnected | | `out1` | signal | Signal output 1, written each step | | `out2` | signal | Signal output 2, written each step | ## Model The module registered under the component's module name runs once per accepted step with the current time t, reads in1 and in2, and writes out1 and out2. Numeric parameters are passed in the order of their names sorted by bytes, at most 16, with upper case before lower case. The module has no access to files, network or clock, and limits on memory and instruction count stop a runaway module with an error. ## Common mistakes - Register the module under the same name before the circuit runs, because the plug-in is not saved in the circuit file. An unregistered module stops the compile with an error. - Parameters arrive in alphabetical order, not the order you typed them, so gain comes before offset. A NaN or infinite output stops the run, and an unconnected input reads 0. Problems rules: `compile.error`, `pin.unconnected` ## Datasheet and sources There is no datasheet. The parameters are your own design constants, such as gains, limits and sample times, and the module reads the time t itself when it needs a fixed sample rate. ## Example Open the example with the command `file.openExample` and the name `demo:plugin`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Subsystem (`subsystem`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/custom/subsystem/ > A reusable group of parts, shown as one block with pins. ![subsystem](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/subsystem.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/custom/subsystem/) **Group:** Custom blocks · **Kind:** `{"definition":"Sub1","kind":"subsystem"}` ## When to use it Use it to repeat the same sub-circuit, such as a phase leg or a gate driver, or to tuck detail into a named block. ## Model At compile time, the instance is replaced by a copy of the definition's parts. Their names get the instance name as a prefix, such as U1.R1, and inner nets belong to the instance alone. A net whose name equals a port name joins the matching pin, and ground nets (0, gnd, GND) stay global. Nesting is limited to 16 levels, and a subsystem that contains itself is an error. The instance has no parameters of its own. ## Common mistakes - Connect every port of the instance to a net of the same kind. A signal port joined to a power net is flagged, and a port left open becomes its own floating net inside. - Ground inside a subsystem is the same global ground as outside, so a subsystem cannot hold an isolated ground. A missing definition, or subsystems that contain each other, stop the compile with an error. Problems rules: `pin.domain_mismatch`, `compile.error` ## Datasheet and sources There is no datasheet for the wrapper. Each part inside takes its numbers from its own datasheet, and values shared by several instances belong in circuit variables. ## Example Open the example with the command `file.openExample` and the name `demo:subsystem`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Buck Regulator (Integrated High-Side MOSFET) (`buckRegulator`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/buckRegulator/ > A complete step-down regulator IC with its own high-side switch: you add the catch diode, inductor, output capacitor, divider and compensation. ![buckRegulator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/buckRegulator.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/buckRegulator/) **Group:** ICs · **Kind:** `{"definition":"buckRegulator","kind":"subsystem"}` ## When to use it Use it when your buck is a TPS54360B-, TPS54560B- or TPS54331-class regulator with an external catch diode and you want to check the external parts, the start-up and the loop with the part's own numbers. For a controller with external MOSFETs use Synchronous Buck Controller. ## Pins | Pin | Domain | Meaning | |---|---|---| | `VIN` | electrical | Input supply, the drain of the internal high-side MOSFET | | `EN` | electrical | Enable and input UVLO, wire the divider from VIN here | | `SS` | electrical | Soft start, the capacitor to GND sets the ramp (leave open on a part with an internal soft start) | | `FB` | electrical | Feedback input, wire the output divider here | | `COMP` | electrical | Error amplifier output, the type II network goes from here to GND | | `BOOT` | electrical | Bootstrap capacitor to SW | | `SW` | electrical | Switch node, the catch diode goes from GND to here | | `GND` | electrical | Ground and reference of every pin | ## Common parameters - `fsw`: Switching frequency (the part sets it with RT; ic.designExternals sizes RT) (Default: 500000) - `vRef`: Feedback reference voltage (Default: 0.8) - `gmEa`: Error amplifier transconductance (Default: 0.00035) - `gmPs`: COMP to switch current transconductance: the peak switch current is gmPs times V(COMP) (Default: 12) - `iLim`: Peak switch current limit (Default: 5.5) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `fsw` | Hz | 500000 | 10k – 10meg Hz | Switching frequency (the part sets it with RT; ic.designExternals sizes RT) | Section 6.5 fSW typ 500 kHz (RT = 200 kOhm), p.5 | | `vRef` | V | 0.8 | 100m – 5 V | Feedback reference voltage | Section 6.5 Voltage reference typ 0.8 V (0.792 to 0.808 V), p.5 | | `gmEa` | S | 0.00035 | 100n – 100m S | Error amplifier transconductance | Section 6.5 Error amplifier transconductance (gM) typ 350 uS, p.5 | | `a0` | V/V | 10000 | 1 – 1g V/V | Error amplifier DC gain (sets the COMP output resistance a0 / gmEa) | Section 6.5 Error amplifier DC gain typ 10,000 V/V (VFB = 0.8 V), p.5 | | `iEaMax` | A | 0.00003 | 100n – 10m A | Error amplifier source and sink current limit | Section 6.5 Error amplifier source/sink typ +-30 uA (V(COMP) = 1 V, 100-mV overdrive), p.5 | | `gmPs` | A/V | 12 | 10m – 1k A/V | COMP to switch current transconductance: the peak switch current is gmPs times V(COMP) | Section 6.5 COMP to SW current transconductance typ 12 A/V, p.5 | | `iLim` | A | 5.5 | 10m – 1k A | Peak switch current limit | Section 6.5 Current limit threshold typ 5.5 A (open loop), p.5 | | `rdsOn` | Ω | 0.092 | 100u – 100 Ω | High-side MOSFET on-resistance | Section 6.5 High-side MOSFET on-resistance typ 92 mOhm (VIN = 12 V, BOOT-SW = 6 V), p.5 | | `tOnMin` | s | 0.000000135 | 1n – 10u s | Minimum on-time (the current comparator is blanked for it) | Section 6.6 Minimum controllable on time typ 135 ns (VIN = 12 V, 25 C), p.6 | | `dmax` | — | 1 | 50m – 1 | Maximum duty cycle (1: the switch may stay on through the clock) | Section 7.3.4: the high-side MOSFET operates at 100 % duty cycle while BOOT-SW is above 2.1 V, p.12 | | `tSs` | s | 0.0021 | 0 – 1 s | Internal soft-start time, 10 % to 90 % of the reference (0: none, the SS pin alone) | Section 6.6 Internal soft-start time typ 2.1 ms (fSW = 500 kHz, 10 % to 90 %), p.6 | | `iSs` | A | 0 | 0 – 1m A | Current that charges the soft-start capacitor on SS (0: no SS pin) | Section 5 Pin Functions: the TPS54360B has no SS pin (internal soft start, Section 7.1), p.3 | | `vEn` | V | 1.2 | 100m – 10 V | EN threshold (rising and falling) | Section 6.5 Enable threshold voltage typ 1.2 V, no voltage hysteresis, p.5 | | `iEnPu` | A | 0.0000012 | 0 – 1m A | Pull-up current out of EN, always | Section 6.5 EN input current typ -1.2 uA (enable threshold - 50 mV), p.5 | | `iEnHys` | A | 0.0000034 | 0 – 1m A | Hysteresis current out of EN, added while EN is above vEn | Section 6.5 EN hysteresis current typ -3.4 uA, p.5 | | `vUvlo` | V | 4.3 | 500m – 100 V | Internal VIN undervoltage lockout, rising | Section 6.5 Internal undervoltage lockout threshold rising typ 4.3 V, p.5 | | `vUvloHys` | V | 0.325 | 0 – 10 V | Internal VIN undervoltage lockout hysteresis | Section 6.5 Internal undervoltage lockout threshold hysteresis typ 325 mV, p.5 | | `se` | A/s | 0 | 0 – 1t A/s | Slope compensation, in amperes of switch current per second | assumption: Section 7.3.2 says a compensating ramp is added to the switch current sense but gives no slope, p.11; 0 here, so the current loop is stable below 50 % duty only | | `rOff` | Ω | 1000000 | 1k – 1t Ω | Off-state resistance of the internal switches, and the leak that keeps EN, SS and BOOT from floating | assumption: the solver's default switch off resistance | _Parameter descriptions are in English in both languages._ ## Model A clock at fsw turns the high-side MOSFET (rdsOn) on; after at least tOnMin it turns off once the switch current plus se times the time reaches gmPs times V(COMP), clamped to iLim, and it is forced off after dmax of the period. The error amplifier drives gmEa times (reference minus FB), limited to plus or minus iEaMax, into COMP, loaded inside by a0 / gmEa. The reference is the lowest of vRef, V(SS) and an internal ramp with a 10 to 90 percent time of tSs. iEnPu flows out of EN always and iEnHys more above vEn; VIN must be above vUvlo. ## Common mistakes - The frequency is the parameter fsw: the RT resistor of the real part is not modelled. ic.designExternals sizes RT for a frequency with the data sheet's equation. - The data sheet gives no value for the internal slope compensation, so se is 0 and the current loop is stable below 50 percent duty only. Above that, set se. - The catch diode is outside the IC. Without it the inductor current has no path when the switch turns off. Problems rules: `step.too_large`, `param.out_of_range`, `pin.unconnected` ## Datasheet and sources fsw, vRef, gmEa, a0, iEaMax, gmPs, iLim, rdsOn, vEn, iEnPu, iEnHys, vUvlo and vUvloHys come from the electrical characteristics, and tOnMin and tSs from the timing table. dmax is 1 because the BOOT recharge lets the part run at 100 percent duty. se and rOff are assumptions: the data sheet gives no slope. ## Example Open the example with the command `file.openExample` and the name `demo:buckRegulator`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # CCM Boost PFC Controller (Average Current Mode) (`ccmPfcController`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/ccmPfcController/ > Shapes the input current of a boost PFC to follow the line voltage without sensing the line, and regulates the output voltage. ![ccmPfcController](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/ccmPfcController.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/ccmPfcController/) **Group:** ICs · **Kind:** `{"definition":"ccmPfcController","kind":"subsystem"}` ## When to use it Use it for a universal-input boost PFC with a UCC28180-class controller, when you want the data sheet's design procedure, the M1 and M2 loop gains, soft start, EDR and the protections with your own power stage. circuit.applicationCircuit with topology ccmPfc sizes every external part. To try your own PFC control law, use the PI Controller and PWM Generator instead. ## Pins | Pin | Domain | Meaning | |---|---|---| | `GND` | electrical | Ground reference of every pin | | `ICOMP` | electrical | Current amplifier output, the capacitor CICOMP goes to GND | | `ISENSE` | electrical | Current sense, through 220 ohm from the bridge side of the sense resistor | | `FREQ` | electrical | Frequency set, the resistor RFREQ goes to GND | | `VCOMP` | electrical | Voltage amplifier output, the RC compensation goes to GND | | `VSENSE` | electrical | Output voltage sense, wire the divider from the PFC output here | | `VCC` | electrical | Supply, the controller runs above the UVLO threshold | | `GATE` | electrical | Gate drive of the boost switch | ## Common parameters - `vRef`: Voltage error amplifier reference (Default: 5) - `gmv`: Voltage error amplifier transconductance (Default: 0.000056) - `gmi`: Current amplifier transconductance (Default: 0.00095) - `vSoc`: Soft overcurrent threshold, magnitude of the negative ISENSE voltage (Default: 0.285) - `vPcl`: Peak current limit threshold, magnitude of the negative ISENSE voltage (Default: 0.4) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `vFreq` | V | 1.5 | 500m – 5 V | Voltage FREQ is held at | Section 7.5 VFREQ typ 1.5 V, p.6 | | `fTyp` | Hz | 65000 | 1k – 1meg Hz | fTYP of the frequency equation | Section 9.2.2.2 equation 12: fTYP = 65 kHz | | `rTyp` | Ω | 32700 | 1k – 1meg Ω | RTYP of the frequency equation | Section 9.2.2.2 equation 12: RTYP = 32.7 kΩ | | `rInt` | Ω | 1000000 | 10k – 100meg Ω | RINT of the frequency equation | Section 9.2.2.2 equation 12: RINT = 1 MΩ | | `tOffMin` | s | 0.00000057 | 0 – 10u s | Minimum off-time of every period | Section 7.5 tOFF(min) typ 570 ns, p.6 | | `kIsense` | V/V | 2.5 | 100m – 100 V/V | Gain from -V(ISENSE) to the internal current signal | Section 8.3.10: ISENSE is buffered by a fixed gain of -2.5 | | `gmi` | S | 0.00095 | 1u – 1 S | Current amplifier transconductance | Section 7.5 gmi typ 0.95 mS, p.6 | | `k1` | V/V | 7 | 100m – 100 V/V | Current loop constant K1 | Section 9.2.2.12 equation 79: K1 = 7 | | `iCompMax` | A | 0.00005 | 100n – 10m A | Current amplifier output current limit | Section 7.5 current loop output linear range ±50 µA (characterized by design), p.6 | | `vIcompFault` | V | 3 | 0 – 6 V | ICOMP voltage during OVP_H, OLP and ISOP | Section 7.5 ICOMP voltage during OLP typ 3 V, p.6; section 8.3.17 | | `vRef` | V | 5 | 1 – 10 V | Voltage error amplifier reference | Section 7.5 VREF typ 5 V, p.6 | | `gmv` | S | 0.000056 | 100n – 10m S | Voltage error amplifier transconductance | Section 7.5 gmv typ -56 µS (current out of VCOMP), p.6 | | `iVcompMax` | A | 0.00004 | 100n – 10m A | Voltage error amplifier output current limit (soft-start source and normal sink) | Section 7.5 source current under soft start typ -40 µA and maximum sink current typ 40 µA, p.6 | | `gmvEdr` | S | 0.00028 | 100n – 100m S | Transconductance under enhanced dynamic response | Section 7.5 gmv-EDR typ -280 µS, p.6 | | `iEdrMax` | A | 0.000275 | 100n – 100m A | Voltage error amplifier output current limit under EDR | Section 7.5 maximum current under EDR operation typ -275 µA, p.6 | | `kUvd` | — | 0.95 | 500m – 1 | UVD threshold, a fraction of vRef (EDR below it) | Section 7.5 VUVD typ 95 %VREF, p.6 | | `kOvd` | — | 1.05 | 1 – 1.5 | OVD threshold, a fraction of vRef (EDR above it) | Section 7.5 VOVD typ 105 %VREF, p.6 | | `kSsEnd` | — | 0.98 | 500m – 1 | End-of-soft-start threshold on VSENSE, a fraction of vRef | Section 7.5 VSENSE threshold, end-of-soft-start typ 98 %VREF, p.7 | | `vPrecharge` | V | 1.5 | 0 – 5 V | VCOMP pre-charge voltage before the soft start | Section 7.5 VPRECHARGE typ 1.5 V, p.7 | | `iPrecharge` | A | 0.001 | 1u – 100m A | VCOMP pre-charge current at VCOMP = 0 V | Section 7.5 IPRECHARGE typ -1 mA, p.7 | | `kOlp` | — | 0.165 | 10m – 900m | OLP/standby threshold on VSENSE, a fraction of vRef | Section 7.5 VOLP typ 16.5 %VREF, p.6 | | `vIsop` | V | 0.085 | 0 – 1 V | ISENSE open-pin threshold | Section 7.5 VISOP typ 0.085 V, p.6 | | `iIsop` | A | 0.0000023 | 0 – 1m A | ISENSE open-pin pull-up current | Section 7.5 IISOP typ -2.3 µA, p.6 | | `rVcompFault` | Ω | 80 | 1 – 1meg Ω | VCOMP pull-down in UVLO, OLP and ISOP | Section 7.5 VCOMP voltage during OLP typ 0.04 V at 0.5 mA, p.7 | | `kOvpL` | — | 1.07 | 1 – 1.5 | OVP_L threshold on VSENSE, a fraction of vRef (VCOMP discharged through rVcompDis) | Section 7.5 VOVP_L typ 107 %VREF, p.6 | | `kOvpH` | — | 1.09 | 1 – 1.5 | OVP_H threshold on VSENSE, a fraction of vRef (GATE off) | Section 7.5 VOVP_H typ 109 %VREF, p.6 | | `kOvpHRst` | — | 1.02 | 900m – 1.5 | OVP_H reset threshold on VSENSE, a fraction of vRef | Section 7.5 VOVP_H(RST) typ 102 %VREF, p.6 | | `rVcompDis` | Ω | 4000 | 1 – 1meg Ω | VCOMP discharge resistor of OVP_L and SOC | Sections 8.3.4 and 8.3.11: a 4-kΩ resistor connects VCOMP to ground | | `vSoc` | V | 0.285 | 10m – 2 V | Soft overcurrent threshold, magnitude of the negative ISENSE voltage | Section 7.5 VSOC typ -0.285 V, p.6 | | `vPcl` | V | 0.4 | 10m – 2 V | Peak current limit threshold, magnitude of the negative ISENSE voltage | Section 7.5 VPCL typ -0.4 V, p.6 | | `vccOn` | V | 11.5 | 1 – 30 V | VCC UVLO turn-on threshold | Section 7.5 VCCON typ 11.5 V, p.6 | | `vccOff` | V | 9.5 | 500m – 30 V | VCC UVLO turn-off threshold | Section 7.5 VCCOFF typ 9.5 V, p.6 | | `vGateClamp` | V | 15.2 | 1 – 30 V | GATE high-level clamp | Section 7.5 GATE high voltage typ 15.2 V at VCC = 20 V, p.7 | | `vGateDrop` | V | 1 | 0 – 5 V | GATE high level below VCC when not clamped | Section 7.5 GATE high voltage typ 11.2 V at VCC = 12.2 V, p.7 | | `rGateHi` | Ω | 10.1 | 100m – 10k Ω | GATE pull-up resistance | assumption: the 15.2 V clamp over the 1.5 A peak sourcing current (section 7.5, p.7) | | `rGateLo` | Ω | 2 | 100m – 10k Ω | GATE pull-down resistance | Section 7.5 GATE low voltage, sinking, typ 0.04 V at 20 mA, p.7 | | `rOff` | Ω | 100000000 | 1k – 1t Ω | Off-state resistance of the internal switches | assumption: large against the VCOMP network | _Parameter descriptions are in English in both languages._ ## Model FREQ is held at vFreq and the switching frequency follows its current: fsw = fTyp * rTyp * (rInt + RFREQ) / (RFREQ * (rInt + rTyp)) with RFREQ = vFreq / I. The internal current signal is -kIsense times V(ISENSE). ICOMP is fed gmi * (signal - M1 * V(ICOMP) / k1), limited to iCompMax, with M1 a piecewise-linear function of V(VCOMP). Each period starts with GATE low; GATE turns on where a ramp rising at M2 = fsw / 65 kHz * 0.1223 * (V(VCOMP) - 0.5)^2 V/us crosses V(ICOMP), after tOffMin. VCOMP is fed gmv * (vRef - V(VSENSE)) limited to iVcompMax, or gmvEdr limited to iEdrMax when VSENSE leaves 95 to 105 % of vRef after the soft start; until VSENSE first reaches kSsEnd * vRef a pre-charge source pulls VCOMP to vPrecharge. UVLO, OLP (VSENSE below kOlp * vRef) and ISOP stop GATE, pull VCOMP to GND and ICOMP to vIcompFault. OVP_L and the soft overcurrent (ISENSE below -vSoc) discharge VCOMP through rVcompDis. OVP_H holds GATE off from kOvpH * vRef until kOvpHRst * vRef. ISENSE below -vPcl ends the period. ## Common mistakes - The voltage loop crosses over near 10 Hz, so a start from an empty output takes hundreds of milliseconds of soft start. Start the output capacitor and the VCOMP capacitors charged to the operating point, as the ccmPfc application circuit does, to look at a few line cycles. - The sense resistor sits in the return path and ISENSE reads negative. Wiring it on the positive side leaves ISENSE above 0.085 V and the open-pin protection stops the converter. Problems rules: `step.too_large`, `param.out_of_range`, `pin.unconnected` ## Datasheet and sources RFREQ, CICOMP, the VCOMP network, the VSENSE divider and the sense resistor are your own parts. vFreq, tOffMin, gmi, iCompMax, vIcompFault, vRef, gmv, iVcompMax, gmvEdr, iEdrMax, the UVD, OVD, OLP, OVP and end-of-soft-start fractions, vPrecharge, iPrecharge, vIsop, iIsop, vSoc, vPcl, vccOn, vccOff, the GATE levels and rGateLo come from the electrical characteristics, rVcompFault from the VCOMP voltage during OLP at its test current. fTyp, rTyp, rInt and k1 come from the design procedure (equations 12 and 79), kIsense and rVcompDis from the feature description. rGateHi is an assumption: the clamp voltage over the peak sourcing current. ## Example Open the example with the command `file.openExample` and the name `demo:ccmPfcController`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Closed-Loop Hall Transducer (`closedLoopHall`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/closedLoopHall/ > A compensated Hall current transducer whose secondary current is the primary current over the turns ratio, from DC. ![closedLoopHall](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/closedLoopHall.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/closedLoopHall/) **Group:** ICs · **Kind:** `{"definition":"closedLoopHall","kind":"subsystem"}` ## When to use it Use it to measure DC and AC currents of tens of amperes with isolation, such as an inverter phase or a DC link, through a measuring resistor. Use Hall-Effect Current Sensor for a small open-loop part with a voltage output. ## Pins | Pin | Domain | Meaning | |---|---|---| | `IPP` | electrical | Primary conductor in, positive reading | | `IPN` | electrical | Primary conductor out | | `M` | electrical | Secondary current output, into the measuring resistor | | `GND` | electrical | 0 V of the supply, return of the secondary current | ## Common parameters - `ratio`: Secondary turns per primary turn: the output current is the primary current over this (Default: 1000) - `bw`: Bandwidth at -1 dB (a single pole whose -3 dB corner is about twice this) (Default: 200000) - `io`: Offset current at zero primary current (the data sheet gives +/-0.2 mA max) (Default: 0) - `isMax`: Largest secondary current: the measuring range over ratio (Default: 0.07) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `ratio` | — | 1000 | 1 – 100k | Secondary turns per primary turn: the output current is the primary current over this | Turns ratio 1 : 1000, p.1 | | `bw` | Hz | 200000 | 1k – 100meg Hz | Bandwidth at -1 dB (a single pole whose -3 dB corner is about twice this) | Frequency bandwidth DC to 200 kHz at -1 dB, p.1 | | `io` | A | 0 | -10m – 10m A | Offset current at zero primary current (the data sheet gives +/-0.2 mA max) | Electrical offset current IOE +/-0.2 mA max at 25 °C, p.1 (set to 0 here) | | `isMax` | A | 0.07 | 100u – 10 A | Largest secondary current: the measuring range over ratio | Primary measuring range +/-70 A, p.1 | _Parameter descriptions are in English in both languages._ ## Model A current meter in series with the primary (no resistance) reads the current, divides it by ratio and adds the offset current io. A first-order low-pass whose -3 dB corner is bw / 0.509 puts the response 1 dB down at bw. The result is limited to plus or minus isMax and drives a current source that pushes it out of M, so V(M) = rM * (io + i / ratio) across your measuring resistor rM to GND. The supply, its voltage headroom for rM and the supply current are not modelled. ## Common mistakes - M must have a measuring resistor to GND. Left open, the current source has nowhere to go and the circuit does not solve. - The real part stays linear only while its supply can drive rM: 50 to 160 Ohm at plus or minus 15 V and 50 A. Here any rM is driven, so keep it in that range yourself. Problems rules: `step.too_large`, `param.out_of_range` ## Datasheet and sources ratio is the secondary turns per primary turn (1 : 1000 means 1000), bw is the frequency bandwidth at -1 dB, io is the electrical offset current (given as a maximum, so 0 is nominal) and isMax is the measuring range over ratio. The defaults are the LEM LA 55-P, data sheet N° 97.13.25.000.0 version 19. Pass them to ic.fromSpec with the closedLoopHall template. ## Example Open the example with the command `file.openExample` and the name `demo:closedLoopHall`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Comparator with Hysteresis (`comparatorHyst`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/comparatorHyst/ > Compares two voltages and gives a high or low output. ![comparatorHyst](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/comparatorHyst.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/comparatorHyst/) **Group:** ICs · **Kind:** `{"definition":"comparatorHyst","kind":"subsystem"}` ## When to use it Use it for protection thresholds, zero-crossing detection and Schmitt-trigger logic when delay and output type matter. Use Single-Pole Operational Amplifier when you need a linear output. ## Pins | Pin | Domain | Meaning | |---|---|---| | `INP` | electrical | Non-inverting input, above INN gives high | | `INN` | electrical | Inverting input | | `OUT` | electrical | Output, open drain or push-pull | | `VCC` | electrical | Supply, only a push-pull output uses it | | `GND` | electrical | Ground reference of the output | ## Common parameters - `vHys`: Hysteresis: total width of the band around zero input difference (Default: 0.05) - `vos`: Input offset voltage (the datasheet gives it as +/-) (Default: 0.00037) - `tPdLh`: Delay from the input crossing the threshold to OUT going high (Default: 0.0000003) - `tPdHl`: Delay from the input crossing the threshold to OUT going low (Default: 0.0000003) - `openDrain`: 1 = open drain (needs an external pull-up), 0 = push-pull from VCC (Default: 1) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `vHys` | V | 0.05 | 0 – 10 V | Hysteresis: total width of the band around zero input difference | assumption: the LM393B has no internal hysteresis (typical comparators with it: tens of mV) | | `vos` | V | 0.00037 | -100m – 100m V | Input offset voltage (the datasheet gives it as +/-) | Section 5.5 VIO typ +/-0.37 mV, p.6 | | `tPdLh` | s | 0.0000003 | 0 – 1m s | Delay from the input crossing the threshold to OUT going high | Section 5.7 tresponse typ, TTL input with Vref = 1.4 V, p.7 | | `tPdHl` | s | 0.0000003 | 0 – 1m s | Delay from the input crossing the threshold to OUT going low | Section 5.7 tresponse typ, TTL input with Vref = 1.4 V, p.7 | | `rOutLo` | Ω | 27.5 | 1m – 100k Ω | Output resistance to GND when low (110 mV at 4 mA) | Section 5.5 VOL typ 110 mV at ISINK <= 4 mA, p.6 | | `rOutHi` | Ω | 50 | 1m – 100k Ω | Output resistance to VCC when high (push-pull only) | assumption: not specified for an open-collector part | | `openDrain` | — | 1 | 0 – 1 | 1 = open drain (needs an external pull-up), 0 = push-pull from VCC | Section 5.5 IOH-LKG: the LM393B output is open collector, p.6 | | `rOff` | Ω | 100000000 | 1k – 1t Ω | Off-state resistance of the output switches (leakage) | assumption: IOH-LKG typ 0.1 nA at 5 V is far below this model's resolution | _Parameter descriptions are in English in both languages._ ## Model The difference Vid = V(INP) - V(INN) + vos goes through a Schmitt trigger that turns high above +vHys/2 and low below -vHys/2. The result is delayed by tPdLh (rising) and tPdHl (falling) and drives two switches: OUT to GND through rOutLo when low and, for a push-pull part, VCC to OUT through rOutHi when high. The output starts low, so an input inside the hysteresis band at t = 0 reads as low. A pulse shorter than the delay is dropped, the delay does not depend on overdrive, and input bias current and output leakage are not modelled. ## Common mistakes - An open-drain output, which is the default, has no high level of its own. Add a pull-up resistor from OUT to a supply, for example 10 kOhm to VCC, or the output never rises. - The real switching points are shifted by the offset vos. A real part without built-in hysteresis needs positive feedback outside to get any, and the default 50 mV is only a typical value for a part that has it. - The output control reaches the switches one solver step late. Keep the step at a tenth of the 300 ns delay or less, or the edge timing is wrong. Problems rules: `step.too_large` ## Datasheet and sources vos is the typical input offset. rOutLo is the low-level output voltage divided by its test current (110 mV at 4 mA gives 27.5 Ohm). tPdLh and tPdHl come from the response-time row at the overdrive and input step given there. vHys is the internal hysteresis if the part lists one, and otherwise comes from your external positive feedback. openDrain is 1 for an open-collector or open-drain output and 0 for push-pull, where rOutHi is the high-level on resistance. ## Example Open the example with the command `file.openExample` and the name `demo:comparatorHyst`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Constant On-Time Modulator (`cotModulator`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/cotModulator/ > Starts a fixed or adaptive on-time whenever the feedback falls below the reference. ![cotModulator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/cotModulator.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/cotModulator/) **Group:** ICs · **Kind:** `{"definition":"cotModulator","kind":"subsystem"}` ## When to use it Use it at the architecture stage of a ripple-based (COT, D-CAP class) controller, to see the frequency, the DC offset of valley regulation and the ESR condition for stability with the real output capacitor. Use the Hysteretic Modulator for bang-bang control without a fixed on-time. ## Pins | Pin | Domain | Meaning | |---|---|---| | `FB` | electrical | Feedback, the divided output with its ripple | | `REF` | electrical | Reference voltage | | `EN` | signal | Enable signal, high to switch | | `GATE` | signal | Switch command, 0 or 1 | | `GND` | electrical | Reference of FB, REF, VIN and VOUT | | `VIN` | electrical | Input voltage, read for an adaptive on-time | | `VOUT` | electrical | Output voltage, read when adaptive is 1 | ## Common parameters - `tOn`: On-time of every pulse; in a buck fsw = Vout/(Vin·tOn) (Default: 0.0000005) - `tOffMin`: Minimum off-time between pulses (sets the highest duty, tOn/(tOn + tOffMin)) (Default: 0.0000001) - `adaptive`: On-time: 0 = tOn fixed, 1 = kOn·V(VOUT)/V(VIN) + tOnAdd, 2 = kOn/V(VIN) + tOnAdd (Default: 0) - `kOn`: Adaptive on-time constant: with adaptive = 1 in s (a buck switches at 1/kOn), with adaptive = 2 in V·s (a buck switches at Vout/kOn) (Default: 0.000002) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `tOn` | s | 0.0000005 | 1n – 10m s | On-time of every pulse; in a buck fsw = Vout/(Vin·tOn) | typical, user must set | | `tOffMin` | s | 0.0000001 | 1n – 10m s | Minimum off-time between pulses (sets the highest duty, tOn/(tOn + tOffMin)) | typical, user must set | | `adaptive` | — | 0 | 0 – 2 | On-time: 0 = tOn fixed, 1 = kOn·V(VOUT)/V(VIN) + tOnAdd, 2 = kOn/V(VIN) + tOnAdd | typical, user must set | | `kOn` | s | 0.000002 | 1n – 1 s | Adaptive on-time constant: with adaptive = 1 in s (a buck switches at 1/kOn), with adaptive = 2 in V·s (a buck switches at Vout/kOn) | typical, user must set | | `tOnAdd` | s | 0 | 0 – 1m s | Time added to every adaptive on-time (make up for a driver's dead time or delay) | typical, user must set | | `tOnMin` | s | 0.00000005 | 1n – 10m s | Shortest adaptive on-time (it holds at start-up, while V(VOUT) is near zero) | typical, user must set | _Parameter descriptions are in English in both languages._ ## Model When V(FB) falls below V(REF), EN is high and at least tOffMin has passed since the last pulse, a pulse of tOn starts. The valley of the feedback is held at the reference (Redl and Sun, IEEE TPEL 2009). In a buck, volt-second balance gives fsw = Vout/(Vin·tOn). With the feedback taken from the output capacitor the loop is stable when ESR·C > tOn/2 (Li and Lee, IEEE TCAS-I 2010); ceramic capacitors need ripple injection. With adaptive = 1 each on-time is kOn·V(VOUT)/V(VIN) + tOnAdd, read at the start of the pulse and never below tOnMin, so a buck switches at 1/kOn at every input once tOnAdd makes up for the driver's dead time; adaptive = 2 uses kOn/V(VIN) + tOnAdd and gives fsw = Vout/kOn. ## Common mistakes - The defaults are typical, user must set. Size tOn for your frequency, tOn = Vout/(Vin·fsw), and remember that a driver's dead time shortens the on-time the switch node sees. - With low-ESR ceramic capacitors the feedback ripple lags the inductor current and the pulses bunch together. Check ESR·C > tOn/2, or add a ripple-injection network: a resistor from the switch node and a capacitor to the output across the inductor, coupled into FB through a small capacitor (the cotBuck application circuit with rippleInjection 1). Problems rules: `step.too_large`, `ground.missing` ## Datasheet and sources This is an architecture block, so its numbers come from your design. tOn is the on-time and tOffMin the minimum off-time. When you later model a real COT controller, take the on-time equation (often tOn = k·RON/VIN) and the minimum off-time from its data sheet. ## Example Open the example with the command `file.openExample` and the name `demo:cotModulator`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Transition-Mode Boost PFC Controller (Critical Conduction with Zero-Current Detection) (`crmPfcController`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/crmPfcController/ > Runs a boost PFC at the boundary of continuous conduction: each pulse starts when an inductor winding shows the current at zero and ends when the switch current reaches a multiplier of the line and the error voltage. ![crmPfcController](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/crmPfcController.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/crmPfcController/) **Group:** ICs · **Kind:** `{"definition":"crmPfcController","kind":"subsystem"}` ## When to use it Use it for a low to medium power boost PFC (up to about 300 W) with a UCC38050-class controller: no oscillator, no current amplifier, and a boost diode that never sees reverse recovery. circuit.applicationCircuit with topology transitionModePfc builds the data sheet's universal-line 100 W preregulator. For higher power use the CCM Boost PFC Controller or the Multiplier Boost PFC Controller. ## Pins | Pin | Domain | Meaning | |---|---|---| | `VO_SNS` | electrical | Output voltage sense, regulated to 2.5 V; low disables the gate | | `COMP` | electrical | Transconductance amplifier output, its network goes to GND | | `MULTIN` | electrical | Multiplier input from a divider on the rectified line | | `CS` | electrical | Switch current sense; the pulse ends when it passes the multiplier | | `ZCD` | electrical | Zero-current detect from an auxiliary winding through a resistor | | `GND` | electrical | Ground reference of every pin | | `DRV` | electrical | Gate drive of the boost switch | | `VCC` | electrical | Supply, the controller runs above the UVLO threshold | ## Common parameters - `vRef`: Voltage amplifier reference on VO_SNS (Default: 2.5) - `gm`: Voltage amplifier transconductance (Default: 0.00009) - `kMult`: Multiplier gain constant of kMult·(V(MULTIN) + vMultOffset)·(V(COMP) − vCompOffset) (Default: 0.65) - `vZcdRise`: ZCD rising-edge threshold (arms the detector) (Default: 1.7) - `tRestart`: Restart timer: DRV turns on after this long off (Default: 0.0004) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `vccOn` | V | 15.8 | 1 – 20 V | VCC UVLO turn-on threshold | Section 6.5 VCC turnon threshold, UCCx8050 typ 15.8 V, p.5 | | `vccOff` | V | 9.7 | 500m – 20 V | VCC UVLO turn-off threshold | Section 6.5 VCC turnoff threshold typ 9.7 V, p.5 | | `vRef` | V | 2.5 | 500m – 5 V | Voltage amplifier reference on VO_SNS | Section 6.5 voltage amplifier input voltage (VREF) typ 2.5 V, p.5 | | `gm` | S | 0.00009 | 100n – 10m S | Voltage amplifier transconductance | Section 6.5 gM typ 90 µS at TJ = 25 °C, VCOMP = 3.5 V, p.5 | | `iLin` | A | 0.00001 | 100n – 1m A | Voltage amplifier output current in normal operation (either way) | Section 7.3.2: sink and source capability approximately 10 µA during normal operation, p.12; pin table, COMP, p.3 | | `kUvd` | — | 0.88 | 100m – 1 | VO_SNS fraction of vRef below which the enhanced source is on | Section 7.3.2: slew-rate enhancement when VO_SNS < 0.88 × VREF, p.12 | | `kOvd` | — | 1.05 | 1 – 2 | VO_SNS fraction of vRef above which the enhanced sink is on | Section 7.3.2: slew-rate enhancement when VO_SNS > 1.05 × VREF, p.12 | | `iSrcEdr` | A | 0.0013 | 1u – 100m A | Enhanced source current into COMP | Sections 7.1 and 8.1: the UCC38050 gM amplifier source current is typically 1.3 mA, pp.10 and 16 | | `iSinkEdr` | A | 0.001 | 1u – 100m A | Enhanced sink current out of COMP | Section 6.5 sink current typ 1 mA at VO_SNS = 2.7 V, VCOMP = 3.5 V, p.5 | | `vCompEdrLow` | V | 2.4 | 0 – 5 V | COMP the enhanced sink slews down to | Section 7.3.5: the slew rate enhancement slews the COMP pin to approximately 2.4 V, p.13 | | `vCompLo` | V | 1.8 | 0 – 5 V | COMP lowest output | Section 6.5 VCOMP low typ 1.8 V at VO_SNS = 2.55 V, p.5 | | `vCompHi` | V | 5 | 1 – 10 V | COMP highest output | Section 6.5 VCOMP high min 4.5 V, max 5.5 V at VO_SNS = 2.1 V, p.5 (no typical value: the middle of the band) | | `kMult` | 1/V | 0.65 | 10m – 10 1/V | Multiplier gain constant of kMult·(V(MULTIN) + vMultOffset)·(V(COMP) − vCompOffset) | Section 6.5 multiplier gain constant (k) typ 0.65 /V, p.5; section 7.3.6 gives the law with about 0.67, p.13 | | `vMultOffset` | V | 0.075 | 0 – 1 V | Positive offset added to MULTIN in the multiplier | Section 7.3.6: a positive offset of about 75 mV to the VMULTIN signal, p.13; pin table, CS: VOFFSET approximately 75 mV, p.3 | | `vCompOffset` | V | 2.5 | 0 – 5 V | COMP below which the multiplier output is zero | Section 7.3.6: multiplier output approximately 0.67 × VMULTIN × (VCOMP − 2.5 V), p.13 | | `vCompMax` | V | 4 | 1 – 10 V | Top of the COMP dynamic input range of the multiplier | Section 6.5 dynamic input range, COMP input typ 2.5 to 4 V, p.5 | | `vCsMax` | V | 1.7 | 100m – 5 V | Maximum current sense threshold (clamp on the multiplier output) | Section 6.5 maximum current sense threshold voltage typ 1.7 V, p.6; pin table, CS, p.3 | | `rCsFilt` | Ω | 40000 | 0 – 10meg Ω | Internal current-sense filter resistance | Section 7.2 functional block diagram: 40 kΩ in the CS path, p.11 | | `cCsFilt` | F | 0.000000000005 | 1f – 1n F | Internal current-sense filter capacitance | Section 7.2 functional block diagram: 5 pF on the CS path, p.11 | | `vZeroPower` | V | 2.3 | 0 – 5 V | COMP below which the zero-power comparator stops the gate | Section 6.5 zero power comparator threshold typ 2.3 V, p.5; section 7.3.5, p.13 | | `vOvp` | V | 0.19 | 0 – 1 V | OVP threshold above vRef on VO_SNS | Section 6.5 overvoltage reference, UCCx8050 typ VREF + 0.19 V, p.5 | | `vOvpHyst` | V | 0.2 | 0 – 1 V | OVP hysteresis | Section 6.5 OVP hysteresis, UCCx8050 typ 200 mV, p.5 | | `vEnable` | V | 0.67 | 0 – 2.5 V | Enable threshold on VO_SNS (rising) | Section 6.5 enable threshold, UCCx8050 typ 0.67 V, p.5 | | `vEnableHyst` | V | 0.1 | 0 – 1 V | Enable hysteresis | Section 6.5 enable hysteresis typ 0.1 V, p.5 | | `vZcdRise` | V | 1.7 | 100m – 5 V | ZCD rising-edge threshold (arms the detector) | Section 6.5 zero current detect input threshold (rising edge) typ 1.7 V, p.6 | | `vZcdHyst` | V | 0.35 | 0 – 2 V | ZCD hysteresis (the falling threshold is vZcdRise − vZcdHyst) | Section 6.5 zero current detect hysteresis typ 350 mV, p.6 | | `vZcdHi` | V | 5 | 1 – 20 V | ZCD input high clamp | Section 6.5 input high clamp typ 5 V at I = 3 mA, p.6 | | `vZcdLo` | V | 0.65 | 0 – 2 V | ZCD input low clamp | Section 6.5 input low clamp typ 0.65 V at I = −3 mA, p.6 | | `tRestart` | s | 0.0004 | 1u – 100m s | Restart timer: DRV turns on after this long off | Section 6.5 restart time delay typ 400 µs, p.6; section 7.3.3, p.12 | | `rGateHi` | Ω | 5 | 100m – 10k Ω | DRV pull-up resistance | Section 6.5 GT1 pull-up resistance typ 5 Ω at IOUT = −125 mA, p.6 | | `rGateLo` | Ω | 2 | 100m – 10k Ω | DRV pull-down resistance | Section 6.5 GT1 pull-down resistance typ 2 Ω at IOUT = 125 mA, p.6 | _Parameter descriptions are in English in both languages._ ## Model DRV turns on when ZCD, armed above vZcdRise while the switch is off, falls below vZcdRise - vZcdHyst, or after DRV has been off for tRestart; it turns off when CS, through the internal rCsFilt and cCsFilt filter, rises above the multiplier output kMult * (V(MULTIN) + vMultOffset) * (min(V(COMP), vCompMax) - vCompOffset), clamped at vCsMax and zero below COMP = vCompOffset. The voltage amplifier sources gm * (vRef - V(VO_SNS)) into COMP within plus or minus iLin, plus iSrcEdr below kUvd * vRef, minus iSinkEdr above kOvd * vRef while COMP is above vCompEdrLow; COMP is clamped between vCompLo and vCompHi. The gate is held low below the VCC UVLO, below the VO_SNS enable threshold, below COMP = vZeroPower and from vRef + vOvp until VO_SNS falls by vOvpHyst. ZCD is clamped between vZcdLo and vZcdHi. ## Common mistakes - The auxiliary winding must put more than vZcdRise on ZCD while the switch is off, (Vout - Vline) / N with N the turns ratio. Near the peak of a high line that difference is small; when ZCD never arms, each pulse waits for the 400 us restart timer and the line current is wrong there. - The drain needs a capacitance (the switch's coss or a capacitor) so the inductor rings after its current ends and ZCD sees the fall; with none the drain node floats once the boost diode stops conducting. - The voltage loop is slow (a crossover of a few hertz in the data sheet's circuit), so a start from an empty output takes many line cycles. Start the output and the COMP capacitors at the operating point, as the transitionModePfc application circuit does. Problems rules: `step.too_large`, `param.out_of_range`, `pin.unconnected` ## Datasheet and sources The MULTIN and VO_SNS dividers, the COMP network, the sense resistor, the CS filter and the ZCD resistor are your own parts. vccOn, vccOff, vRef, gm, iSinkEdr, vCompLo, vCompHi, kMult, vCompMax, vCsMax, vZeroPower, vOvp, vOvpHyst, vEnable, vEnableHyst, the ZCD thresholds and clamps, tRestart and the gate resistances come from the electrical characteristics. iLin, kUvd, kOvd, iSrcEdr, vCompEdrLow, vMultOffset and vCompOffset come from the feature description, and rCsFilt and cCsFilt from the block diagram. vCompHi is the middle of its band, which has no typical value. ## Example Open the example with the command `file.openExample` and the name `demo:crmPfcController`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Current-Sense Amplifier (`currentSenseAmp`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/currentSenseAmp/ > Turns the small voltage across a shunt into a larger ground-referenced signal. ![currentSenseAmp](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/currentSenseAmp.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/currentSenseAmp/) **Group:** ICs · **Kind:** `{"definition":"currentSenseAmp","kind":"subsystem"}` ## When to use it Use it to feed a controller or comparator from a shunt, with the real bandwidth and supply limits. Use Single-Pole Operational Amplifier when you want your own feedback network. ## Pins | Pin | Domain | Meaning | |---|---|---| | `INP` | electrical | Positive sense input, the bus side of the shunt | | `INN` | electrical | Negative sense input, the load side of the shunt | | `OUT` | electrical | Output, measured against GND | | `VS` | electrical | Supply, sets the top of the output | | `GND` | electrical | Ground reference of output and supply | ## Common parameters - `gain`: Gain (the A3 device) (Default: 100) - `bw`: Bandwidth: the single pole of the response (Default: 150000) - `sr`: Slew rate (2 V/us) (Default: 2000000) - `vos`: Input offset voltage (the datasheet gives it as +/-) (Default: 0.000025) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `gain` | V/V | 100 | 100m – 100k V/V | Gain (the A3 device) | Section 7.5 G, A3 devices, p.8 | | `gainErr` | — | 0 | -100m – 100m | Gain error as a fraction (the datasheet gives +/-0.1 % typical; 0 = nominal) | Section 7.5 EG typ +/-0.1 %, p.8 (set to 0 here) | | `bw` | Hz | 150000 | 1 – 1g Hz | Bandwidth: the single pole of the response | Section 7.5 BW, A3 devices, CLOAD = 10 pF, p.8 | | `sr` | V/s | 2000000 | 1k – 10g V/s | Slew rate (2 V/us) | Section 7.5 SR typ, p.8 | | `vos` | V | 0.000025 | -100m – 100m V | Input offset voltage (the datasheet gives it as +/-) | Section 7.5 VOS typ +/-25 uV, p.8 | | `swingHi` | V | 0.02 | 0 – 10 V | Output swing below the VS rail | Section 7.5 VSP typ, RL = 10 kOhm, p.8 | | `swingLo` | V | 0.0005 | 0 – 10 V | Output swing above GND | Section 7.5 VSN typ, RL = 10 kOhm, p.8 | _Parameter descriptions are in English in both languages._ ## Model The target is gain * (1 + gainErr) * (V(INP) - V(INN) + vos), clamped to GND + swingLo ... VS - swingHi. The output follows the clamped target through a single pole dy/dt = 2*pi*bw*(target - y) limited to plus or minus sr, so it never winds up beyond the rails. The inputs draw nothing and see only their difference. Common-mode range and CMRR, bias currents, output impedance, noise and bidirectional (reference pin) variants are not modelled. The output only swings between GND and VS, so a negative sense voltage clips at swingLo. ## Common mistakes - gain and bw belong together, because the datasheet lists a different bandwidth for each gain variant. Also check that the gain times the full-scale sense voltage stays below the supply, or the output clips and the current reads too low. - The output reaches the circuit one to two solver steps late. Keep the step below about a tenth of the response time, which is about 1 us at 150 kHz, and finer for an accurate settling time. - Wire INP to the supply side of the shunt and INN to the load side. Otherwise the sense voltage is negative and the output sits at its lowest level, and VS and GND must share the circuit ground. Problems rules: `step.too_large`, `param.out_of_range` ## Datasheet and sources gain is the nominal gain of your variant, and bw is its small-signal bandwidth at the load capacitance listed. sr is the typical slew rate in V/s (2 V/us is 2e6). vos is the typical input offset. gainErr is the gain error as a fraction (0.001 for 0.1 percent, and 0 means nominal). swingHi and swingLo are how far the output stays from the supply and from ground at the stated load. ## Example Open the example with the command `file.openExample` and the name `demo:currentSenseAmp`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Current Transformer (`currentTransformer`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/currentTransformer/ > A one-turn primary through a core with a secondary winding and its burden, giving a voltage proportional to an AC current. ![currentTransformer](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/currentTransformer.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/currentTransformer/) **Group:** ICs · **Kind:** `{"definition":"currentTransformer","kind":"subsystem"}` ## When to use it Use it to measure the switch or transformer current of a converter with isolation and no loss, such as in peak current-mode control. It cannot pass DC; use Closed-Loop Hall Transducer or Hall-Effect Current Sensor for that. ## Pins | Pin | Domain | Meaning | |---|---|---| | `IPP` | electrical | Primary in, dotted end, positive reading | | `IPN` | electrical | Primary out | | `OUT` | electrical | Secondary dotted end, across the burden | | `GND` | electrical | Secondary other end, reference of the output | ## Common parameters - `turns`: Secondary turns per primary turn (1 : turns) (Default: 100) - `ls`: Secondary inductance: the magnetising inductance seen from the secondary (Default: 0.02) - `vt`: Volt-time product of the secondary: the flux linkage where the core saturates (Default: 0.000298) - `rBurden`: Burden (terminating) resistor across OUT and GND (Default: 2.9) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `turns` | — | 100 | 1 – 10k | Secondary turns per primary turn (1 : turns) | Turns (N) pri : sec 1 : 100, p.1 | | `ls` | H | 0.02 | 1u – 10 H | Secondary inductance: the magnetising inductance seen from the secondary | Inductance min 20 mH (note 1: secondary, 15.75 kHz, 1 Vrms), p.1 | | `rSec` | Ω | 1.4 | 0 – 1k Ω | Secondary winding resistance | DCR max sec 1.4 Ohm, p.1 | | `rPri` | Ω | 0.001 | 0 – 1 Ω | Primary resistance | DCR max pri 0.001 Ohm, p.1 | | `vt` | V·s | 0.000298 | 100n – 1 V·s | Volt-time product of the secondary: the flux linkage where the core saturates | Volt-time product 298 V-us (note 2: secondary), p.1 | | `rBurden` | Ω | 2.9 | 1m – 100k Ω | Burden (terminating) resistor across OUT and GND | Terminating resistance RT 2.9 Ohm (note 3: 1 V at 35 A), p.1 | | `lsatFrac` | — | 0.01 | 100u – 1 | Magnetising inductance once saturated, as a fraction of the unsaturated one | assumption: the data sheet gives no saturated inductance | _Parameter descriptions are in English in both languages._ ## Model A transformer with turns ratio 1 : turns, primary resistance rPri and secondary resistance rSec. Its magnetising inductance is the secondary inductance ls, referred to the one-turn primary as ls / turns². The core saturates when the secondary flux linkage reaches the volt-time product vt, a magnetising current of turns * vt / ls on the primary side, and the inductance then falls to lsatFrac of its value. The burden rBurden sits inside, across OUT and GND, so the output is rBurden / turns times the primary current, less the magnetising current. The low-frequency corner is (rBurden + rSec) / (2 pi ls). ## Common mistakes - A DC part of the primary current, or a unipolar pulse train without a reset, builds up flux until the core saturates, and the output then collapses. Give the core a reset (a diode and a reset resistor) or keep the current AC. - A larger burden gives more volts per ampere but saturates the core at a lower current or a shorter pulse, because the secondary voltage is higher. Check that the secondary volt-seconds of one pulse stay below vt. Problems rules: `param.out_of_range` ## Datasheet and sources turns is the turns ratio (1 : 100 means 100), ls is the secondary inductance (the minimum in the table), rSec and rPri are the winding DC resistances, vt is the volt-time product (298 V-us is 298u) and rBurden is the terminating resistor. lsatFrac is not in the data sheet. The defaults are the Coilcraft CS4100V-01L, Document 132 revised 05/05/21. Pass them to ic.fromSpec with the currentTransformer template. ## Example Open the example with the command `file.openExample` and the name `demo:currentTransformer`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Digital Isolator (`digitalIsolator`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/digitalIsolator/ > Passes a logic signal to an isolated ground after a short delay. ![digitalIsolator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/digitalIsolator.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/digitalIsolator/) **Group:** ICs · **Kind:** `{"definition":"digitalIsolator","kind":"subsystem"}` ## When to use it Use it to send PWM or enable signals across an isolation barrier with the real delay and output levels. Use Optocoupler for an analog feedback current. ## Pins | Pin | Domain | Meaning | |---|---|---| | `IN` | electrical | Logic input, measured against GND1 | | `VCC1` | electrical | Input-side supply, sets the thresholds | | `GND1` | electrical | Input-side ground | | `OUT` | electrical | Push-pull output on the isolated side | | `VCC2` | electrical | Output-side supply | | `GND2` | electrical | Output-side ground | ## Common parameters - `tPd`: Propagation delay IN to OUT (both edges) (Default: 0.000000011) - `riseFrac`: Rising input threshold as a fraction of VCC1 (Default: 0.6) - `fallFrac`: Falling input threshold as a fraction of VCC1 (Default: 0.4) - `defaultHigh`: Output while VCC1 is unpowered: 1 = high (ISO7710), 0 = low (ISO7710F) (Default: 1) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `riseFrac` | — | 0.6 | 50m – 950m | Rising input threshold as a fraction of VCC1 | Section 5.9 VIT+(IN) typ 0.6 x VCC1, p.11 | | `fallFrac` | — | 0.4 | 50m – 950m | Falling input threshold as a fraction of VCC1 | Section 5.9 VIT-(IN) typ 0.4 x VCC1, p.11 | | `tPd` | s | 0.000000011 | 0 – 1m s | Propagation delay IN to OUT (both edges) | Section 5.15 tPLH, tPHL typ, p.14 | | `rOutHi` | Ω | 50 | 100m – 100k Ω | Output resistance to VCC2 when high (0.2 V at 4 mA) | Section 5.9 VOH typ 4.8 V at IOH = -4 mA, p.11 | | `rOutLo` | Ω | 50 | 100m – 100k Ω | Output resistance to GND2 when low (0.2 V at 4 mA) | Section 5.9 VOL typ 0.2 V at IOL = 4 mA, p.11 | | `vUvloOn` | V | 2 | 500m – 10 V | Supply UVLO rising threshold (VCC1 and VCC2) | Section 5.3 VCC(UVLO+) nom, p.6 | | `vUvloOff` | V | 1.8 | 500m – 10 V | Supply UVLO falling threshold (VCC1 and VCC2) | Section 5.3 VCC(UVLO-) nom, p.6 | | `defaultHigh` | — | 1 | 0 – 1 | Output while VCC1 is unpowered: 1 = high (ISO7710), 0 = low (ISO7710F) | Table 7-2 Function Table, p.20 | | `rOff` | Ω | 100000000 | 1k – 1t Ω | Off-state resistance of the output switches | assumption: leakage is not specified | | `cmti` | V/s | 100000000000 | 0 – 10t V/s | Common-mode transient immunity: the barrier slope the output withstands (0: not set, no check) | Section 5.9 CMTI typ 100 kV/µs | | `tGlitch` | s | 0.00000002 | 1p – 1m s | Width of the spurious output pulse while the barrier slope is above cmti | assumption (typical, user must set): data sheets give CMTI as a pass/fail limit, not the glitch it causes | _Parameter descriptions are in English in both languages._ ## Model IN is compared with riseFrac and fallFrac of VCC1, which is a Schmitt trigger that follows the supply. While VCC1 is below its UVLO the output takes the default level. The data reaches OUT after tPd on both edges, as VCC2 through rOutHi or GND2 through rOutLo. While VCC2 is below its UVLO both output switches are open. The slope of GND2 against GND1 is measured; above cmti (100 V/ns, the ISO7710's typical CMTI) the output inverts for tGlitch and Problems reports CMTI exceeded. Pulse-width distortion and the barrier capacitance are not modelled. ## Common mistakes - Give each side its own supply and ground. The output is measured against GND2, so a probe against the circuit ground also shows the ground offset. - The control reaches the output switches one step late, so the delay grows by about one step. Use a step of 1 ns or less with the default delay of 11 ns. Problems rules: `step.too_large`, `ground.missing` ## Datasheet and sources riseFrac and fallFrac are the typical input thresholds divided by VCC1. tPd is the typical propagation delay. rOutHi and rOutLo are the output drops divided by their test currents. vUvloOn and vUvloOff are the supply UVLO thresholds, and defaultHigh is the default output of your variant. Pass them to ic.fromSpec with the digitalIsolator template. ## Example Open the example with the command `file.openExample` and the name `demo:digitalIsolator`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Fiber-Optic Receiver (`fiberRx`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/fiberRx/ > Turns the light from a fiber back into a logic signal, with the fiber's losses, the sensitivity, delay and jitter. ![fiberRx](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/fiberRx.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/fiberRx/) **Group:** ICs · **Kind:** `{"definition":"fiberRx","kind":"subsystem"}` ## When to use it Use it at the far end of a Fiber-Optic Transmitter. Its fiber parameters are the link's: the length, the attenuation per metre and the connector losses. ## Pins | Pin | Domain | Meaning | |---|---|---| | `OPT` | signal | Optical input from the fiber, a Fiber-Optic Transmitter's OPT | | `VCC` | electrical | Receiver supply | | `OUT` | electrical | Push-pull logic output | | `GND` | electrical | Receiver ground, isolated from the transmitter by the fiber | ## Common parameters - `length`: Fiber length (Default: 1) - `alpha`: Fiber attenuation at the wavelength of the link (Default: 0.2) - `pSens`: Sensitivity: the least received power read as light on (Default: -25) - `tRx`: Delay from the light changing to OUT (both edges, includes tPwMin) (Default: 0.00000003) - `tPwMin`: Shortest pulse the receiver passes: a shorter one is dropped (Default: 0.00000002) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `length` | m | 1 | 0 – 100k m | Fiber length | typical, user must set | | `alpha` | dB/m | 0.2 | 0 – 10 dB/m | Fiber attenuation at the wavelength of the link | typical, user must set | | `lossConn` | dB | 2 | 0 – 40 dB | Connector and coupling losses of the whole link | typical, user must set | | `nGroup` | — | 1.5 | 1 – 3 | Group index of the fiber core: the time of flight is length · nGroup / c | typical, user must set | | `pSens` | dBm | -25 | -80 – 10 dBm | Sensitivity: the least received power read as light on | typical, user must set | | `pMax` | dBm | 0 | -60 – 20 dBm | Highest received power the receiver takes without overload | typical, user must set | | `tRx` | s | 0.00000003 | 0 – 1m s | Delay from the light changing to OUT (both edges, includes tPwMin) | typical, user must set | | `jitter` | s | 0.000000002 | 0 – 1m s | Peak-to-peak jitter: each edge comes up to this much later, uniformly | typical, user must set | | `tPwMin` | s | 0.00000002 | 0 – 1m s | Shortest pulse the receiver passes: a shorter one is dropped | typical, user must set | | `maxRate` | Bd | 10000000 | 1 – 10g Bd | Highest data rate of the receiver (used to choose a link; tPwMin enforces the pulse limit) | typical, user must set | | `inverting` | — | 0 | 0 – 1 | 0: OUT is high while the light is on; 1: low while it is on | typical, user must set | | `rOutHi` | Ω | 50 | 100m – 100k Ω | Output resistance to VCC when high | typical, user must set | | `rOutLo` | Ω | 50 | 100m – 100k Ω | Output resistance to GND when low | typical, user must set | | `vccMin` | V | 4.5 | 500m – 30 V | Lowest supply: below it the output is open | typical, user must set | | `seed` | — | 1 | 0 – 1g | Seed of the jitter draws | assumption: any seed; the same seed gives the same run | | `rOff` | Ω | 100000000 | 1k – 1t Ω | Off-state resistance of the output switches | assumption: leakage is not modelled | _Parameter descriptions are in English in both languages._ ## Model The power at OPT loses alpha times length (dB) in the fiber and lossConn (dB) in the connectors. Above the sensitivity pSens the light is on. A pulse shorter than tPwMin is dropped. Each edge reaches OUT tRx after the light changed, plus the time of flight length times nGroup over c and a uniform jitter of up to jitter (seeded, the same in both solvers). The output is push-pull, high while the light is on (or off with inverting = 1), and open below vccMin. The internal signal x_over is 1 while the received power is above pMax. The defaults are typical of the 650 nm plastic-fiber class, not a part's values. ## Common mistakes - The defaults are typical, user must set. Enter the sensitivity, delays, minimum pulse width and jitter from your receiver's data sheet, and the attenuation of your fiber at the link's wavelength. - tRx includes the pulse filter, so it must be at least tPwMin. A PWM pulse shorter than tPwMin never reaches the gate: check the minimum duty at the switching frequency. - Below the sensitivity the output stops following the input. Run fiber.linkBudget, or read the Problems list, which warns when the margin is under 3 dB. Problems rules: `step.too_large`, `ground.missing` ## Datasheet and sources pSens is the receiver's input power for a valid logic level (dBm, the worst case), pMax its overload. tRx is the propagation delay, tPwMin the shortest pulse it passes (from the pulse-width or data-rate limit), jitter the peak-to-peak jitter and maxRate the data rate. alpha is the fiber's attenuation at the wavelength (dB/m) and lossConn the connector and coupling losses of the link. Pass them to ic.fromSpec with the fiberRx template. ## Example Open the example with the command `file.openExample` and the name `demo:fiberRx`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Fiber-Optic Transmitter (`fiberTx`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/fiberTx/ > Turns a logic signal into light for a fiber, with its delay and launched power. ![fiberTx](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/fiberTx.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/fiberTx/) **Group:** ICs · **Kind:** `{"definition":"fiberTx","kind":"subsystem"}` ## When to use it Use it with Fiber-Optic Receiver to carry gate signals or converter control across a barrier with no galvanic path, as medium-voltage converters and modular multilevel converters do. Use Digital Isolator or High-Speed Logic Optocoupler on one board. ## Pins | Pin | Domain | Meaning | |---|---|---| | `IN` | electrical | Logic input, measured against GND | | `VCC` | electrical | Transmitter supply | | `GND` | electrical | Transmitter ground | | `OPT` | signal | Optical output, the launched power in watts as a signal | ## Common parameters - `tTx`: Delay from IN to the light changing (both edges) (Default: 0.000000015) - `pTx`: Optical power launched into the fiber while on (Default: -8) - `maxRate`: Highest data rate of the transmitter (used to choose a link; not enforced) (Default: 10000000) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `vInH` | V | 2 | 100m – 30 V | Input high threshold | typical, user must set | | `vInL` | V | 0.8 | 50m – 30 V | Input low threshold | typical, user must set | | `tTx` | s | 0.000000015 | 0 – 1m s | Delay from IN to the light changing (both edges) | typical, user must set | | `pTx` | dBm | -8 | -60 – 20 dBm | Optical power launched into the fiber while on | typical, user must set | | `vccMin` | V | 4.5 | 500m – 30 V | Lowest supply: below it the light stays off | typical, user must set | | `maxRate` | Bd | 10000000 | 1 – 10g Bd | Highest data rate of the transmitter (used to choose a link; not enforced) | typical, user must set | _Parameter descriptions are in English in both languages._ ## Model IN goes through a Schmitt trigger (vInH, vInL) and is held off while VCC is below vccMin. After tTx on both edges the light is on, and OPT carries the launched power pTx (dBm, as watts) or 0. The defaults are typical of the 650 nm plastic-fiber class, not a part's values. ## Common mistakes - The defaults are typical, user must set. Enter the launched power, the delay and the data rate from your transmitter's data sheet. - Connect OPT only to the OPT pin of a Fiber-Optic Receiver: that net is the fiber. fiber.linkBudget and the Problems list check the power that arrives. Problems rules: `step.too_large`, `ground.missing` ## Datasheet and sources pTx is the optical output power into the fiber at your drive current (dBm, the minimum for a safe budget). tTx is the propagation delay of the transmitter, vInH and vInL its input thresholds, vccMin its lowest supply and maxRate its data rate. Pass them to ic.fromSpec with the fiberTx template. ## Example Open the example with the command `file.openExample` and the name `demo:fiberTx`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # GaN Power Stage (`ganPowerStage`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/ganPowerStage/ > Switches a 600 V GaN FET with its own driver and protection in one package. ![ganPowerStage](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/ganPowerStage.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/ganPowerStage/) **Group:** ICs · **Kind:** `{"definition":"ganPowerStage","kind":"subsystem"}` ## When to use it Use it for a hard- or soft-switched leg built from integrated GaN parts (LMG3422R030 class), when the overcurrent, short-circuit and overtemperature behaviour matters. Use a MOSFET with tech gan for a discrete GaN HEMT and its own gate driver. ## Pins | Pin | Domain | Meaning | |---|---|---| | `DRAIN` | electrical | GaN FET drain | | `SOURCE` | electrical | GaN FET source and signal ground | | `IN` | electrical | Logic input against SOURCE | | `VDD` | electrical | Driver supply against SOURCE | | `FAULT` | electrical | Push-pull output, low on short circuit, overtemperature or UVLO | | `OC` | electrical | Push-pull output, low on overcurrent or short circuit | ## Common parameters - `ron25`: Channel on resistance at 25 °C (Default: 0.026) - `tj`: Junction temperature: sets the on resistance (straight line through ron25 and ron125) and the overtemperature shutdown (Default: 25) - `itOc`: Overcurrent threshold (Default: 70) - `itSc`: Short-circuit threshold (Default: 95) - `tdOn`: IN rising to the channel turning on (Default: 0.000000028) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `vInH` | V | 1.9 | 100m – 18 V | IN positive-going threshold | Section 5.5 VIN,IT+ typ, p.8 | | `vInL` | V | 1 | 50m – 18 V | IN negative-going threshold | Section 5.5 VIN,IT- typ, p.8 | | `rIn` | Ω | 150000 | 1k – 1g Ω | IN pull-down resistance | Section 5.5 input pulldown resistance typ, VIN = 2 V, p.8 | | `vUvloOn` | V | 7 | 1 – 20 V | VDD UVLO positive-going threshold | Section 5.5 VVDD,T+(UVLO) typ, p.8 | | `vUvloOff` | V | 6.5 | 1 – 20 V | VDD UVLO negative-going threshold | Section 5.5 VDD UVLO negative-going threshold typ, p.8 | | `rVdd` | Ω | 17100 | 10 – 1g Ω | VDD load: the quiescent current at 12 V | Section 5.5 VDD quiescent current 700 µA typ at VVDD = 12 V (12 V / 700 µA), p.7 | | `tdOn` | s | 0.000000028 | 0 – 1u s | IN rising to the channel turning on | Section 5.6 td(on)(Idrain) typ, IN > VIN,IT+ to ID > 1 A, p.9 | | `tdOff` | s | 0.000000044 | 0 – 1u s | IN falling to the channel turning off | Section 5.6 td(off) typ, IN < VIN,IT- to VDS > 80 V, p.9 | | `ron25` | Ω | 0.026 | 100u – 10 Ω | Channel on resistance at 25 °C | Section 5.5 RDS(on) typ, VIN = 5 V, TJ = 25 °C, p.7 | | `ron125` | Ω | 0.045 | 100u – 10 Ω | Channel on resistance at 125 °C | Section 5.5 RDS(on) typ, VIN = 5 V, TJ = 125 °C, p.7 | | `tj` | °C | 25 | -40 – 200 °C | Junction temperature: sets the on resistance (straight line through ron25 and ron125) and the overtemperature shutdown | operating point, chosen by the user; Section 5.1 TJ -40 to 150 °C, p.6 | | `roff` | Ω | 600000000 | 1k – 1t Ω | Channel off resistance | Section 5.5 IDSS 1 µA typ at VDS = 600 V, TJ = 25 °C (600 V / 1 µA), p.7 | | `vf3q` | V | 3.794 | 0 – 20 V | Off-state third-quadrant drop of the straight-line fit | Section 5.5 VSD typ: 3.8 V at IS = 0.1 A and 5 V at 20 A, fitted by a straight line, p.7 | | `r3q` | Ω | 0.0603 | 100u – 10 Ω | Off-state third-quadrant resistance of the straight-line fit | Section 5.5 VSD typ: 3.8 V at IS = 0.1 A and 5 V at 20 A, fitted by a straight line, p.7 | | `coss` | F | 0.000000000276 | 0 – 1u F | Drain-source capacitance: the energy-related output capacitance | Section 5.5 CO(er) typ, VDS = 0 V to 400 V, p.7 | | `itOc` | A | 70 | 100m – 1k A | Overcurrent threshold | Section 5.5 IT(OC) typ, p.8 | | `itSc` | A | 95 | 100m – 1k A | Short-circuit threshold | Section 5.5 IT(SC) typ, p.8 | | `tWindow` | s | 0.00000005 | 0 – 1u s | Overcurrent-to-short-circuit window: a current that reaches itSc within it is a short circuit | Section 5.6 t(window)(OC) typ, p.10 | | `toffOc` | s | 0.00000011 | 0 – 10u s | Drain current above itOc to the turn-off (includes tWindow) | Section 5.6 toff(OC) typ, FET on before overcurrent, di/dt = 100 A/µs, p.9 | | `toffSc` | s | 0.000000065 | 0 – 10u s | Drain current above itSc to the turn-off | Section 5.6 toff(SC) typ, FET on before short circuit, di/dt = 700 A/µs, p.9 | | `tReset` | s | 0.00038 | 0 – 1 s | IN must stay low this long to clear the short-circuit latch | Section 5.6 IN reset time to clear FAULT latch typ, p.10 | | `tOtsd` | °C | 175 | 0 – 300 °C | GaN overtemperature threshold: at or above it the device runs in ideal-diode mode | Section 5.5 GaN temperature fault positive-going threshold typ, p.8 | | `vOut` | V | 5 | 1 – 20 V | High level of FAULT and OC (the LDO5V output) | Section 5.5 LDO5V output voltage typ, p.8 | | `rOh` | Ω | 25 | 100m – 10k Ω | FAULT and OC pull-up resistance | Section 5.5 high-level output 0.2 V typ below LDO5V at 8 mA (0.2 V / 8 mA), p.8 | | `rOl` | Ω | 20 | 100m – 10k Ω | FAULT and OC pull-down resistance | Section 5.5 low-level output 0.16 V typ at 8 mA (0.16 V / 8 mA), p.8 | _Parameter descriptions are in English in both languages._ ## Model IN goes through a Schmitt trigger and turns the channel on after tdOn and off after tdOff. Below the VDD UVLO the channel stays off and FAULT is low. The channel conducts both ways with the on resistance at tj, and while off it conducts in the third quadrant with a drop of about 4 to 5 V. A drain current above itOc for tWindow turns the channel off for the rest of the cycle and pulls OC low. A current that reaches itSc within that window is a short circuit: the channel is latched off, FAULT and OC go low, and IN must stay low for tReset to clear it. At tj of tOtsd or more the part runs in ideal-diode mode. The turn-on slew rate set by RDRV, the die temperature as a state and the start-up time are not modelled. ## Common mistakes - The channel switches at once, so a slow slew setting (a large RDRV resistor) loses more at turn-on than the simulation shows. Add the overlap loss from the data sheet's slew rate when you size the heatsink. - tj is a fixed parameter. Set it to the junction temperature you expect, since it sets the on resistance and the overtemperature shutdown. - The protection reads the drain current one step late and its windows are tens of nanoseconds. Use a step of 5 ns or less to see the overcurrent and short-circuit timing. Problems rules: `pin.unconnected`, `step.too_large` ## Datasheet and sources ron25 and ron125 are the typical on resistances of the electrical table. vf3q and r3q are a straight-line fit through the two third-quadrant VSD rows. coss is the energy-related output capacitance. itOc, itSc, tWindow, toffOc, toffSc and tReset come from the fault rows of the electrical and switching tables. tdOn and tdOff are the typical delays. Pass them to ic.fromSpec with the ganPowerStage template. ## Example Open the example with the command `file.openExample` and the name `demo:ganPowerStage`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Isolated Gate Driver with DESAT Protection (`gateDriverIso`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/gateDriverIso/ > Drives a power switch gate and shuts it down softly on a short circuit. ![gateDriverIso](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/gateDriverIso.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/gateDriverIso/) **Group:** ICs · **Kind:** `{"definition":"gateDriverIso","kind":"subsystem"}` ## When to use it Use it to study short-circuit protection timing of a SiC MOSFET or IGBT. Use a Pulse Voltage Source and a Resistor when you only need a plain gate signal. ## Pins | Pin | Domain | Meaning | |---|---|---| | `IN` | electrical | Control input, high turns the output on | | `FLT` | electrical | Fault output, goes low on a fault | | `VDD` | electrical | Positive supply of the output side | | `VEE` | electrical | Negative supply of the output side | | `OUT` | electrical | Gate drive output | | `COM` | electrical | Output reference, goes to the power switch source | | `DESAT` | electrical | Short-circuit sense, needs a capacitor to COM | ## Common parameters - `tPd`: Propagation delay IN to OUT (rising and falling) (Default: 0.00000009) - `vDesat`: DESAT detection threshold (DESAT - COM) (Default: 5) - `tLeb`: DESAT leading-edge blanking time after turn-on (Default: 0.0000002) - `tDesatOff`: DESAT above threshold to the start of the soft turn-off (includes the deglitch filter) (Default: 0.0000002) - `tFltDelay`: DESAT above threshold to FLT low (Default: 0.00000058) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `vInH` | V | 1.85 | 100m – 10 V | Input high threshold | Table 5.8 VINH typ, p.7 | | `vInL` | V | 1.52 | 50m – 10 V | Input low threshold | Table 5.8 VINL typ, p.7 | | `tPd` | s | 0.00000009 | 0 – 10u s | Propagation delay IN to OUT (rising and falling) | Table 5.9 tPDLH, tPDHL typ, p.9 | | `vUvloOn` | V | 12 | 1 – 40 V | VDD UVLO turn-on threshold (VDD - COM) | Table 5.8 VVDD_ON typ, p.7 | | `vUvloHys` | V | 0.8 | 0 – 10 V | VDD UVLO hysteresis | Table 5.8 VVDD_HYS typ, p.7 | | `rSource` | Ω | 2.5 | 1m – 1k Ω | Pull-up resistance VDD to OUT | Table 5.8 ROUTH typ (internal PMOS), p.7 | | `rSink` | Ω | 0.3 | 1m – 1k Ω | Pull-down resistance OUT to VEE | Table 5.8 ROUTL typ, p.7 | | `iSto` | A | 0.9 | 1m – 100 A | Soft turn-off current | Table 5.8 ISTO typ, p.8 | | `vStoRef` | V | 13 | 500m – 100 V | OUT-to-VEE voltage at which iSto is specified; the soft path is the resistor vStoRef / iSto | assumption: Table 5.8 test point OUTL = 8 V with COM - VEE = 5 V, p.8 | | `vStoEnd` | V | 2 | 100m – 10 V | OUT-to-VEE voltage below which the hard pull-down takes over from the soft turn-off | assumption: Miller clamp threshold VCLMPTH typ 2 V above VEE, Table 5.8 p.8 | | `vDesat` | V | 5 | 500m – 20 V | DESAT detection threshold (DESAT - COM) | Table 5.8 VDESAT typ, p.8 | | `iChg` | A | 0.0005 | 1u – 100m A | DESAT blanking capacitor charge current | Table 5.8 ICHG typ, p.8 | | `iDchg` | A | 0.015 | 100u – 1 A | DESAT pull-down current at 6 V; the pull-down is the resistor 6 V / iDchg | Table 5.8 IDCHG typ, p.8 | | `tLeb` | s | 0.0000002 | 0 – 10u s | DESAT leading-edge blanking time after turn-on | Table 5.8 tDESATLEB typ, p.8 | | `tDesatOff` | s | 0.0000002 | 0 – 10u s | DESAT above threshold to the start of the soft turn-off (includes the deglitch filter) | Table 5.8 tDESATOFF typ, p.8 | | `tFltDelay` | s | 0.00000058 | 0 – 10u s | DESAT above threshold to FLT low | Table 5.8 tDESATFLT typ, p.8 | | `rFltOn` | Ω | 30 | 100m – 10k Ω | FLT open-drain on resistance | Table 5.8 RODON typ, p.8 | | `tReset` | s | 0.000001 | 0 – 1 s | IN must stay low this long to release the latched fault | Table 4-1 RST/EN pin text (low for more than 1000 ns; RST/EN tied to IN+ for automatic reset), p.3 | | `rOff` | Ω | 1000000 | 1k – 1t Ω | Off-state resistance of the output switches | assumption: the solver's default switch off resistance | | `cmti` | V/s | 0 | 0 – 10t V/s | Common-mode transient immunity: the barrier slope the output withstands (0: not set, no check) | not set: the UCC21756-Q1's CMTI row is not in Voltecx yet; the UCC21750 preset sets 150 V/ns (SLUSD78C Table 6.8, p.8) | | `tGlitch` | s | 0.00000002 | 1p – 1m s | Width of the spurious output pulse while the barrier slope is above cmti | assumption (typical, user must set): data sheets give CMTI as a pass/fail limit, not the glitch it causes | _Parameter descriptions are in English in both languages._ ## Model The input goes through a Schmitt trigger (vInH, vInL) and a delay tPd on both edges. VDD minus COM passes a UVLO Schmitt trigger (vUvloOn, vUvloOn - vUvloHys) that holds the output low. After the blanking time tLeb from turn-on, a current iChg flows out of DESAT into the external capacitor. If V(DESAT) - V(COM) stays above vDesat for tDesatOff, the fault latches. The output then discharges through the soft resistor vStoRef / iSto until OUT is within vStoEnd of VEE, and then pulls down hard. FLT goes low tFltDelay after detection, and the fault is released once IN has been low for tReset. The output stage is linear (switches with fixed resistances). When cmti is set, a slope of COM against the circuit ground above it inverts the output for tGlitch (a spurious turn-on or a dropout) and Problems reports CMTI exceeded; the UCC21750 preset sets 150 V/ns. The barrier capacitance, the Miller clamp, the input-side supply and the RDY pin are not modelled. ## Common mistakes - IN and FLT are measured against the circuit ground, but VDD, DESAT and OUT are measured against COM and VEE. Connect COM to the switch source, use two separate supplies for VDD and VEE, and keep a ground in the circuit. - FLT has no high level of its own, so add a pull-up resistor to a logic supply. DESAT also needs the blanking capacitor, because it sets the trip time (100 pF gives about 1 us at the defaults). - The control signals reach the switches one solver step late, so every delay is about one step longer. Use a step of 5 ns or less with the default delays, or the timing is wrong. - tFltDelay is counted from the moment DESAT crosses the threshold, and it includes tDesatOff. A tFltDelay shorter than tDesatOff makes FLT fall together with the latch, not earlier. Problems rules: `step.too_large`, `ground.missing` ## Datasheet and sources Take vInH, vInL, vUvloOn, vUvloHys, rSource, rSink, iSto, vDesat, iChg, iDchg, tLeb, tDesatOff, tFltDelay and rFltOn from the typical column of the electrical characteristics. Take tPd from the switching characteristics and tReset from the reset pin description. vStoRef and vStoEnd are assumptions. Pass them as params to the ic.fromSpec command, for example tPd 75n. ## Example Open the example with the command `file.openExample` and the name `demo:gateDriverIso`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Half-Bridge Gate Driver with Bootstrap (`halfBridgeDriver`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/halfBridgeDriver/ > Drives the high-side and low-side switch of a half-bridge from one supply, with a bootstrap for the high side. ![halfBridgeDriver](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/halfBridgeDriver.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/halfBridgeDriver/) **Group:** ICs · **Kind:** `{"definition":"halfBridgeDriver","kind":"subsystem"}` ## When to use it Use it to put the driver IC, its gate resistors and its bootstrap capacitor into the circuit. The switches keep their own gate signals, so the driver does not change how they switch. ## Pins | Pin | Domain | Meaning | |---|---|---| | `HI` | signal | High-side input: the gate signal of the high-side switch | | `LI` | signal | Low-side input: the gate signal of the low-side switch | | `VDD` | electrical | Driver supply, referenced to VSS | | `VSS` | electrical | Ground of the driver and of the low-side output | | `HB` | electrical | Bootstrap supply, needs a capacitor to HS | | `HO` | electrical | High-side gate output | | `HS` | electrical | Switch node, the reference of HB and HO | | `LO` | electrical | Low-side gate output | ## Common parameters - `tPd`: Propagation delay from an input to its output (rising and falling) (Default: 0.00000002) - `vUvloOn`: VDD UVLO rising threshold (VDD - VSS); both outputs are held low below it (Default: 7.8) - `vHbUvloOn`: HB UVLO rising threshold (HB - HS); the high-side output is held low below it (Default: 7.9) - `rSource`: Pull-up resistance of each output (Default: 3.243243243243243) - `bootVf`: Forward voltage of the built-in bootstrap diode (Default: 1.05) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `tPd` | s | 0.00000002 | 0 – 10u s | Propagation delay from an input to its output (rising and falling) | Section 5.6 propagation delay typ, p.6 (catalogue tpd) | | `vUvloOn` | V | 7.8 | 1 – 40 V | VDD UVLO rising threshold (VDD - VSS); both outputs are held low below it | Section 5.5 VDDR rising threshold max (the catalogue holds no typical), p.5 | | `vHbUvloOn` | V | 7.9 | 1 – 40 V | HB UVLO rising threshold (HB - HS); the high-side output is held low below it | Section 5.5 VHBR rising threshold max (the catalogue holds no typical), p.5 | | `vHbUvloHys` | V | 1.1 | 0 – 10 V | HB UVLO hysteresis | Section 5.5 VHBHYS typ, p.5 | | `rSource` | Ω | 3.243243243243243 | 1m – 1k Ω | Pull-up resistance of each output | derived: VDD = 12 V over the typical peak pull-up current 3.7 A, Section 5.5 (the sheet gives no output resistance) | | `rSink` | Ω | 2.6666666666666665 | 1m – 1k Ω | Pull-down resistance of each output | derived: VDD = 12 V over the typical peak pull-down current 4.5 A, Section 5.5 (the sheet gives no output resistance) | | `bootVf` | V | 1.05 | 0 – 5 V | Forward voltage of the built-in bootstrap diode | Section 5.5 VFI max at 100 mA, p.5 | | `bootDiode` | — | 1 | 0 – 1 | 1 = the bootstrap diode is built in; 0 = a driver without one (an external diode goes from VDD to HB) | Section 5.5 VFI and RD rows: the UCC27211 has a built-in bootstrap diode | | `bootRd` | Ω | 0.85 | 1m – 100 Ω | Dynamic resistance of the built-in bootstrap diode | Section 5.5 RD max, p.5 | | `iHb` | A | 0.00012 | 0 – 100m A | HB quiescent current, from HB to HS | Section 5.5 IHB max, p.5 | | `rOff` | Ω | 1000000 | 1k – 1t Ω | Off-state resistance of the output switches | assumption: the solver's default switch off resistance | _Parameter descriptions are in English in both languages._ ## Model Each input reaches its output after tPd on both edges. HO is HB through rSource or HS through rSink, and LO is VDD through rSource or VSS through rSink. Both outputs stay low while VDD minus VSS is below vUvloOn, and HO stays low while HB minus HS is below its UVLO (vHbUvloOn rising, vHbUvloOn - vHbUvloHys falling). A diode with bootVf and bootRd charges HB from VDD, and iHb flows from HB to HS. rSource and rSink are the resistances that give the data sheet's peak currents at its 12 V test supply. The input thresholds, the VDD UVLO hysteresis, the supply currents and the delay matching are not modelled. ## Common mistakes - HI and LI are 0/1 signals, not voltages. Connect them to the nets that drive the switches' gates. - Without a capacitor from HB to HS the high side has no supply and HO stays low. HB reaches only VDD less the diode drop, so with a 12 V supply the switch node must come back near VSS for the capacitor to charge above the HB UVLO. Problems rules: `step.too_large`, `ground.missing` ## Datasheet and sources Take tPd from the switching characteristics, vUvloOn and vHbUvloOn from the VDD and HB rising thresholds and vHbUvloHys from the HB hysteresis, bootVf and bootRd from the bootstrap diode rows, iHb from the HB quiescent current, and rSource and rSink as the test supply over the peak source and sink currents. Pass them as params to the ic.fromSpec command. ## Example Open the example with the command `file.openExample` and the name `demo:halfBridgeDriver`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Hall-Effect Current Sensor (`hallCurrentSensor`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/hallCurrentSensor/ > Measures current through a conductor and gives a proportional voltage, isolated. ![hallCurrentSensor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/hallCurrentSensor.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/hallCurrentSensor/) **Group:** ICs · **Kind:** `{"definition":"hallCurrentSensor","kind":"subsystem"}` ## When to use it Use it to see what a real current sensor does to a reading. Use Ammeter for a plain measurement, Shunt Amplifier with Shunt for a shunt, and Closed-Loop Hall Transducer for tens of amperes from DC to 200 kHz. ## Pins | Pin | Domain | Meaning | |---|---|---| | `IPP` | electrical | Primary current in, positive reading | | `IPN` | electrical | Primary current out | | `VIOUT` | electrical | Sensor output, measured against GND | | `GND` | electrical | Ground reference of the output | ## Common parameters - `sens`: Sensitivity (the 05B device: 185 mV/A) (Default: 0.185) - `vq`: Output at zero current, VCC x 0.5 with a 5 V supply (Default: 2.5) - `bw`: Bandwidth: the single pole of the response (-3 dB) (Default: 80000) - `rSense`: Resistance of the primary conductor between IPP and IPN (Default: 0.0012) - `noise`: RMS output noise; 0 = a noiseless sensor (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `sens` | V/A | 0.185 | 1m – 10 V/A | Sensitivity (the 05B device: 185 mV/A) | x05B Performance Characteristics, Sens typ, p.6 | | `vq` | V | 2.5 | 0 – 15 V | Output at zero current, VCC x 0.5 with a 5 V supply | Common Operating Characteristics, VIOUT(Q), p.5 | | `bw` | Hz | 80000 | 1k – 100meg Hz | Bandwidth: the single pole of the response (-3 dB) | Common Operating Characteristics, f, p.5 | | `rSense` | Ω | 0.0012 | 1u – 10 Ω | Resistance of the primary conductor between IPP and IPN | Common Operating Characteristics, RPRIMARY typ, p.5 | | `outMin` | V | 0.1 | -15 – 15 V | Lowest output voltage (saturation near GND) | assumption: the datasheet does not give the saturation level | | `outMax` | V | 4.9 | -15 – 15 V | Highest output voltage (saturation near VCC = 5 V) | assumption: the datasheet does not give the saturation level | | `tDelay` | s | 0 | 0 – 10u s | Propagation delay ahead of the bandwidth pole: with the pole, a step reaches 50 % this plus ln 2 / (2 pi bw) late; 0 = none | model parameter: the ACS712 default applies none (a preset sets its sheet's tpd) | | `noise` | V | 0 | 0 – 1 V | RMS output noise; 0 = a noiseless sensor | x05B Performance Characteristics, VNOISE(PP) typ 21 mV peak to peak at 2 kHz, p.6 (set to simulate; about a sixth of peak to peak is the rms) | | `seed` | — | 1 | 0 – 9007t | Whole-number seed of the noise | model parameter | _Parameter descriptions are in English in both languages._ ## Model The primary path is the conductor resistance rSense in series with a current meter, so the part adds the drop rSense * i to the circuit. The output is a controlled voltage source driven by vq + sens * i, then a first-order low-pass at bw, then seeded Gaussian noise of noise volts rms, then a limit to outMin ... outMax. The noise depends only on seed and on time, so a run repeats exactly. The real part is ratiometric (sensitivity and zero level follow VCC), isolated and drifts with temperature. None of that is modelled. ## Common mistakes - The output saturates near the supply rails, which is about plus or minus 13 A at the default sensitivity. A larger current reads as a flat top, so pick a variant with lower sensitivity for it. - The sensor is not ratiometric here, so the sensitivity and the zero level stay fixed. Connect the output to a load that expects the 2.5 V zero level, and keep the step below about a tenth of the response time. - The noise is 0 by default, so set an rms value of a few millivolts to see it. A different seed gives a different noise, and the same seed always gives the same run. Problems rules: `step.too_large`, `param.out_of_range` ## Datasheet and sources sens is the typical sensitivity of the variant (185 mV/A for the 5 A device, 100 mV/A for 20 A, 66 mV/A for 30 A). vq is the zero-current output (VCC x 0.5), bw is the -3 dB bandwidth, and rSense is the primary conductor resistance. outMin and outMax are assumptions, and noise is converted from the peak-to-peak noise in the table. Pass them to ic.fromSpec with the hallCurrentSensor template and rename the pins to the datasheet names. Or place a preset: ACS724LLCTR-05AB, or the TI isolated Hall sensor TMCS1123 in 16 grades (A1A-A5A at 2.5 V, B1A-B5A at 1.65 V, C1A-C5A at 0.33 V zero-current output, D71; 25 to 150 mV/A, SBOSA24D). tDelay is an optional fixed propagation delay ahead of the bandwidth pole (default 0); the TMCS1123 presets set it so that the pole and the delay together give the sheet's 110 ns tpd. ## Example Open the example with the command `file.openExample` and the name `demo:hallCurrentSensor`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Half-Bridge Driver with Dead Time (`hbDriverArch`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/hbDriverArch/ > Drives both switches of a half-bridge from one PWM command, with a fixed or an adaptive dead time. ![hbDriverArch](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/hbDriverArch.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/hbDriverArch/) **Group:** ICs · **Kind:** `{"definition":"hbDriverArch","kind":"subsystem"}` ## When to use it Use it at the architecture stage to choose the dead-time scheme of an integrated driver: see the duty error a fixed dead time causes, how long the body diodes conduct, and how an adaptive dead time shortens it. Use the Half-Bridge Gate Driver with Bootstrap to put a real driver IC with its supply into the circuit. ## Pins | Pin | Domain | Meaning | |---|---|---| | `IN` | signal | PWM command, high for the high side | | `SW` | electrical | Switch node sense, for the adaptive dead time | | `HO` | signal | High-side gate signal, 0 or 1 | | `LO` | signal | Low-side gate signal, 0 or 1 | | `GND` | electrical | Reference of SW | ## Common parameters - `tDead`: Fixed mode: the wait before each turn-on; adaptive mode: the longest the low side waits for SW to fall (Default: 0.00000002) - `adaptive`: 1 = adaptive dead time (sense SW and the other gate); 0 = fixed (Default: 0) - `tAdapt`: Adaptive mode: delay from the sensed edge (SW below vSwTh, or the other gate below vTh) to the turn-on (Default: 0.000000002) - `cGate`: Gate capacitance each output charges (0 = no gate stage: the outputs follow their commands at once) (Default: 0) - `rSource`: Pull-up resistance of each output (driver and gate resistor) (Default: 2) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `tPd` | s | 0 | 0 – 10u s | Propagation delay from IN to both outputs, on both edges (0 = none) | typical, user must set | | `tDead` | s | 0.00000002 | 0 – 10u s | Fixed mode: the wait before each turn-on; adaptive mode: the longest the low side waits for SW to fall | typical, user must set | | `adaptive` | — | 0 | 0 – 1 | 1 = adaptive dead time (sense SW and the other gate); 0 = fixed | typical, user must set | | `tAdapt` | s | 0.000000002 | 0 – 10u s | Adaptive mode: delay from the sensed edge (SW below vSwTh, or the other gate below vTh) to the turn-on | typical, user must set | | `vSwTh` | V | 1 | -100 – 10k V | Adaptive mode: SW below this level lets the low side turn on | typical, user must set | | `cGate` | F | 0 | 0 – 1u F | Gate capacitance each output charges (0 = no gate stage: the outputs follow their commands at once) | typical, user must set | | `rSource` | Ω | 2 | 1m – 1k Ω | Pull-up resistance of each output (driver and gate resistor) | typical, user must set | | `rSink` | Ω | 1 | 1m – 1k Ω | Pull-down resistance of each output (driver and gate resistor) | typical, user must set | | `vDrive` | V | 5 | 100m – 100 V | Gate drive voltage | typical, user must set | | `vTh` | V | 2 | 10m – 100 V | Gate threshold: an output is high while its gate is above it (below vDrive) | typical, user must set | _Parameter descriptions are in English in both languages._ ## Model IN is delayed by tPd on both edges. With a fixed dead time each side turns on tDead after the other side's command falls. With adaptive 1 the low side turns on tAdapt after V(SW) falls below vSwTh, or after tDead if it never does, and the high side turns on tAdapt after the low-side gate falls below vTh. With cGate above 0 each gate charges to vDrive through rSource and discharges through rSink, so it crosses vTh after rSource·cGate·ln(vDrive/(vDrive − vTh)) on and rSink·cGate·ln(vDrive/vTh) off. A fixed dead time shortens the on-time the switch node sees by tDead plus the turn-on delay minus the turn-off delay (TI SLUA618, TI SLVAF84). ## Common mistakes - The defaults are typical, user must set. A fixed dead time must be longer than the turn-off delay of the other gate, or both switches conduct at once. - The adaptive sense reads the other gate one solver step late, so the body-diode time is about two maximum steps longer than 2·tAdapt. Keep the maximum step well below tAdapt when you measure it. Problems rules: `step.too_large`, `ground.missing` ## Datasheet and sources This is an architecture block, so its numbers come from your design. tPd is the propagation delay, tDead the dead time (in adaptive mode the longest wait), tAdapt the sensing delay, cGate the switch's gate capacitance and rSource and rSink the pull-up and pull-down resistances with the gate resistor. When you later model a real driver, take its delay and dead-time rows from its switching characteristics table. ## Example Open the example with the command `file.openExample` and the name `demo:hbDriverArch`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # High-Speed Logic Optocoupler (`highSpeedOpto`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/highSpeedOpto/ > Passes a fast logic signal across an isolation barrier through an LED and a logic output stage. ![highSpeedOpto](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/highSpeedOpto.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/highSpeedOpto/) **Group:** ICs · **Kind:** `{"definition":"highSpeedOpto","kind":"subsystem"}` ## When to use it Use it for PWM, fault or communication signals at up to tens of MBd, with the real threshold current, both edge delays and the CMTI. Use Optocoupler for an analog feedback current and Digital Isolator for the fastest signals. ## Pins | Pin | Domain | Meaning | |---|---|---| | `AN` | electrical | LED anode | | `CAT` | electrical | LED cathode, the input-side reference | | `VCC` | electrical | Output-side supply | | `OUT` | electrical | Logic output, open collector or totem pole | | `GND` | electrical | Output-side ground, isolated from the LED | ## Common parameters - `iFth`: Input threshold current: above it the LED is lit and the output switches (Default: 0.005) - `tPhl`: Propagation delay to the output going low (Default: 0.000000035) - `tPlh`: Propagation delay to the output going high (\|tPlh − tPhl\| is the pulse-width distortion) (Default: 0.00000004) - `totemPole`: 1: totem-pole output; 0: open collector (add a pull-up) (Default: 0) - `cmti`: Common-mode transient immunity: the barrier slope the output withstands (0: not set, no check) (Default: 10000000000) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `vf` | V | 1.3 | 100m – 5 V | LED forward drop of the straight-line fit | typical, user must set | | `rLed` | Ω | 10 | 0 – 1k Ω | LED series resistance of the straight-line fit | typical, user must set | | `iFth` | A | 0.005 | 10u – 100m A | Input threshold current: above it the LED is lit and the output switches | typical, user must set | | `iFhys` | A | 0.0005 | 0 – 50m A | Hysteresis of the threshold: the LED counts as dark again below iFth − iFhys | typical, user must set | | `tPhl` | s | 0.000000035 | 0 – 1m s | Propagation delay to the output going low | typical, user must set | | `tPlh` | s | 0.00000004 | 0 – 1m s | Propagation delay to the output going high (\|tPlh − tPhl\| is the pulse-width distortion) | typical, user must set | | `inverting` | — | 1 | 0 – 1 | 1: the output is low while the LED is lit; 0: high while it is lit | typical, user must set | | `totemPole` | — | 0 | 0 – 1 | 1: totem-pole output; 0: open collector (add a pull-up) | typical, user must set | | `rOnLo` | Ω | 25 | 100m – 100k Ω | Output resistance to GND when low | typical, user must set | | `rOnHi` | Ω | 50 | 100m – 100k Ω | Output resistance to VCC when high (totem pole only) | typical, user must set | | `cOut` | F | 0.000000000015 | 0 – 10n F | Output capacitance: with the pull-up it sets the rise and fall | typical, user must set | | `vccMin` | V | 4.5 | 500m – 40 V | Lowest supply: below it the output stage is off | typical, user must set | | `vccMax` | V | 5.5 | 500m – 40 V | Highest supply of the recommended range (checked against vccMin only) | typical, user must set | | `maxRate` | Bd | 10000000 | 1 – 10g Bd | Highest data rate of the part (used to choose an isolator; not a limit of the model) | typical, user must set | | `rOff` | Ω | 100000000 | 1k – 1t Ω | Off-state resistance of the output switches | assumption: leakage is not modelled | | `cmti` | V/s | 10000000000 | 0 – 10t V/s | Common-mode transient immunity: the barrier slope the output withstands (0: not set, no check) | typical, user must set | | `tGlitch` | s | 0.00000002 | 1p – 1m s | Width of the spurious output pulse while the barrier slope is above cmti | assumption (typical, user must set): data sheets give CMTI as a pass/fail limit, not the glitch it causes | _Parameter descriptions are in English in both languages._ ## Model The LED is a diode with a drop vf and a resistance rLed. Above the threshold current iFth (with hysteresis iFhys) the LED is lit, and the output goes low (inverting = 1) or high (inverting = 0). A falling output edge comes tPhl later and a rising one tPlh later, so the pulse-width distortion is the difference. The output pulls low through rOnLo and, for a totem pole, high through rOnHi, while VCC is above vccMin. cOut sits on the output and sets the rise with the pull-up. The slope of GND against CAT is measured; above cmti the output inverts for tGlitch and Problems reports CMTI exceeded. The defaults are typical of the 10 MBd class, not a part's values. ## Common mistakes - The defaults are typical, user must set. Enter the threshold current, both delays, the output capacitance and the CMTI from your part's data sheet before you trust the timing. - An open-collector output has no high level of its own. Add a pull-up resistor from OUT to VCC; with cOut it sets the rise time. - The output reaches the switches one solver step late. Use a step of 1 ns or less with delays of tens of nanoseconds. Problems rules: `step.too_large`, `ground.missing` ## Datasheet and sources iFth is the input threshold current (IFT or IFLH, the maximum for a safe design). tPhl and tPlh are the propagation delays at your LED current and load, and their difference is the pulse-width distortion. rOnLo is VOL divided by its test current. cOut is the output capacitance, vccMin and vccMax the supply range, maxRate the data rate and cmti the common-mode transient immunity (the minimum). Pass them to ic.fromSpec with the highSpeedOpto template. ## Example Open the example with the command `file.openExample` and the name `demo:highSpeedOpto`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Hysteretic Modulator (`hystModulator`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/hystModulator/ > Turns the switch on below a window around the reference and off above it. ![hystModulator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/hystModulator.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/hystModulator/) **Group:** ICs · **Kind:** `{"definition":"hystModulator","kind":"subsystem"}` ## When to use it Use it at the architecture stage of a hysteretic (bang-bang) regulator, to see how the frequency follows the ESR, the inductor, the input and the loop delay. Use the Constant On-Time Modulator for a more stable frequency. ## Pins | Pin | Domain | Meaning | |---|---|---| | `FB` | electrical | Feedback, the divided output with its ripple | | `REF` | electrical | Reference, the centre of the window | | `EN` | signal | Enable signal, high to switch | | `GATE` | signal | Switch command, 0 or 1 | | `GND` | electrical | Reference of FB and REF | ## Common parameters - `vHyst`: Full width of the window at FB, centred on REF (Default: 0.01) - `tDelay`: Delay of both edges of the switch command (comparator and driver; 0 = none) (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `vHyst` | V | 0.01 | 1u – 10 V | Full width of the window at FB, centred on REF | typical, user must set | | `tDelay` | s | 0 | 0 – 1m s | Delay of both edges of the switch command (comparator and driver; 0 = none) | typical, user must set | _Parameter descriptions are in English in both languages._ ## Model Below V(REF) − vHyst/2 the switch command goes high, above V(REF) + vHyst/2 it goes low, and in between it holds (Redl and Sun, IEEE TPEL 2009). With tDelay both edges are delayed. For a buck whose output ripple is set by the ESR, the frequency is ESR·Vout·(Vin − Vout)/(Vin·L·window at the output), where the window at the output is vHyst divided by the feedback divider's ratio; a delay lowers it. ## Common mistakes - The defaults are typical, user must set. vHyst is the full window at FB, so the output ripple is vHyst divided by the divider ratio. - The frequency is not fixed: it moves with the ESR, the input and the load's ESL and delay. Check it at every corner before you trust an EMI filter. Problems rules: `step.too_large`, `ground.missing` ## Datasheet and sources This is an architecture block, so its numbers come from your design. vHyst is the hysteresis window at the feedback pin and tDelay the comparator plus driver delay. A real hysteretic controller lists both in its electrical table. ## Example Open the example with the command `file.openExample` and the name `demo:hystModulator`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Isolated Amplifier with Shunt (`isolatedAmplifier`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/isolatedAmplifier/ > A shunt resistor and amplifier whose reading crosses an isolation barrier. ![isolatedAmplifier](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/isolatedAmplifier.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/isolatedAmplifier/) **Group:** ICs · **Kind:** `{"definition":"isolatedAmplifier","kind":"subsystem"}` ## When to use it Use it to measure current on a high-voltage node, such as a motor phase, and pass the reading to a controller. Use Shunt Amplifier with Shunt when no isolation is needed. ## Pins | Pin | Domain | Meaning | |---|---|---| | `IPP` | electrical | Primary current in, positive reading | | `IPN` | electrical | Primary current out | | `OUTP` | electrical | Positive output, read as OUTP minus OUTN | | `OUTN` | electrical | Negative output, sits above GND2 | | `GND2` | electrical | Ground reference of the output side | ## Common parameters - `rSense`: The shunt resistor between IPP and IPN (your choice, not part of the IC) (Default: 0.01) - `gain`: Nominal gain (Default: 8.2) - `bw`: Output bandwidth: the single pole of the response (Default: 210000) - `clip`: Clipping differential output voltage: the output is limited to plus and minus this (Default: 2.49) - `noise`: RMS output noise; 0 = a noiseless amplifier (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `rSense` | Ω | 0.01 | 1u – 10 Ω | The shunt resistor between IPP and IPN (your choice, not part of the IC) | assumption | | `gain` | V/V | 8.2 | 1 – 100 V/V | Nominal gain | Section 6.9 nominal gain, p.9 | | `gainErr` | — | 0 | -100m – 100m | Gain error as a fraction (typically +/-0.05 %; 0 = nominal) | Section 6.9 EG typ +/-0.05 %, p.9 (set to 0 here) | | `bw` | Hz | 210000 | 1k – 100meg Hz | Output bandwidth: the single pole of the response | Section 6.9 BW typ, p.9 | | `vos` | V | 0.00005 | -1m – 1m V | Input offset voltage (the datasheet gives it as +/-) | Section 6.9 VOS typ +/-0.05 mV, p.9 | | `clip` | V | 2.49 | 100m – 5 V | Clipping differential output voltage: the output is limited to plus and minus this | Section 6.9 VCLIPout typ +/-2.49 V, p.9 | | `vcm` | V | 1.44 | 0 – 5 V | Common-mode output voltage (the output pins sit this far above GND2) | Section 6.9 VCMout typ, p.9 | | `rIn` | Ω | 22000 | 1k – 1g Ω | Differential input resistance, across the shunt | Section 6.9 RIND typ, p.9 | | `tDelay` | s | 0.000001075 | 0 – 1m s | Signal delay ahead of the bandwidth pole: with the pole, a step reaches 50 % this plus ln 2 / (2 pi bw) late | Section 6.10 VINx to VOUTx signal delay (50 % - 50 %, unfiltered output) typ 1.6 us (max 2.6 us), p.10, less the pole's own 50 % time ln 2 / (2 pi 210 kHz) = 0.525 us (derived) | | `noise` | V | 0 | 0 – 1 V | RMS output noise; 0 = a noiseless amplifier | Section 6.9 output noise typ 220 uV rms with a 100 kHz brickwall filter, p.9 (set to simulate) | | `seed` | — | 1 | 0 – 9007t | Whole-number seed of the noise | model parameter | | `vIowm` | V | 1500 | 0 – 100k V | Isolation working voltage (DC, peak): the largest voltage across the barrier the part is rated for (0: not set, no check) | Section 6.6 VIOWM at DC voltage 1500 VDC (1000 VRMS at AC sine; VIORM 1500 VPK), p.7 | _Parameter descriptions are in English in both languages._ ## Model The primary path is the shunt rSense in series with a current meter, with the input resistance rIn across it. The differential output V(OUTP) - V(OUTN) is gain * (1 + gainErr) * (rSense * i + vos), then a first-order low-pass at bw, then seeded Gaussian noise of noise volts rms, then a limit to plus or minus clip. V(OUTN) sits at vcm above GND2. The isolation barrier, the common-mode transient immunity and the fail-safe output are not modelled. ## Common mistakes - Read the output as the difference between OUTP and OUTN, not against ground. Each pin sits near 1.44 V, so a single-ended reading is wrong by that level. - The output clips at plus or minus 2.49 V, which is an input of about 0.3 V. The input range is only plus or minus 250 mV, so choose rSense so that the peak current stays below it. - Connect GND2 to the controller ground, and keep a ground in the primary-side circuit as well. Keep the step below about a tenth of the response time, which is about 0.8 us at 210 kHz. - The noise is 0 by default. Set 220u to see the datasheet noise, and use another seed for another noise. Problems rules: `step.too_large`, `param.out_of_range` ## Datasheet and sources gain is the nominal gain (8.2 V/V), bw is the output bandwidth, and vos is the typical input offset. gainErr is the gain error as a fraction. clip is the clipping differential output voltage, vcm is the common-mode output voltage, rIn is the differential input resistance, and noise is the output noise. rSense is your design value. Pass them to ic.fromSpec with the isolatedAmplifier template and rename the pins to the datasheet names. ## Example Open the example with the command `file.openExample` and the name `demo:isolatedAmplifier`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Isolated Amplifier with Shunt, ±50 mV (`isolatedAmplifierAmc1302`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/isolatedAmplifierAmc1302/ > A low-loss shunt and an isolated amplifier with a ±50 mV input and a gain of 41. ![isolatedAmplifierAmc1302](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/isolatedAmplifierAmc1302.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/isolatedAmplifierAmc1302/) **Group:** ICs · **Kind:** `{"definition":"isolatedAmplifierAmc1302","kind":"subsystem"}` ## When to use it Use it to measure a large current, such as an inverter leg, on a small shunt that loses little power. Use Isolated Amplifier with Shunt for a ±250 mV input. ## Pins | Pin | Domain | Meaning | |---|---|---| | `IPP` | electrical | Primary current in, positive reading | | `IPN` | electrical | Primary current out | | `OUTP` | electrical | Positive output, read as OUTP minus OUTN | | `OUTN` | electrical | Negative output, sits above GND2 | | `GND2` | electrical | Ground reference of the output side | ## Common parameters - `rSense`: The shunt resistor between IPP and IPN (your choice, not part of the IC) (Default: 0.0015) - `gain`: Nominal gain (Default: 41) - `bw`: Output bandwidth: the single pole of the response (Default: 280000) - `vFsr`: Linear full-scale input: up to plus or minus this the gain is linear (Default: 0.05) - `clip`: Clipping differential output voltage: the output is limited to plus and minus this (Default: 2.49) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `rSense` | Ω | 0.0015 | 1u – 10 Ω | The shunt resistor between IPP and IPN (your choice, not part of the IC) | assumption: the 1.5 mOhm leg shunt of the thesis 12 kW design, 50 mV at 33.3 A | | `gain` | V/V | 41 | 1 – 100 V/V | Nominal gain | Section 6.9 nominal gain, p.8 | | `gainErr` | — | 0 | -100m – 100m | Gain error as a fraction (typically +/-0.04 %; 0 = nominal) | Section 6.9 EG typ +/-0.04 %, max +/-0.2 %, p.8 (set to 0 here) | | `bw` | Hz | 280000 | 1k – 100meg Hz | Output bandwidth: the single pole of the response | Section 6.9 BW typ (220 kHz min), p.8 | | `vos` | V | 0.0000025 | -1m – 1m V | Input offset voltage (the datasheet gives it as +/-) | Section 6.9 VOS typ +/-2.5 uV, max +/-50 uV, p.8 | | `vFsr` | V | 0.05 | 1m – 1 V | Linear full-scale input: up to plus or minus this the gain is linear | Section 6.3 VFSR +/-50 mV, p.7 | | `vClipIn` | V | 0.064 | 1m – 1 V | Input at which the output reaches clip; between vFsr and this the gain falls | Section 6.3 VClipping +/-64 mV, p.7; the straight line from vFsr to it is an assumption (section 7.3.3, p.19) | | `clip` | V | 2.49 | 100m – 5 V | Clipping differential output voltage: the output is limited to plus and minus this | Section 6.9 VCLIPout typ +/-2.49 V, p.8 | | `vcm` | V | 1.44 | 0 – 5 V | Common-mode output voltage (the output pins sit this far above GND2) | Section 6.9 VCMout typ, p.8 | | `rIn` | Ω | 4900 | 1k – 1g Ω | Differential input resistance, across the shunt | Section 6.9 RIND typ, p.8 | | `noise` | V | 0 | 0 – 1 V | RMS output noise; 0 = a noiseless amplifier | Section 6.9 output noise typ 260 uV rms with a 100 kHz brickwall filter, p.8 (set to simulate) | | `seed` | — | 1 | 0 – 9007t | Whole-number seed of the noise | model parameter | | `tDelay` | s | 0.000001206 | 0 – 1m s | Signal delay ahead of the bandwidth pole: with the pole, a step reaches 50 % this plus ln 2 / (2 pi bw) late | Section 6.10 VINx to VOUTx signal delay (50 % - 50 %) typ 1.6 us (max 2.1 us), p.9, less the pole's own 50 % time ln 2 / (2 pi 280 kHz) = 0.394 us (derived) | | `vIowm` | V | 2121 | 0 – 100k V | Isolation working voltage (DC, peak): the largest voltage across the barrier the part is rated for (0: not set, no check) | Section 6.6 VIOWM at DC voltage 2121 VDC (1500 VRMS at AC sine; VIORM 2121 VPK), p.6 | _Parameter descriptions are in English in both languages._ ## Model The primary path is the shunt rSense in series with a current meter, with the input resistance rIn across it. The meter gives gain * (1 + gainErr) * (rSense * i + vos) through a first-order low-pass at bw, with seeded noise, limited where the input reaches vClipIn. The output is that value up to the input vFsr. From vFsr to vClipIn it rises at a lower slope and reaches clip at vClipIn, and above that it stays at clip. V(OUTN) sits at vcm above GND2. The straight line between vFsr and vClipIn is an assumption, because the data sheet gives no curve there. The reading is delayed by tDelay ahead of the low-pass. The isolation barrier, the signal delay and the fail-safe output are not modelled. ## Common mistakes - The linear input is only plus or minus 50 mV. With the default 1.5 mOhm shunt, 33.3 A gives the full-scale output of 2.05 V. Above that the reading is low, and above about 42.7 A (64 mV) it is flat at 2.49 V. - Read the output as the difference between OUTP and OUTN, not against ground. Each pin sits near 1.44 V. - The part delays the signal by 1.6 us typical (2.1 us max): tDelay (1.206 us) ahead of the bw pole gives that 50 % delay. Delay the ADC sample in your controller by the same time, and set tDelay to 1.706 us to study the slowest part. - The noise is 0 by default. Set 260u to see the data sheet noise, and use another seed for another noise. Problems rules: `step.too_large`, `param.out_of_range` ## Datasheet and sources The defaults are the TI AMC1302, data sheet SBAS812D (revised June 2021). vFsr and vClipIn are the linear full-scale and clipping inputs of section 6.3. gain, gainErr, bw, vos, clip, vcm, rIn and noise are the typical column of section 6.9. tDelay is the 1.6 us signal delay of section 6.10 less the pole's own 0.394 us. rSense is your design value; the default 1.5 mOhm is an assumption taken from the thesis 12 kW design. Pass them to ic.fromSpec with the isolatedAmplifierAmc1302 template and rename the pins to the data sheet names. ## Example Open the example with the command `file.openExample` and the name `demo:isolatedAmplifierAmc1302`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Isolated Voltage Sensor with Divider (`isolatedVoltageSensor`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/isolatedVoltageSensor/ > A resistive divider into a high-impedance isolated amplifier, giving a low-voltage reading of a high voltage. ![isolatedVoltageSensor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/isolatedVoltageSensor.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/isolatedVoltageSensor/) **Group:** ICs · **Kind:** `{"definition":"isolatedVoltageSensor","kind":"subsystem"}` ## When to use it Use it to read a DC-link or line voltage with isolation and pass it to a controller. Use Voltmeter for a plain measurement. ## Pins | Pin | Domain | Meaning | |---|---|---| | `HVP` | electrical | High-voltage input, top of the divider | | `HVN` | electrical | High-voltage reference, bottom of the divider | | `OUTP` | electrical | Positive output, read as OUTP minus OUTN | | `OUTN` | electrical | Negative output, sits above GND2 | | `GND2` | electrical | Ground reference of the output side | ## Common parameters - `rTop`: Divider resistor from HVP to the amplifier input (your choice) (Default: 2000000) - `rBottom`: Divider resistor across the amplifier input, to HVN (your choice) (Default: 10000) - `gain`: Nominal gain (Default: 1) - `bw`: Output bandwidth: the single pole of the response (Default: 220000) - `clip`: Clipping differential output: limited to plus and minus this (Default: 2.49) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `rTop` | Ω | 2000000 | 1k – 10g Ω | Divider resistor from HVP to the amplifier input (your choice) | assumption: with rBottom, 400 V gives 1.99 V, inside the 2 V full scale of section 7.3, p.6 | | `rBottom` | Ω | 10000 | 1 – 1g Ω | Divider resistor across the amplifier input, to HVN (your choice) | assumption | | `gain` | V/V | 1 | 100m – 100 V/V | Nominal gain | Section 7.9 nominal gain 1 V/V, p.10 | | `gainErr` | — | 0 | -100m – 100m | Gain error as a fraction (typically 0.4 %; 0 = nominal) | Section 7.9 EG typ 0.4 %, p.10 (set to 0 here) | | `bw` | Hz | 220000 | 1k – 100meg Hz | Output bandwidth: the single pole of the response | Section 7.9 BW typ 220 kHz, p.10 | | `vos` | V | 0.0004 | -10m – 10m V | Input offset voltage (the data sheet gives it as +/-) | Section 7.9 VOS typ +/-0.4 mV, p.10 | | `clip` | V | 2.49 | 100m – 5 V | Clipping differential output: limited to plus and minus this | Section 7.9 VCLIPout typ 2.49 V, p.10 (the negative limit is an assumption) | | `vcm` | V | 1.44 | 0 – 5 V | Common-mode output voltage (the output pins sit this far above GND2) | Section 7.9 VCMout typ 1.44 V, p.10 | | `rIn` | Ω | 1000000000 | 1k – 1t Ω | Input resistance of the amplifier, across rBottom | Section 7.9 RIN typ 1 GOhm, p.10 | | `noise` | V | 0 | 0 – 1 V | RMS output noise; 0 = a noiseless amplifier | Section 7.9 output noise typ 220 uV rms (100 kHz), p.10 (set to simulate) | | `seed` | — | 1 | 0 – 9007t | Whole-number seed of the noise | model parameter | | `tDelay` | s | 0.000001599 | 0 – 1m s | Signal delay ahead of the bandwidth pole: with the pole, a step reaches 50 % this plus ln 2 / (2 pi bw) late | Section 7.10 IN to OUTx signal delay (50 % - 50 %, AMC1311) typ 2.1 us (max 3.1 us), p.12, less the pole's own 50 % time ln 2 / (2 pi 220 kHz) = 0.501 us (derived) | _Parameter descriptions are in English in both languages._ ## Model rTop runs from HVP to the amplifier input and rBottom from the input to HVN, with the input resistance rIn across rBottom, so the divider draws its current from the measured node. A voltage meter across rBottom reads the input. The differential output V(OUTP) - V(OUTN) is gain * (1 + gainErr) * (v + vos), delayed by tDelay, then a first-order low-pass at bw, then seeded Gaussian noise of noise volts rms, then a limit to plus or minus clip. V(OUTN) sits at vcm above GND2. The isolation barrier and the fail-safe output are not modelled. ## Common mistakes - The amplifier's linear input is only -0.1 to 2 V. Choose rTop and rBottom so that the highest voltage gives about 2 V across rBottom; the defaults give 1.99 V at 400 V. - Read the output as OUTP minus OUTN, not against ground: each pin sits near 1.44 V. Problems rules: `step.too_large`, `param.out_of_range` ## Datasheet and sources gain is the nominal gain (1 V/V), bw is the output bandwidth, vos is the typical input offset and gainErr the gain error as a fraction. clip is the clipping differential output, vcm the common-mode output, rIn the input resistance and noise the output noise. tDelay is the 2.1 us signal delay of section 7.10 less the pole's own 0.501 us. rTop and rBottom are your divider. The defaults are the TI AMC1311, SBAS786C. Pass them to ic.fromSpec with the isolatedVoltageSensor template, or place the AMC3330 preset (SBASA34B: gain 2, ±1 V input, 375 kHz, 1.6 us), whose divider is the 1001 V bus divider of the thesis design. ## Example Open the example with the command `file.openExample` and the name `demo:isolatedVoltageSensor`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Low-Dropout Regulator (`ldo`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/ldo/ > Makes a clean fixed voltage from a slightly higher supply. ![ldo](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/ldo.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/ldo/) **Group:** ICs · **Kind:** `{"definition":"ldo","kind":"subsystem"}` ## When to use it Use it after a switching stage to clean the ripple, or to power logic, with its dropout, current limit and supply rejection. Use Voltage Reference for a precise low-current level. ## Pins | Pin | Domain | Meaning | |---|---|---| | `IN` | electrical | Input supply | | `OUT` | electrical | Regulated output, needs its capacitor | | `GND` | electrical | Ground | | `EN` | electrical | Enable, tie to IN to keep it on | ## Common parameters - `vOut`: Output voltage (Default: 3.3) - `psrr`: Supply rejection at low frequency (Default: 90) - `rDo`: Dropout resistance: dropout per ampere of output (Default: 0.48) - `iLim`: Current limit (Default: 0.5) - `tOn`: Start-up time: the set point ramps to vOut over it (Default: 0.00008) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `vOut` | V | 3.3 | 500m – 40 V | Output voltage | LP5907MFX-3.3 option; Section 5.5 tolerance applies to VOUT(NOM), p.5 | | `psrr` | dB | 90 | 0 – 160 dB | Supply rejection at low frequency | Section 5.5 PSRR typ at 100 Hz, IOUT = 20 mA, p.5 | | `fZero` | Hz | 430 | 100m – 1g Hz | Frequency where the rejection starts to fall (20 dB per decade) | fit to the four PSRR rows of Section 5.5 (100 Hz to 100 kHz), p.5 | | `fPole` | Hz | 13600 | 100m – 1g Hz | Frequency where the rejection stops falling | fit to the four PSRR rows of Section 5.5 (60 dB at 100 kHz), p.5 | | `vDo0` | V | 0 | 0 – 5 V | Dropout with no load | assumption: Section 5.5 gives the dropout at 250 mA only, p.5 | | `rDo` | Ω | 0.48 | 100u – 1k Ω | Dropout resistance: dropout per ampere of output | Section 5.5 VDO typ 120 mV at 250 mA (DSBGA), p.5 | | `rLoad` | Ω | 0.033 | 0 – 1k Ω | Load regulation as a resistance | Section 5.5 load regulation typ 0.001 %/mA at 3.3 V, p.5 | | `rHf` | Ω | 0.48 | 100u – 1k Ω | Output resistance a load step sees before the loop responds | assumption: set to rDo (the pass device fully on); no output impedance curve is given | | `fLoop` | Hz | 46000 | 1 – 1g Hz | Bandwidth with which the loop corrects load and dropout changes | fit: a 1 to 250 mA step in 10 us droops 40 mV with rHf and no capacitor (Section 5.5 load transient max), p.6 | | `iLim` | A | 0.5 | 100u – 100 A | Current limit | Section 5.5 ISC typ, p.5 | | `iq` | A | 0.000012 | 0 – 100m A | Quiescent current drawn from IN while enabled | Section 5.5 IQ typ at IOUT = 0, p.5 | | `tOn` | s | 0.00008 | 1n – 1 s | Start-up time: the set point ramps to vOut over it | Section 5.5 tON typ (to 95 % of VOUT), p.6 | | `vEnOn` | V | 1.2 | 100m – 10 V | EN rising threshold | Section 5.5 VIH min (used as the threshold), p.6 | | `vEnOff` | V | 0.4 | 0 – 10 V | EN falling threshold | Section 5.5 VIL max (used as the threshold), p.6 | | `rAd` | Ω | 230 | 1 – 1g Ω | Output discharge resistance while disabled | Section 5.5 RAD typ, p.5 | _Parameter descriptions are in English in both languages._ ## Model The set point is vOut plus the input through the supply rejection, which is psrr at low frequency with a zero at fZero and a pole at fPole. After enable the set point ramps up over tOn. The output falls by rLoad times the current, and a fast load step sees rHf until the loop catches up at fLoop. In dropout the output is the input less vDo0 and rDo times the current. The current stops at iLim, the output cannot sink, and the input draws the output current plus iq. Noise, temperature and thermal shutdown are not modelled. ## Common mistakes - Give the input a capacitor or a stiff source. The input current reaches the circuit one step late, and a soft source without a capacitor can make it oscillate. - The control reaches the output one step late. Keep the step below about a tenth of 1 / (2 pi fLoop), which is about 0.35 us at the defaults. Problems rules: `step.too_large`, `param.out_of_range` ## Datasheet and sources vOut is your output option. psrr is the rejection at the lowest frequency listed, and fZero and fPole fit the other rows or the curve. rDo is the dropout divided by its test current, rLoad is the load regulation times vOut, iLim is the short-circuit current, iq is the quiescent current, and tOn is the turn-on time. vEnOn and vEnOff are the enable thresholds. Pass them to ic.fromSpec with the ldo template. ## Example Open the example with the command `file.openExample` and the name `demo:ldo`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # LDO Loop (Architecture) (`ldoArch`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/ldoArch/ > The loop of a low-dropout regulator with its error-amplifier and gate poles, to choose the output capacitor's ESR window. ![ldoArch](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/ldoArch.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/ldoArch/) **Group:** ICs · **Kind:** `{"definition":"ldoArch","kind":"subsystem"}` ## When to use it Use it at the architecture stage to place the error-amplifier and pass-device poles and to see which ESR of the output capacitor keeps the loop stable. Put the output capacitor with its ESR, the load and the divider to FB in the circuit, then run analysis.loopGain with signal U1.x_err. ## Pins | Pin | Domain | Meaning | |---|---|---| | `IN` | electrical | Input supply, the pass device's source | | `OUT` | electrical | Output, the pass device's drain | | `FB` | electrical | Feedback from the output divider, regulated to vRef | | `GND` | electrical | Reference of FB | ## Common parameters - `gmEa`: Transconductance of the error amplifier; its DC gain is gmEa·roEa (Default: 0.0003) - `cEa`: Capacitance at the error amplifier's output: its pole is 1/(2π·roEa·cEa) (Default: 0.000000000318) - `cGate`: Gate capacitance of the pass device: the gate pole is 1/(2π·rGate·cGate) (Default: 0.000000001) - `gmPass`: Transconductance of the pass device at its operating point (Default: 1) - `rDo`: On resistance of the pass device at full gate drive: the dropout is rDo·I (Default: 1) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `vRef` | V | 1.2 | 100m – 10 V | Reference: FB is regulated to it | typical, user must set | | `gmEa` | S | 0.0003 | 1n – 10 S | Transconductance of the error amplifier; its DC gain is gmEa·roEa | typical, user must set | | `roEa` | Ω | 10000000 | 1 – 1t Ω | Output resistance of the error amplifier | typical, user must set | | `cEa` | F | 0.000000000318 | 1f – 1m F | Capacitance at the error amplifier's output: its pole is 1/(2π·roEa·cEa) | typical, user must set | | `rGate` | Ω | 1000 | 1m – 1g Ω | Output resistance of the stage that drives the pass device's gate | typical, user must set | | `cGate` | F | 0.000000001 | 1f – 1m F | Gate capacitance of the pass device: the gate pole is 1/(2π·rGate·cGate) | typical, user must set | | `gmPass` | A/V | 1 | 1u – 1k A/V | Transconductance of the pass device at its operating point | typical, user must set | | `roPass` | Ω | 330 | 1m – 1g Ω | Output resistance of the pass device (the supply's path to the output) | typical, user must set | | `rDo` | Ω | 1 | 100u – 1k Ω | On resistance of the pass device at full gate drive: the dropout is rDo·I | typical, user must set | | `iLim` | A | 0.5 | 1u – 100 A | Current limit of the pass device | typical, user must set | _Parameter descriptions are in English in both languages._ ## Model The error vRef − V(FB) goes through the error amplifier, gain gmEa·roEa with its pole at 1/(2π·roEa·cEa), then the gate pole 1/(2π·rGate·cGate), to a pass current gmPass·g limited to iLim, which flows from IN through rDo to OUT; roPass joins IN to OUT. In dropout the output current is (V(IN) − V(OUT))/rDo. The loop gain is β·gmEa·roEa·gmPass·Zp/((1 + s/ωea)(1 + s/ωg)), where Zp holds the load pole and the ESR zero 1/(2π·ESR·C). The loop is the one of TI SLVA115A (Section 1, Figure 1; the ESR zero is its Equation 1), and the ESR window follows its rule: the ESR zero below the crossover, the crossover below the pass-device pole. ## Common mistakes - The defaults are typical, user must set. With them and 10 µF, the phase margin is above 45° only for an ESR of about 0.7 Ω to 4 Ω; a ceramic capacitor's few milliohms make the loop oscillate. - gmPass is taken at one operating point. A real pass device's gm grows with the load current, which moves the loop gain and the load pole: check the light and the full load with their own gmPass. Problems rules: `ground.missing` ## Datasheet and sources This is an architecture block. The numbers are the designer's: the error amplifier's gm, output resistance and output capacitance, the gate driver's resistance, the pass device's gate capacitance, gm, output and on resistance, and the current limit. An LDO's data sheet gives only the stable output capacitance and ESR range, the dropout and the current limit. ## Example Open the example with the command `file.openExample` and the name `demo:ldoArch`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # LLC Resonant Controller (Hybrid Hysteretic Control) (`llcController`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/llcController/ > Drives a half-bridge LLC from an optocoupler feedback current, with the data sheet's start sequence, soft start and protections. ![llcController](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/llcController.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/llcController/) **Group:** ICs · **Kind:** `{"definition":"llcController","kind":"subsystem"}` ## When to use it Use it for an LLC half bridge with a UCC25640x-class controller, when you want the hybrid hysteretic control, the BLK start threshold, the LL/SS soft start and OCP1 with your own tank. circuit.applicationCircuit with topology llcHhc builds the converter and sizes every external part with the data sheet's design steps. ## Pins | Pin | Domain | Meaning | |---|---|---| | `GND` | electrical | Ground reference of every pin | | `VCC` | electrical | Supply, the controller starts above the UVLO threshold | | `RVCC` | electrical | Regulated 13 V supply of the gate drivers, feeds the bootstrap diode | | `BLK` | electrical | Bulk voltage sense through a divider | | `FB` | electrical | Feedback, the optocoupler pulls current out of it | | `ISNS` | electrical | Resonant current sense through CISNS and RISNS | | `VCR` | electrical | Resonant capacitor voltage through the capacitor divider | | `BW` | electrical | Bias winding sense for the output overvoltage protection | | `LLSS` | electrical | Soft-start capacitor and the divider from RVCC | | `HB` | electrical | High-side bootstrap supply | | `HO` | electrical | High-side gate drive | | `HS` | electrical | Switch node of the half bridge | | `LO` | electrical | Low-side gate drive | ## Common parameters - `iFb`: FB internal current source (Default: 0.000082) - `rFb`: Internal pull-down resistor of the feedback chain (Default: 100000) - `vcm`: Common-mode voltage of VCR (Default: 3) - `iRamp`: Frequency compensation ramp current (Default: 0.002) - `tDead`: Dead time between the outgoing and the incoming gate (Default: 0.0000001) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `vccOn` | V | 8.25 | 2 – 30 V | VCC UVLO rising threshold | Section 6.5 VCCUVLOrising typ 8.25 V, p.7 | | `vccHys` | V | 0.25 | 0 – 5 V | VCC UVLO hysteresis | Section 6.5 VCCUVLOHYS typ 0.25 V, p.7 | | `vRvcc` | V | 13 | 5 – 17 V | Regulated RVCC voltage | Section 6.5 VRVCC typ 13 V at VCC = 15 V, p.8 | | `vRvccDrop` | V | 0.02 | 0 – 5 V | VCC minus RVCC when VCC is too low to regulate | derived: section 6.5 VRVCC typ 12.98 V at VCC = 13 V, no load, p.8 | | `rRvcc` | Ω | 12.7 | 0 – 1k Ω | Output resistance of RVCC | derived: section 6.5 VRVCC typ 12.98 V no load and 12.6 V at 30 mA at VCC = 13 V, p.8 | | `vRvccUvlo` | V | 7 | 1 – 15 V | RVCC UVLO threshold | Section 6.5 VRVCCUVLO typ 7 V, p.8 (no hysteresis is given) | | `vBlkStart` | V | 1 | 100m – 7 V | BLK voltage that allows the LLC to start switching | Section 6.5 VBLKStart typ 1 V for UCC256404, p.8 (3 V for UCC256402 and UCC256403) | | `vBlkStop` | V | 0.9 | 100m – 7 V | BLK voltage that forces the LLC to stop | Section 6.5 VBLKStop typ 0.9 V for UCC256404, p.8 (2.2 V for UCC256402 and UCC256403) | | `vFb` | V | 5.6 | 1 – 7 V | Voltage FB is held at | Section 6.5 VFB typ 5.6 V at a sink current of IFB − 50 µA, p.9 | | `iFb` | A | 0.000082 | 1u – 1m A | FB internal current source | Section 6.5 IFB typ 82 µA for UCC256404, p.9 (164 µA for UCC256403) | | `rFb` | Ω | 100000 | 1k – 10meg Ω | Internal pull-down resistor of the feedback chain | Section 6.5 RFBInternal typ 100 kΩ, p.8 | | `avdd` | V | 6 | 3 – 12 V | Upper limit of the control effort | derived: section 7.3.1 requires AVDD at least twice VCM; the sheet gives no value, so the lower bound is used | | `bmtl` | V | 0.2 | 0 – 6 V | Lowest control effort (the burst mode entry threshold BMTL) | Section 6.5 BMTLmin 0.2 V, p.10; burst mode is not modelled | | `vcm` | V | 3 | 1 – 5 V | Common-mode voltage of VCR | Section 6.5 VCM typ 3 V, p.9 | | `iRamp` | A | 0.002 | 10u – 100m A | Frequency compensation ramp current | Section 6.5 IRAMP typ 2 mA, p.9 | | `rClamp` | Ω | 100 | 1 – 100k Ω | Resistance that clamps VCR to VCM while idle | assumption: the sheet says the pin is clamped to VCM in idle (section 7.3.4) but not how hard | | `tDead` | s | 0.0000001 | 10n – 5u s | Dead time between the outgoing and the incoming gate | Section 6.6 tDT(min) typ 100 ns, p.11; the part adapts it between 100 ns and 1.1 µs, the model keeps it fixed | | `vOcp1` | V | 4 | 500m – 7 V | OCP1 threshold on ISNS | Section 6.5 VISNS_OCP1 typ 4 V, p.9 | | `vOcp1Ss` | V | 5 | 500m – 7 V | OCP1 threshold on ISNS during the soft start | Section 6.5 VISNS_OCP1_SS typ 5 V, p.9 | | `vOcp3` | V | 0.43 | 50m – 7 V | OCP3 threshold on the average ISNS (read by the design equations only: OCP2 and OCP3 are not modelled) | Section 6.5 VISNS_OCP3 typ 0.43 V, p.9 | | `vBwOvp` | V | 4 | 500m – 7 V | Bias winding overvoltage threshold (positive and negative) | Section 6.5 VBWOVPos typ 4 V and VBWOVNeg typ −4 V, p.10 | | `tPause` | s | 1 | 1m – 100 s | Wait after a fault before the next start | Section 7.3.9 (every fault) and section 6.5 tPauseTimeOut 1 s, p.11 | | `iSsUp` | A | 0.000036 | 100n – 1m A | Current that charges the soft-start capacitor on LL/SS | Section 6.5 ISSUp typ 36 µA, p.10 | | `rSsDown` | Ω | 1200 | 10 – 100k Ω | LL/SS pull-down while idle | Section 7.4.3.1: the pin is pulled low with a typical 1.2 kΩ resistor | | `tSsInit` | s | 0.000776 | 1u – 100m s | Time the LL/SS initial voltage is programmed before the soft start | Section 6.5 tSSInitVolPrgm typ 776 µs, p.10 | | `tChargeBoot` | s | 0.000265 | 1u – 100m s | Time LO is held on to charge the bootstrap capacitor | Section 6.5 tChargeBoot typ 265 µs, p.10 | | `iccRun` | A | 0.0022 | 0 – 100m A | Supply current from VCC while the gates switch | Section 6.5 ICCRun typ 2.2 mA (gate current excluded), p.8 | | `vHbUvloFall` | V | 7.25 | 1 – 30 V | HB − HS UVLO falling threshold | Section 6.5 VHB-HSUVLOFall typ 7.25 V, p.9 | | `vHbUvloHys` | V | 0.9 | 0 – 10 V | HB − HS UVLO hysteresis | Section 6.5 VHB-HSUVLOHys typ 0.9 V, p.9 | | `rGateHi` | Ω | 9 | 100m – 1k Ω | Pull-up resistance of each gate output | derived: section 6.5 VRVCC − VLOH typ 0.18 V and VHB − VHOH typ 0.18 V at 20 mA, p.9 | | `rGateLo` | Ω | 2.5 | 100m – 1k Ω | Pull-down resistance of each gate output | derived: section 6.5 VLOL and VHOL − VHS typ 0.05 V at 20 mA, p.9 | | `iHb` | A | 0.000062 | 0 – 10m A | HB quiescent current, from HB to HS | Section 6.5 IBOOT_QUIESCENT typ 62 µA, p.10 | | `rOff` | Ω | 100000000 | 1k – 1t Ω | Off-state resistance of the internal switches | assumption: large against the external networks | _Parameter descriptions are in English in both languages._ ## Model FB is held at vFb and the control effort is Vcomp = rFb * (iFb - Iopto), at least bmtl and at most avdd. The thresholds are VTH = vcm + Vcomp / 2 and VTL = vcm - Vcomp / 2; VCR gets +-iRamp from the controller, so the high side turns off at VTH and the low side at VTL, which makes a smaller Vcomp a higher frequency. The incoming gate follows the outgoing one after tDead. ## Common mistakes - Burst mode, the capacitive-region (ZCS) protection and OCP2 and OCP3 are not modelled, so a heavy load can drive the frequency below resonance. The llcHhc application runs at half load for this reason. - A fault (OCP1, the bias winding OVP) holds the switching off for tPause, one second by default, so a short run shows only the stop. Problems rules: `step.too_large`, `param.out_of_range`, `pin.unconnected` ## Datasheet and sources The tank, the BLK, ISNS, VCR and BW networks and the LL/SS parts are your own. vccOn, vccHys, vRvcc, vBlkStart, vBlkStop, vFb, iFb, rFb, vcm, iRamp, vOcp1, vBwOvp, iSsUp, tSsInit and tChargeBoot come from the UCC256404 data sheet; avdd, rClamp and tDead are labelled in their sources. ## Example Open the example with the command `file.openExample` and the name `demo:llcController`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Low-Side Gate Driver (`lowSideDriver`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/lowSideDriver/ > Drives one ground-referenced switch from one supply, such as the switch of a boost or a flyback. ![lowSideDriver](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/lowSideDriver.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/lowSideDriver/) **Group:** ICs · **Kind:** `{"definition":"lowSideDriver","kind":"subsystem"}` ## When to use it Use it to put the driver IC and its gate resistors into the circuit. The switch keeps its own gate signal, so the driver does not change how it switches. ## Pins | Pin | Domain | Meaning | |---|---|---| | `IN` | signal | Input: the gate signal of the switch | | `VDD` | electrical | Driver supply, referenced to GND | | `GND` | electrical | Ground of the driver: the switch's source | | `OUT` | electrical | Gate output | ## Common parameters - `tPd`: Propagation delay from the input to the output (rising and falling) (Default: 0.000000013) - `vUvloOn`: VDD UVLO start threshold (VDD - GND); the output is held low below it (Default: 4.65) - `rSource`: Pull-up resistance of the output (Default: 3) - `rSink`: Pull-down resistance of the output (Default: 0.5) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `tPd` | s | 0.000000013 | 0 – 10u s | Propagation delay from the input to the output (rising and falling) | Section 8.6 turn-on propagation delay tD1 typ (catalogue tpd) | | `vUvloOn` | V | 4.65 | 1 – 40 V | VDD UVLO start threshold (VDD - GND); the output is held low below it | Section 8.5 VON supply start threshold max (the catalogue holds no typical) | | `rSource` | Ω | 3 | 1m – 1k Ω | Pull-up resistance of the output | derived: VDD = 12 V over the peak source current 4 A, Section 8.5 (ROH is only the P-channel part of the pull-up, note 2) | | `rSink` | Ω | 0.5 | 1m – 1k Ω | Pull-down resistance of the output | Section 8.5 ROL typ | | `rOff` | Ω | 1000000 | 1k – 1t Ω | Off-state resistance of the output switches | assumption: the solver's default switch off resistance | _Parameter descriptions are in English in both languages._ ## Model The input reaches the output after tPd on both edges. OUT is VDD through rSource or GND through rSink, and it stays low while VDD minus GND is below vUvloOn. rSource is the resistance that gives the data sheet's peak source current at its 12 V test supply. The input thresholds, the UVLO hysteresis and the supply currents are not modelled. ## Common mistakes - IN is a 0/1 signal, not a voltage. Connect it to the net that drives the switch's gate. - GND must be the switch's source. A switch whose source is not on the driver's ground needs a half-bridge or an isolated driver. Problems rules: `step.too_large`, `ground.missing` ## Datasheet and sources Take tPd from the switching characteristics, vUvloOn from the VDD start threshold, rSink from the pull-down resistance, and rSource as the test supply over the peak source current. Pass them as params to the ic.fromSpec command. ## Example Open the example with the command `file.openExample` and the name `demo:lowSideDriver`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Multiplier Boost PFC Controller (Average Current Mode with Line Sensing) (`multiplierPfcController`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/multiplierPfcController/ > Shapes the input current of a boost PFC from the sensed line waveform through an analog multiplier with RMS feedforward, and regulates the output voltage. ![multiplierPfcController](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/multiplierPfcController.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/multiplierPfcController/) **Group:** ICs · **Kind:** `{"definition":"multiplierPfcController","kind":"subsystem"}` ## When to use it Use it for a boost PFC with a UC3854-class controller, when you want the classic multiplier, the VRMS squared feedforward and two operational amplifiers whose compensation networks you draw yourself. circuit.applicationCircuit with topology multiplierPfc builds the data sheet's 250 W preregulator. For a PFC without line sensing use the CCM Boost PFC Controller; to try your own control law use the PI Controller and PWM Generator. ## Pins | Pin | Domain | Meaning | |---|---|---| | `GND` | electrical | Ground reference of every pin | | `PKLMT` | electrical | Peak current limit, the pulse ends below 0 V | | `CAOUT` | electrical | Current amplifier output, its network goes to ISENSE | | `ISENSE` | electrical | Current amplifier inverting input | | `MULTOUT` | electrical | Multiplier output current and current amplifier non-inverting input | | `IAC` | electrical | Line waveform current into a pin held at 6 V | | `VAOUT` | electrical | Voltage amplifier output | | `VRMS` | electrical | Feedforward voltage proportional to the RMS line | | `VREF` | electrical | 7.5 V reference output | | `ENA` | electrical | Enable input | | `VSENSE` | electrical | Voltage amplifier inverting input, the output divider goes here | | `RSET` | electrical | Resistor to GND sets the oscillator and the multiplier limit | | `SS` | electrical | Soft-start capacitor to GND | | `CT` | electrical | Timing capacitor to GND | | `VCC` | electrical | Supply, the controller runs above the UVLO threshold | | `GTDRV` | electrical | Gate drive of the boost switch | ## Common parameters - `vRef`: Reference output voltage, and the voltage amplifier reference (Default: 7.5) - `kMult`: Multiplier gain constant k of IMO = k·IAC·(VAOUT − vaOffset)/VRMS² (Default: 1) - `gbwCa`: Current amplifier gain-bandwidth product (Default: 800000) - `vRamp`: CT ramp peak-to-valley amplitude (Default: 5.4) - `dMax`: Maximum duty cycle (the rest of the period discharges CT) (Default: 0.95) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `vccOn` | V | 16 | 1 – 35 V | VCC UVLO turn-on threshold | Section 7.5 VCC turn-on threshold typ 16 V, p.6 | | `vccOff` | V | 10 | 500m – 35 V | VCC UVLO turn-off threshold | Section 7.5 VCC turn-off threshold typ 10 V, p.6 | | `vEnaRise` | V | 2.55 | 100m – 14 V | ENA rising threshold | Section 7.5 ENA threshold, rising typ 2.55 V, p.6 | | `vEnaHyst` | V | 0.25 | 0 – 5 V | ENA threshold hysteresis | Section 7.5 ENA threshold hysteresis typ 0.25 V, p.6 | | `vRef` | V | 7.5 | 1 – 10 V | Reference output voltage, and the voltage amplifier reference | Section 7.5 reference output voltage typ 7.5 V, p.7 | | `rRef` | Ω | 0.5 | 0 – 100 Ω | Reference output resistance | Section 7.5 VREF load regulation typ 5 mV over 0 to -10 mA, p.7 | | `iSs` | A | 0.000014 | 100n – 1m A | Soft-start charging current | Section 7.5 SS current typ -14 µA at VSS = 2.5 V, p.6 | | `a0Va` | V/V | 100000 | 10 – 100meg V/V | Voltage amplifier open-loop gain | Section 7.5 voltage amplifier gain typ 100 dB, p.6 | | `gbwVa` | Hz | 1000000 | 1k – 100meg Hz | Voltage amplifier unity-gain frequency | Figure 2: open-loop gain 80 dB at 100 Hz falling 20 dB/decade, 0 dB near 1 MHz (read off the plot), p.8 | | `vaLo` | V | 0.5 | 0 – 5 V | Voltage amplifier lowest output | Section 7.5 voltage amplifier output swing min 0.5 V, p.6 | | `vaHi` | V | 5.8 | 1 – 10 V | Voltage amplifier output limit | Section 7.5 voltage amplifier output swing 5.8 V, p.6; pin table: limited to about 5.8 V | | `a0Ca` | V/V | 316228 | 10 – 100meg V/V | Current amplifier open-loop gain | Section 7.5 current amplifier gain typ 110 dB, p.6 | | `gbwCa` | Hz | 800000 | 1k – 100meg Hz | Current amplifier gain-bandwidth product | Section 7.5 current amplifier gain-bandwidth product typ 800 kHz, p.7 | | `caLo` | V | 0.5 | 0 – 5 V | Current amplifier lowest output | Section 7.5 current amplifier output swing min 0.5 V, p.7 | | `caHi` | V | 16 | 1 – 35 V | Current amplifier highest output | Section 7.5 current amplifier output swing 16 V, p.7 | | `rPullDown` | Ω | 8000 | 10 – 10meg Ω | Pull-down resistor of each amplifier output | Pin table, CAOUT and VAOUT: an NPN emitter-follower pull-up and an 8-kΩ resistor to ground, p.4 | | `vIac` | V | 6 | 0 – 10 V | Voltage IAC is held at | Pin table, IAC: the nominal voltage on IAC is 6 V, p.4 | | `kMult` | V | 1 | 10m – 100 V | Multiplier gain constant k of IMO = k·IAC·(VAOUT − vaOffset)/VRMS² | Section 7.5 multiplier gain constant typ -1 V and note (2), p.7 | | `vaOffset` | V | 1 | 0 – 5 V | VAOUT below which the multiplier output is zero | Section 7.5 note (2): (VA Out − 1); pin table: VAOUT below 1 V inhibits the multiplier, p.4 | | `kIacLimit` | — | 2 | 100m – 100 | Multiplier output limit, a multiple of IAC | Section 9.2.2.2: the multiplier output current never exceeds twice IAC, p.15 | | `vRset` | V | 3.75 | 100m – 10 V | Multiplier limit IMO ≤ vRset/RSET; RSET is held at this voltage | Section 9.2.2.2 equation 4: IMULTMAX = -3.75 V/RSET, p.15 (the pin voltage itself is not given: holding it at 3.75 V makes its current that limit) | | `kOsc` | — | 1.25 | 100m – 10 | Oscillator constant of f = kOsc/(RSET·CT) | Pin table, CT: equation 1, F = 1.25/(RSET·CT), p.4 | | `vValley` | V | 1.1 | 0 – 5 V | CT ramp valley voltage | Section 7.5 CT ramp valley voltage typ 1.1 V, p.7 | | `vRamp` | V | 5.4 | 500m – 10 V | CT ramp peak-to-valley amplitude | Section 7.5 CT ramp peak-to-valley amplitude typ 5.4 V, p.7 | | `dMax` | — | 0.95 | 500m – 999m | Maximum duty cycle (the rest of the period discharges CT) | Section 7.5 gate driver maximum duty cycle typ 95 % at VCAOUT = 7 V, p.7 | | `vPklmt` | V | 0 | -1 – 1 V | Peak current limit threshold on PKLMT | Pin table, PKLMT: the threshold is 0 V, p.4 | | `vGateClamp` | V | 14.5 | 1 – 35 V | GTDRV high-level clamp | Section 7.5 maximum gate driver output voltage typ 14.5 V (0 mA, 18 V < VCC < 35 V), p.7 | | `rGateHi` | Ω | 11 | 100m – 10k Ω | GTDRV pull-up resistance | Section 7.5 gate driver output voltage high typ 12.8 V at -200 mA, VCC = 15 V, p.7 (assumption: unloaded it would be at VCC) | | `rGateLo` | Ω | 5 | 100m – 10k Ω | GTDRV pull-down resistance | Section 7.5 gate driver output voltage low typ 1 V at 200 mA, p.7 | _Parameter descriptions are in English in both languages._ ## Model The multiplier sources IMO = kMult * IAC * (V(VAOUT) - vaOffset) / V(VRMS)^2 out of MULTOUT, at most kIacLimit * IAC and vRset / RSET, and zero below VAOUT = vaOffset; IAC is held at vIac and RSET at vRset. The voltage amplifier compares the lower of SS and vRef with VSENSE, the current amplifier MULTOUT with ISENSE: each has the gain a0 with one pole and unity gain at gbw, an output held between its lowest and highest swing, and an emitter follower with rPullDown to GND, so it sources only. CT charges from vValley to vValley + vRamp and discharges in the last 1 - dMax of the period, at f = kOsc / (RSET * CT). GTDRV turns on at the end of each discharge and off when CT passes CAOUT or PKLMT falls below vPklmt. The VCC UVLO and ENA enable VREF, the oscillator and the gate and release SS, which charges at iSs. Both amplifiers and the multiplier read node voltages only, so the solver stamps them with the circuit. ## Common mistakes - The current amplifier's 800 kHz gain-bandwidth needs a step well under a microsecond near the switching edges; the application circuit uses 100 steps per switching period. A much coarser maximum step makes the line current wrong. - VRMS must stay between 1.5 V and 3.5 V for the multiplier law to hold; below that the real part gives less than the law (80 uA where it gives 100 uA at 1 V). Size the VRMS filter for your line range. - The voltage loop is slow (a pole near 19 Hz in the data sheet's circuit), so a start from an empty output takes many line cycles. Start the output and the VAOUT capacitor at the operating point, as the multiplierPfc application circuit does. Problems rules: `step.too_large`, `param.out_of_range`, `pin.unconnected` ## Datasheet and sources RSET, CT, the SS capacitor, the IAC and VRMS resistors, both amplifier networks, the output divider and the PKLMT divider are your own parts. vccOn, vccOff, the ENA threshold and hysteresis, vRef, iSs, both amplifier gains, gbwCa, the output swings, kMult, vValley, vRamp, dMax and the gate levels come from the electrical characteristics. rPullDown, vIac and vPklmt come from the pin table, kOsc from equation 1, vRset from equation 4, kIacLimit from the design text. gbwVa is read off the voltage amplifier's gain plot, and rGateHi assumes the unloaded high level is VCC. ## Example Open the example with the command `file.openExample` and the name `demo:multiplierPfcController`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # OCP with Hiccup (`ocpHiccup`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/ocpHiccup/ > Stops switching for a fixed time after a sustained over-current, then lets the converter restart. ![ocpHiccup](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/ocpHiccup.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/ocpHiccup/) **Group:** ICs · **Kind:** `{"definition":"ocpHiccup","kind":"subsystem"}` ## When to use it Use it at the architecture stage to choose the over-current level, the filter and the hiccup off-time, and to see the restart into a short. Wire FAULT to the soft start's FLT. ## Pins | Pin | Domain | Meaning | |---|---|---| | `ISNS` | electrical | Sensed current as a voltage Ri·i | | `FAULT` | signal | High for tHiccup after a sustained over-current | | `GND` | electrical | Reference of ISNS | ## Common parameters - `vTrip`: Over-current level at ISNS (Default: 2) - `tFilter`: Time ISNS must stay above vTrip before FAULT (0 = at once) (Default: 0.000005) - `tHiccup`: Time FAULT stays high: the off-time of the hiccup (Default: 0.0002) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `vTrip` | V | 2 | 1m – 100 V | Over-current level at ISNS | typical, user must set | | `tFilter` | s | 0.000005 | 0 – 1 s | Time ISNS must stay above vTrip before FAULT (0 = at once) | typical, user must set | | `tHiccup` | s | 0.0002 | 1n – 10 s | Time FAULT stays high: the off-time of the hiccup | typical, user must set | _Parameter descriptions are in English in both languages._ ## Model Once V(ISNS) has stayed above vTrip for tFilter, FAULT goes high for tHiccup. With FAULT on the soft start's FLT, switching stops and the soft-start capacitor discharges, and a new soft start follows the off-time, the hiccup scheme of the LM5145 data sheet (section 7.3). A trip during the hiccup does not extend it. ## Common mistakes - The defaults are typical, user must set. Put vTrip below the modulator's cycle-by-cycle limit, or the limit holds the current under the trip level and the hiccup never starts. - The level must be sustained for tFilter. A current sensed only while the switch is on (a switch shunt) drops every period, so sense the inductor current or shorten the filter. Problems rules: `ground.missing` ## Datasheet and sources This is an architecture block. vTrip is the over-current level at ISNS, tFilter the time it must last and tHiccup the off-time. A real controller often counts current-limited cycles instead; take the count times the period as tFilter. ## Example Open the example with the command `file.openExample` and the name `demo:ocpHiccup`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Single-Pole Operational Amplifier (`opAmp`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/opAmp/ > Amplifies a small input difference, with limited speed and output swing. ![opAmp](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/opAmp.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/opAmp/) **Group:** ICs · **Kind:** `{"definition":"opAmp","kind":"subsystem"}` ## When to use it Use it for error amplifiers, filters and level shifting. Use Current-Sense Amplifier on a shunt, and Comparator with Hysteresis for a logic output. ## Pins | Pin | Domain | Meaning | |---|---|---| | `INP` | electrical | Non-inverting input, draws only ib (0 by default) | | `INN` | electrical | Inverting input, draws only ib (0 by default) | | `OUT` | electrical | Output, measured against circuit ground | | `VCC` | electrical | Positive supply, sets the top of the output | | `VEE` | electrical | Negative supply, sets the bottom of the output | ## Common parameters - `gbw`: Gain-bandwidth product (single pole at GBW / a0) (Default: 1200000) - `a0`: DC open-loop gain (Default: 140000) - `sr`: Slew rate (0.5 V/us) (Default: 500000) - `vos`: Input offset voltage (the datasheet gives it as +/-) (Default: 0.0003) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `a0` | V/V | 140000 | 10 – 1g V/V | DC open-loop gain | Section 5.5 AOL typ 140 V/mV (VS = 15 V, RL >= 10 kOhm), p.6 | | `gbw` | Hz | 1200000 | 1k – 10g Hz | Gain-bandwidth product (single pole at GBW / a0) | Section 5.5 GBW typ, p.6 | | `sr` | V/s | 500000 | 1k – 10g V/s | Slew rate (0.5 V/us) | Section 5.5 SR typ (G = +1), p.6 | | `vos` | V | 0.0003 | -100m – 100m V | Input offset voltage (the datasheet gives it as +/-) | Section 5.5 VOS typ +/-0.3 mV (LM358B), p.6 | | `headHi` | V | 1.35 | 0 – 20 V | Output swing below the positive rail | Section 5.5 VO positive rail, IOUT = 50 uA, p.6 | | `headLo` | V | 0.1 | 0 – 20 V | Output swing above the negative rail | Section 5.5 VO negative rail, IOUT = 50 uA, p.6 | | `rOut` | Ω | 300 | 0 – 1meg Ω | Output resistance (0 = ideal output) | Section 5.5 RO open-loop output resistance typ, p.6 | | `pm` | ° | 0 | 0 – 85 ° | Phase margin at unity gain, set by a second pole (0 = single pole) | Off by default, so results stay those of the single-pole model | | `cmrr` | dB | 0 | 0 – 200 dB | Common-mode rejection ratio (0 = ideal, no common-mode error) | Off by default, so results stay those of the single-pole model | | `ib` | A | 0 | -1m – 1m A | Input bias current drawn by each input (positive into the pin) | Off by default, so results stay those of the single-pole model | _Parameter descriptions are in English in both languages._ ## Model The internal state y follows dy/dt = 2*pi*gbw*(Vid + vos) - (2*pi*gbw / a0) * y, which is a single pole at gbw / a0 with DC gain a0. The rate is limited to plus or minus sr. The state stops integrating while it is beyond a rail and still pushed outward, so there is no wind-up and recovery is immediate. The output is y clamped to VEE + headLo ... VCC - headHi, behind rOut. Three options are off by default. pm (degrees) adds a second pole in front of the first one, placed so a follower has that phase margin: fc = gbw*cos(90 - pm) and fp2 = fc / tan(90 - pm). cmrr (dB) adds the common-mode voltage divided by the CMRR to Vid. ib draws a current from each input net. The common-mode range, noise and the supply current are not modelled, and the phase margin does not fall with a capacitive load. ## Common mistakes - The output cannot reach the supply rails, since it stops 1.35 V below VCC and 0.1 V above VEE by default. A circuit that needs 14.5 V from a 15 V supply is clipped. - The output reaches the circuit one to two solver steps late. Keep the step well below one two-hundredth of the period of the highest closed-loop bandwidth, or the bandwidth is off by more than a few percent. - By default the model is a clean single pole, so a compensator designed near the op-amp bandwidth looks better than it is. Set pm (or use a preset such as TLV9062, which sets pm 55) when the loop crossover is within a decade of gbw. - The offset vos has one sign, while the datasheet gives plus or minus. Try both signs for a worst-case run, and enter gbw and sr with unit prefixes such as 1.2meg. Problems rules: `step.too_large`, `param.out_of_range` ## Datasheet and sources a0 is the typical open-loop gain, converted from V/mV to V/V (140 V/mV is 1.4e5). gbw is the gain-bandwidth product, and sr is the slew rate in V/s (0.5 V/us is 0.5e6). vos is the typical input offset. headHi and headLo are how far the output stays from each rail at the light load in the table, and rOut is the open-loop output resistance. pm is the phase margin row (G = +1), cmrr the CMRR row in dB and ib the typical input bias current; leave pm at 0 when the table gives no phase margin. Pass them to ic.fromSpec with the opAmp template and rename the pins to the datasheet names. ## Example Open the example with the command `file.openExample` and the name `demo:opAmp`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Optocoupler (`optocoupler`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/optocoupler/ > Passes a current across an isolation barrier through an LED and a phototransistor. ![optocoupler](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/optocoupler.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/optocoupler/) **Group:** ICs · **Kind:** `{"definition":"optocoupler","kind":"subsystem"}` ## When to use it Use it to carry the feedback of an isolated supply from the secondary to the primary, with the real current transfer ratio, its drift and its pole. Use Digital Isolator for fast logic signals. ## Pins | Pin | Domain | Meaning | |---|---|---| | `AN` | electrical | LED anode | | `CAT` | electrical | LED cathode | | `C` | electrical | Collector, sinks the transferred current | | `E` | electrical | Emitter, isolated from the LED side | ## Common parameters - `ctrScale`: Multiplies the whole CTR curve: another CTR bin, or the lower CTR after ageing (Default: 1) - `tAmb`: Ambient temperature for the CTR (Default: 25) - `fc`: Pole of the current transfer (Default: 110000) - `vf`: LED forward drop of the straight-line fit (Default: 1) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `vf` | V | 1 | 100m – 5 V | LED forward drop of the straight-line fit | Fig. 7 fit through 1.005 V at 1 mA and 1.088 V at 10 mA, p.6 | | `rLed` | Ω | 9 | 0 – 1k Ω | LED series resistance of the straight-line fit | Fig. 7 fit through 1.005 V at 1 mA and 1.088 V at 10 mA, p.6 | | `ctrScale` | — | 1 | 10m – 20 | Multiplies the whole CTR curve: another CTR bin, or the lower CTR after ageing | Fig. 13 is one typical unit; the CTR table allows 50 % to 600 % at 5 mA, p.3 | | `tAmb` | °C | 25 | -25 – 75 °C | Ambient temperature for the CTR | Fig. 8 relative CTR vs ambient temperature, IF = 5 mA, p.6 | | `ctr0m2` | — | 0.146 | 0 – 20 | CTR at an LED current of 0.2 mA, 25 °C (0: not given, the curve starts at the next point) | Fig. 13 at 0.2 mA, p.7 | | `ctr0m5` | — | 0.28 | 0 – 20 | CTR at 0.5 mA, 25 °C (0: not given) | Fig. 13 at 0.5 mA, p.7 | | `ctr1m` | — | 0.46 | 0 – 20 | CTR at 1 mA, 25 °C (0: not given) | Fig. 13 at 1 mA, p.7 | | `ctr2m` | — | 0.71 | 0 – 20 | CTR at 2 mA, 25 °C (0: not given) | Fig. 13 at 2 mA, p.7 | | `ctr5m` | — | 0.98 | 0 – 20 | CTR at 5 mA, 25 °C (0: not given) | Fig. 13 at 5 mA, p.7 | | `ctr10m` | — | 0.85 | 0 – 20 | CTR at 10 mA, 25 °C (0: not given) | Fig. 13 at 10 mA, p.7 | | `ctr20m` | — | 0.59 | 0 – 20 | CTR at 20 mA, 25 °C (0: not given) | Fig. 13 at 20 mA, p.7 | | `ctr50m` | — | 0.32 | 0 – 20 | CTR at 50 mA, 25 °C (0: not given) | Fig. 13 at 50 mA, p.7 | | `ctr100m` | — | 0.19 | 0 – 20 | CTR at 100 mA, 25 °C (0: not given, the collector current holds the last given point) | Fig. 13 at 100 mA, p.7 | | `kTm25` | — | 1.13 | 50m – 5 | CTR at −25 °C relative to 25 °C | Fig. 8 at −25 °C, IF = 5 mA, p.6 | | `kT0` | — | 1.105 | 50m – 5 | CTR at 0 °C relative to 25 °C | Fig. 8 at 0 °C, IF = 5 mA, p.6 | | `kT50` | — | 0.887 | 50m – 5 | CTR at 50 °C relative to 25 °C | Fig. 8 at 50 °C, IF = 5 mA, p.6 | | `kT75` | — | 0.761 | 50m – 5 | CTR at 75 °C relative to 25 °C | Fig. 8 at 75 °C, IF = 5 mA, p.6 | | `fc` | Hz | 110000 | 1 – 1g Hz | Pole of the current transfer | Coupler table fc typ, VCE = 5 V, IF = 10 mA, RL = 100 Ω, p.3 | | `vceSat` | V | 0.3 | 0 – 5 V | Collector-emitter voltage where the transistor saturates | Coupler table VCEsat max, IF = 10 mA, IC = 1 mA, p.3 | | `cmti` | V/s | 0 | 0 – 10t V/s | Common-mode transient immunity: the barrier slope the output withstands (0: not set, no check) | not set: the TCET1100's common-mode transient immunity is not in Voltecx yet; enter your part's rating | | `tGlitch` | s | 0.00000002 | 1p – 1m s | Width of the spurious output pulse while the barrier slope is above cmti | assumption (typical, user must set): data sheets give CMTI as a pass/fail limit, not the glitch it causes | _Parameter descriptions are in English in both languages._ ## Model The LED is a diode with a drop vf and a resistance rLed. The collector current is the current transfer ratio curve at the LED current, times ctrScale and a factor for the ambient temperature tAmb. It follows that target through one pole at fc and flows from C to E, and the transistor saturates at vceSat. When cmti is set, a slope of E against CAT above it turns the transistor on for tGlitch and Problems reports CMTI exceeded. The fall of the pole with a larger pull-up, the ageing of the ratio, the junction capacitance and the dark current are not modelled. ## Common mistakes - The transfer ratio spreads widely between parts and falls with age and heat. Check the loop with ctrScale at about half and at twice the default, and with a high tAmb. - The data sheet gives the pole with a 100 Ohm load. A pull-up of several kOhm makes the real pole much lower, so enter fc measured with your pull-up, or set the pole with a capacitor across the pull-up. - The collector current reaches the circuit one or two steps late. Keep the step below about a tenth of the response time, which is about 0.15 us at 110 kHz. Problems rules: `step.too_large`, `param.out_of_range` ## Datasheet and sources vf and rLed are a straight-line fit through two points of the forward-current curve. ctr0m2 to ctr100m are the CTR curve read at 0.2 to 100 mA (0 where the figure stops), and kTm25 to kT75 the relative ratio against temperature. ctrScale moves the curve to your bin, and tAmb reads the temperature factor. fc is the cut-off frequency of the coupler table, and vceSat is the saturation voltage. Pass them to ic.fromSpec with the optocoupler template; crates/engine-core/ics/presets holds them for PC817, LTV-817 and SFH617A. ## Example Open the example with the command `file.openExample` and the name `demo:optocoupler`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Output OVP (`ovpComparator`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/ovpComparator/ > Holds the switch off while the feedback voltage is above a multiple of the reference, non-latched or latch-off. ![ovpComparator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/ovpComparator.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/ovpComparator/) **Group:** ICs · **Kind:** `{"definition":"ovpComparator","kind":"subsystem"}` ## When to use it Use it at the architecture stage to set the over-voltage threshold against the overshoot after a load release. Wire OVP through an inverter into the modulator's enable, together with the soft start's RUN. ## Pins | Pin | Domain | Meaning | |---|---|---| | `FB` | electrical | Feedback voltage | | `REF` | electrical | Reference the thresholds scale with | | `OVP` | signal | High while the output is over-voltage | | `GND` | electrical | Reference of FB and REF | ## Common parameters - `kOv`: Rising threshold as a multiple of the reference: OVP trips above kOv·REF at FB (Default: 1.1) - `kHys`: Hysteresis as a fraction of the reference: OVP releases below (kOv − kHys)·REF (Default: 0.02) - `vRef`: Fixed reference instead of the REF pin (0 = read REF) (Default: 0) - `tFilter`: Time FB must stay above the threshold before OVP rises (0 = at once) (Default: 0) - `latch`: 1 = latch off: OVP stays high to the end of the run; 0 = released below the falling threshold (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `kOv` | — | 1.1 | 1 – 3 | Rising threshold as a multiple of the reference: OVP trips above kOv·REF at FB | typical, user must set | | `kHys` | — | 0.02 | 0 – 500m | Hysteresis as a fraction of the reference: OVP releases below (kOv − kHys)·REF | typical, user must set | | `vRef` | V | 0 | 0 – 100 V | Fixed reference instead of the REF pin (0 = read REF) | typical, user must set | | `tFilter` | s | 0 | 0 – 1 s | Time FB must stay above the threshold before OVP rises (0 = at once) | typical, user must set | | `latch` | — | 0 | 0 – 1 | 1 = latch off: OVP stays high to the end of the run; 0 = released below the falling threshold | typical, user must set | _Parameter descriptions are in English in both languages._ ## Model OVP goes high once V(FB) has stayed above kOv·REF for tFilter and low again once V(FB) falls below (kOv − kHys)·REF. With latch set it stays high to the end of the run. With vRef above zero the block compares with that fixed reference and only holds REF to GND through 1 GΩ. ## Common mistakes - The defaults are typical, user must set. Put kOv above the output's regulation band and its ripple at FB, or the OVP trips in steady state. - A soft-started REF trips the OVP at start-up when the output leads it. Compare with a steady reference: set vRef, or wire REF to the internal reference rather than the soft start. Problems rules: `ground.missing` ## Datasheet and sources This is an architecture block. kOv is the OVP rising threshold as a fraction of the reference and kHys its hysteresis. A real controller gives them as percentages of its feedback reference. ## Example Open the example with the command `file.openExample` and the name `demo:ovpComparator`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Peak-Current-Mode Modulator (`pcmModulator`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/pcmModulator/ > Turns a switch on at each clock and off when the sensed current plus a ramp reaches the control voltage. ![pcmModulator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/pcmModulator.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/pcmModulator/) **Group:** ICs · **Kind:** `{"definition":"pcmModulator","kind":"subsystem"}` ## When to use it Use it at the architecture stage of a current-mode controller, to choose the frequency, the slope compensation, the blanking and the current limit with the real power stage before transistor level. Use PWM Controller (UC384x class) or the controller ICs for a real part. ## Pins | Pin | Domain | Meaning | |---|---|---| | `VC` | electrical | Control voltage, from the error amplifier | | `ISNS` | electrical | Sensed current as a voltage Ri·i | | `EN` | signal | Enable signal, high to switch | | `GATE` | signal | Switch command, 0 or 1 | | `GND` | electrical | Reference of VC and ISNS | ## Common parameters - `fsw`: Clock frequency: the switch turns on at each clock edge (Default: 500000) - `se`: Slope of the compensation ramp added to ISNS (0 = none). Stable at any duty when se is at least half the sensed down-slope (U-97); the boundary is mc·D' = 0.5, mc = 1 + se/Sn (Ridley 1991). Valley mode: stable when se > (sE − sD)/2, half the sensed up-slope minus the down-slope (Tiwary & Rincon-Mora 2026, Eq. 22) (Default: 0) - `dmax`: Maximum duty: the switch is forced off after this fraction of the period (Default: 0.9) - `tBlank`: Leading-edge blanking after the clock: the minimum on-time in peak mode, the minimum off-time in valley mode (Default: 0.00000005) - `vcMax`: Clamp of the control voltage: the cycle-by-cycle current limit, in volts at ISNS (Default: 2.5) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `fsw` | Hz | 500000 | 1k – 100meg Hz | Clock frequency: the switch turns on at each clock edge | typical, user must set | | `se` | V/s | 0 | 0 – 1t V/s | Slope of the compensation ramp added to ISNS (0 = none). Stable at any duty when se is at least half the sensed down-slope (U-97); the boundary is mc·D' = 0.5, mc = 1 + se/Sn (Ridley 1991). Valley mode: stable when se > (sE − sD)/2, half the sensed up-slope minus the down-slope (Tiwary & Rincon-Mora 2026, Eq. 22) | typical, user must set | | `dmax` | — | 0.9 | 50m – 999m | Maximum duty: the switch is forced off after this fraction of the period | typical, user must set | | `tBlank` | s | 0.00000005 | 100p – 1m s | Leading-edge blanking after the clock: the minimum on-time in peak mode, the minimum off-time in valley mode | typical, user must set | | `vcMax` | V | 2.5 | 10m – 100 V | Clamp of the control voltage: the cycle-by-cycle current limit, in volts at ISNS | typical, user must set | | `valley` | — | 0 | 0 – 1 | 0 = peak current mode; 1 = valley current mode: the clock turns the switch off, it turns on when ISNS minus the ramp falls to VC, tBlank is the minimum off-time and dmax does not apply | typical, user must set | _Parameter descriptions are in English in both languages._ ## Model A clock at fsw sets the switch on and forces it off after dmax of the period. After the blanking time tBlank the switch turns off once V(ISNS) plus a ramp rising at se from the clock exceeds V(VC), limited to 0 to vcMax (the cycle-by-cycle current limit). Ridley (IEEE TPEL 1991) gives the sampling double pole at fsw/2 with Qp = 1/(π·(mc·D' − 0.5)), mc = 1 + Se/Sn: without a ramp the current loop oscillates at half the clock above D = 0.5, and a ramp of half the sensed down-slope keeps it stable at any duty (Unitrode U-97). In steady state the average sensed current is V(VC) − Se·D·Ts − Sn·D·Ts/2 (Erickson & Maksimovic, ch. 12). ## Common mistakes - The defaults are typical, user must set. They are design values of an architecture block, not a part's data sheet: set fsw, se and vcMax for your design. - Above a duty of 0.5 the current loop needs slope compensation. With se at zero the inductor current alternates from period to period; set se to at least half the sensed down-slope, Ri·Vout/L for a buck. - The comparator acts one solver step late, so the peak overshoots by the slope times the step. Keep the maximum step near 1/(200·fsw) or smaller. Problems rules: `step.too_large`, `ground.missing` ## Datasheet and sources This is an architecture block, so its numbers come from your design, not a data sheet. fsw is the switching frequency, se the ramp slope in volts per second at ISNS, dmax the maximum duty, tBlank the leading-edge blanking (and minimum on-time) and vcMax the current limit in volts at ISNS. When you later model a real controller, take the oscillator, ramp and current-limit rows of its electrical table. ## Example Open the example with the command `file.openExample` and the name `demo:pcmModulator`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Phase-Shifted Full-Bridge Controller (`psfbController`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/psfbController/ > Drives a full bridge from an error amplifier with the data sheet's frequency, delays, soft start and current limit. ![psfbController](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/psfbController.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/psfbController/) **Group:** ICs · **Kind:** `{"definition":"psfbController","kind":"subsystem"}` ## When to use it Use it for a phase-shifted full-bridge converter with a UCC28950-class controller, when you want the programmed dead times, the closed-loop soft start and the CS current limit with your own power stage. circuit.applicationCircuit with topology psfbVoltageMode builds the converter and sizes every external part with the data sheet's design steps. ## Pins | Pin | Domain | Meaning | |---|---|---| | `GND` | electrical | Ground reference of every pin | | `VDD` | electrical | Bias supply, the controller starts above the UVLO threshold | | `VREF` | electrical | 5 V reference, feeds the error amplifier dividers | | `EAP` | electrical | Error amplifier non-inverting input, the reference divider | | `EAN` | electrical | Error amplifier inverting input, the output divider and compensation | | `COMP` | electrical | Error amplifier output, the input of the PWM comparator | | `SS` | electrical | Soft-start capacitor and enable, off below 0.5 V | | `CS` | electrical | Primary current sense for the cycle-by-cycle limit | | `OUTA` | electrical | Leading leg, high side | | `OUTB` | electrical | Leading leg, low side | | `OUTC` | electrical | Lagging leg, high side | | `OUTD` | electrical | Lagging leg, low side | | `OUTE` | electrical | Synchronous rectifier drive, rising with OUTC | | `OUTF` | electrical | Synchronous rectifier drive, rising with OUTD | ## Common parameters - `rt`: Resistor from RT to VREF (leader), which sets the switching frequency (Default: 59000) - `rAb`: Resistor from DELAB to GND (delay between OUTA and OUTB) (Default: 22600) - `rCd`: Resistor from DELCD to GND (delay between OUTC and OUTD) (Default: 22600) - `rEf`: Resistor from DELEF to GND (delay between OUTA and OUTF, OUTB and OUTE) (Default: 13300) - `rTmin`: Resistor from TMIN to GND, which sets the minimum pulse (Default: 88700) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `vddOn` | V | 7.3 | 2 – 17 V | VDD UVLO rising threshold | Section 5.5 UVLO_RTH typ 7.3 V at 25 °C, p.6 | | `vddHys` | V | 0.6 | 0 – 5 V | VDD UVLO hysteresis | Section 5.5 UVLO_HYST typ 0.6 V at 25 °C, p.6 | | `vRef` | V | 5 | 3 – 5.6 V | Reference voltage | Section 5.5 VREF typ 5 V at 25 °C, p.6 | | `rt` | Ω | 59000 | 5k – 1meg Ω | Resistor from RT to VREF (leader), which sets the switching frequency | Section 5.5 test conditions RT = 59 kΩ for FSW = 100 kHz, p.6; equation 10, p.25 | | `rTmin` | Ω | 88700 | 10k – 1meg Ω | Resistor from TMIN to GND, which sets the minimum pulse | Section 5.5 test conditions RTMIN = 88.7 kΩ, p.6; equation 8, p.23 (minimum 10 kΩ) | | `rAb` | Ω | 22600 | 5k – 1meg Ω | Resistor from DELAB to GND (delay between OUTA and OUTB) | Section 5.5 test conditions RAB = 22.6 kΩ, p.6; equation 3, p.20 | | `rCd` | Ω | 22600 | 5k – 1meg Ω | Resistor from DELCD to GND (delay between OUTC and OUTD) | Section 5.5 test conditions RCD = 22.6 kΩ, p.6; equation 4, p.20 | | `rEf` | Ω | 13300 | 13k – 90k Ω | Resistor from DELEF to GND (delay between OUTA and OUTF, OUTB and OUTE) | Section 5.5 test conditions REF = 13.3 kΩ, p.6; equation 6 and the 13 kΩ to 90 kΩ range, p.22 | | `vAdel` | V | 0 | 0 – 5 V | Voltage at ADEL: the CS divider RA/(RA+RAHI) at the current the delay is evaluated for (0 = the delay is fixed, ADEL tied to GND) | Section 6.3.6, p.20; the model keeps the delay fixed instead of following CS | | `vAdelEf` | V | 0 | 0 – 5 V | Voltage at ADELEF (0 = the delay is fixed, ADELEF tied to GND) | Section 6.3.7, p.22; the model keeps the delay fixed instead of following CS | | `dMax` | — | 0.95 | 500m – 970m | Maximum duty cycle | Section 5.5 DMAX typ 95 % (max 97 %), p.6 | | `rampLow` | V | 0.8 | 0 – 3 V | Bottom of the PWM comparator ramp | Section 6.3.3 ramp-signal range 0.8 V to 2.8 V, p.18 | | `rampHigh` | V | 2.8 | 500m – 4 V | Top of the PWM comparator ramp | Section 6.3.3 ramp-signal range 0.8 V to 2.8 V, p.18 | | `eaLow` | V | 0.25 | 0 – 2 V | Lowest error amplifier output | Section 5.5 EALOW typ 0.25 V at 25 °C, p.7 | | `eaHigh` | V | 4.25 | 2 – 5 V | Highest error amplifier output | Section 5.5 EAHIGH typ 4.25 V at 25 °C, p.7 | | `gbw` | Hz | 3000000 | 10k – 100meg Hz | Error amplifier unity-gain bandwidth | Section 5.5 GBW typ 3 MHz (verified in characterization only), p.7 | | `iSs` | A | 0.000025 | 100n – 1m A | Soft-start charge current | Section 5.5 ISS typ 25 µA at 25 °C, p.7 | | `vSsStd` | V | 0.5 | 100m – 1 V | Soft-start shutdown and restart threshold | Section 5.5 VSS_STD typ 0.5 V at 25 °C, p.7 (section 6.3.4 text says 0.55 V) | | `vSsOffset` | V | 0.55 | 0 – 1 V | Offset between SS/EN and the loop reference during the soft start | Section 6.3.4, p.19: the lower of (SS/EN − 0.55 V) and EA+ | | `vSsClamp` | V | 4.65 | 3 – 5 V | Soft-start clamp voltage | Section 5.5 VSS_CL typ 4.65 V at 25 °C, p.7 | | `rSsDown` | Ω | 1000 | 10 – 100k Ω | SS/EN pull-down while the controller is off | assumption: the sheet gives a 1 kΩ switch for the fast pull-up (section 6.3.14); the pull-down is not given | | `pcm` | — | 0 | 0 – 1 | Control mode: 1 = peak current mode (RSUM to GND), 0 = voltage mode with the internal ramp (RSUM to VREF) | Section 6.3.11, p.26 and Figure 6-9: the RSUM connection selects the mode | | `rSum` | Ω | 124000 | 10k – 1meg Ω | Slope compensation resistor at RSUM | Section 5.5 test conditions RSUM = 124 kΩ, p.6; equations 13 and 14 and the 10 kΩ to 1 MΩ range, p.27 | | `vPcmOffset` | V | 0.85 | 0 – 2 V | Offset added to the CS ramp at the PWM comparator in peak current mode | Figures 5-1 and 5-2 "Add 0.85 V offset to RAMP", p.10; Figure 6-9, p.26 | | `vCsLim` | V | 2 | 500m – 4 V | CS cycle-by-cycle threshold | Section 5.5 VCS_LIM typ 2 V at 25 °C, p.7 | | `iddRun` | A | 0.005 | 0 – 100m A | Operating supply current from VDD (gate current excluded) | Section 5.5 IDD typ 5 mA at 25 °C, p.6 | | `rSrc` | Ω | 20 | 1 – 1k Ω | Output source resistance of OUTA to OUTF | Section 5.5 RSRC typ 20 Ω at 25 °C, p.8 | | `rSink` | Ω | 10 | 1 – 1k Ω | Output sink resistance of OUTA to OUTF | Section 5.5 RSINK typ 10 Ω at 25 °C, p.8 | | `rOff` | Ω | 100000000 | 1k – 1t Ω | Off-state resistance of the internal switches | assumption: large against the external networks | _Parameter descriptions are in English in both languages._ ## Model RT sets the oscillator (fsw = 2.5e3 / (RT / (VREF - 2.5) + 1) kHz). The error amplifier integrates EA+ - EA- (EA+ is the lower of EAP and SS - 0.55 V) and COMP sets the duty D = (COMP - 0.8) / 2, held between DMIN and dMax. OUTA and OUTB are the leading pair, OUTC and OUTD the pair delayed by D * 180 degrees; TABSET and TCDSET (equations 3 and 4) are the dead times in each pair, TAFSET and TBESET (equation 6) hold the rectifier drives after OUTA and OUTB fall. ## Common mistakes - The module runs voltage mode: peak current mode and the slope compensation of RSUM, burst mode, the adaptive delays that follow CS and the hiccup mode are not modelled. - The programming resistors (rt, rAb, rCd, rEf, rTmin) are parameters of the module, not resistors on the schematic: change the frequency and the delays there. Problems rules: `step.too_large`, `param.out_of_range`, `pin.unconnected` ## Datasheet and sources The power stage, the dividers, the compensation network and the soft-start capacitor are your own. vddOn, vddHys, vRef, rt, rTmin, rAb, rCd, rEf, dMax, iSs, vSsStd, vCsLim, rSrc and rSink come from the UCC28950 data sheet; rSsDown and rOff are labelled in their sources. ## Example Open the example with the command `file.openExample` and the name `demo:psfbController`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Photovoltaic MOSFET Driver (`pvDriver`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/pvDriver/ > Charges a MOSFET gate across an isolation barrier from an LED, with no supply on the gate side. ![pvDriver](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/pvDriver.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/pvDriver/) **Group:** ICs · **Kind:** `{"definition":"pvDriver","kind":"subsystem"}` ## When to use it Use it to drive the MOSFETs of a solid-state relay, a battery disconnect or a precharge switch, where the gate floats and switches seldom. Its micro-amperes charge a gate in hundreds of microseconds: use an isolated gate driver for PWM. ## Pins | Pin | Domain | Meaning | |---|---|---| | `AN` | electrical | LED anode | | `CAT` | electrical | LED cathode | | `VOP` | electrical | Photovoltaic output, positive, to the MOSFET gate | | `VON` | electrical | Photovoltaic output, negative, to the MOSFET source | ## Common parameters - `vocRef`: Open-circuit output voltage at iFref (Default: 8) - `iscRef`: Short-circuit output current at iFref (taken proportional to the LED current) (Default: 0.000015) - `iFref`: LED current at which vocRef and iscRef are given (Default: 0.01) - `rDis`: Resistance of the turn-off circuit while the LED is dark (Default: 20000) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `vf` | V | 1.3 | 100m – 5 V | LED forward drop of the straight-line fit | typical, user must set | | `rLed` | Ω | 10 | 0 – 1k Ω | LED series resistance of the straight-line fit | typical, user must set | | `iFref` | A | 0.01 | 10u – 100m A | LED current at which vocRef and iscRef are given | typical, user must set | | `vocRef` | V | 8 | 500m – 30 V | Open-circuit output voltage at iFref | typical, user must set | | `iscRef` | A | 0.000015 | 10n – 100m A | Short-circuit output current at iFref (taken proportional to the LED current) | typical, user must set | | `iFoff` | A | 0.0002 | 0 – 50m A | Below this LED current the turn-off circuit discharges the output | typical, user must set | | `rDis` | Ω | 20000 | 1 – 1g Ω | Resistance of the turn-off circuit while the LED is dark | typical, user must set | | `rClamp` | Ω | 1000 | 1 – 10meg Ω | Resistance of the open-circuit clamp: the output falls this times the load current below vocRef | typical, user must set | | `tauPv` | s | 0.000001 | 0 – 10m s | Time constant with which the stack's current follows the LED | typical, user must set | _Parameter descriptions are in English in both languages._ ## Model The LED is a diode with a drop vf and a resistance rLed. The photodiode stack is a current source of iscRef times the LED current over iFref, which follows the LED through one pole of tauPv and flows out of VOP. A clamp at vocRef with a resistance rClamp sets the open-circuit voltage. While the LED current is below iFoff, the turn-off circuit joins VOP to VON through rDis. The turn-on time into a gate capacitance C is about C times the threshold over the short-circuit current, and the turn-off time about rDis times C. The defaults are typical of the class, not a part's values. ## Common mistakes - The defaults are typical, user must set. Enter the open-circuit voltage, the short-circuit current at its test LED current and the turn-off resistance from your part's data sheet. - The open-circuit voltage must be above the MOSFET's threshold with margin, and a gate that leaks more than the short-circuit current never turns on. Problems rules: `ground.missing` ## Datasheet and sources vocRef and iscRef are the open-circuit voltage and short-circuit current at the LED current iFref of the electrical characteristics. rDis is the turn-off time divided by the test capacitance (and by ln of the voltage ratio of its test points). vf and rLed are a straight-line fit of the LED's forward voltage. Pass them to ic.fromSpec with the pvDriver template. ## Example Open the example with the command `file.openExample` and the name `demo:pvDriver`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Peak-Current-Mode PWM Controller (`pwmController`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/pwmController/ > Controls a converter switch by comparing its current with a set level. ![pwmController](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/pwmController.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/pwmController/) **Group:** ICs · **Kind:** `{"definition":"pwmController","kind":"subsystem"}` ## When to use it Use it when your converter uses a fixed-frequency peak-current-mode chip, with its compensation network on COMP. To try your own control law, use PI Controller and PWM Generator instead. ## Pins | Pin | Domain | Meaning | |---|---|---| | `VFB` | electrical | Feedback input, wire the output divider here | | `COMP` | electrical | Error amplifier output, wire the compensation here | | `CS` | electrical | Current sense input, from the sense resistor | | `OUT` | electrical | Gate drive output | | `VCC` | electrical | Supply, output stays off below the UVLO level | | `GND` | electrical | Ground reference of every pin | ## Common parameters - `rt`: Timing resistor RT (the datasheet: never below 5 kOhm, Table 5-1 Pin Functions, RT/CT, p.4) (Default: 10000) - `ct`: Timing capacitor CT (the datasheet recommends at least about 1000 pF) (Default: 0.0000000033) - `dmax`: Maximum duty cycle of the output (Default: 0.97) - `vRef`: Error amplifier reference at the non-inverting input (Default: 2.5) - `acs`: Current-sense gain: COMP volts per volt of CS threshold (Default: 3) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `rt` | Ω | 10000 | 5k – 10meg Ω | Timing resistor RT (the datasheet: never below 5 kOhm, Table 5-1 Pin Functions, RT/CT, p.4) | Section 6.5 test condition RRT = 10 kOhm, p.7 | | `ct` | F | 0.0000000033 | 100p – 1u F | Timing capacitor CT (the datasheet recommends at least about 1000 pF) | Section 6.5 test condition CCT = 3.3 nF, p.7 | | `dmax` | — | 0.97 | 50m – 990m | Maximum duty cycle of the output | Section 6.5 DMAX typ (UCx842/3), p.8 | | `oscDiv` | — | 1 | 1 – 2 | Oscillator periods per output period: 1, or 2 for a toggle flip-flop (UCx844/5), which switches at half the oscillator frequency | Section 6.5 note (5): fSW = fOSC for the UCx842/3, fOSC / 2 for the UCx844/5, p.8 | | `vRef` | V | 2.5 | 500m – 10 V | Error amplifier reference at the non-inverting input | Section 6.5 VVFB typ, p.7 | | `a0` | V/V | 31623 | 10 – 1g V/V | Error amplifier DC gain (90 dB) | Section 6.5 AVOL typ 90 dB, p.7 | | `gbw` | Hz | 1000000 | 1k – 1g Hz | Error amplifier unity-gain bandwidth | Section 6.5 unity gain bandwidth typ, p.7 | | `vCompLo` | V | 0.7 | 0 – 10 V | Lowest COMP voltage | Section 6.5 VCOMP low-level typ, p.7 | | `vCompHi` | V | 5 | 1 – 20 V | Highest COMP voltage (the datasheet guarantees at least 5 V) | Section 6.5 VCOMP high-level min, p.7 | | `rCompOut` | Ω | 1250 | 0 – 1meg Ω | COMP output resistance (0 = ideal) | assumption: 6 V at no load falling to 5 V at the 0.8 mA source current, p.7 | | `iSource` | A | 0 | 0 – 10m A | Error amplifier output source current limit: COMP is fed by this current and clamped to the amplifier's voltage through rCompOut (0 = not modelled: the amplifier drives COMP through rCompOut alone) | Section 6.5 error amplifier output source current typ 0.8 mA, p.7 | | `acs` | V/V | 3 | 500m – 20 V/V | Current-sense gain: COMP volts per volt of CS threshold | Section 6.5 ACS typ, p.8 | | `vcsMax` | V | 1 | 50m – 10 V | Maximum current-sense threshold (the COMP clamp) | Section 6.5 VISENSE maximum input signal typ, p.8 | | `vCompOff` | V | 1.4 | 0 – 5 V | COMP voltage at which the current-sense threshold is zero | Section 7.3.8 p.18: COMP below two diode drops above ground stops the output (0.7 V a drop is an assumption; Figure 6-2 gives the threshold graphically) | | `vccOn` | V | 8.4 | 1 – 40 V | VCC UVLO enable threshold | Section 6.5 VCCON typ (UCx843/5), p.8 | | `vccOff` | V | 7.6 | 500m – 40 V | VCC UVLO off threshold | Section 6.5 VCCOFF typ (UCx843/5), p.8 | | `tSoft` | s | 0 | 0 – 1 s | Soft-start time: the current-sense threshold ramps from 0 to vcsMax after the UVLO releases (0 = none) | assumption: the UCx84x has no internal soft start; usually done with a capacitor on COMP | | `rOutHi` | Ω | 75 | 100m – 10k Ω | Output resistance to VCC (high level) | Section 6.5 VOUT high 13.5 V at 20 mA from VCC = 15 V, p.8 | | `rOutLo` | Ω | 5 | 100m – 10k Ω | Output resistance to GND (low level) | Section 6.5 VOUT low 0.1 V at 20 mA, p.8 | | `rOff` | Ω | 1000000 | 1k – 1t Ω | Off-state resistance of the output switches | assumption: the solver's default switch off resistance | _Parameter descriptions are in English in both languages._ ## Model The oscillator runs at fosc = 1.72 / (rt * ct), and the output switches at fsw = fosc / oscDiv (oscDiv 2 is the toggle flip-flop of the UCx844/5). A sawtooth gates the output on for the first dmax of every period, which is also the clock that turns the switch on. The error amplifier is a single pole (a0, gbw) driven by err = vRef - VFB, limited to vCompLo ... vCompHi, and it drives COMP through rCompOut. With iSource above zero the amplifier only clamps COMP from above through rCompOut and a current source of iSource feeds the pin, as the real output stage in current limit does when an optocoupler pulls COMP down with VFB grounded. The current threshold is (V(COMP) - vCompOff) / acs, limited to 0 ... vcsMax (and to a ramp over tSoft if that is above zero). When V(CS) exceeds it, the output turns off until the next clock, once per cycle. Below the VCC UVLO (vccOn, vccOff) the output is held low. There is no slope compensation, so duty cycles above 50 percent are subharmonically unstable unless a ramp is added to CS externally. ## Common mistakes - The frequency comes from rt and ct, and there is no separate frequency parameter. With the defaults it is about 52 kHz, and entering 3.3 instead of 3.3n for ct is off by nine orders of magnitude. - The error amplifier makes the loop stiff, so use a step of 50 ns or less and a few hundred steps per switching period. A larger step makes the current trip overshoot or leaves the COMP node unsettled. - Do not leave VFB or CS open. An open VFB pushes COMP to its upper limit, and the converter then runs at full current. Problems rules: `step.too_large`, `param.out_of_range`, `pin.unconnected` ## Datasheet and sources rt and ct are your own timing parts, and the datasheet gives f = 1.72 / (RT*CT). oscDiv is 1 for the UCx842/3 and 2 for the UCx844/5 (electrical characteristics note 5). dmax, vRef, a0, gbw, vCompLo, vCompHi, acs and vcsMax come from the PWM, error amplifier and current-sense rows of the electrical characteristics. vccOn, vccOff, rOutHi and rOutLo come from the UVLO and output rows. iSource is the error amplifier's output source current. vCompOff, tSoft and rCompOut are assumptions. ## Example Open the example with the command `file.openExample` and the name `demo:pwmController`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Quasi-Resonant Flyback Controller (Valley Lockout) (`qrFlybackController`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/qrFlybackController/ > Runs an off-line flyback in peak current mode and turns the switch on in a drain valley read from the auxiliary winding; FB picks the valley, and at light load the controller folds the frequency back and skips. ![qrFlybackController](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/qrFlybackController.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/qrFlybackController/) **Group:** ICs · **Kind:** `{"definition":"qrFlybackController","kind":"subsystem"}` ## When to use it Use it for an off-line flyback adapter or auxiliary supply with an NCP1342-class controller, when you want valley switching, valley lockout, frequency foldback, skip mode and over-power protection from the auxiliary winding. circuit.applicationCircuit with topology qrFlyback builds a 65 W, 19 V flyback around the data sheet's ZCD/OPP design example. For a fixed-frequency flyback use the PWM Controller. ## Pins | Pin | Domain | Meaning | |---|---|---| | `FB` | electrical | Feedback, internal 20 kΩ pull-up to 5 V; an optocoupler to GND sets the peak current | | `ZCD` | electrical | Auxiliary winding divider: valleys in the off-time, the negative OPP voltage in the on-time | | `CS` | electrical | Current sense resistor voltage | | `VCC` | electrical | Supply, the controller starts above 17 V and stops below 9 V | | `GND` | electrical | Ground reference, at the lower end of the sense resistor | | `DRV` | electrical | Gate drive of the flyback switch, clamped at 12 V | ## Common parameters - `kFb`: VFB to internal current set point division ratio (Default: 4) - `vIlim1`: Current limit threshold on CS (Default: 0.8) - `vCsMin`: Minimum peak current on CS (Default: 0.2) - `vZcdTrig`: ZCD threshold, falling (valley detection) (Default: 0.06) - `tZcdBlank`: ZCD blanking delay after turn-off (Default: 0.0000007) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `vccOn` | V | 17 | 1 – 30 V | VCC start-up threshold | Table 6 VCC(on) typ 17.0 V (16.0 to 18.0 V), p.7 | | `vccOff` | V | 9 | 500m – 30 V | VCC minimum operating voltage (UVLO) | Table 6 VCC(off) typ 9.0 V (8.5 to 9.5 V), p.7 | | `vFbOpen` | V | 5 | 500m – 20 V | FB open-pin voltage (the pull-up's source) | Table 6 VFB(open) typ 5.0 V, p.8 | | `kFb` | — | 4 | 500m – 20 | VFB to internal current set point division ratio | Table 6 KFB typ 4.0 (3.7 to 4.3), p.8 | | `rFb` | Ω | 20000 | 100 – 1meg Ω | FB internal pull-up resistor | Table 6 RFB typ 20 kΩ (17 to 23 kΩ), p.8 | | `v1to2` | V | 1.4 | 0 – 5 V | FB falling: 1st to 2nd valley | Table 6 V1to2 typ 1.400 V, p.8; Table 7, p.18 | | `v2to3` | V | 1.2 | 0 – 5 V | FB falling: 2nd to 3rd valley | Table 6 V2to3 typ 1.200 V, p.8; Table 7, p.18 | | `v3to4` | V | 1.1 | 0 – 5 V | FB falling: 3rd to 4th valley | Table 6 V3to4 typ 1.100 V, p.8; Table 7, p.18 | | `v4to5` | V | 1 | 0 – 5 V | FB falling: 4th to 5th valley | Table 6 V4to5 typ 1.000 V, p.8; Table 7, p.18 | | `v5to6` | V | 0.9 | 0 – 5 V | FB falling: 5th to 6th valley | Table 6 V5to6 typ 0.900 V, p.8; Table 7, p.18 | | `v2to1` | V | 2 | 0 – 5 V | FB rising: 2nd to 1st valley | Table 6 V2to1 typ 2.000 V, p.8; Table 7, p.18 | | `v3to2` | V | 1.8 | 0 – 5 V | FB rising: 3rd to 2nd valley | Table 6 V3to2 typ 1.800 V, p.8; Table 7, p.18 | | `v4to3` | V | 1.7 | 0 – 5 V | FB rising: 4th to 3rd valley | Table 6 V4to3 typ 1.700 V, p.8; Table 7, p.18 | | `v5to4` | V | 1.6 | 0 – 5 V | FB rising: 5th to 4th valley | Table 6 V5to4 typ 1.600 V, p.8; Table 7, p.18 | | `v6to5` | V | 1.5 | 0 – 5 V | FB rising: 6th to 5th valley | Table 6 V6to5 typ 1.500 V, p.8; Table 7, p.18 | | `tOnMax` | s | 0.000032 | 100n – 1m s | Maximum on-time | Table 6 ton(MAX) typ 32 µs (28 to 40 µs), p.8 | | `vZcdTrig` | V | 0.06 | -500m – 5 V | ZCD threshold, falling (valley detection) | Table 6 VZCD(trig) typ 60 mV, p.8 | | `vZcdHys` | V | 0.025 | 0 – 1 V | ZCD hysteresis | Table 6 VZCD(HYS) typ 25 mV, p.8 | | `tDemag` | s | 0.00000008 | 0 – 10u s | Demagnetization propagation delay (valley to DRV high) | Table 6 tdemag typ 80 ns, p.8 | | `vZcdMin` | V | -0.7 | -5 – 0 V | ZCD negative clamp: the most negative VOPP | Table 6 VZCD(MIN) typ -0.7 V, p.8 | | `tZcdBlank` | s | 0.0000007 | 0 – 100u s | ZCD blanking delay after turn-off | Table 6 tZCD(blank) typ 700 ns, p.8 | | `tTout1` | s | 0.0001 | 100n – 10m s | Valley timeout during soft-start | Table 6 t(tout1) typ 100 µs, p.8 | | `tTout2` | s | 0.000006 | 100n – 10m s | Valley timeout after soft-start | Table 6 t(tout2) typ 6.0 µs, p.8 | | `vIlim1` | V | 0.8 | 10m – 5 V | Current limit threshold on CS | Table 6 VILIM1 typ 0.800 V, p.8 | | `tLeb1` | s | 0.000000265 | 0 – 10u s | Leading-edge blanking of the CS comparators | Table 6 tLEB1 typ 265 ns, p.8 | | `vCsMin` | V | 0.2 | 0 – 5 V | Minimum peak current on CS | Table 6 VCS(MIN) typ 200 mV (versions xxxAx), p.9; page 14: 0.2 V typical | | `vMpcmDelta` | V | 0.4 | 0 – 5 V | Minimum peak current shift in frequency foldback | Table 6 VMPCM(delta) typ 400 mV (versions xxxxA), p.10; page 19: 400 mV typical | | `vMpcmEntry` | V | 0.8 | 0 – 5 V | FB below which frequency foldback (MPCM) starts | Table 6 VMPCM(entry) typ 800 mV, p.10 | | `tDtMax` | s | 0.000036 | 0 – 1m s | Dead time added at the skip threshold in frequency foldback | Page 19: tDT(MAX) 36 µs typical as FB falls to 0.4 V (Table 6 gives 32 µs minimum, p.10) | | `vSkip` | V | 0.4 | 0 – 5 V | Skip threshold, FB falling | Table 6 Vskip typ 400 mV, p.10 | | `vSkipHys` | V | 0.05 | 0 – 1 V | Skip hysteresis, FB rising | Table 6 Vskip(HYS) typ 50 mV, p.10 | | `fMin` | Hz | 25000 | 100 – 1meg Hz | Minimum frequency clamp | Table 6 fMIN typ 25 kHz, p.9 | | `tSsStart` | s | 0.004 | 1u – 1 s | Soft-start period (the current limit ramps from 0 to VILIM1) | Table 6 tSSTART typ 4.0 ms, p.9; page 14: the clamp ramps from 0 to 0.8 V within 4 ms | | `vDrvHigh` | V | 12 | 1 – 30 V | DRV high-level clamp | Table 6 VDRV(high2) typ 12 V at VCC = 30 V, p.8 | | `vDrvDrop` | V | 1.2 | 0 – 10 V | DRV high level below VCC when not clamped | Table 6 VDRV(high1) min 8.0 V at VCC = VCC(off) + 0.2 V = 9.2 V, p.8 | | `rDrvH` | Ω | 24 | 100m – 10k Ω | DRV pull-up resistance | derived: 12 V clamp over the 500 mA IDRV(SRC) of Table 6, p.8 | | `rDrvL` | Ω | 15 | 100m – 10k Ω | DRV pull-down resistance | derived: 12 V clamp over the 800 mA IDRV(SNK) of Table 6, p.8 | | `rOff` | Ω | 100000000 | 1k – 1t Ω | Off-state resistance of the internal switches | assumption: large against the pin networks | _Parameter descriptions are in English in both languages._ ## Model The CS set point is V(FB) / kFb, at least vCsMin (plus vMpcmDelta in foldback, falling to vCsMin at vSkip) and at most the soft-start ramp and vIlim1 + VOPP, where VOPP is the negative ZCD voltage in the on-time down to vZcdMin. The on-time ends when CS passes it after tLeb1, or after tOnMax. After tZcdBlank each fall of ZCD below vZcdTrig is a valley; FB selects the 1st to 6th valley through the valley lockout thresholds (v1to2 ... v5to6 falling, v2to1 ... v6to5 rising), and the switch turns on tDemag after it. Below vMpcmEntry the controller waits for the 6th valley and adds a dead time up to tDtMax at vSkip. Without a valley within tTout1 (soft-start) or tTout2 a cycle starts anyway, and a cycle longer than 1/fMin is ended. Switching stops below vSkip on FB and below the VCC UVLO. ## Common mistakes - The drain rings with the drain capacitance near a few hundred kilohertz after demagnetization; valley detection needs a step of a few tens of nanoseconds. The application circuit uses 20 ns. - VCC must start above vccOn (17 V): the model has no HV start-up pin, so supply VCC from a source or a bias winding that is already up. Problems rules: `step.too_large`, `param.out_of_range`, `pin.unconnected` ## Datasheet and sources The ZCD/OPP divider, the sense resistor, the transformer and the feedback network are your own parts. vccOn, vccOff, vFbOpen, kFb, rFb, the valley thresholds, tOnMax, vZcdTrig, vZcdHys, tDemag, vZcdMin, tZcdBlank, the timeouts, vIlim1, tLeb1, vCsMin, vMpcmDelta, vMpcmEntry, vSkip, vSkipHys, fMin, tSsStart and the DRV levels come from the electrical characteristics (Table 6) and Table 7; tDtMax from the frequency foldback text (page 19). rDrvH and rDrvL are derived from the DRV clamp and its source and sink currents. ## Example Open the example with the command `file.openExample` and the name `demo:qrFlybackController`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Rogowski Coil with Integrator (`rogowskiCoil`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/rogowskiCoil/ > An air-cored coil around a conductor and its integrator, giving a voltage proportional to the AC current. ![rogowskiCoil](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/rogowskiCoil.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/rogowskiCoil/) **Group:** ICs · **Kind:** `{"definition":"rogowskiCoil","kind":"subsystem"}` ## When to use it Use it to measure fast or large AC currents, such as a switch current with di/dt in the kA/us range, without breaking the circuit and with no core to saturate. It cannot read DC; use Closed-Loop Hall Transducer for that. ## Pins | Pin | Domain | Meaning | |---|---|---| | `IPP` | electrical | Conductor in, positive reading | | `IPN` | electrical | Conductor out | | `OUT` | electrical | Integrator output, measured against GND | | `GND` | electrical | Ground reference of the output | ## Common parameters - `sens`: Sensitivity of the coil and its integrator (CWTUM/1: 20 mV/A) (Default: 0.02) - `fLow`: Low-frequency -3 dB corner: the integrator's leak, so DC reads 0 (Default: 9.2) - `fHigh`: High-frequency -3 dB corner of the coil and integrator (Default: 30000000) - `outMax`: Output limit: plus or minus this (peak current times sens) (Default: 6) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `sens` | V/A | 0.02 | 1u – 10 V/A | Sensitivity of the coil and its integrator (CWTUM/1: 20 mV/A) | p.2 model table, CWTUM/1 sensitivity 20 mV/A | | `fLow` | Hz | 9.2 | 1m – 100k Hz | Low-frequency -3 dB corner: the integrator's leak, so DC reads 0 | p.2 model table, CWTUM/1 LF (-3 dB) 9.2 Hz | | `fHigh` | Hz | 30000000 | 1k – 1g Hz | High-frequency -3 dB corner of the coil and integrator | p.2 model table, HF (-3 dB) 30 MHz (note 2: 1 m cable, 80 mm coil) | | `outMax` | V | 6 | 10m – 100 V | Output limit: plus or minus this (peak current times sens) | p.3 Output: +/-6 V peak at the peak current into 100 kOhm or more | | `vOff` | V | 0 | -1 – 1 V | DC offset at the output (the data sheet gives +/-3 mV max) | p.3 DC offset +/-3 mV max at 25 °C (set to 0 here) | | `noise` | V | 0 | 0 – 1 V | RMS output noise; 0 = a noiseless probe | p.2 model table, CWTUM/1 noise 15 mV peak to peak (set to simulate; about a sixth of peak to peak is the rms) | | `seed` | — | 1 | 0 – 9007t | Whole-number seed of the noise | model parameter | _Parameter descriptions are in English in both languages._ ## Model The coil gives the emf M di/dt and the integrator, with time constant M / sens, turns it back into sens times the current. A current meter in series with the conductor (no resistance) reads the current, times sens, through a first-order low-pass at fHigh. The integrator's leak is a first-order high-pass s / (s + 2 pi fLow), so a DC current reads 0 and a long pulse droops. Then the offset vOff is added and the output is limited to plus or minus outMax. ## Common mistakes - A pulse longer than about a tenth of 1 / (2 pi fLow) droops visibly, and a DC current reads 0. Pick a probe with a lower fLow for long pulses. - The output is limited to plus or minus outMax, which is the peak current times sens. Above it the reading is a flat top. Problems rules: `step.too_large`, `param.out_of_range` ## Datasheet and sources sens is the probe sensitivity (20 mV/A is 20m), fLow and fHigh are the LF and HF -3 dB bandwidths, outMax is the output at the peak current, vOff is the DC offset and noise is converted from the peak-to-peak noise (about a sixth). The data sheet gives the sensitivity of the coil and integrator together, not the coil's mutual inductance. The defaults are the PEM CWT Ultra-mini CWTUM/1, data sheet Rev. 10/25. Pass them to ic.fromSpec with the rogowskiCoil template. ## Example Open the example with the command `file.openExample` and the name `demo:rogowskiCoil`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Shunt Amplifier with Shunt (`shuntAmplifier`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/shuntAmplifier/ > A shunt resistor and amplifier that read current in both directions. ![shuntAmplifier](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/shuntAmplifier.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/shuntAmplifier/) **Group:** ICs · **Kind:** `{"definition":"shuntAmplifier","kind":"subsystem"}` ## When to use it Use it to measure a current that flows both ways with a shunt. Use Current-Sense Amplifier for one direction, and Isolated Amplifier with Shunt for isolation. ## Pins | Pin | Domain | Meaning | |---|---|---| | `IPP` | electrical | Primary current in, positive reading | | `IPN` | electrical | Primary current out | | `OUT` | electrical | Output, measured against GND | | `GND` | electrical | Ground reference of the output | ## Common parameters - `rSense`: The shunt resistor between IPP and IPN (your choice, not part of the IC) (Default: 0.005) - `gain`: Gain (the A1 device: 20 V/V) (Default: 20) - `bw`: Bandwidth: the single pole of the response (-3 dB, all gains) (Default: 400000) - `vref`: Output at zero current: both reference pins at VS / 2 for a bidirectional output (Default: 2.5) - `noise`: RMS output noise; 0 = a noiseless amplifier (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `rSense` | Ω | 0.005 | 1u – 10 Ω | The shunt resistor between IPP and IPN (your choice, not part of the IC) | assumption | | `gain` | V/V | 20 | 1 – 10k V/V | Gain (the A1 device: 20 V/V) | Section 7.5 G, INA240A1, p.5 | | `gainErr` | — | 0 | -100m – 100m | Gain error as a fraction (typically +/-0.05 %; 0 = nominal) | Section 7.5 gain error typ +/-0.05 %, p.5 (set to 0 here) | | `bw` | Hz | 400000 | 1k – 100meg Hz | Bandwidth: the single pole of the response (-3 dB, all gains) | Section 7.5 BW typ, p.5 | | `vos` | V | 0.000005 | -1m – 1m V | Input offset voltage (the datasheet gives it as +/-) | Section 7.5 VOS typ +/-5 uV, p.5 | | `vref` | V | 2.5 | 0 – 5.5 V | Output at zero current: both reference pins at VS / 2 for a bidirectional output | Section 7.5 test conditions VREF1 = VREF2 = VS / 2, p.5 | | `vs` | V | 5 | 2.7 – 5.5 V | Supply voltage: sets the upper output limit | Section 7.5 test conditions VS = 5 V, p.5 | | `swingHi` | V | 0.05 | 0 – 1 V | Output swing below the VS rail | Section 7.5 swing to VS power-supply rail typ, RL = 10 kOhm, p.5 | | `swingLo` | V | 0.001 | 0 – 1 V | Output swing above GND | Section 7.5 swing to GND typ, VREF = 0 V, p.5 | | `noise` | V | 0 | 0 – 1 V | RMS output noise; 0 = a noiseless amplifier | Section 7.5 voltage noise density 40 nV/sqrt(Hz) input referred, p.5 (about 0.6 mV rms at the output over 400 kHz with gain 20) | | `seed` | — | 1 | 0 – 9007t | Whole-number seed of the noise | model parameter | _Parameter descriptions are in English in both languages._ ## Model The primary path is the shunt rSense in series with a current meter, so it drops rSense * i. The output is a controlled voltage source driven by vref + gain * (1 + gainErr) * (rSense * i + vos), then a first-order low-pass at bw, then seeded Gaussian noise of noise volts rms, then a limit to GND + swingLo ... vs - swingHi. The supply and the reference are parameters (vs, vref), not pins. Input bias currents, common-mode range, PWM rejection, slew rate and drift are not modelled. ## Common mistakes - The output saturates when the current is too large, which is near 24 A with the default gain and shunt. Use a smaller shunt or a lower gain when the current is larger. - rSense is your own shunt and not a datasheet value, so check its voltage drop and heating yourself. gain and bw belong together, and the step must stay below about a tenth of the response time. - The noise is 0 by default. Set about 0.6 mV rms to see the datasheet noise at the default gain, and use another seed for another noise. Problems rules: `step.too_large`, `param.out_of_range` ## Datasheet and sources gain is the gain of your variant (20, 50, 100 or 200 V/V), bw is the -3 dB bandwidth, and vos is the typical input offset. gainErr is the gain error as a fraction (0.05 % is 0.0005). swingHi and swingLo are the typical output swing to the supply and to ground, and vref is half the supply for a bidirectional output. rSense and vs are your design values. Pass them to ic.fromSpec with the shuntAmplifier template and rename the pins to the datasheet names, or place the INA181A1 to INA181A4 presets (SBOS793H: gain 20, 50, 100, 200 V/V, 350, 210, 150, 105 kHz). ## Example Open the example with the command `file.openExample` and the name `demo:shuntAmplifier`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Adjustable Shunt Regulator (`shuntRegulator`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/shuntRegulator/ > Sinks current at its cathode to hold REF at its reference voltage. ![shuntRegulator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/shuntRegulator.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/shuntRegulator/) **Group:** ICs · **Kind:** `{"definition":"shuntRegulator","kind":"subsystem"}` ## When to use it Use it as the error amplifier on the secondary of an isolated supply, driving an optocoupler, or as a precise shunt reference with two resistors. Use Voltage Reference when the load needs a sourcing output. ## Pins | Pin | Domain | Meaning | |---|---|---| | `K` | electrical | Cathode, sinks the regulating current | | `A` | electrical | Anode, the reference for REF and K | | `REF` | electrical | Reference input, compared with vref | ## Common parameters - `vref`: Reference voltage: REF above the anode where the device regulates (Default: 2.495) - `gm`: Low-frequency transconductance: cathode current per volt of REF error (Default: 2.57) - `fPole`: Pole of the transconductance (Default: 6500) - `iMin`: Cathode current with REF exactly at vref (the internal bias) (Default: 0.0004) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `vref` | V | 2.495 | 500m – 40 V | Reference voltage: REF above the anode where the device regulates | Section 6.5 Vref typ (TL431C), p.6 | | `iRef` | A | 0.000002 | 0 – 1m A | Current flowing into REF | Section 6.5 Iref typ (R1 = 10 kΩ), p.6 | | `gm` | A/V | 2.57 | 1m – 1k A/V | Low-frequency transconductance: cathode current per volt of REF error | Figure 6-10: 55.5 dB at 1 kHz into the 232 Ω load of Figure 6-11 (10^(55.5/20) / 232 Ω), p.16 | | `fPole` | Hz | 6500 | 1 – 100meg Hz | Pole of the transconductance | Figure 6-10: 3 dB below the low-frequency gain near 6.5 kHz, read off the plot, p.16 | | `iMin` | A | 0.0004 | 0 – 100m A | Cathode current with REF exactly at vref (the internal bias) | Section 6.5 Imin typ, p.6 | | `ikMax` | A | 0.1 | 1m – 1 A | Most cathode current | Section 6.4 IKA max (recommended), p.5 | | `vKaMin` | V | 2 | 0 – 10 V | Lowest cathode voltage (above the anode) while sinking | assumption: no saturation voltage is given; Section 6.4 recommends VKA >= Vref, p.5 | _Parameter descriptions are in English in both languages._ ## Model The error V(REF) - V(A) - vref passes one pole at fPole and becomes a sink current gm times that error, plus iMin at the reference point. The current stays between 0 and ikMax without wind-up, and the cathode stops sinking at vKaMin above the anode. A constant iRef flows into REF. Everything is solved with the circuit, so a cathode tied to REF or a type II network needs no small step. The second pole near 1 MHz, the instability with capacitive loads, and the loss of regulation below Imin are not modelled. ## Common mistakes - Keep at least 1 mA in the cathode. The real part stops regulating below Imin, but the model keeps regulating, so add a bias resistor across the optocoupler LED. - The cathode cannot go below about 2 V while sinking. With an optocoupler LED and a series resistor on a low output voltage, check that the cathode stays above that. - The REF current flows through the upper divider resistor and raises the output by iRef times that resistor, which is 20 mV for 10 kOhm. Problems rules: `pin.unconnected`, `param.out_of_range` ## Datasheet and sources vref, iRef and iMin are the typical values of the electrical characteristics. ikMax is the largest recommended cathode current. gm and fPole come from the small-signal voltage amplification plot: gm is the low-frequency gain divided by the load resistor of its test circuit, and fPole is where the gain is 3 dB lower. vKaMin is an assumption. Pass them to ic.fromSpec with the shuntRegulator template. ## Example Open the example with the command `file.openExample` and the name `demo:shuntRegulator`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Soft-Start Reference (`softStartRef`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/softStartRef/ > Raises the reference with a capacitor charged by a current, and enables the modulator. ![softStartRef](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/softStartRef.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/softStartRef/) **Group:** ICs · **Kind:** `{"definition":"softStartRef","kind":"subsystem"}` ## When to use it Use it to give an architecture-stage controller its reference, its start-up ramp and its restart after a UVLO or a hiccup. Wire EN from the UVLO, FLT from the OCP, and RUN to the modulator's EN. ## Pins | Pin | Domain | Meaning | |---|---|---| | `EN` | signal | Enable signal, from the UVLO | | `FLT` | signal | Fault signal, from the OCP | | `SS` | electrical | Soft-start capacitor to GND | | `REF` | electrical | Reference output | | `RUN` | signal | High while enabled and not in a fault | | `GND` | electrical | Reference of SS and REF | ## Common parameters - `vRef`: Final value of REF (Default: 1) - `iSs`: Charging current out of SS; tSs = Css·vRef/iSs (Default: 0.00001) - `rDis`: Discharge resistance of SS while the block does not run (Default: 100) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `vRef` | V | 1 | 10m – 100 V | Final value of REF | typical, user must set | | `iSs` | A | 0.00001 | 1n – 1 A | Charging current out of SS; tSs = Css·vRef/iSs | typical, user must set | | `rDis` | Ω | 100 | 1m – 1g Ω | Discharge resistance of SS while the block does not run | typical, user must set | _Parameter descriptions are in English in both languages._ ## Model While EN is high and FLT low, RUN is high and iSs charges the capacitor on SS until it reaches vRef; otherwise SS discharges through rDis. REF is the lower of V(SS) and vRef, so it reaches vRef after Css·vRef/iSs, the soft-start scheme of the LM5145 data sheet (section 7.3). ## Common mistakes - The defaults are typical, user must set. Choose Css for the soft-start time you want, Css = iSs·tSs/vRef. - REF is an ideal source. Drive a high-impedance input with it, such as the error amplifier's non-inverting input or the modulator's REF. Problems rules: `ground.missing` ## Datasheet and sources This is an architecture block. vRef is the reference, iSs the soft-start current and rDis the discharge resistance. A real controller gives VREF, ISS and the SS discharge in its electrical table. ## Example Open the example with the command `file.openExample` and the name `demo:softStartRef`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Synchronous Boost Controller (Peak Current Mode) (`syncBoostController`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/syncBoostController/ > Controls both switches of a synchronous boost from its output voltage and inductor current, with soft start, current limit and hiccup. ![syncBoostController](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/syncBoostController.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/syncBoostController/) **Group:** ICs · **Kind:** `{"definition":"syncBoostController","kind":"subsystem"}` ## When to use it Use it when your boost uses an LM5122-class peak-current-mode controller and you want to see slope compensation, soft start, the cycle-by-cycle current limit and the RES hiccup timer with your own power stage and compensation. To try your own control law, use PI Controller and PWM Generator instead. ## Pins | Pin | Domain | Meaning | |---|---|---| | `VIN` | electrical | Input voltage sense for the slope compensation | | `UVLO` | electrical | Input UVLO, wire the divider from VIN here | | `SS` | electrical | Soft start, the capacitor to GND sets the ramp time | | `FB` | electrical | Feedback input, wire the output divider here | | `COMP` | electrical | Error amplifier output, wire the compensation to FB | | `SLOPE` | electrical | Slope compensation, RSLOPE goes to GND | | `RES` | electrical | Hiccup timer, the capacitor CRES goes to GND | | `CSP` | electrical | Current sense, the input side of the shunt | | `CSN` | electrical | Current sense, the inductor side of the shunt | | `BST` | electrical | High-side driver supply, the bootstrap capacitor goes to SW | | `HO` | electrical | High-side gate drive of the synchronous rectifier | | `SW` | electrical | Switch node, return of the high-side driver | | `LO` | electrical | Low-side gate drive of the main switch | | `VCC` | electrical | Gate driver supply | | `GND` | electrical | Ground reference of every pin | ## Common parameters - `rt`: Oscillator resistor RT; fsw = 9e9 / rt (Default: 20000) - `vRef`: Feedback reference voltage (Default: 1.2) - `acs`: Current-sense amplifier gain (Default: 10) - `vCsLim`: Cycle-by-cycle current limit threshold (CSP - CSN) (Default: 0.075) - `kSlope`: Slope constant: the ramp reaches kSlope / (fsw · RSLOPE) · D' in a period (Default: 6000000000) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `rt` | Ω | 20000 | 5k – 500k Ω | Oscillator resistor RT; fsw = 9e9 / rt | Section 7.3.3 equation 4 RT = 9e9 / fSW, p.17; Section 6.5 fSW typ 450 kHz at RT = 20 kOhm, p.8 | | `vRef` | V | 1.2 | 100m – 5 V | Feedback reference voltage | Section 6.5 VREF typ 1.2 V (1.188 to 1.212 V), p.8 | | `a0` | V/V | 10000 | 10 – 1g V/V | Error amplifier DC gain (80 dB) | Section 6.5 AOL typ 80 dB, p.8 | | `gbw` | Hz | 3000000 | 10k – 1g Hz | Error amplifier gain-bandwidth product | Section 6.5 fBW typ 3 MHz, p.8 | | `vCompLo` | V | 0.25 | 0 – 5 V | Lowest COMP voltage | Derived from a limit: Section 6.5 COMP VOL max 0.25 V (no typical), p.8 | | `vCompHi` | V | 3.4 | 1 – 10 V | Highest COMP voltage | Derived from a limit: Section 6.5 COMP VOH min 3.4 V sourcing 2 mA at VCC 12 V (no typical), p.8 | | `vCompDrop` | V | 1.1 | 0 – 3 V | COMP to PWM comparator voltage drop | Section 6.5 COMP to PWM voltage drop typ 1.1 V, p.8 (Section 7.3.6 p.19 says 1.2 V in the text) | | `acs` | V/V | 10 | 1 – 100 V/V | Current-sense amplifier gain | Section 6.5 CS amplifier gain typ 10 V/V, p.9 | | `vCsLim` | V | 0.075 | 1m – 1 V | Cycle-by-cycle current limit threshold (CSP - CSN) | Section 6.5 VCS-TH1 typ 75 mV, p.9; Section 7.3.10 equation 13 IPEAK(CL) = 75 mV / RS, p.21 | | `vSlope` | V | 1.2 | 100m – 5 V | SLOPE pin voltage | Section 6.5 SLOPE pin voltage typ 1.2 V, p.8 | | `kSlope` | V·Ω/s | 6000000000 | 1meg – 1t V·Ω/s | Slope constant: the ramp reaches kSlope / (fsw · RSLOPE) · D' in a period | Section 7.3.4 equation 5 VSLOPE = 6e9 / (fSW · RSLOPE) · D', D' = VIN / VOUT, p.17 | | `tOffMin` | s | 0.00000033 | 0 – 10u s | Forced LO off-time at the end of every period | Section 6.5 forced LO off-time typ 330 ns (VCC 5.5 V; 560 ns at 4.5 V), p.8 | | `tOnMin` | s | 0.00000015 | 0 – 10u s | Minimum LO on-time (the current comparators are blanked for it) | Section 6.5 minimum LO on-time typ 150 ns (RSLOPE 20 kOhm; 300 ns at 200 kOhm), p.8 | | `iSs` | A | 0.00001 | 100n – 1m A | Soft-start charging current | Section 6.5 ISS typ 10 uA, p.8 | | `rSsDis` | Ω | 13 | 100m – 10k Ω | Soft-start discharge resistance | Section 6.5 SS discharge switch typ 13 Ohm, p.8 | | `vUvlo` | V | 1.2 | 100m – 10 V | UVLO threshold above which switching is enabled | Section 6.5 UVLO threshold typ 1.2 V (rising), p.7 | | `iUvloHys` | A | 0.00001 | 0 – 1m A | Hysteresis current out of UVLO while enabled | Section 6.5 UVLO hysteresis current typ 10 uA, p.7 | | `vccOn` | V | 4 | 1 – 20 V | VCC undervoltage threshold, rising | Section 6.5 VCC UV threshold typ 4.0 V (rising), p.7 | | `vccHys` | V | 0.385 | 0 – 5 V | VCC undervoltage hysteresis | Section 6.5 VCC UV hysteresis typ 0.385 V, p.7 | | `iResLim` | A | 0.00003 | 100n – 1m A | Current into RES for the rest of a current-limited period | Section 6.5 RES source current typ 30 uA, p.9; Section 7.4.3, p.24 | | `iResSink` | A | 0.000005 | 0 – 1m A | Current out of RES in a period without current limit | Section 6.5 RES sink current typ 5 uA, p.9; Section 7.4.3, p.24 | | `vResTrip` | V | 1.2 | 100m – 10 V | RES voltage that starts a hiccup | Section 6.5 hiccup enable threshold typ 1.2 V, p.9 | | `vResLo` | V | 2.15 | 100m – 10 V | Lower RES threshold of the hiccup off-time | Section 6.5 RES lower threshold typ 2.15 V, p.9; Section 7.4.3, p.24 | | `vResHi` | V | 4.2 | 200m – 20 V | Upper RES threshold of the hiccup off-time | Section 6.5 RES upper threshold typ 4.2 V, p.9; Section 7.4.3, p.24 | | `iResUp` | A | 0.00001 | 100n – 1m A | RES charging current in the hiccup off-time | Section 6.5 RES charge current typ 10 uA (hiccup off-time), p.9 | | `iResDown` | A | 0.000005 | 100n – 1m A | RES discharging current in the hiccup off-time | Section 6.5 RES discharge current typ 5 uA (hiccup off-time), p.9 | | `nResCycles` | — | 8 | 1 – 1k | RES ramps between vResLo and vResHi in a hiccup off-time | Section 7.4.3: RES ramps between 2.15 V and 4.2 V eight times, then SS is released, p.24 | | `rResDis` | Ω | 40 | 100m – 10k Ω | RES discharge resistance at the end of a hiccup | Section 6.5 RES discharge switch typ 40 Ohm, p.9 | | `tDead` | s | 0.00000008 | 0 – 1u s | Dead time between one gate turning off and the other turning on | Section 6.5 tDLH and tDHL typ 80 ns, p.10 (adaptive on the part, a fixed delay here) | | `rHoUp` | Ω | 1.5 | 100m – 1k Ω | HO pull-up resistance (to BST) | Derived: Section 6.5 HO high-state voltage drop typ 0.15 V at -100 mA, p.9 | | `rHoDown` | Ω | 1 | 100m – 1k Ω | HO pull-down resistance (to SW) | Derived: Section 6.5 HO low-state voltage drop typ 0.1 V at 100 mA, p.9 | | `rLoUp` | Ω | 1.5 | 100m – 1k Ω | LO pull-up resistance (to VCC) | Derived: Section 6.5 LO high-state voltage drop typ 0.15 V at -100 mA, p.10 | | `rLoDown` | Ω | 1 | 100m – 1k Ω | LO pull-down resistance (to GND) | Derived: Section 6.5 LO low-state voltage drop typ 0.1 V at 100 mA, p.10 | | `rOff` | Ω | 1000000 | 1k – 1t Ω | Off-state resistance of the gate driver switches (the SS and RES switches use 10 GOhm) | assumption: the solver's default switch off resistance | _Parameter descriptions are in English in both languages._ ## Model The oscillator runs at fsw = 9e9 / rt. LO turns on at each clock and is forced off for tOffMin at the end of the period. After the blanking time tOnMin, LO turns off when acs times V(CSP) - V(CSN) plus the slope ramp exceeds COMP - vCompDrop, or when V(CSP) - V(CSN) exceeds vCsLim. SLOPE is held at vSlope, and the resistor from SLOPE to GND sets the ramp: it rises at kSlope / RSLOPE times D' = VIN / VOUT per second, with VOUT read on SW in the forced off-time. The error amplifier is a single pole (a0, gbw) driven by the lower of vRef and V(SS) minus FB, limited to vCompLo ... vCompHi. Above vUvlo on UVLO and vccOn on VCC, iSs charges SS and iUvloHys flows out of UVLO; otherwise SS is discharged through rSsDis. In a period the current limit ended, iResLim flows into RES; otherwise iResSink flows out. At vResTrip both gates turn off and SS is discharged, RES ramps up at iResUp to vResHi and down at iResDown to vResLo nResCycles times, then it is discharged through rResDis and a new soft start begins. HO is the complement of LO, each turning on tDead after the other turned off. ## Common mistakes - Without a resistor on SLOPE there is no slope compensation, and above 50 % duty the current loop alternates long and short pulses. Size RSLOPE so the ramp is at least half the sensed inductor down-slope acs * RS * (VOUT - VIN) / L. - The current limit also acts in the soft start: charging the output capacitor takes COUT * VOUT / tSs more output current, VOUT / VIN times that at the input. A limit sized for the full load alone makes the converter hiccup at start-up. - The hiccup off-time is about CRES * (3 V / 10 uA + 8 * 2.05 V / 5 uA + 7 * 2.05 V / 10 uA), so 1 nF already gives about 5 ms. Use a small CRES for a short run. - VCC and BST must be supplied from outside, because the internal regulator and the charge pump are not modelled. A boost cannot limit an output short: the current flows through the synchronous rectifier's body diode, so the limit and hiccup act only on an overload the converter still boosts into. Problems rules: `step.too_large`, `param.out_of_range`, `pin.unconnected` ## Datasheet and sources rt is your own timing resistor, and RSLOPE and CRES are your own parts on SLOPE and RES. vRef, a0, gbw, vCompDrop, acs, vCsLim, vSlope, tOffMin, tOnMin, iSs, rSsDis, vUvlo, iUvloHys, vccOn, vccHys, the RES currents and thresholds, rResDis and tDead come from the electrical characteristics, kSlope from the slope compensation equation and nResCycles from the hiccup description. The four driver resistances are the driver voltage drops divided by their test currents. vCompLo and vCompHi are limits, because the data sheet gives no typical COMP levels. ## Example Open the example with the command `file.openExample` and the name `demo:syncBoostController`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Synchronous Buck Controller (Voltage Mode) (`syncBuckController`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/syncBuckController/ > Controls both switches of a synchronous buck from its output voltage, with soft start and current limit. ![syncBuckController](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/syncBuckController.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/syncBuckController/) **Group:** ICs · **Kind:** `{"definition":"syncBuckController","kind":"subsystem"}` ## When to use it Use it when your buck uses an LM5145-class voltage-mode controller and you want to see soft start, PGOOD, the valley current limit and hiccup with your own power stage and type-III compensation. To try your own control law, use PI Controller and PWM Generator instead. ## Pins | Pin | Domain | Meaning | |---|---|---| | `VIN` | electrical | Input voltage sense for the feed-forward ramp | | `EN` | electrical | Enable and input UVLO, wire the divider from VIN here | | `SS` | electrical | Soft start, the capacitor to GND sets the ramp time | | `FB` | electrical | Feedback input, wire the output divider here | | `COMP` | electrical | Error amplifier output, wire the compensation to FB | | `PGOOD` | electrical | Power good, open drain, needs a pull-up | | `ILIM` | electrical | Valley current limit, R_ILIM goes to SW | | `BST` | electrical | High-side driver supply, the bootstrap capacitor goes to SW | | `HO` | electrical | High-side gate drive | | `SW` | electrical | Switch node, return of the high-side driver | | `LO` | electrical | Low-side gate drive | | `VCC` | electrical | Low-side driver supply | | `GND` | electrical | Ground reference of every pin | ## Common parameters - `rt`: Oscillator resistor RT; fsw = 1 / (rt · 99.63 pF + 37 ns) (Default: 25000) - `vRef`: Feedback reference voltage (Default: 0.8) - `kff`: PWM feed-forward gain VIN / VRAMP (Default: 15) - `iSs`: Soft-start charging current (Default: 0.00001) - `iLim`: Current out of ILIM (RDS(on) sensing; 100 uA for a shunt) (Default: 0.0002) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `rt` | Ω | 25000 | 5k – 250k Ω | Oscillator resistor RT; fsw = 1 / (rt · 99.63 pF + 37 ns) | Section 7.5 FSW1..FSW3 typ: RT = 100 kOhm 100 kHz, 25 kOhm 400 kHz, 12.5 kOhm 780 kHz, p.9; the equation is a fit to them | | `vRef` | V | 0.8 | 100m – 5 V | Feedback reference voltage | Section 7.5 VREF typ 800 mV (792 to 808 mV), p.8 | | `kff` | V/V | 15 | 1 – 100 V/V | PWM feed-forward gain VIN / VRAMP | Section 7.5 kFF typ 15 V/V (6 V to 75 V), p.9 | | `vValley` | V | 0.3 | 0 – 2 V | Ramp valley voltage: COMP below it gives 0 % duty | Section 7.5 VRAMP(min) typ 300 mV (COMP at 0 % duty cycle), p.9 | | `tOffMin` | s | 0.00000014 | 0 – 10u s | Minimum off-time of HO in every period | Section 7.5 tOFF(MIN) typ 140 ns (VBST - VSW = 7 V, HO 50 % to 50 %), p.9 | | `a0` | V/V | 50119 | 10 – 1g V/V | Error amplifier DC gain (94 dB) | Section 7.5 AVOL typ 94 dB, p.8 | | `gbw` | Hz | 6500000 | 10k – 1g Hz | Error amplifier gain-bandwidth product | Section 7.5 GBW typ 6.5 MHz, p.8 | | `vCompLo` | V | 0 | 0 – 5 V | Lowest COMP voltage | assumption: Section 7.5 gives VCOMP-OL max 0.3 V sinking 1 mA and no typical, p.8; ground | | `vCompHi` | V | 5 | 1 – 10 V | Highest COMP voltage (full duty needs vValley + VIN / kff below it) | Section 7.5 VCOMP-OH typ 5 V (VFB = 0 V, sourcing 1 mA), p.8 | | `iSs` | A | 0.00001 | 100n – 1m A | Soft-start charging current | Section 7.5 ISS typ 10 uA (VSS/TRK = 0 V), p.8 | | `rSsDis` | Ω | 11 | 100m – 10k Ω | Soft-start discharge resistance | Section 7.5 RSS typ 11 Ohm, p.8 | | `vEn` | V | 1.2 | 100m – 10 V | EN threshold above which switching is enabled | Section 7.5 VEN typ 1.2 V (EN/UVLO rising), p.8 | | `iEnHys` | A | 0.00001 | 0 – 1m A | Hysteresis current out of EN while enabled | Section 7.5 IEN-HYS typ 10 uA, p.8 | | `iLim` | A | 0.0002 | 1u – 10m A | Current out of ILIM (RDS(on) sensing; 100 uA for a shunt) | Section 7.5 IRDSON typ 200 uA (180 to 220 uA at 25 C; IRS 100 uA in RSENSE mode), p.9 | | `vIlimOff` | V | -0.002 | -100m – 100m V | ILIM comparator threshold | Section 7.5 VILIM-TH typ -2 mV (-8 to 3.5 mV), p.9 | | `nHiccup` | — | 128 | 1 – 4.1k | Consecutive current-limited periods before a hiccup | Section 7.5 CHICC-DEL 128 cycles, p.9; Section 8.3.11: 128 continuous clock cycles, p.25 | | `nHiccupReset` | — | 4 | 1 – 4.1k | Clean periods in a row that restart the hiccup count | assumption: Section 8.3.11 counts 128 continuous clock cycles of overcurrent, p.25, but in a hard short the model skips only every other period, so up to 3 unskipped periods between skips still count as one overcurrent run (the LM5143 data sheet rule) | | `nHiccupOff` | — | 8192 | 1 – 1meg | Periods without switching in a hiccup | Section 7.5 CHICCUP 8192 cycles, p.9 | | `pgUvRise` | — | 0.94 | 500m – 1 | PGOOD lower threshold, FB rising, as a fraction of vRef | Section 7.5 PGLTH typ 92 % (FB falling) plus PGHYS_L 2 %, p.8 | | `pgUvFall` | — | 0.92 | 500m – 1 | PGOOD lower threshold, FB falling | Section 7.5 PGLTH typ 92 % (90 to 94 %), p.8 | | `pgOvRise` | — | 1.08 | 1 – 1.5 | PGOOD upper threshold, FB rising | Section 7.5 PGUTH typ 108 % (106 to 110 %), p.8 | | `pgOvFall` | — | 1.05 | 1 – 1.5 | PGOOD upper threshold, FB falling | Section 7.5 PGUTH typ 108 % minus PGHYS_U 3 %, p.8 | | `tPgFilter` | s | 0.000025 | 0 – 10m s | PGOOD rising and falling filter time | Section 7.5 TPG-RISE and TPG-FALL typ 25 us, p.8 | | `rPgood` | Ω | 75 | 100m – 100k Ω | PGOOD pull-down resistance | Derived from a limit: Section 7.5 VPG-OL max 150 mV at 2 mA (no typical), p.8 | | `tDead` | s | 0.000000014 | 0 – 1u s | Dead time between one gate turning off and the other turning on | Section 7.6 THO-DT and TLO-DT typ 14 ns, p.10 (adaptive on the part, a fixed delay here) | | `rHoUp` | Ω | 1.5 | 100m – 1k Ω | HO pull-up resistance (to BST) | Section 7.5 RHO-UP typ 1.5 Ohm (VBST - VSW = 7 V, 100 mA), p.10 | | `rHoDown` | Ω | 0.9 | 100m – 1k Ω | HO pull-down resistance (to SW) | Section 7.5 RHO-DOWN typ 0.9 Ohm (100 mA), p.10 | | `rLoUp` | Ω | 1.5 | 100m – 1k Ω | LO pull-up resistance (to VCC) | Section 7.5 RLO-UP typ 1.5 Ohm (100 mA), p.10 | | `rLoDown` | Ω | 0.9 | 100m – 1k Ω | LO pull-down resistance (to GND) | Section 7.5 RLO-DOWN typ 0.9 Ohm (100 mA), p.10 | | `rOff` | Ω | 1000000 | 1k – 1t Ω | Off-state resistance of the internal switches | assumption: the solver's default switch off resistance | _Parameter descriptions are in English in both languages._ ## Model The oscillator runs at fsw = 1 / (rt * 99.63 pF + 37 ns), a fit to the data sheet's frequency rows. Each period a ramp starts at vValley and rises by V(VIN) / kff, so the gain from COMP to the switch node is kff at any input voltage. HO is on while COMP is above the ramp, with at least tOffMin off before the next clock, and LO is its complement, each turning on tDead after the other turned off. The error amplifier is a single pole (a0, gbw) driven by the lower of vRef and V(SS) minus FB, limited to vCompLo ... vCompHi. Above vEn on EN, iSs charges SS and iEnHys flows out of EN; otherwise SS is discharged through rSsDis. iLim flows out of ILIM, and when V(ILIM) is below vIlimOff while LO is on at the clock, that period's HO pulse is skipped. After nHiccup skipped periods (the count restarts after nHiccupReset clean periods in a row) both gates stay off and SS is held at zero for nHiccupOff periods. PGOOD pulls low unless FB is inside the window pgUvRise ... pgOvRise times vRef, with hysteresis and the filter time tPgFilter. ## Common mistakes - The frequency comes from rt, and there is no separate frequency parameter. With the default 25 kOhm it is about 396 kHz, so use a step of a few hundredths of a period (about 13 ns at the default) or the error amplifier and the dead time are off by a step. - ILIM reads the low-side MOSFET's on resistance through R_ILIM, so R_ILIM = valley limit times RDS(on) / iLim. Leaving ILIM open or tied to GND disables the limit, and in a short the current then runs away. - The hiccup off-time is 8192 periods, about 21 ms at the default frequency. For a short run, set nHiccupOff lower to see the restart. - VCC and BST must be supplied from outside, because the internal regulator and the bootstrap diode are not modelled. Without them HO and LO have no high level. Problems rules: `step.too_large`, `param.out_of_range`, `pin.unconnected` ## Datasheet and sources rt is your own timing resistor. vRef, kff, vValley, tOffMin, a0, gbw, vCompHi, iSs, rSsDis, vEn, iEnHys, iLim, vIlimOff, nHiccup, nHiccupOff, the PGOOD thresholds and filter time, and the four driver resistances (RHO-UP, RHO-DOWN, RLO-UP, RLO-DOWN) come from the electrical characteristics, and tDead from the switching characteristics. rPgood is the largest PGOOD low-state voltage divided by its test current. nHiccupReset (4) and vCompLo are assumptions: the data sheet counts 128 continuous overcurrent cycles, while the model skips only every other period in a short, and it gives only a maximum COMP low level. ## Example Open the example with the command `file.openExample` and the name `demo:syncBuckController`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # 555 Timer (`timer555`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/timer555/ > Makes timed pulses or a steady square wave from a resistor and a capacitor. ![timer555](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/timer555.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/timer555/) **Group:** ICs · **Kind:** `{"definition":"timer555","kind":"subsystem"}` ## When to use it Use it for RC timing such as an oscillator, a one-shot pulse or a delay. Use Comparator with Hysteresis when you need a threshold and no timing. ## Pins | Pin | Domain | Meaning | |---|---|---| | `VCC` | electrical | Supply, sets the thresholds and the output high level | | `GND` | electrical | Ground reference of every pin | | `TRIG` | electrical | Trigger, a low level sets the output high | | `THR` | electrical | Threshold, a high level sets the output low | | `CTRL` | electrical | Control voltage, add 10 nF to GND | | `DIS` | electrical | Discharge, shorted to GND while the output is low | | `OUT` | electrical | Output | | `RESET` | electrical | Reset, a low level forces the output low | ## Common parameters - `rDiv`: Each of the three equal resistors of the internal divider VCC-CTRL-GND (Default: 5000) - `vOhDrop`: Output high level below VCC with no load (Default: 0.9) - `rOutHi`: Output resistance when high (Default: 8) - `rOutLo`: Output resistance to GND when low (Default: 7.5) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `rDiv` | Ω | 5000 | 100 – 10meg Ω | Each of the three equal resistors of the internal divider VCC-CTRL-GND | Functional block diagram: three 5 kOhm resistors (hence the name 555) | | `vReset` | V | 0.7 | 100m – 5 V | RESET threshold: below it the output is forced low | Electrical characteristics, reset voltage typ 0.7 V | | `vOhDrop` | V | 0.9 | 0 – 5 V | Output high level below VCC with no load | Derived: VOH typ 13.3 V at 100 mA and 12.5 V at 200 mA from VCC = 15 V, extended to zero current | | `rOutHi` | Ω | 8 | 10m – 10k Ω | Output resistance when high | Derived: the slope between the VOH rows (0.8 V per 100 mA) | | `rOutLo` | Ω | 7.5 | 10m – 10k Ω | Output resistance to GND when low | Derived: VOL typ 0.1 V at 10 mA and 0.4 V at 50 mA from VCC = 15 V | | `rDis` | Ω | 10 | 10m – 10k Ω | On resistance of the discharge transistor from DIS to GND | assumption: a saturated transistor carrying the timing capacitor's discharge current | | `rOff` | Ω | 100000000 | 1k – 1t Ω | Off-state resistance of the output and discharge switches (leakage) | assumption: discharge off-state current typ 20 nA is below this model's resolution | _Parameter descriptions are in English in both languages._ ## Model Three resistors rDiv from VCC through CTRL to GND set the upper threshold V(CTRL) = 2/3 VCC and the lower one V(CTRL)/2 = 1/3 VCC. The latch is set while V(TRIG) < V(CTRL)/2 and reset while V(THR) > V(CTRL). The trigger wins when both hold, and RESET below vReset resets it over both. Set, OUT is driven to VCC - vOhDrop through rOutHi and DIS is open. Reset, OUT goes to GND through rOutLo and DIS to GND through rDis. The latch starts reset. An astable with RA, RB and C runs at f = 1.44 / ((RA + 2 RB) C) with duty (RA + RB) / (RA + 2 RB). A monostable with R and C gives a pulse of ln 3 R C, about 1.1 R C. Propagation delay, bias currents and supply current are not modelled. ## Common mistakes - The comparators reach the latch and the latch reaches the output one solver step late each. Keep the step below a thousandth of the period, or the frequency comes out a few percent low. - RESET has no internal pull-up, so tie it to VCC. A capacitor on CTRL starts at 0 V and moves the thresholds until it charges, so precharge it to two thirds of VCC or ignore the first periods. - In an astable, RA carries current through the discharge transistor while the output is low. A very small RA lengthens the low time and loads the supply, so keep RA at 1 kOhm or more. Problems rules: `step.too_large` ## Datasheet and sources rDiv is the internal divider resistor of the block diagram (5 kOhm for the bipolar 555, and much larger for CMOS versions such as the 7555). vReset is the typical reset voltage. vOhDrop and rOutHi come from two rows of the high-level output voltage, and rOutLo from two rows of the low-level output voltage. rDis is the discharge saturation voltage divided by its test current. Pass them to ic.fromSpec with the timer555 template, for example rDiv 100k for a CMOS timer. ## Example Open the example with the command `file.openExample` and the name `demo:timer555`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Transition-Mode Boost PFC Controller (Constant On-Time) (`tmPfcController`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/tmPfcController/ > Runs a boost PFC in transition mode: a constant on-time per line cycle, the next cycle starting when the drain shows the inductor current is zero, so the line current follows the line voltage. ![tmPfcController](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/tmPfcController.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/tmPfcController/) **Group:** ICs · **Kind:** `{"definition":"tmPfcController","kind":"subsystem"}` ## When to use it Use it for a boost PFC up to a few hundred watts with a UCC28056-class controller, when you want valley turn-on without an auxiliary winding, line feed-forward and burst mode. circuit.applicationCircuit with topology tmPfc builds the data sheet's 165 W, 390 V preregulator. For larger power in continuous conduction use the CCM Boost PFC Controller. ## Pins | Pin | Domain | Meaning | |---|---|---| | `VOSNS` | electrical | Output voltage sense, regulated to 2.5 V | | `ZCD` | electrical | Drain divider while DRV is low, sense resistor while DRV is high | | `VCC` | electrical | Supply, the controller runs above the UVLO threshold | | `GND` | electrical | Ground reference, at the lower end of the sense resistor | | `DRV` | electrical | Gate drive of the boost switch | | `COMP` | electrical | Error amplifier output and power demand | ## Common parameters - `vOsReg`: Error amplifier reference (Default: 2.5) - `gM`: Error amplifier transconductance for small errors (Default: 0.00005) - `vCoMax`: COMP voltage of full power demand (VCOMax of equation 8) (Default: 5) - `tZcdDrv`: Delay from the zero-current detection to DRV high (Default: 0.00000017) - `vOcp1`: First-level over-current threshold on ZCD while DRV is high (Default: 0.5) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `vccStart` | V | 10.65 | 1 – 34 V | VCC UVLO turn-on threshold | Section 7.5 VCCStart typ 10.65 V (max 11 V), p.7 | | `vccStop` | V | 8.85 | 500m – 34 V | VCC UVLO turn-off threshold | Section 7.5 VCCStop typ 8.85 V, p.7 | | `vOsReg` | V | 2.5 | 500m – 5 V | Error amplifier reference | Section 7.5 VOSReg typ 2.5 V, p.7 | | `gM` | S | 0.00005 | 100n – 10m S | Error amplifier transconductance for small errors | Section 7.5 gM typ 50 µS, p.7 | | `gMNL` | S | 0.0003 | 100n – 100m S | Error amplifier transconductance beyond dSuThs (incremental) | Section 7.5 gMNL typ 300 µS, p.8 | | `dSuThs` | V | 0.067 | 1m – 1 V | Error beyond which the large-error gain applies | Section 7.5 DSuThs typ 67 mV, p.8 | | `iCoMax` | A | 0.00012 | 100n – 10m A | COMP maximum source and sink current | Section 7.5 ICOMin typ -120 µA, ICOMax typ 120 µA, p.8 | | `vCoClmp` | V | 5.6 | 1 – 10 V | COMP internal high clamp | Section 7.5 VCOClmp typ 5.6 V, p.8 | | `rCoDisch` | Ω | 5000 | 1 – 1meg Ω | COMP discharge resistance in the stop state | Section 7.5 RCODisch typ 5 kΩ, p.8 | | `vCoMax` | V | 5 | 500m – 10 V | COMP voltage of full power demand (VCOMax of equation 8) | Section 9.2.2.5.2 equations 98 and 99: 0.0202 = VCOMax·2 % / 4.95 V gives VCOMax = 5.0 V | | `vBstFall` | V | 0.5 | 0 – 5 V | COMP threshold below which switching halts (burst off) | Section 5 Device Comparison Table VBSTFall 0.5 V (UCC28056, UCC28056C), p.4 | | `vBstRise` | V | 0.625 | 0 – 5 V | COMP threshold above which switching resumes (burst on) | Section 5 Device Comparison Table VBSTRise 0.625 V (UCC28056, UCC28056C), p.4 | | `vOvp1Rise` | V | 2.75 | 500m – 6 V | VOSNS over-voltage threshold, rising (switching halts) | Section 5 VOSOvp1Rise typ 2.75 V (UCC28056, B, C), p.4 | | `vOvp1Fall` | V | 2.675 | 500m – 6 V | VOSNS over-voltage threshold, falling (switching resumes) | Section 5 VOSOvp1Fall typ 2.675 V (UCC28056, B, C), p.4 | | `vZcBo` | V | 0.3 | 0 – 5 V | Brown-in threshold on the peak of VInSynth | Section 7.5 VZCBoRise typ 0.3 V, p.9 | | `vOcp1` | V | 0.5 | 10m – 5 V | First-level over-current threshold on ZCD while DRV is high | Section 7.5 VZCOcp1 typ 500 mV, p.9 | | `tOcp1Blk` | s | 0.00000045 | 0 – 10u s | Over-current blanking from the DRV rising edge | Section 7.5 TOcp1Blk 450 ns, p.9 | | `tDchVinMin` | s | 0.000000358 | 0 – 10u s | ZCD comparator blanking from the DRV falling edge | Section 7.5 TDCHVinMin typ 358 ns, p.9 | | `tDchMax0` | s | 0.00025 | 1u – 10m s | Longest off-time without a zero-current detection | Section 7.5 TDCHMax0 250 µs, p.9 | | `tZcdDrv` | s | 0.00000017 | 0 – 10u s | Delay from the zero-current detection to DRV high | Section 7.5 TZCDR0 typ 170 ns (RDG0, max 235 ns), p.9 | | `tauSynth` | s | 0.0001 | 100n – 10m s | Averaging time constant of VInSynth | assumption: the data sheet says only that the drain waveform is filtered to its switching-cycle average (section 8.3.2.1); 100 µs is many switching periods and a few degrees of a 100 Hz half-cycle | | `tPeakHold` | s | 1 | 1m – 100 s | Decay time constant of the line peak detector | assumption: in place of the 12.3 ms THLinMax window (section 7.5, p.8), a peak detector that decays slowly enough not to cross the feed-forward hysteresis within a line cycle | | `vDrHigh` | V | 13.7 | 1 – 20 V | DRV high-level limit | Section 7.5 VDRHigh typ 13.7 V at VCC = 25 V, p.7 | | `vDrDrop` | V | 1.05 | 0 – 5 V | DRV high level below VCC when not limited | Section 7.5 VDRHighMin 8 V at VCC = VCCStop + 200 mV (9.05 V), p.7 | | `rDrH` | Ω | 9.7 | 100m – 10k Ω | DRV pull-up resistance | Section 7.5 RDRH typ 9.7 Ω, p.7 | | `rDrL` | Ω | 4.6 | 100m – 10k Ω | DRV pull-down resistance | Section 7.5 RDRL typ 4.6 Ω, p.7 | | `rOff` | Ω | 100000000 | 1k – 1t Ω | Off-state resistance of the internal switches | assumption: large against the COMP network | _Parameter descriptions are in English in both languages._ ## Model The on-time is TONMAX0 * GFF * V(COMP) / vCoMax, at most the TONMAX of the selected level. While DRV is low the drain part of ZCD is averaged over tauSynth into VInSynth; after tDchVinMin the drain falling below VInSynth is the zero-current detection, and the next on-time starts tZcdDrv later (or after tDchMax0 without one). The peak of VInSynth selects GFF0 to GFF7 through seven comparators with hysteresis, and switching starts once it passes vZcBo. The error amplifier sources gM * (vOsReg - V(VOSNS)), with the slope gMNL beyond dSuThs, limited to iCoMax; COMP is clamped between 0 V and vCoClmp and discharged through rCoDisch below the UVLO. Switching halts below vBstFall on COMP and above vOvp1Rise on VOSNS; ZCD above vOcp1 after tOcp1Blk ends the on-time. ## Common mistakes - The drain rings with the ZCD divider capacitance at a few megahertz when the inductor current reaches zero; the detection needs a step of a few tens of nanoseconds. The application circuit uses 25 ns. - Light-load DCM operation is not modelled: the model stays in transition mode down to the burst threshold, so its switching frequency rises at light load where the real part's falls. Problems rules: `step.too_large`, `param.out_of_range`, `pin.unconnected` ## Datasheet and sources The ZCD divider, the VOSNS divider, the COMP network, the sense resistor and the DRV-to-GND resistor are your own parts. vccStart, vccStop, vOsReg, gM, gMNL, dSuThs, iCoMax, vCoClmp, rCoDisch, vZcBo, vOcp1, tOcp1Blk, tDchVinMin, tDchMax0, tZcdDrv and the DRV levels come from the electrical characteristics, the burst and OVP1 thresholds from the device comparison table, vCoMax from the loop design example (equations 98 and 99). tauSynth and tPeakHold are assumptions. ## Example Open the example with the command `file.openExample` and the name `demo:tmPfcController`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # UVLO Comparator (`uvloComparator`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/uvloComparator/ > Says when the input is high enough to run, with hysteresis. ![uvloComparator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/uvloComparator.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/uvloComparator/) **Group:** ICs · **Kind:** `{"definition":"uvloComparator","kind":"subsystem"}` ## When to use it Use it on a divider from the input to start and stop an architecture-stage controller at chosen input voltages. Wire OK to the soft start's EN. ## Pins | Pin | Domain | Meaning | |---|---|---| | `SENSE` | electrical | Divided input voltage | | `OK` | signal | High above the rising threshold until below the falling one | | `GND` | electrical | Reference of SENSE | ## Common parameters - `vRise`: Rising threshold at SENSE (Default: 1.2) - `vFall`: Falling threshold at SENSE (at most vRise) (Default: 1.1) - `iHys`: Current out of SENSE while OK is high (0 = none); lowers the input's falling threshold by iHys·R1 (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `vRise` | V | 1.2 | 1m – 100 V | Rising threshold at SENSE | typical, user must set | | `vFall` | V | 1.1 | 1m – 100 V | Falling threshold at SENSE (at most vRise) | typical, user must set | | `iHys` | A | 0 | 0 – 10m A | Current out of SENSE while OK is high (0 = none); lowers the input's falling threshold by iHys·R1 | typical, user must set | _Parameter descriptions are in English in both languages._ ## Model OK goes high once V(SENSE) rises above vRise and low once it falls below vFall. While OK is high, iHys flows out of SENSE into the divider, as the EN/UVLO pin of the LM5145 data sheet (section 7.3) does. With R1 from the input to SENSE and R2 to GND, the input thresholds are vRise·(R1 + R2)/R2 and vFall·(R1 + R2)/R2 − iHys·R1. ## Common mistakes - The defaults are typical, user must set. Size the divider for the input voltage at which you want to start. - SENSE must have a path to GND. The hysteresis current needs the divider, so a SENSE pin tied straight to the input gets no extra hysteresis from it. Problems rules: `ground.missing` ## Datasheet and sources This is an architecture block. vRise and vFall are the comparator's thresholds and iHys the hysteresis current. A real controller gives them as the EN or UVLO rising threshold, its hysteresis and the hysteresis current. ## Example Open the example with the command `file.openExample` and the name `demo:uvloComparator`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Voltage Reference (`voltageReference`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/voltageReference/ > Gives a precise voltage that changes little with supply and load. ![voltageReference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/voltageReference.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/voltageReference/) **Group:** ICs · **Kind:** `{"definition":"voltageReference","kind":"subsystem"}` ## When to use it Use it as the reference of an ADC or a comparator, with its dropout, current limit and output impedance. Use Adjustable Shunt Regulator to set a level with two resistors. ## Pins | Pin | Domain | Meaning | |---|---|---| | `IN` | electrical | Input supply | | `OUT` | electrical | Reference output | | `GND` | electrical | Ground | ## Common parameters - `vOut`: Output voltage (Default: 2.5) - `psrr`: Supply rejection at low frequency (Default: 80) - `rHf`: Output resistance a load step sees before the loop responds (Default: 40) - `iLim`: Current limit (Default: 0.045) ## Parameters | Key | Unit | Default | Typical range | Description | Datasheet source | |---|---|---|---|---|---| | `vOut` | V | 2.5 | 500m – 40 V | Output voltage | Section 6.6 REF3025 VOUT typ, p.8 | | `psrr` | dB | 80 | 0 – 160 dB | Supply rejection at low frequency | Figure 6-38 PSRR at 1 to 10 Hz, p.16 | | `fZero` | Hz | 22 | 100m – 1g Hz | Frequency where the rejection starts to fall (20 dB per decade) | Figure 6-38: 47 dB at 1 kHz and 27 dB at 10 kHz, read off the plot, p.16 | | `fPole` | Hz | 220000 | 100m – 1g Hz | Frequency where the rejection stops falling | Figure 6-38: the 20 dB per decade line reaches 0 dB here (4 dB at 100 kHz on the plot), p.16 | | `vDo0` | V | 0.001 | 0 – 5 V | Dropout with no load | Section 6.6 VDO typ, p.9 | | `rDo` | Ω | 10 | 100u – 1k Ω | Dropout resistance: dropout per ampere of output | assumption: no dropout-vs-load row; Figure 6-40 shows regulation at VIN = 3 V and 25 mA, so the dropout at 25 mA (here 0.25 V) is below 0.5 V, p.16 | | `rLoad` | Ω | 0.0075 | 0 – 1k Ω | Load regulation as a resistance | Section 6.6 load regulation typ 3 ppm/mA of 2.5 V, p.9 | | `rHf` | Ω | 40 | 100u – 1k Ω | Output resistance a load step sees before the loop responds | Figure 6-37 output impedance at 100 kHz, p.16 | | `fLoop` | Hz | 100000 | 1 – 1g Hz | Bandwidth with which the loop corrects load and dropout changes | Figure 6-37: rHf / fLoop is the slope of the rising impedance (40 Ω at 100 kHz, still rising there), p.16 | | `iLim` | A | 0.045 | 100u – 100 A | Current limit | Section 6.6 ISC typ, p.9 | | `iq` | A | 0.000042 | 0 – 100m A | Quiescent current drawn from IN | Section 6.6 IQ typ, p.9 | | `tOn` | s | 0.00012 | 1n – 1 s | Start-up time: the set point ramps to vOut over it | Section 6.6 turn-on settling time typ (to 0.1 %, CL = 1 uF), p.9 | _Parameter descriptions are in English in both languages._ ## Model The output is vOut plus the input through the supply rejection, which is psrr at low frequency with a zero at fZero and a pole at fPole. It ramps up over tOn after power-up. It falls by rLoad times the current at DC, and the output resistance rises to rHf above fLoop. In dropout the output is the input less vDo0 and rDo times the current. The current stops at iLim, the output cannot sink, and the input draws the output current plus iq. Noise, drift and thermal hysteresis are not modelled. ## Common mistakes - The output impedance rises with frequency, to 40 Ohm at 100 kHz by default, so a fast load step makes a short spike. With an output capacitor the model rings near 20 kHz and settles more slowly than the real part. - The dropout growth with load is an assumption, because the data sheet gives the dropout without load only. Leave at least 0.5 V of headroom at full load. Problems rules: `step.too_large`, `param.out_of_range` ## Datasheet and sources vOut is your output option. psrr, fZero and fPole come from the supply rejection curve. rHf and fLoop come from the output impedance curve, as the value at its highest frequency and that frequency. rLoad is the load regulation times vOut, vDo0 is the dropout, iLim is the short-circuit current, iq is the quiescent current, and tOn is the turn-on settling time. Pass them to ic.fromSpec with the voltageReference template. ## Example Open the example with the command `file.openExample` and the name `demo:voltageReference`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # BLDC Machine (`bldc`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/machines/bldc/ > A brushless DC motor with a trapezoidal back-EMF and built-in Hall outputs. ![bldc](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/bldc.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/machines/bldc/) **Group:** Machines · **Kind:** `{"kind":"machine","model":"bldc"}` ## When to use it Use it for six-step drives that commutate from the Hall signals. Use Surface PMSM when the back-EMF is sinusoidal and the drive is field-oriented. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | electrical | Stator phase a, current enters when motoring | | `b` | electrical | Stator phase b, current enters when motoring | | `c` | electrical | Stator phase c, current enters when motoring | | `n` | electrical | Star point, optional | | `shaft` | mechanical | Mechanical shaft, speed in rad/s | | `ha` | signal | Hall signal a, 0 or 1 | | `hb` | signal | Hall signal b, 120 degrees after a | | `hc` | signal | Hall signal c, 240 degrees after a | ## Common parameters - `ke`: Voltage made per unit of speed (Default: 0.05) - `rs`: Stator winding resistance per phase (Default: 0.3) - `ls`: Inductance of each phase (Default: 1m) - `poles`: Number of poles of the machine (Default: 8) - `j`: How strongly the rotor resists speeding up (Default: 1m) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `rs` | Ω | 0.3 | | Stator winding resistance per phase | | `ls` | H | 1m | | Inductance of each phase | | `ke` | V·s/rad | 0.05 | | Voltage made per unit of speed | | `flat` | ° | 120 | | Width of the flat part of the voltage | | `poles` | — | 8 | | Number of poles of the machine | | `j` | kg·m² | 1m | | How strongly the rotor resists speeding up | | `b` | N·m·s/rad | 0 | | Friction that grows with speed | | `w0` | rad/s | 0 | | Shaft speed at the start | | `theta0` | rad | 0 | | Rotor position at the start | | `hall0` | rad | 0.5236 | | Angle where the first Hall signal rises | _Parameter descriptions are in English in both languages._ ## Model Each phase follows v = rs·i + ls·di/dt + e, where e = ke·f(θe - k·120 degrees)·ωm, and the torque is Te = ke times the sum of f(θe - k·120 degrees)·ik. The function f is a unit trapezoid whose flat top is flat electrical degrees wide, and the phases do not couple. With two phases carrying I on their flat tops, Te = 2·ke·I. Hall signal ha is high for 180 electrical degrees from hall0, and hb and hc follow 120 and 240 degrees later. Rotating forward, ha hb hc read 101, 100, 110, 010, 011, 001. The machine never commutates by itself, so the inverter must switch the phases. ## Common mistakes - ke is the flat-top back-EMF of one phase against the neutral, per mechanical rad/s. A line-to-line constant from a datasheet is twice that, so halve it, and note that two conducting phases give a torque constant of 2·ke. - A fixed three-phase sine source does not commutate. Pick the conducting pair from ha, hb and hc with control blocks, and keep hall0 at its default of 30 degrees so the Hall edges fall at the commutation instants. - ha, hb and hc are 0 or 1 signals, not voltages, and poles is a pole count, not pole pairs. A phase that is not conducting needs a freewheeling path in the inverter, such as the MOSFET body diode. ## Datasheet and sources Take rs and ls as half the line-to-line resistance and inductance, and ke as half the line-to-line back-EMF constant in V·s/rad, which is half the torque constant in N·m/A with two phases conducting. Take poles and j from the datasheet and hall0 from the Hall phasing diagram. ## Example Open the example with the command `file.openExample` and the name `demo:bldc`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # DC Machine (`dc`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/machines/dc/ > A DC motor with separate armature and field windings. ![dc](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/dc.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/machines/dc/) **Group:** Machines · **Kind:** `{"kind":"machine","model":"dc"}` ## When to use it Use it when you need field control, field weakening, or a shunt or series connection. Use PM DC Machine when magnets make the field. ## Pins | Pin | Domain | Meaning | |---|---|---| | `ap` | electrical | Armature positive, current in gives positive torque | | `an` | electrical | Armature negative terminal | | `fp` | electrical | Field positive, current in makes a positive field | | `fn` | electrical | Field negative terminal | | `shaft` | mechanical | Mechanical shaft, speed in rad/s | ## Common parameters - `ra`: Resistance of the armature winding (Default: 0.5) - `la`: Inductance of the armature winding (Default: 5m) - `laf`: Field-armature coupling; illustrative default (Default: 1) - `rf`: Resistance of the field winding (Default: 100) - `j`: How strongly the rotor resists speeding up (Default: 0.01) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `ra` | Ω | 0.5 | | Resistance of the armature winding | | `la` | H | 5m | | Inductance of the armature winding | | `rf` | Ω | 100 | | Resistance of the field winding | | `lf` | H | 1 | | Inductance of the field winding | | `laf` | H | 1 | | Field-armature coupling; illustrative default | | `j` | kg·m² | 0.01 | | How strongly the rotor resists speeding up | | `b` | N·m·s/rad | 0 | | Friction that grows with speed | | `w0` | rad/s | 0 | | Shaft speed at the start | _Parameter descriptions are in English in both languages._ ## Model The equations are va = ra·ia + la·dia/dt + laf·if·ωm, vf = rf·if + lf·dif/dt and Te = laf·if·ia, so laf·if acts as the flux constant ke. Armature reaction, brush drop, commutation and field saturation are not modelled. The results are i(M1.a) for the armature, i(M1.f) for the field, wm(M1) and Te(M1). ## Common mistakes - Without field current the machine makes no torque and no back-EMF. Supply the field through fp and fn and let it settle, because the default field time constant is 10 ms. - Full voltage at standstill draws the stall current, which is the voltage divided by ra and far above the rated current. Limit it with a chopper current loop. - The rotor inertia j is already on the shaft, so adding it again as an Inertia part counts it twice. Reversing the field polarity reverses the torque and the back-EMF. Problems rules: `pin.unconnected` ## Datasheet and sources Take ra and la from the armature winding and rf and lf from the field winding. Get laf by dividing the rated back-EMF constant (in V·s/rad at the rated field current) by that field current, and take j from the datasheet. ## Example Open the example with the command `file.openExample` and the name `demo:dc`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # PM DC Machine (`dcPm`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/machines/dcPm/ > A DC motor with magnets and a single armature winding. ![dcPm](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/dcPm.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/machines/dcPm/) **Group:** Machines · **Kind:** `{"kind":"machine","model":"dcPm"}` ## When to use it Use it for small brushed DC motors and servos driven by a chopper or an H-bridge. Use DC Machine when you need to control the field. ## Pins | Pin | Domain | Meaning | |---|---|---| | `ap` | electrical | Armature positive, current in gives positive torque | | `an` | electrical | Armature negative terminal | | `shaft` | mechanical | Mechanical shaft, speed in rad/s | ## Common parameters - `ke`: Voltage made per unit of speed (Default: 0.5) - `ra`: Resistance of the armature winding (Default: 0.5) - `la`: Inductance of the armature winding (Default: 5m) - `j`: How strongly the rotor resists speeding up (Default: 1m) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `ra` | Ω | 0.5 | | Resistance of the armature winding | | `la` | H | 5m | | Inductance of the armature winding | | `ke` | V·s/rad | 0.5 | | Voltage made per unit of speed | | `j` | kg·m² | 1m | | How strongly the rotor resists speeding up | | `b` | N·m·s/rad | 0 | | Friction that grows with speed | | `w0` | rad/s | 0 | | Shaft speed at the start | _Parameter descriptions are in English in both languages._ ## Model The back-EMF constant equals the torque constant. The equations are va = ra·ia + la·dia/dt + ke·ωm and Te = ke·ia, so in steady state the speed is ωm = (va - ra·ia)/ke. When va falls below ke·ωm the current reverses and the machine brakes, which a one-quadrant chopper cannot carry. Brush drop, friction other than b and temperature effects are not modelled. The armature current is i(M1.a). ## Common mistakes - ke in V·s/rad equals the torque constant in N·m/A, so enter it once. Convert values given in V per krpm or mN·m/A first, for example 10 V per krpm is 0.0955 V·s/rad. - The stall current is the voltage divided by ra, far above the continuous rating. Limit the current with a loop, and never start the shaft at full voltage without one. - A buck chopper built on a diode cannot return braking current to the source. Lower the speed reference only slowly, or use a two-quadrant stage, because otherwise the current loop cannot go negative. ## Datasheet and sources Take ke from the back-EMF constant or the torque constant, ra and la from the terminal resistance and inductance, and j from the rotor inertia. Resistance rises with winding temperature, so use the value at the operating temperature. ## Example Open the example with the command `file.openExample` and the name `demo:dcPm`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Induction Machine (`induction`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/machines/induction/ > A three-phase cage motor that runs from the mains or an inverter. ![induction](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/induction.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/machines/induction/) **Group:** Machines · **Kind:** `{"kind":"machine","model":"induction"}` ## When to use it Use it for a cage motor on the mains or an inverter. Use Wound-Rotor Induction to reach the rotor, or Saturating Induction when the iron saturates. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | electrical | Stator phase a, current enters when motoring | | `b` | electrical | Stator phase b, current enters when motoring | | `c` | electrical | Stator phase c, current enters when motoring | | `n` | electrical | Star point, optional | | `shaft` | mechanical | Mechanical shaft, speed in rad/s | ## Common parameters - `poles`: Number of poles of the machine (Default: 4) - `rs`: Stator winding resistance per phase (Default: 0.5) - `rr`: Rotor winding resistance per phase (Default: 0.4) - `lm`: Inductance that magnetizes the core (Default: 60m) - `j`: How strongly the rotor resists speeding up (Default: 0.02) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `rs` | Ω | 0.5 | | Stator winding resistance per phase | | `rr` | Ω | 0.4 | | Rotor winding resistance per phase | | `lls` | H | 2m | | Stator inductance that does not reach the rotor | | `llr` | H | 2m | | Rotor inductance that does not reach the stator | | `lm` | H | 60m | | Inductance that magnetizes the core | | `poles` | — | 4 | | Number of poles of the machine | | `j` | kg·m² | 0.02 | | How strongly the rotor resists speeding up | | `b` | N·m·s/rad | 0 | | Friction that grows with speed | | `w0` | rad/s | 0 | | Shaft speed at the start | _Parameter descriptions are in English in both languages._ ## Model Each phase is the usual equivalent circuit with rs, rr, lls, llr and lm, with the rotor values referred to the stator. The machine tracks stator and rotor flux, and the torque is Te = (3/2)·pp·Im(conj(λs)·is) with pp = poles/2. Current is positive into a, b and c, and Te·ωm above zero means motoring. The rotor inertia j and the friction b sit on the shaft net and add to anything else there. Iron loss and saturation are not modelled. The results are wm(M1), Te(M1) and i(M1.a). ## Common mistakes - poles is the number of poles, not pole pairs, so a 50 Hz motor near 1450 rpm has 4. An odd number is refused. - Enter every resistance and inductance per phase of the equivalent star. A delta resistance divided by 3 gives the star value, and a line-to-line resistance divided by 2 gives the value per phase. - The rotor inertia j is already on the shaft, so add only the load inertia. Leaving shaft unconnected is reported as a problem, although the machine still spins up on its own j. Problems rules: `compile.error`, `pin.unconnected` ## Datasheet and sources Take rs from the DC winding resistance per phase, and get lm, rr, lls and llr from the no-load and locked-rotor tests. Choose poles so the synchronous speed is just above the rated speed, take j from the datasheet, and split a single leakage figure equally between lls and llr. ## Example Open the example with the command `file.openExample` and the name `demo:induction`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Saturating Induction (`inductionSat`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/machines/inductionSat/ > A cage induction motor that saturates at high main flux. ![inductionSat](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/inductionSat.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/machines/inductionSat/) **Group:** Machines · **Kind:** `{"kind":"machine","model":"inductionSat"}` ## When to use it Use it for overexcitation, field weakening and low-frequency starts where the iron saturates. Use Induction Machine when the flux stays in the linear range. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | electrical | Stator phase a, current enters when motoring | | `b` | electrical | Stator phase b, current enters when motoring | | `c` | electrical | Stator phase c, current enters when motoring | | `n` | electrical | Star point, optional | | `shaft` | mechanical | Mechanical shaft, speed in rad/s | ## Common parameters - `psik`: Flux level where saturation starts (Default: 0.2) - `lmsat`: Inductance once the core is saturated (Default: 15m) - `lm`: Inductance before the core saturates (Default: 60m) - `poles`: Number of poles of the machine (Default: 4) - `rs`: Stator winding resistance per phase (Default: 0.5) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `rs` | Ω | 0.5 | | Stator winding resistance per phase | | `rr` | Ω | 0.4 | | Rotor winding resistance per phase | | `lls` | H | 2m | | Stator inductance that does not reach the rotor | | `llr` | H | 2m | | Rotor inductance that does not reach the stator | | `lm` | H | 60m | | Inductance before the core saturates | | `psik` | Wb | 0.2 | | Flux level where saturation starts | | `lmsat` | H | 15m | | Inductance once the core is saturated | | `poles` | — | 4 | | Number of poles of the machine | | `j` | kg·m² | 0.02 | | How strongly the rotor resists speeding up | | `b` | N·m·s/rad | 0 | | Friction that grows with speed | | `w0` | rad/s | 0 | | Shaft speed at the start | _Parameter descriptions are in English in both languages._ ## Model It has the parameters of Induction Machine plus psik and lmsat. With the magnetizing flux amplitude ψm = abs(λs - lls·is), the curve is linear with slope lm up to psik and has slope lmsat above it. The model uses the secant inductance Lm = ψm/im, which falls from lm to lmsat. Lm comes from the last accepted step, so saturation lags by one step. The leakage inductances stay constant, and there is no cross-saturation. ## Common mistakes - lmsat must not exceed lm, or the run is refused. Setting psik to 0 turns saturation off and gives the plain Induction Machine. - psik is a flux amplitude in Wb, the peak phase flux, not an RMS voltage or a current. A knee set below the rated flux saturates the machine at rated operation, and poles is a pole count, not pole pairs. - The inductance changes every step, so the fast solver refactors every step and the run is slower. The rotor inertia j is already on the shaft, so do not add it again. Problems rules: `compile.error` ## Datasheet and sources Take rs, rr, lls, llr and poles as for Induction Machine, and take lm as the unsaturated value from the low-voltage no-load test. psik is the flux where the no-load current curve bends, about the peak phase voltage there divided by the electrical frequency in rad/s, and lmsat follows from the slope above the knee. ## Example Open the example with the command `file.openExample` and the name `demo:inductionSat`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Wound-Rotor Induction (`inductionWound`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/machines/inductionWound/ > A three-phase induction motor with the rotor windings brought out. ![inductionWound](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/inductionWound.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/machines/inductionWound/) **Group:** Machines · **Kind:** `{"kind":"machine","model":"inductionWound"}` ## When to use it Use it when you must connect something to the rotor, such as resistors or a converter. Use Induction Machine when the rotor is shorted anyway. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | electrical | Stator phase a, current enters when motoring | | `b` | electrical | Stator phase b, current enters when motoring | | `c` | electrical | Stator phase c, current enters when motoring | | `n` | electrical | Star point, optional | | `ra` | electrical | Rotor phase a, at slip frequency | | `rb` | electrical | Rotor phase b, at slip frequency | | `rc` | electrical | Rotor phase c, at slip frequency | | `shaft` | mechanical | Mechanical shaft, speed in rad/s | ## Common parameters - `poles`: Number of poles of the machine (Default: 4) - `rs`: Stator winding resistance per phase (Default: 0.5) - `rr`: Rotor winding resistance per phase (Default: 0.4) - `lm`: Inductance that magnetizes the core (Default: 60m) - `j`: How strongly the rotor resists speeding up (Default: 0.02) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `rs` | Ω | 0.5 | | Stator winding resistance per phase | | `rr` | Ω | 0.4 | | Rotor winding resistance per phase | | `lls` | H | 2m | | Stator inductance that does not reach the rotor | | `llr` | H | 2m | | Rotor inductance that does not reach the stator | | `lm` | H | 60m | | Inductance that magnetizes the core | | `poles` | — | 4 | | Number of poles of the machine | | `j` | kg·m² | 0.02 | | How strongly the rotor resists speeding up | | `b` | N·m·s/rad | 0 | | Friction that grows with speed | | `w0` | rad/s | 0 | | Shaft speed at the start | _Parameter descriptions are in English in both languages._ ## Model It has the same parameters as Induction Machine. Stator and rotor are both star connected, and the rotor has its own internal neutral. Rotor values are referred to the stator with a turns ratio of 1 and live in the rotor frame, with λs = Ls·is + lm·exp(jθr)·ir and λr = Lr·ir + lm·exp(-jθr)·is, where θr = pp·θm. Shorting ra, rb and rc together gives the plain Induction Machine. The rotor currents are i(M1.ra), i(M1.rb) and i(M1.rc). ## Common mistakes - Open rotor terminals carry no current, so the machine makes no torque. Short ra, rb and rc together or connect a rotor circuit. - The rotor values must be referred to the stator. Multiply the real rotor resistance and inductance by the square of the stator-to-rotor turns ratio, and expect rotor voltages at slip frequency, not line frequency. - poles is the number of poles, not pole pairs, and every value is per phase of the equivalent star. The rotor inertia j is already on the shaft, so do not add it again. Problems rules: `pin.unconnected` ## Datasheet and sources Take rs, lls and lm as for Induction Machine. Multiply the rotor winding resistance and leakage by the square of the turns ratio to get rr and llr, and find the turns ratio from the rotor open-circuit voltage at standstill. ## Example Open the example with the command `file.openExample` and the name `demo:inductionWound`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Interior PMSM (`ipmsm`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/machines/ipmsm/ > A magnet motor with different d and q inductances, so it also makes reluctance torque. ![ipmsm](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/ipmsm.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/machines/ipmsm/) **Group:** Machines · **Kind:** `{"kind":"machine","model":"ipmsm"}` ## When to use it Use it for magnet motors with salient poles, such as traction and compressor drives. Use Surface PMSM when the two inductances are equal. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | electrical | Stator phase a, current enters when motoring | | `b` | electrical | Stator phase b, current enters when motoring | | `c` | electrical | Stator phase c, current enters when motoring | | `n` | electrical | Star point, optional | | `shaft` | mechanical | Mechanical shaft, speed in rad/s | ## Common parameters - `psif`: Magnetic flux of the magnets per phase (Default: 0.1) - `ld`: Inductance along the magnet axis (Default: 1m) - `lq`: Inductance across the magnet axis (Default: 2m) - `rs`: Stator winding resistance per phase (Default: 0.2) - `poles`: Number of poles of the machine (Default: 8) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `rs` | Ω | 0.2 | | Stator winding resistance per phase | | `ld` | H | 1m | | Inductance along the magnet axis | | `lq` | H | 2m | | Inductance across the magnet axis | | `l0` | H | optional (off) | | Inductance of the neutral path | | `psif` | Wb | 0.1 | | Magnetic flux of the magnets per phase | | `poles` | — | 8 | | Number of poles of the machine | | `j` | kg·m² | 1m | | How strongly the rotor resists speeding up | | `b` | N·m·s/rad | 0 | | Friction that grows with speed | | `w0` | rad/s | 0 | | Shaft speed at the start | | `theta0` | rad | 0 | | Rotor position at the start | _Parameter descriptions are in English in both languages._ ## Model It shares the dq model of Surface PMSM, with λd = ld·id + psif and λq = lq·iq. The torque is Te = (3/2)·pp·(psif·iq + (ld - lq)·id·iq), so when lq is larger than ld the reluctance part is positive for id below zero. In stationary variables the flux has a saliency term at twice the electrical angle. The zero sequence uses the mean (ld + lq)/2, and there is no iron loss or saturation. ## Common mistakes - Do not swap ld and lq. An interior machine usually has the larger lq, and swapped values flip the reluctance term so a negative id then lowers the torque. - A controller that holds id at 0 uses only the magnet torque and wastes the reluctance torque. Give it an id reference below zero for the most torque per ampere. - As for Surface PMSM, the rotor angle must come from a Position Sensor whose theta0 matches the machine theta0 divided by the pole pairs. Open-loop operation falls out of step past the pull-out torque, and poles is a pole count, not pole pairs. ## Datasheet and sources Take rs as half the line-to-line resistance of the star winding, and take ld and lq from the datasheet or a finite-element result because they are not the line-to-line inductance. Get psif from the back-EMF constant as for Surface PMSM. ## Example Open the example with the command `file.openExample` and the name `demo:ipmsm`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Surface PMSM (`spmsm`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/machines/spmsm/ > A magnet motor whose d and q inductances are equal. ![spmsm](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/spmsm.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/machines/spmsm/) **Group:** Machines · **Kind:** `{"kind":"machine","model":"spmsm"}` ## When to use it Use it for servo and traction drives with a magnet rotor. Use Interior PMSM when the q inductance is larger, and BLDC Machine for a trapezoidal back-EMF. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | electrical | Stator phase a, current enters when motoring | | `b` | electrical | Stator phase b, current enters when motoring | | `c` | electrical | Stator phase c, current enters when motoring | | `n` | electrical | Star point, optional | | `shaft` | mechanical | Mechanical shaft, speed in rad/s | ## Common parameters - `psif`: Magnetic flux of the magnets per phase (Default: 0.1) - `poles`: Number of poles of the machine (Default: 8) - `rs`: Stator winding resistance per phase (Default: 0.2) - `ls`: Stator inductance per phase (Default: 1m) - `j`: How strongly the rotor resists speeding up (Default: 1m) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `rs` | Ω | 0.2 | | Stator winding resistance per phase | | `ls` | H | 1m | | Stator inductance per phase | | `l0` | H | optional (off) | | Inductance of the neutral path | | `psif` | Wb | 0.1 | | Magnetic flux of the magnets per phase | | `poles` | — | 8 | | Number of poles of the machine | | `j` | kg·m² | 1m | | How strongly the rotor resists speeding up | | `b` | N·m·s/rad | 0 | | Friction that grows with speed | | `w0` | rad/s | 0 | | Shaft speed at the start | | `theta0` | rad | 0 | | Rotor position at the start | _Parameter descriptions are in English in both languages._ ## Model The machine is written in the dq frame: vd = rs·id + dλd/dt - ωe·λq and vq = rs·iq + dλq/dt + ωe·λd, with λd = Ld·id + psif, λq = Lq·iq, ωe = pp·ωm and Ld = Lq = ls. The torque is Te = (3/2)·pp·psif·iq, so id = 0 gives the most torque per ampere. With the stator open, the line-to-line back-EMF amplitude is sqrt(3)·psif·ωe. There is no cogging or iron loss, and the zero-sequence path through n uses ls. ## Common mistakes - The controller does not know the rotor angle by itself. Field-oriented control needs the angle from a Position Sensor on the same shaft, and the sensor theta0 (mechanical) must equal the machine theta0 (electrical) divided by the pole pairs, or the current vector sits at the wrong angle. - Driving it open loop from a fixed or ramped three-phase source works only for small loads and slow ramps. When the load passes the pull-out torque, the machine falls out of step and its average torque drops to zero. - psif is the peak flux per phase, not a line-to-line voltage constant, and poles is the pole count, not pole pairs. A wrong factor of the square root of 3 or of the pole pairs spoils the torque and the back-EMF by the same factor. ## Datasheet and sources Take rs and ls as half the line-to-line resistance and inductance of the star winding, and take poles and j from the datasheet. psif is the peak line-to-line back-EMF per mechanical rad/s divided by the square root of 3 and by the pole pairs, and a value in V rms per krpm gets there by multiplying by the square root of 2 and dividing by 104.72. ## Example Open the example with the command `file.openExample` and the name `demo:spmsm`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Switched Reluctance (`srm`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/machines/srm/ > A motor with no magnets whose phase inductance changes with rotor angle. ![srm](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/srm.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/machines/srm/) **Group:** Machines · **Kind:** `{"kind":"machine","model":"srm"}` ## When to use it Use it for magnet-free drives that excite one phase at a time from an asymmetric half-bridge. Use Stepper Motor for open-loop stepping. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p1+` | electrical | Phase 1 positive end, current enters here | | `p1-` | electrical | Phase 1 negative end | | `p2+` | electrical | Phase 2 positive end, current enters here | | `p2-` | electrical | Phase 2 negative end | | `p3+` | electrical | Phase 3 positive end, current enters here | | `p3-` | electrical | Phase 3 negative end | | `p4+` | electrical | Phase 4 positive end, only with 4 phases | | `p4-` | electrical | Phase 4 negative end, only with 4 phases | | `shaft` | mechanical | Mechanical shaft, speed in rad/s | ## Common parameters - `phases`: Number of phases, 3 or 4 (Default: 3) - `lu`: Phase inductance when poles are apart (Default: 2m) - `la`: Phase inductance when poles line up (Default: 20m) - `isat`: Current where the aligned core saturates (Default: 10) - `r`: Resistance of each phase (Default: 0.1) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `phases` | — | 3 | | Number of phases, 3 or 4 | | `nr` | — | 0 | | Number of rotor poles | | `r` | Ω | 0.1 | | Resistance of each phase | | `lu` | H | 2m | | Phase inductance when poles are apart | | `la` | H | 20m | | Phase inductance when poles line up | | `isat` | A | 10 | | Current where the aligned core saturates | | `j` | kg·m² | 5m | | How strongly the rotor resists speeding up | | `b` | N·m·s/rad | 0 | | Friction that grows with speed | | `w0` | rad/s | 0 | | Shaft speed at the start | | `theta0` | rad | 0 | | Rotor angle at the start | _Parameter descriptions are in English in both languages._ ## Model Each phase has the flux linkage λ(i, θ) = lu·i + (la - lu)·s(θ)·isat·tanh(i/isat), where s is the overlap, 1 when aligned and 0 when unaligned. The torque is the angle derivative of the co-energy, so it does not depend on the current sign. Phase 1 is aligned at angle 0 and phase k at (k - 1)·2π/(phases·nr), so exciting 1, 2, 3 in order turns the rotor forward. The phases do not couple, and theta(M1) is the mechanical angle. ## Common mistakes - A three-phase sine source does nothing useful, because each phase must be excited in turn while its inductance rises, in the order 1, 2, 3. Switch each phase with an asymmetric half-bridge driven by the angle from a Position Sensor. - Turn a phase off before its inductance starts to fall, or it makes negative torque. At the aligned position the torque is zero, so a rotor resting there cannot start, and theta0 should avoid that point. - la must not be below lu, or the run is refused. A very large isat turns saturation off, and nr set to 0 picks 4 rotor poles for three phases and 6 for four phases. Problems rules: `compile.error` ## Datasheet and sources lu and la are the smallest and largest phase inductance in the inductance-versus-angle plot, and isat is the current where the aligned flux curve bends over. r is the phase resistance, nr is the rotor tooth count (a 6/4 machine has 4), and j is the rotor inertia. ## Example Open the example with the command `file.openExample` and the name `demo:srm`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Stepper Motor (`stepper`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/machines/stepper/ > A two-phase hybrid stepper motor with a magnet rotor. ![stepper](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/stepper.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/machines/stepper/) **Group:** Machines · **Kind:** `{"kind":"machine","model":"stepper"}` ## When to use it Use it for open-loop positioning with a driver that switches the winding currents. Use BLDC Machine or Surface PMSM for continuous rotation under feedback. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a+` | electrical | Winding a positive end, current enters here | | `a-` | electrical | Winding a negative end | | `b+` | electrical | Winding b positive end, current enters here | | `b-` | electrical | Winding b negative end | | `shaft` | mechanical | Mechanical shaft, speed in rad/s | ## Common parameters - `steps`: Full steps per turn (Default: 200) - `kt`: Torque made per amp of phase current (Default: 0.5) - `r`: Winding resistance per phase (Default: 1.5) - `l`: Winding inductance per phase (Default: 3m) - `j`: How strongly the rotor resists speeding up (Default: 5u) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `r` | Ω | 1.5 | | Winding resistance per phase | | `l` | H | 3m | | Winding inductance per phase | | `kt` | N·m/A | 0.5 | | Torque made per amp of phase current | | `steps` | — | 200 | | Full steps per turn | | `detent` | N·m | 10m | | Holding torque with the windings off | | `j` | kg·m² | 5u | | How strongly the rotor resists speeding up | | `b` | N·m·s/rad | 0 | | Friction that grows with speed | | `w0` | rad/s | 0 | | Shaft speed at the start | | `theta0` | rad | 0 | | Rotor position at the start | _Parameter descriptions are in English in both languages._ ## Model With Nr = steps/4 rotor teeth, the electrical angle is θe = Nr·θm. The flux is λa = l·ia + (kt/Nr)·cos(θe) and λb = l·ib + (kt/Nr)·sin(θe). The torque is Te = kt·(-ia·sin(θe) + ib·cos(θe)) - detent·sin(4·θe). One phase carrying I holds with a peak torque kt·I. Energizing +a, +b, -a, -b in turn moves the balance point by 90 electrical degrees, which is one full step of 2π/steps radians. The two windings do not couple. ## Common mistakes - A stepper rings and resonates at low speed. Add viscous friction b or load damping, use microstepping with sine currents, and avoid stepping at the rotor's natural frequency. - The driver sets the current, so supply each winding from an H-bridge that can reverse it. A plain voltage source lets the current rise only with the winding time constant, and the torque falls at high step rates. - steps is the number of full steps per turn, a multiple of 4 from 4 to 4000 (200 for 1.8 degrees), or the run is refused. theta0 is an electrical angle, steps/4 times the mechanical angle, and the motor loses steps when the load or the acceleration exceeds the torque it can give. Problems rules: `compile.error` ## Datasheet and sources r and l are the winding resistance and inductance per phase, steps is 360 divided by the step angle, and detent is the detent torque. kt is the holding torque divided by the rated current (divide by the square root of 2 times the current if both phases were on), and j is the rotor inertia, where 1 g·cm² is 1e-7 kg·m². ## Example Open the example with the command `file.openExample` and the name `demo:stepper`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Wound-Field Synchronous (`syncWound`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/machines/syncWound/ > A synchronous machine with a field winding and optional damper windings. ![syncWound](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/syncWound.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/machines/syncWound/) **Group:** Machines · **Kind:** `{"kind":"machine","model":"syncWound"}` ## When to use it Use it for synchronous motors and generators where the field current sets the excitation. Use Surface PMSM for a magnet rotor. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | electrical | Stator phase a, current enters when motoring | | `b` | electrical | Stator phase b, current enters when motoring | | `c` | electrical | Stator phase c, current enters when motoring | | `n` | electrical | Star point, optional | | `fp` | electrical | Field positive, current in magnetizes the d axis | | `fn` | electrical | Field negative terminal | | `shaft` | mechanical | Mechanical shaft, speed in rad/s | ## Common parameters - `lmd`: Main flux inductance along the field axis (Default: 40m) - `lmq`: Main flux inductance across the field axis (Default: 25m) - `rf`: Resistance of the field winding (Default: 5) - `poles`: Number of poles of the machine (Default: 4) - `j`: How strongly the rotor resists speeding up (Default: 0.05) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `rs` | Ω | 0.1 | | Stator winding resistance per phase | | `lls` | H | 2m | | Stator inductance that does not reach the rotor | | `lmd` | H | 40m | | Main flux inductance along the field axis | | `lmq` | H | 25m | | Main flux inductance across the field axis | | `rf` | Ω | 5 | | Resistance of the field winding | | `llf` | H | 3m | | Leakage inductance of the field winding | | `rkd` | Ω | 0 | | Resistance of the field-axis damper | | `llkd` | H | 1m | | Leakage inductance of the field-axis damper | | `rkq` | Ω | 0 | | Resistance of the cross-axis damper | | `llkq` | H | 1m | | Leakage inductance of the cross-axis damper | | `poles` | — | 4 | | Number of poles of the machine | | `j` | kg·m² | 0.05 | | How strongly the rotor resists speeding up | | `b` | N·m·s/rad | 0 | | Friction that grows with speed | | `w0` | rad/s | 0 | | Shaft speed at the start | | `theta0` | rad | 0 | | Rotor position at the start | _Parameter descriptions are in English in both languages._ ## Model The rotor model has stator, field and damper windings, with Te = (3/2)·pp·(λd·iq - λq·id). The field current is referred to the stator, so a field current If gives an open-circuit phase EMF with peak ωe·lmd·If. In steady state If = Vf/rf, and a locked field has the time constant (llf + 1.5·lmd)/rf. A damper exists only when rkd or rkq is above zero. The field current is i(M1.f). ## Common mistakes - The stator alone gives no starting torque. Start the rotor near synchronous speed with w0, or add a damper by setting rkd above zero and bring it up asynchronously, and always feed the field. - With rkd and rkq at their default of 0 there are no dampers, so the rotor swings against a stiff source with almost no damping. Add dampers to see a realistic decay of the swing. - A load above the pull-out torque makes the rotor fall out of step. The field values rf and llf are terminal values, not referred to the stator, and poles is a pole count, not pole pairs. Problems rules: `pin.unconnected` ## Datasheet and sources Get lmd and lmq from the d-axis and q-axis synchronous reactances minus the leakage, divided by the electrical frequency in rad/s, and treat lls the same way. The open-circuit test on the air-gap line also gives lmd, and rf and llf come from the field winding, with rkd, llkd, rkq and llkq from the damper data. ## Example Open the example with the command `file.openExample` and the name `demo:syncWound`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Common-Mode Choke (`cmChoke`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/cmChoke/ > Two equal coupled windings that block common-mode noise and pass the load current. ![cmChoke](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/cmChoke.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/magnetics/cmChoke/) **Group:** Magnetics · **Kind:** `{"kind":"cmChoke"}` ## When to use it Use it in the input filter of a converter, one winding in the supply line and one in the return. For one line only, use Inductor. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p1` | electrical | Winding 1, dotted end; put it on the supply side of the line | | `n1` | electrical | Winding 1, other end | | `p2` | electrical | Winding 2, dotted end; put it on the supply side of the return | | `n2` | electrical | Winding 2, other end | ## Common parameters - `l`: Inductance of each winding (Default: 6.8m) - `lstray`: Stray inductance: one winding with the other shorted (Default: 80u) - `rdc`: Wire resistance of each winding (Default: 0.17) - `irated`: Rated current of each winding; a peak above it raises a warning (Default: 2) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `l` | H | 6.8m | | Inductance of each winding | | `lstray` | H | 80u | | Stray inductance: one winding with the other shorted | | `rdc` | Ω | 0.17 | | Wire resistance of each winding | | `irated` | A | 2 | | Rated current of each winding; a peak above it raises a warning | _Parameter descriptions are in English in both languages._ **Use for:** Converter input filters · Mains EMI filters · Common-mode noise **Not for:** Filtering one line → [`inductor`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/inductor/) · Noise above 30 MHz → [`ferriteBead`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/ferriteBead/) ## Formulas | Formula | Equation | Source | |---|---|---| | Coupling factor | k = √(1 − Lstray/L) | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 13 (coupling coefficient) | | Common-mode inductance | Lcm = (L + M)/2, M = k·L | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 13 (mutual inductance) | | Differential-mode inductance | Ldm = 2·(L − M) | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 13 (mutual inductance) | | Corner with the Y capacitors | f = 1/(2π·√(Lcm·2·Cy)) | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 16 (resonance) | ## Quick check Inputs: - `l`: Inductance per winding = 6.8m H, `l` - `lstray`: Stray inductance = 80u H, `lstray` - `cy`: Y capacitance per line = 4.7n F Outputs: - `k`: Coupling factor = `sqrt(1 - lstray/l)` — - `lcm`: Common-mode inductance = `(l + k*l)/2` H - `ldm`: Differential-mode inductance = `2*(l - k*l)` H - `fcm`: Common-mode corner = `1/(2*pi*sqrt(lcm*2*cy))` Hz ## Model logic - Each winding is the inductance l behind its DC resistance rdc, and the two are coupled with k = sqrt(1 - lstray/l). - A common-mode current, the same way through both windings, sees about (l + M)/2; a differential current sees 2·(l - M), close to lstray. - The core does not saturate and has no loss or winding capacitance, so the impedance keeps rising with frequency. - A warning appears when a winding current peaks above irated; the currents are i(name.1) and i(name.2). ## Model Each winding has the inductance l and sits behind its DC resistance rdc. The two are coupled with k = sqrt(1 - lstray / l), so lstray is the inductance of one winding with the other shorted. A common-mode current, the same way through both windings, sees (l + M) / 2 with the windings in parallel, close to l. A differential current, out through one winding and back through the other, sees 2 * (l - M), close to lstray. The core does not saturate, the winding capacitance and the core loss are not modelled, so the impedance keeps rising with frequency. A warning appears when a winding current peaks above irated. The currents are i(name.1) and i(name.2). ## Common mistakes - The dots must be on the same side. With one winding turned round, the load current no longer cancels and sees the full l. - A choke alone does little against common-mode noise without a path for it. Add Y capacitors from each line to ground on the converter side. Problems rules: `island.floating`, `param.out_of_range` ## Datasheet and sources Take l from the nominal inductance (it is given per winding), lstray from the stray inductance column and rdc from the DC resistance per winding. irated is the rated current. The defaults are the TDK B82724A2202N001 (2 A, 6.8 mH), B82724A/J data sheet of April 2026, characteristics table on page 5. ## Example Open the example with the command `file.openExample` and the name `demo:cmChoke`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Coupled Inductor (`coupledInductor`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/coupledInductor/ > Two windings that share magnetic flux, with a coupling coefficient k. ![coupledInductor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/coupledInductor.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/magnetics/coupledInductor/) **Group:** Magnetics · **Kind:** `{"kind":"coupledInductor"}` ## When to use it Use it for flyback converters, coupled-inductor converters and transformers with leakage. Use Transformer for an ideal turns ratio. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p1` | electrical | Winding 1, dotted end; positive current enters here | | `n1` | electrical | Winding 1, other end | | `p2` | electrical | Winding 2, dotted end; positive current enters here | | `n2` | electrical | Winding 2, other end | ## Common parameters - `l1`: Inductance of the first winding (Default: required) - `l2`: Inductance of the second winding (Default: required) - `k`: How tightly the two windings are linked (Default: 0.99) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `l1` | H | required | | Inductance of the first winding | | `l2` | H | required | | Inductance of the second winding | | `k` | — | 0.99 | | How tightly the two windings are linked | | `coupledCurve` | — | optional (off) | | Incremental inductances of the two windings against the core's magnetizing current from a field solve; rows i:L11:M:L22 in A and H from 0 A, such as 0:1e-4:9.8e-5:1e-4, 2:6e-5:5.8e-5:6e-5; sets the coupling in place of k | | `rw1` | Ω | 0 | | Wire resistance of the first winding | | `rw2` | Ω | 0 | | Wire resistance of the second winding | | `rcore` | Ω | optional (off) | | Resistance across the first winding that models core loss | | `surface` | m² | optional (off) | | Outside surface of the wound part to the air; design.thermal gives its temperature rise from it and the loss | _Parameter descriptions are in English in both languages._ **Use for:** Flyback converters · Coupled-inductor converters · Transformers with leakage **Not for:** Ideal turns ratio and isolation → [`transformer`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/transformer/) · Common-mode EMI filtering → [`cmChoke`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/cmChoke/) ## Formulas | Formula | Equation | Source | |---|---|---| | Mutual inductance | M = k·√(l1·l2) | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 13 (coefficient of coupling) | | Leakage seen from winding 1 | Llk = l1·(1 − k²) | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 13 (input impedance with the second winding shorted) | | Turns ratio | n = √(l1 / l2) | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), ch. 10 (L ∝ N² on one core) | ## Quick check Inputs: - `l1`: Inductance of winding 1 = 100u H, `l1` - `l2`: Inductance of winding 2 = 25u H, `l2` - `k`: Coupling coefficient = 990m —, `k` Outputs: - `m`: Mutual inductance = `k*sqrt(l1*l2)` H - `llk`: Leakage inductance = `l1*(1 - k^2)` H - `n`: Turns ratio = `sqrt(l1/l2)` — ## Model logic - The two windings are stamped together as a 2 by 2 conductance matrix with current sources (trapezoidal or backward Euler), with M = k·√(l1·l2). - k must satisfy 0 <= k < 1, or the run is refused; both winding currents start at zero, and there is no initial-current parameter. - With coupledCurve set, the inductance matrix at the currents of the previous accepted step replaces l1, l2 and k, and k only draws a warning. - Winding resistance, core loss and a two-slope saturation are not modelled; add series resistors yourself. ## Model The windings obey v1 = l1 * di1/dt + M * di2/dt and v2 = M * di1/dt + l2 * di2/dt with M = k * sqrt(l1 * l2). Both currents are positive into the dotted ends. k must satisfy 0 <= k < 1 (default 0.99), and the leakage inductance of winding 1 is about l1 * (1 - k^2). Winding resistance, core loss, saturation and initial currents are not modelled. ## Common mistakes - A k of 1 is refused, so use 0.999 for a near-ideal pair. The p1 and p2 pins are the dots, and swapping the connections of one winding reverses the polarity. - A winding with no path to ground floats. Inductance is in henry, so 100 means 100 H, not 100u. Problems rules: `island.floating`, `param.out_of_range` ## Datasheet and sources l1 and l2 are the inductances measured at each winding with the other one open. k comes from the leakage measurement: k = sqrt(1 - Lleak / l1), where Lleak is measured on winding 1 with winding 2 shorted. ## Example Open the example with the command `file.openExample` and the name `demo:coupledInductor`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Flux Probe (`fluxProbe`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/fluxProbe/ > Reads the flux, or the flux density, through a magnetic path as a signal. ![fluxProbe](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/fluxProbe.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/magnetics/fluxProbe/) **Group:** Magnetics · **Kind:** `{"element":"fluxProbe","kind":"magnetic"}` ## When to use it Use it to check the peak flux density of a core against Bsat, or to feed the flux to control. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | magnetic | Flux enters here | | `b` | magnetic | Flux leaves here | | `out` | signal | The flux in Wb, or the flux density in T when ae is set | ## Common parameters - `ae`: Area the flux is divided by: with it the output is the flux density (T), without it the flux (Wb) (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `ae` | m² | optional (off) | | Area the flux is divided by: with it the output is the flux density (T), without it the flux (Wb) | _Parameter descriptions are in English in both languages._ **Use for:** Peak flux density against Bsat · Flux as a control signal · Flux walking with a DC offset **Not for:** Electrical voltages → [`voltmeter`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/meters/voltmeter/) ## Formulas | Formula | Equation | Source | |---|---|---| | Flux change over the on time | ΔΦ = v·ton / N | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), ch. 10 (Faraday's law) | | Flux density change | ΔB = v·ton / (N·Ae) | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), ch. 10 (Faraday's law) | ## Quick check Inputs: - `v`: Winding voltage while on = 48 V - `ton`: On time = 5u s - `n`: Turns of the winding = 12 - - `ae`: Area of the leg = 100u m², `ae` - `bsat`: Saturation flux density = 300m T Outputs: - `dphi`: Flux change over the on time = `v*ton/n` Wb - `db`: Flux density change = `dphi/ae` T - `margin`: Margin to Bsat = `bsat - db` T ## Model logic - It is a gyrator port in series with the path, shorted so it adds no reluctance; the flux rate through it from a to b drives an inner node. - That rate charges a 1 F capacitor integrated with the step's own method, starting at zero, so its voltage is the flux. - out = Phi, or Phi / ae when ae is set; a non-positive ae stops the build. The inner nodes are recorded as v(name:rate) and v(name:flux). ## Model The probe sits in series in the path and adds no reluctance. It integrates the flux rate from a to b with the solver's own method, starting at zero, so out = Phi or Phi / ae. ## Common mistakes - The flux starts at zero, so a core that starts magnetized needs a run long enough to settle, or a winding current that sets it. - The probe reads only the flux of the branch it is in series with. Put it in the leg you want to check, not across a gap or a winding. ## Datasheet and sources Set ae to the effective area of the core leg the probe sits in, from the core data sheet. ## Example Open the example with the command `file.openExample` and the name `demo:fluxProbe`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Leakage Path (`leakagePath`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/leakagePath/ > A linear flux path that returns flux outside the core, so windings link less than all of it. ![leakagePath](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/leakagePath.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/magnetics/leakagePath/) **Group:** Magnetics · **Kind:** `{"element":"leakagePath","kind":"magnetic"}` ## When to use it Use it beside a winding, or between the legs of a core, to give the coupling less than one that measured leakage inductance shows. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | magnetic | One end of the path | | `b` | magnetic | The other end | ## Common parameters - `r`: Reluctance of the flux path; when set, the geometry is not used (Default: optional (off)) - `p`: Permeance of the leakage path (1/r); set this or r (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `r` | A/Wb | optional (off) | | Reluctance of the flux path; when set, the geometry is not used | | `p` | H | optional (off) | | Permeance of the leakage path (1/r); set this or r | _Parameter descriptions are in English in both languages._ **Use for:** Measured leakage inductance · Flux between core legs · Leakage in integrated magnetics **Not for:** Core legs and air gaps → [`reluctance`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/reluctance/) ## Formulas | Formula | Equation | Source | |---|---|---| | Leakage permeance | P = Lleak / N² | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), ch. 10 (L = N²·P) | | Leakage reluctance | R = N² / Lleak | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), ch. 10 (magnetic circuits) | | Share of the winding's flux that leaks | Lleak / (Lm + Lleak) | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), ch. 10 (parallel flux paths) | ## Quick check Inputs: - `llk`: Measured leakage inductance = 4.5u H - `n`: Turns of the winding = 30 - - `lm`: Magnetizing inductance = 450u H Outputs: - `perm`: Leakage permeance = `llk/n^2` H - `rel`: Leakage reluctance = `1/perm` A/Wb - `share`: Share of the winding's flux that leaks = `llk/(lm + llk)` - ## Model logic - It is a capacitor of value p, or 1/r, between magnetic nodes, the same element as Reluctance. - Exactly one of r and p must be set; both, neither or a non-positive r stops the build. - The path is linear and never saturates, which suits flux that runs through air. ## Model The path is a permeance p, or 1 / r, between its ends, as a Reluctance is. Set exactly one of r and p. ## Common mistakes - A leakage path across a winding by itself takes flux that links only that winding: its leakage inductance is n^2 * p. - p is a permeance in henry per turn squared, so a leakage of a few microhenry on 30 turns is only a few nanohenry of p. ## Datasheet and sources Work p out from a measured leakage inductance: p = Lleak / n^2, with Lleak measured on that winding with the others shorted. ## Example Open the example with the command `file.openExample` and the name `demo:leakagePath`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Multi-Winding Transformer (`multiTransformer`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/multiTransformer/ > A transformer with one primary and up to three secondaries on one core, each secondary with its own turns ratio, leakage and winding resistance. ![multiTransformer](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/multiTransformer.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/magnetics/multiTransformer/) **Group:** Magnetics · **Kind:** `{"kind":"multiTransformer"}` ## When to use it Use it for a multi-output flyback or forward converter, or any supply whose outputs share one transformer, such as the design magnetics.design gives with secondaries. For one secondary, Transformer does the same with fewer parameters. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p1` | electrical | Primary, dotted end; positive current enters here | | `n1` | electrical | Primary, other end | | `p2` | electrical | Winding 2, dotted end | | `n2` | electrical | Winding 2, other end | | `p3` | electrical | Winding 3, dotted end; open when n3 is unset | | `n3` | electrical | Winding 3, other end; open when n3 is unset | | `p4` | electrical | Winding 4, dotted end; open when n4 is unset | | `n4` | electrical | Winding 4, other end; open when n4 is unset | ## Common parameters - `n2`: Turns ratio, primary to winding 2 (Default: 1) - `n3`: Turns ratio, primary to winding 3; unset leaves winding 3 off and its pins open (Default: optional (off)) - `n4`: Turns ratio, primary to winding 4; unset leaves winding 4 off and its pins open (Default: optional (off)) - `lm`: Inductance that magnetizes the core, seen from the primary (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `n2` | — | 1 | | Turns ratio, primary to winding 2 | | `n3` | — | optional (off) | | Turns ratio, primary to winding 3; unset leaves winding 3 off and its pins open | | `n4` | — | optional (off) | | Turns ratio, primary to winding 4; unset leaves winding 4 off and its pins open | | `lm` | H | optional (off) | | Inductance that magnetizes the core, seen from the primary | | `im0` | A | 0 | | Magnetizing current at the start, seen from the primary; needs lm | | `llk1` | H | 0 | | Leakage inductance in series with the primary | | `llk2` | H | 0 | | Leakage inductance in series with winding 2 | | `llk3` | H | 0 | | Leakage inductance in series with winding 3 | | `llk4` | H | 0 | | Leakage inductance in series with winding 4 | | `lk12` | H | optional (off) | | Primary leakage, winding 2 shorted: measured at the primary with winding 2 shorted and winding 3 open; with lk13 and lk23 it sets llk1 to llk3 | | `lk13` | H | optional (off) | | Primary leakage, winding 3 shorted: measured at the primary with winding 3 shorted and winding 2 open; with lk12 and lk23 it sets llk1 to llk3 | | `lk23` | H | optional (off) | | Winding 2 leakage, winding 3 shorted: measured at winding 2 with winding 3 shorted and the primary open; with lk12 and lk13 it sets llk1 to llk3 | | `lk14` | H | optional (off) | | Primary leakage, winding 4 shorted: measured at the primary with winding 4 shorted and the others open; with lk12, lk13 and lk23 it sets llk4 | | `lk24` | H | optional (off) | | Winding 2 leakage, winding 4 shorted: measured at winding 2 with winding 4 shorted and the others open; with lk12, lk13, lk23 and lk14 it sets the coupling of windings 2 and 4 | | `lk34` | H | optional (off) | | Winding 3 leakage, winding 4 shorted: measured at winding 3 with winding 4 shorted and the others open; with lk12, lk13, lk23 and lk14 it sets the coupling of windings 3 and 4 | | `rw1` | Ω | 0 | | Wire resistance of the primary | | `rw2` | Ω | 0 | | Wire resistance of winding 2 | | `rw3` | Ω | 0 | | Wire resistance of winding 3 | | `rw4` | Ω | 0 | | Wire resistance of winding 4 | | `rcore` | Ω | optional (off) | | Resistance across the primary that models core loss | | `isat` | A | optional (off) | | Magnetizing current where the core saturates, seen from the primary; needs lm | | `lmsat` | H | optional (off) | | Magnetizing inductance once the core is saturated; a fifth of lm when unset | _Parameter descriptions are in English in both languages._ **Use for:** Isolation · Isolated DC-DC stages **Not for:** One secondary → [`transformer`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/transformer/) · Three-phase transformers → [`transformer3`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/transformer3/) ## Model logic - Each secondary is an ideal transformer whose primary sits across the shared core voltage, so the reflected loads add in parallel on the primary. - rw1 and llk1 sit in front of the core voltage; rwk and llkk sit in series with winding k; zero leaves each one out. - lm sits once across the core voltage and starts at im0, with rcore across it; without lm the core is ideal and passes DC. - isat makes lm a two-slope knee (lmsat, or 0.2·lm, above it) by the previous accepted current. - lk12, lk13, lk23 and lk14 are solved into the star's llk1 to llk4 with lm taken into account; lk24 and lk34 add a coupled inductor in series with winding 2 or 3 and winding 4, carved from their leakages. ## Model Before the run the part is expanded into one ideal two-winding transformer per secondary. Their primary windings all sit across one core voltage, so winding k sees v1 / nk, with nk = N1 / Nk, and its current, referred to the primary, adds to the primary current. rw1 and llk1 sit in series between p1 and the core voltage and are shared by every secondary; rwk and llkk sit in series with winding k only. lm sits once across the core voltage, seen from the primary, and starts at im0. Winding 2 is always on (n2 defaults to 1); windings 3 and 4 are on only when n3 or n4 is set. rcore across the core voltage models core loss, and isat with lmsat saturates lm, as on Transformer. ## Common mistakes - Each nk is N1 / Nk, primary turns over that winding's turns, so a 5 V output from a 100 V core voltage uses nk = 20. - Connecting p3, n3, p4 or n4 without setting that winding's ratio is refused, and so is setting llk3, rw3, llk4 or rw4 without it. Each secondary needs its own path to ground or a reference, as with Transformer. - The leakage of each winding is its own series inductance; the leakage between two secondaries is the sum of theirs. To use the leakages measured between pairs of windings, give lk12, lk13 and lk23 (and lk14 with winding 4 on) instead of llk1 to llk4; lk24 and lk34 add the two pairs with winding 4 that the star cannot hold. The two sets cannot be mixed, and a set no passive part can have is refused with the keys named. Problems rules: `island.floating`, `param.out_of_range` ## Datasheet and sources Each nk is the rated primary voltage over the rated voltage of winding k, or the ratio of turns. lm is the primary inductance measured with every secondary open. llk1 is the leakage measured on the primary with the secondaries shorted; with no split given, put it all in llk1. lk12, lk13 and lk14 are measured at the primary with that winding shorted and the others open, lk23 and lk24 at winding 2 and lk34 at winding 3 the same way. rw1 to rw4 are the DC resistances of the windings. rcore comes from the core loss at the operating point, isat from the core's saturation flux density, and lmsat from the inductance measured past it. ## Example Open the example with the command `file.openExample` and the name `demo:multiTransformer`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Reluctance (`reluctance`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/reluctance/ > A linear flux path: a core leg, an air gap or a whole core, from its geometry or a catalogue core. ![reluctance](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/reluctance.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/magnetics/reluctance/) **Group:** Magnetics · **Kind:** `{"element":"reluctance","kind":"magnetic"}` ## When to use it Use it for every leg of a core that stays well below saturation, and for air gaps. Use Saturable Core for a leg that saturates. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | magnetic | One end of the path | | `b` | magnetic | The other end | ## Common parameters - `r`: Reluctance of the flux path; when set, the geometry is not used (Default: optional (off)) - `core`: Catalogue core or shape that gives the area, path length, permeability and gap (Default: optional (off)) - `ae`: Cross-section area of the flux path (Default: optional (off)) - `le`: Length of the flux path through the core material (Default: optional (off)) - `mur`: Relative permeability of the core material (Default: 1) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `r` | A/Wb | optional (off) | | Reluctance of the flux path; when set, the geometry is not used | | `core` | — | optional (off) | | Catalogue core or shape that gives the area, path length, permeability and gap | | `material` | — | optional (off) | | Core material; needed when core names a shape | | `ae` | m² | optional (off) | | Cross-section area of the flux path | | `le` | m | optional (off) | | Length of the flux path through the core material | | `mur` | — | 1 | | Relative permeability of the core material | | `gap` | m | optional (off) | | Air gap in series with the path; unset uses the catalogue core's gap (none without one) | | `coreTemp` | °C | 25 | | Core temperature the material data is read at | _Parameter descriptions are in English in both languages._ **Use for:** Core legs · Air gaps · A whole linear core **Not for:** A leg that saturates → [`saturableCore`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/saturableCore/) ## Formulas | Formula | Equation | Source | |---|---|---| | Reluctance of the path | R = (lg + le/μr) / (μ0·Ae) | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), ch. 10 (magnetic circuits) | | Permeance (inductance per turn squared) | P = 1 / R | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), ch. 10 (magnetic circuits) | | Inductance of n turns on it | L = N² / R | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), ch. 10 (magnetic circuits) | ## Quick check Inputs: - `ae`: Cross-section area = 100u m², `ae` - `le`: Path length in the core = 100m m, `le` - `mur`: Relative permeability = 2k -, `mur` - `gap`: Air gap = 500u m, `gap` - `n`: Turns of a winding on it = 20 - Outputs: - `rel`: Reluctance of the path = `(gap + le/mur)/(4e-7*pi*ae)` A/Wb - `perm`: Permeance = `1/rel` H - `l`: Inductance of the n turns = `n^2/rel` H - `gapshare`: Share of the reluctance in the gap = `gap/(gap + le/mur)` - ## Model logic - It is a capacitor of value P = 1/R between magnetic nodes: the flux is its charge and the MMF its voltage, integrated with the step's own method (trapezoidal, backward Euler after an event). - P = mu0·ae / (gap + le/mur), or 1/r when r is set, with no fringing; a catalogue core gives ae, le, the initial permeability at coreTemp and its own gap. - The path is linear: no saturation, hysteresis or core loss. - A magnetic network that touches no 0, gnd or GND net is referenced at its first net by name, which is exact because only MMF differences count. ## Model The path is a permeance P = mu0 * ae / (gap + le / mur), or 1 / r when r is set, without fringing. A catalogue core gives ae, le, the initial permeability at coreTemp and its own gap; gap overrides the gap. In the solvers P is a capacitance between magnetic nodes, so the flux is its charge and the MMF its voltage. The MMF of a magnetic net is recorded as F(net). ## Common mistakes - le is the length through the core material only; put the gap in gap. Mixing them up makes the inductance far too high or too low. - A closed core needs no ground: a magnetic network that reaches no 0 net is referenced at its first net by name. ## Datasheet and sources Take ae, le and the initial permeability from the core and material data sheets, or name a catalogue core such as E 42/21/15 - N87 - Gapped 0.500 mm. For a gap, ae is the leg area and gap the gap length. ## Example Open the example with the command `file.openExample` and the name `demo:reluctance`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Saturable Core (`saturableCore`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/saturableCore/ > A flux path that saturates: its permeance falls to the air path once the flux density reaches Bsat. ![saturableCore](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/saturableCore.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/magnetics/saturableCore/) **Group:** Magnetics · **Kind:** `{"element":"saturableCore","kind":"magnetic"}` ## When to use it Use it for saturable reactors and magnetic amplifiers, and to see a transformer or inductor saturate at start-up or with a DC offset. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | magnetic | One end of the path | | `b` | magnetic | The other end | ## Common parameters - `core`: Catalogue core or shape that gives the area, path length, permeability and gap (Default: optional (off)) - `bsat`: Saturation flux density; unset uses the catalogue material's, and without one the core stays linear (Default: optional (off)) - `ae`: Cross-section area of the flux path (Default: optional (off)) - `le`: Length of the flux path through the core material (Default: optional (off)) - `mur`: Relative permeability of the core material (Default: 1) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `core` | — | optional (off) | | Catalogue core or shape that gives the area, path length, permeability and gap | | `material` | — | optional (off) | | Core material; needed when core names a shape | | `ae` | m² | optional (off) | | Cross-section area of the flux path | | `le` | m | optional (off) | | Length of the flux path through the core material | | `mur` | — | 1 | | Relative permeability of the core material | | `gap` | m | optional (off) | | Air gap in series with the path; unset uses the catalogue core's gap (none without one) | | `coreTemp` | °C | 25 | | Core temperature the material data is read at | | `bsat` | T | optional (off) | | Saturation flux density; unset uses the catalogue material's, and without one the core stays linear | _Parameter descriptions are in English in both languages._ **Use for:** Saturable reactors · Magnetic amplifiers · Start-up and DC-offset saturation **Not for:** A leg far below saturation → [`reluctance`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/reluctance/) ## Formulas | Formula | Equation | Source | |---|---|---| | Flux at saturation | Φsat = Bsat·Ae | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), ch. 10 (saturation) | | Winding current at the knee | Isat = Bsat·Ae·R / N | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), ch. 10 (magnetic circuits and saturation) | | Inductance once saturated | Lsat = N²·μ0·Ae / (lg + le) | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), ch. 10 (magnetic circuits) | ## Quick check Inputs: - `bsat`: Saturation flux density = 350m T, `bsat` - `ae`: Cross-section area = 100u m², `ae` - `le`: Path length in the core = 100m m, `le` - `mur`: Relative permeability = 2k -, `mur` - `gap`: Air gap = 0 m, `gap` - `n`: Turns of a winding on it = 10 - Outputs: - `rel`: Reluctance below the knee = `(gap + le/mur)/(4e-7*pi*ae)` A/Wb - `phisat`: Flux at saturation = `bsat*ae` Wb - `isat`: Winding current at the knee = `phisat*rel/n` A - `lun`: Inductance below the knee = `n^2/rel` H - `lsat`: Inductance once saturated = `n^2*4e-7*pi*ae/(gap + le)` H ## Model logic - It is a nonlinear capacitor in charge between magnetic nodes, C(F) = dΦ/dF, linearized by Newton each step as a MOSFET's nonlinear capacitance is. - A ferrite keeps P = mu0·ae / (gap + le/mur) up to the flux bsat·ae and takes the air path mu0·ae / (gap + le) above it, over a knee 5 % either side of the knee MMF. - A powder core from the catalogue follows its permeability roll-off with the field H = F / le, used as the incremental permeability. - The curve is single-valued: no hysteresis loop and no core loss. ## Model Below the knee the path has P = mu0 * ae / (gap + le / mur). A ferrite keeps it up to the flux bsat * ae and takes the air path mu0 * ae / (gap + le) above it, over a knee 10 % wide. A powder core from the catalogue follows its permeability roll-off with the field H = F / le instead. bsat overrides the catalogue material's. Without either the core stays linear, and a warning says so. The solvers treat it as a nonlinear capacitance in charge, solved by Newton iteration. ## Common mistakes - A powder core with a gap is refused, and so is a path with no le, because only core material saturates. - Bsat falls as the core heats up. Set coreTemp to the operating temperature to read the catalogue value there. ## Datasheet and sources Take bsat from the material data sheet at the operating temperature, and ae and le from the core data sheet. A catalogue core gives all of them. ## Example Open the example with the command `file.openExample` and the name `demo:saturableCore`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Transformer (`transformer`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/transformer/ > A transformer with turns ratio n, and optional magnetizing inductance, leakage, winding resistance, core loss and saturation. ![transformer](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/transformer.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/magnetics/transformer/) **Group:** Magnetics · **Kind:** `{"kind":"transformer"}` ## When to use it Use it for isolation and voltage scaling. Leave the optional parameters unset for an ideal part, or set llk1, rw1 and the others to see the leakage spike, the copper loss and the magnetizing current. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p1` | electrical | Primary, dotted end; positive current enters here | | `n1` | electrical | Primary, other end | | `p2` | electrical | Secondary, dotted end | | `n2` | electrical | Secondary, other end | ## Common parameters - `n`: Turns ratio, first side to second side (Default: 1) - `lm`: Inductance that magnetizes the core (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `n` | — | 1 | | Turns ratio, first side to second side | | `lm` | H | optional (off) | | Inductance that magnetizes the core | | `im0` | A | 0 | | Magnetizing current at the start, seen from the first side; needs lm or a core | | `llk1` | H | 0 | 1n – 1m H | Leakage inductance in series with the first winding | | `llk2` | H | 0 | 1n – 1m H | Leakage inductance in series with the second winding | | `rw1` | Ω | 0 | 100u – 1 Ω | Wire resistance of the first winding | | `rw2` | Ω | 0 | 100u – 1 Ω | Wire resistance of the second winding | | `rcore` | Ω | optional (off) | 100 – 10meg Ω | Resistance across the first winding that models core loss | | `isat` | A | optional (off) | 10m – 200 A | Magnetizing current where the core saturates; needs lm | | `lmsat` | H | optional (off) | 1n – 10 H | Magnetizing inductance once the core is saturated; a fifth of lm when unset | | `core` | — | optional (off) | | Core from the catalogue; it sets the inductance curve and the core loss | | `material` | — | optional (off) | | Core material; needed when core names a shape | | `turns` | — | optional (off) | | Turns of the first winding | | `gap` | m | optional (off) | | Air gap in the core; unset uses the catalogue core's gap | | `fsw` | Hz | optional (off) | | Switching frequency; core and winding losses are worked out once per period | | `coreTemp` | °C | 25 | | Core and winding temperature | | `coreAe` | m² | optional (off) | | Effective area of a core you describe yourself; use with coreLe instead of core | | `coreLe` | m | optional (off) | | Magnetic path length of a core you describe yourself; use with coreAe | | `coreVe` | m³ | optional (off) | | Volume of that core for its core loss; coreAe times coreLe when unset | | `bhCurve` | — | optional (off) | | B-H curve of the core; pairs H:B in A/m and T, such as 0:0, 50:0.3, 200:0.45; replaces the material's curve | | `psiCurve` | — | optional (off) | | Flux linkage of the winding against its current from a field solve; pairs i:λ in A and Wb, such as 0:0, 1:2e-3, 4:5e-3 (odd about zero current), or from a negative current through 0 for a magnet-biased winding, such as -4:-1e-3, 0:2e-3, 4:4e-3; replaces the core's curve | | `steinmetzK` | W/m³ | optional (off) | | Steinmetz k of the core loss k·f^α·B^β, with f in Hz and B the peak flux density in T | | `steinmetzAlpha` | — | optional (off) | | Steinmetz α, the frequency exponent of the core loss | | `steinmetzBeta` | — | optional (off) | | Steinmetz β, the flux-density exponent of the core loss | | `magneticsDesign` | — | optional (off) | | Saved design from magnetics.design; the separate core parameters win over it | | `surface` | m² | optional (off) | | Outside surface of the wound part to the air; design.thermal gives its temperature rise from it and the loss | | `coupledCurve` | — | optional (off) | | Incremental inductances of the two windings against the core's magnetizing current from a field solve; rows i:L11:M:L22 in A and H from 0 A, such as 0:1e-3:4.8e-4:2.5e-4, 0.4:2e-4:8e-5:5e-5; the whole magnetic model in place of n, lm and the core, with leakage, winding resistance and rcore still added | _Parameter descriptions are in English in both languages._ **Use for:** Isolation · Isolated DC-DC stages · Gate-drive transformers **Not for:** Three-phase transformers → [`transformer3`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/transformer3/) · Current sensing → [`currentTransformer`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/currentTransformer/) ## Formulas | Formula | Equation | Source | |---|---|---| | Secondary voltage | v2 = v1 / n | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 13 (the ideal transformer) | | Load reflected to the primary | zin = n²·rl | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 13 (impedance matching) | | Magnetizing current ripple | Δim = v1·ton / lm | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), §6.3 (transformer isolation, magnetizing inductance) | ## Quick check Inputs: - `n`: Turns ratio N1/N2 = 4 —, `n` - `v1`: Primary voltage = 48 V - `rl`: Secondary load = 2 Ω - `lm`: Magnetizing inductance = 500u H, `lm` - `ton`: Time the voltage is applied = 5u s Outputs: - `v2`: Secondary voltage = `v1/n` V - `zin`: Reflected load = `n^2*rl` Ω - `dim`: Magnetizing current ripple = `v1*ton/lm` A ## Model logic - The ideal windings are one extra branch current that forces v1 = n·v2 and i2 = −n·i1, so on its own the part passes DC. - rw1 and llk1 sit in series on the primary and rw2 and llk2 on the secondary; zero leaves each one out, and leakage starts with no current. - With lm set, an inductor across ideal winding 1 starts at im0, and rcore sits across it; without lm there is no magnetizing current at all. - isat makes lm a two-slope knee (lmsat, or 0.2·lm, above it) by the previous accepted current; a catalogue core replaces it with its curve. ## Model The ideal windings obey v1 = n * v2 with n = N1 / N2, and the currents obey i2 = -n * i1 when both are positive into the dotted ends. rw1 and llk1 sit in series between p1 and ideal winding 1, and rw2 and llk2 between p2 and ideal winding 2, so each side's leakage and resistance is on its own side. With lm set, an inductor of that value sits across ideal winding 1 and carries the magnetizing current, and rcore sits across it for core loss. When isat is set, the magnetizing inductance is lm while its current magnitude stays below isat and lmsat above it (0.2 * lm when lmsat is unset), the same two-slope knee as the Inductor. With every optional parameter unset, the part is ideal and simulates exactly as before. ## Common mistakes - n is N1 / N2, so a 10 to 1 step-down uses n = 10, and 0.1 steps the voltage up. Check the ratio against the rated primary and secondary voltages. - The secondary has no reference unless something in it touches ground. A DC component on the primary drives the lm current up without limit unless isat is set, and even then lmsat only slows it. - Leakage inductance stores energy each time the primary current is cut, about 0.5 * llk1 * i^2. A flyback with llk1 and no clamp or snubber across the switch shows a very high turn-off spike. isat needs lm, because it saturates the magnetizing inductance. Problems rules: `island.floating`, `param.out_of_range` ## Datasheet and sources n is the rated primary voltage divided by the rated secondary voltage, or the ratio of turns. lm is the primary inductance measured with the secondary open. llk1 is the leakage inductance measured on the primary with the secondary shorted; put it all on the primary with llk2 at zero unless the split is known. rw1 and rw2 are the DC resistances of each winding, isat is the magnetizing current where the inductance has dropped by the stated percentage, and rcore is a one-frequency estimate of core loss. ## Example Open the example with the command `file.openExample` and the name `demo:transformer`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Three-Phase Transformer (`transformer3`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/transformer3/ > A three-phase transformer with a chosen vector group, a line-to-line voltage ratio, leakage and magnetizing inductance. ![transformer3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/transformer3.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/magnetics/transformer3/) **Group:** Magnetics · **Kind:** `{"kind":"transformer3"}` ## When to use it Use it to step a three-phase voltage up or down, to isolate a grid connection, or to see the 30 degree phase shift of a Dy11 or Yd1 transformer. For one phase only, use Transformer. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a1` | electrical | Line a of the first side | | `b1` | electrical | Line b of the first side | | `c1` | electrical | Line c of the first side | | `n1` | electrical | Star point of the first side; a wye winding uses it, and left open it floats | | `a2` | electrical | Line a of the second side | | `b2` | electrical | Line b of the second side | | `c2` | electrical | Line c of the second side | | `n2` | electrical | Star point of the second side; a wye winding uses it, and left open it floats | ## Common parameters - `group`: Winding connections and phase shift: Yy0, Dd0, Dy1, Dy11, Yd1 or Yd11 (Default: Dy11) - `ratio`: Line-to-line voltage ratio, first side to second side (Default: 1) - `lk`: Leakage inductance of each phase, seen from the first side (Default: 0) - `rw`: Winding resistance of each phase, seen from the first side (Default: 0) - `lm`: Magnetizing inductance of each phase, seen from the first side (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `group` | — | Dy11 | | Winding connections and phase shift: Yy0, Dd0, Dy1, Dy11, Yd1 or Yd11 | | `ratio` | — | 1 | | Line-to-line voltage ratio, first side to second side | | `lk` | H | 0 | | Leakage inductance of each phase, seen from the first side | | `rw` | Ω | 0 | | Winding resistance of each phase, seen from the first side | | `lm` | H | optional (off) | | Magnetizing inductance of each phase, seen from the first side | _Parameter descriptions are in English in both languages._ **Use for:** Grid interfaces · 30 degree phase shift · Three-phase step-down **Not for:** Single-phase transformers → [`transformer`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/transformer/) ## Formulas | Formula | Equation | Source | |---|---|---| | Second-side line voltage | vll2 = vll1 / ratio | IEC 60076-1:2011, definitions (rated voltage ratio) | | Winding turns ratio of a Dy group | nw = ratio·√3 | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 12 (line and phase voltages) | | Leakage from uk for a delta first side | lk = (uk/100)·(3·vll1²/s) / (2π·f) | IEC 60076-1:2011, definitions (short-circuit impedance) | ## Quick check Inputs: - `ratio`: Line voltage ratio = 27.5 —, `ratio` - `vll1`: First-side line voltage = 11k V - `s`: Rated power = 1meg VA - `uk`: Short-circuit impedance in percent = 6 — - `f`: Frequency = 50 Hz Outputs: - `vll2`: Second-side line voltage = `vll1/ratio` V - `nw`: Winding turns ratio (Dy) = `ratio*sqrt(3)` — - `lk`: Leakage per phase (delta first side) = `(uk/100)*(3*vll1^2/s)/(2*pi*f)` H ## Model logic - Before the run it is expanded into three single-phase transformers wired wye or delta by group, and ratio is the line-to-line ratio. - Each winding ratio is ratio times 1 or 1/√3 for each side (a delta sees the line voltage, a wye the line voltage over √3). - rw and lk sit in series and lm across each first-side winding; with a delta second side and rw of 0, each winding gets 1 µΩ. - The three phases are separate units: no limb coupling, no zero-sequence core path, no saturation and no core loss. ## Model Before the run the transformer is expanded into three single-phase transformers, one per phase. The leakage inductance lk and the winding resistance rw sit in series with each first-side winding, and the magnetizing inductance lm sits across it. The group gives the winding connections and the phase shift. Yy0 and Dd0 have no shift. Dy11 and Yd11 put the second side 30 degrees ahead of the first side, and Dy1 and Yd1 put it 30 degrees behind, for the phase sequence a, b, c. The shift is between phase-to-neutral voltages, as in the clock notation. The ratio is the line-to-line voltage ratio of the nameplate, first side to second side. The turns ratio of each winding follows from it and from the connections: a delta winding sees the line voltage and a wye winding the line voltage divided by sqrt(3), so Dy11 has sqrt(3) times the ratio. With a delta on the second side and rw left at 0, each first-side winding gets 1 µΩ, so the current that can circulate in the delta has a resistance to settle it; it changes no voltage you can see. The three phases are separate single-phase units, so there is no zero-sequence path of a three-limb core, and no saturation or core loss. ## Common mistakes - A second side with no path to ground has no reference. Join pin n2, or the star point of the load, to ground. - The ratio is the ratio of line voltages, not of winding voltages. A Dy11 transformer with ratio 10 gives one tenth of the line voltage on the second side, even though each winding has a turns ratio of about 17. - Pins n1 and n2 are only the star points of wye windings. A delta side ignores its n pin. Problems rules: `island.floating` ## Datasheet and sources ratio is the rated line-to-line voltage of the first side over that of the second side, and group is the vector group on the nameplate, such as Dyn11. The short-circuit impedance in percent and the copper loss give rw and lk: the base impedance of a phase winding is the winding voltage squared over a third of the rated power, rw is the copper-loss part of the impedance, and lk is the rest divided by 2 * pi * f. lm follows from the no-load current in the same way. ## Example Open the example with the command `file.openExample` and the name `demo:transformer3`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Winding (`winding`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/winding/ > N turns that join an electrical circuit to a magnetic circuit of reluctances. ![winding](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/winding.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/magnetics/winding/) **Group:** Magnetics · **Kind:** `{"element":"winding","kind":"magnetic"}` ## When to use it Use it to build coupled or integrated magnetics, gapped flyback transformers and saturable reactors from their core geometry, with as many windings as the core has. For two windings with a known L and k, Coupled Inductor is simpler. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | Electrical end; positive current enters here and drives flux out of a | | `n` | electrical | Electrical other end | | `a` | magnetic | Magnetic end the flux leaves by | | `b` | magnetic | Magnetic end the flux comes back to | ## Common parameters - `n`: Turns of the winding (Default: required) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `n` | — | required | | Turns of the winding | _Parameter descriptions are in English in both languages._ **Use for:** Integrated magnetics · More than two windings · Gapped flyback transformers · Saturable reactors **Not for:** Two windings with a known L and k → [`coupledInductor`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/coupledInductor/) ## Formulas | Formula | Equation | Source | |---|---|---| | Reluctance of the path | R = (lg + le/μr) / (μ0·Ae) | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), ch. 10 (magnetic circuits) | | Inductance of the winding | L = N² / R | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), ch. 10 (magnetic circuits) | | Flux density at a current | B = N·i / (R·Ae) | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), ch. 10 (magnetic circuits) | ## Quick check Inputs: - `n`: Turns = 20 -, `n` - `ae`: Core area = 100u m² - `le`: Path length in the core = 100m m - `mur`: Relative permeability = 2k - - `gap`: Air gap = 500u m - `i`: Winding current = 5 A Outputs: - `rel`: Reluctance of the path = `(gap + le/mur)/(4e-7*pi*ae)` A/Wb - `l`: Inductance of the winding = `n^2/rel` H - `b`: Flux density at the current = `n*i/(rel*ae)` T ## Model logic - It is a gyrator of conductance 1/n: two voltage-controlled current sources, constant entries in the matrix, so the LU cache keeps working. - It sets F(a) − F(b) = n·i with i into p, and v(p) − v(n) = n·dΦ/dt with Φ leaving at a; the current is recorded as i(name). - It has no resistance, capacitance or loss of its own: add a resistor for the copper and model the core with Reluctance or Saturable Core. ## Model The winding sets the magnetomotive force F(a) - F(b) = n * i and the voltage v(p) - v(n) = n * dPhi/dt, where Phi is the flux through it from b to a. It is a gyrator in the solvers, so a winding on a reluctance R is an inductance n^2 / R, and two windings on one path are coupled with M = n1 * n2 / R. It has no resistance or capacitance; add those as parts. The current is recorded as i(name). ## Common mistakes - The direction counts: current into p drives flux out of a. Two windings whose a pins face the same way round the core are coupled in the same sense; swap a and b of one to reverse it. - A magnetic circuit is solved in transient and AC analysis only; DC analysis refuses it. ## Datasheet and sources n is the number of turns you wind. The inductance comes from the core, so give the core as a Reluctance or Saturable Core with its catalogue name or its Ae, le and permeability. ## Example Open the example with the command `file.openExample` and the name `demo:winding`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Backlash (`backlash`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/backlash/ > Free play between two shafts, such as in a gear mesh: no torque inside the gap, a stiff contact outside it. ![backlash](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/backlash.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/mechanical/backlash/) **Group:** Mechanical · **Kind:** `{"element":"backlash","kind":"mechanical"}` ## When to use it Use it next to a Gear to see the impacts and the limit cycles that free play causes when the torque reverses. For a shaft without free play use Elastic Shaft. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | mechanical | Side a, usually the motor | | `b` | mechanical | Side b, usually the load | ## Common parameters - `gap`: Total free play between the two sides (Default: required) - `k`: Stiffness while the two sides touch (Default: required) - `d`: Damping while the two sides touch (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `k` | N·m/rad | required | | Stiffness while the two sides touch | | `gap` | rad | required | | Total free play between the two sides | | `d` | N·m·s/rad | 0 | | Damping while the two sides touch | | `theta0` | rad | 0 | | Twist at the start, from the middle of the free play | _Parameter descriptions are in English in both languages._ ## Model The twist θ is the integral of ωa - ωb, starting at theta0 measured from the middle of the gap. While abs(θ) is below gap/2 no torque passes. Beyond it the flanks touch and the torque from a to b is k·(θ - gap/2) + d·(ωa - ωb) on the positive flank, and k·(θ + gap/2) + d·(ωa - ωb) on the negative one. The flank is the one of the last accepted step, so contact starts and ends up to one step late, and each flank keeps its own factorized matrix. With gap 0 it is the Elastic Shaft. ## Common mistakes - The contact is found one step late, so a fast impact needs a small maximum step: keep it well below the contact time π·sqrt(J/k) of the lighter side. - With contact damping d the torque can pull briefly while the flanks separate, which real teeth cannot do. Keep d small, or 0 for an elastic impact. - gap is the total free play, both flanks together, in rad of the shaft it sits on. Put the backlash on the side whose angle the datasheet gives. Problems rules: `pin.unconnected`, `compile.error` ## Datasheet and sources gap is the angular backlash from the gearbox datasheet, usually in arcmin at the output: gap = arcmin·π/(180·60) rad on the output side. k is the torsional stiffness of the gearbox at that side, in N·m/rad (datasheets often give N·m/arcmin: multiply by 180·60/π). ## Example Open the example with the command `file.openExample` and the name `demo:backlash`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Constant-Power Load (`constantPower`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/constantPower/ > A load that takes constant power, so torque rises as speed falls. ![constantPower](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/constantPower.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/mechanical/constantPower/) **Group:** Mechanical · **Kind:** `{"element":"constantPower","kind":"mechanical"}` ## When to use it Use it for winders, traction loads and machine tools with a constant-power range. Use Load Torque for a constant torque and Fan Load for a load that rises with speed. ## Pins | Pin | Domain | Meaning | |---|---|---| | `shaft` | mechanical | Shaft terminal, the torque opposes rotation | ## Common parameters - `p`: Power the load draws (Default: required) - `wmin`: Speed below which the load torque fades (Default: 1) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `p` | W | required | | Power the load draws | | `wmin` | rad/s | 1 | | Speed below which the load torque fades | _Parameter descriptions are in English in both languages._ ## Model The torque is T = p·ω/max(abs(ω), wmin)², which is p/abs(ω) above wmin and falls linearly to zero below it. The speed is from the last accepted step. The power drawn is p above wmin. A negative p makes the load drive the shaft. ## Common mistakes - A small wmin gives a very large torque at low speed, and the machine may stall instead of starting. Set wmin to the speed where the real load stops following the constant-power rule. - p is in W, not kW or hp, and the speed is in rad/s. One hp is 746 W, so enter 746 for 1 hp. - Below wmin the torque is proportional to speed, so a shaft at rest feels no load torque. A run that starts at 0 begins with an easy start and meets the full torque only above wmin. ## Datasheet and sources p is the constant shaft power of the load from the application need. wmin is the lowest speed of the constant-power range in rad/s, and it is a design value. ## Example Open the example with the command `file.openExample` and the name `demo:constantPower`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Torsional Damper (`damper`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/damper/ > A viscous damper between two shafts: the torque grows with their speed difference. ![damper](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/damper.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/mechanical/damper/) **Group:** Mechanical · **Kind:** `{"element":"damper","kind":"mechanical"}` ## When to use it Use it next to a Torsional Spring for the damping of a shaft or coupling, or for a viscous coupling. Use Friction for damping to the frame. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | mechanical | Side a | | `b` | mechanical | Side b | ## Common parameters - `d`: Torque per rad/s of slip between the two sides (Default: required) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `d` | N·m·s/rad | required | | Torque per rad/s of slip between the two sides | _Parameter descriptions are in English in both languages._ ## Model The torque from a to b is d·(ωa - ωb). In the solver it is a conductance d between the two shaft nodes, so it is exact and never changes the matrix. Two inertias J1 and J2 on a damper reach a common speed with the rate d·(1/J1 + 1/J2). ## Common mistakes - d must be above 0, or the run is refused. To leave the damping out, delete the part. - The damper loses power d·(ωa - ωb)². It acts only on the speed difference, so two shafts turning together lose nothing. Problems rules: `pin.unconnected`, `compile.error` ## Datasheet and sources d is the damping of the shaft or coupling in N·m·s/rad. Coupling datasheets often give a relative damping ψ instead: then d = ψ·k/(2·π·ωr) at the ringing frequency ωr. ## Example Open the example with the command `file.openExample` and the name `demo:damper`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Elastic Shaft (`elasticShaft`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/elasticShaft/ > A compliant shaft between two masses: a torsional spring and a damper in parallel. ![elasticShaft](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/elasticShaft.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/mechanical/elasticShaft/) **Group:** Mechanical · **Kind:** `{"element":"elasticShaft","kind":"mechanical"}` ## When to use it Use it for the two-mass model of a drive, with the motor inertia on a and the load inertia on b, to see the shaft resonance and tune the speed loop against it. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | mechanical | Side a, usually the motor | | `b` | mechanical | Side b, usually the load | ## Common parameters - `k`: Torque per radian of twist between the two sides (Default: required) - `d`: Torque per rad/s of slip between the two sides (Default: 0) - `theta0`: Twist at the start, side a ahead of side b (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `k` | N·m/rad | required | | Torque per radian of twist between the two sides | | `d` | N·m·s/rad | 0 | | Torque per rad/s of slip between the two sides | | `theta0` | rad | 0 | | Twist at the start, side a ahead of side b | _Parameter descriptions are in English in both languages._ ## Model The torque from a to b is k·θ + d·(ωa - ωb), where the twist θ is the integral of ωa - ωb and starts at theta0. It is the same as a Torsional Spring and a Torsional Damper in parallel. With J1 on a and J2 on b the resonance is ωr = sqrt(k·(J1 + J2)/(J1·J2)) and the anti-resonance seen from the motor is sqrt(k/J2). ## Common mistakes - The shaft has no mass. Put the motor inertia and the load inertia on the two sides as Inertia parts, or the resonance is not there. - A speed loop much faster than ωr excites the resonance. Measure the speed on the motor side and keep the loop bandwidth below the anti-resonance, or add a filter. - d can be 0 (an undamped shaft) but not below. Keep the maximum step well below 1/ωr. Problems rules: `pin.unconnected`, `compile.error` ## Datasheet and sources k and d come from the coupling or shaft datasheet (torsional stiffness and damping), or from k = G·π·d⁴/(32·L) for a solid round shaft. Measured drives often give the resonance frequency instead: then k = ωr²·J1·J2/(J1 + J2). ## Example Open the example with the command `file.openExample` and the name `demo:elasticShaft`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Incremental Encoder (`encoder`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/encoder/ > Gives quadrature signals, an index pulse and a position count from the shaft angle. ![encoder](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/encoder.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/mechanical/encoder/) **Group:** Mechanical · **Kind:** `{"element":"encoder","kind":"mechanical"}` ## When to use it Use it to study position feedback in counts and speed estimates from them. Use Position Sensor for a smooth angle and Resolver for sin and cos. ## Pins | Pin | Domain | Meaning | |---|---|---| | `shaft` | mechanical | Shaft terminal, it reads speed and loads nothing | | `a` | signal | Channel A, 0 or 1, leads b going forward | | `b` | signal | Channel B, a quarter cycle behind a | | `z` | signal | Index, high for one count each turn | | `count` | signal | Position count, 4 times lines per turn | ## Common parameters - `lines`: Number of lines per turn (Default: 1024) - `theta0`: Shaft angle at the start (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `lines` | — | 1024 | | Number of lines per turn | | `theta0` | rad | 0 | | Shaft angle at the start | _Parameter descriptions are in English in both languages._ ## Model The angle is the integral of the shaft speed from theta0 and is not wrapped. The output a is a 0 and 1 square wave with lines cycles per turn, and b is a quarter cycle behind it. The count is floor(4·lines·angle/(2π)), so it goes up 4·lines per turn and counts down when the shaft reverses. The z pulse is high for one count at angle 0. The signals are written once per solver step. ## Common mistakes - lines is the number of lines per turn (PPR), and the count is four times that. A 1024 PPR encoder has lines of 1024 and 4096 counts per turn, so do not enter 4096, and lines must be a whole number up to 1 000 000 or the run is refused. - The channels are sampled at the solver step. Keep maxStep well below a quarter of a line period at the highest speed, or the edges of a and b are missed. - z does not reset the count, so it keeps growing across turns. Its angle starts at the encoder theta0 in mechanical radians and does not follow the machine, so align it with the machine start angle. Problems rules: `compile.error` ## Datasheet and sources lines comes from the part number or the PPR entry of the datasheet, in lines per turn before the 4x decoding. theta0 is the shaft angle at the start of the run, in mechanical radians. ## Example Open the example with the command `file.openExample` and the name `demo:encoder`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Fan Load (`fan`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/fan/ > A fan or pump load whose torque grows with the square of speed. ![fan](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/fan.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/mechanical/fan/) **Group:** Mechanical · **Kind:** `{"element":"fan","kind":"mechanical"}` ## When to use it Use it for centrifugal fans and pumps. Use Friction for a load that grows in step with speed and Constant-Power Load for a winder or traction load. ## Pins | Pin | Domain | Meaning | |---|---|---| | `shaft` | mechanical | Shaft terminal, the torque opposes rotation either way | ## Common parameters - `k`: Fan or pump load that rises with speed (Default: required) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `k` | N·m·s²/rad² | required | | Fan or pump load that rises with speed | _Parameter descriptions are in English in both languages._ ## Model The torque is T = k·ω·abs(ω) in N·m with ω in rad/s, so it follows the speed squared and always opposes the rotation. The power therefore grows with the cube of speed. The value uses the speed of the last accepted step. It is zero at standstill, so there is no breakaway torque. ## Common mistakes - Compute k with the speed in rad/s, as the rated torque divided by the rated speed squared. Using rpm gives a value about 91 times too small, so the load is understated. - A pump with static head has torque at standstill, which this part lacks. Add a Load Torque part for the static share so the shaft does not start for free. - A fan makes little torque at low speed, and the speed settles where the machine torque equals the fan torque. Check the settled speed in the results, and do not expect a fixed load torque. ## Datasheet and sources k is the rated load torque divided by the square of the rated speed in rad/s. The fan or pump curve gives the shaft power P at the rated speed, so k is P divided by the cube of the rated speed. ## Example Open the example with the command `file.openExample` and the name `demo:fan`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Friction (`friction`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/friction/ > Drag that grows in step with speed, from a shaft to the frame. ![friction](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/friction.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/mechanical/friction/) **Group:** Mechanical · **Kind:** `{"element":"friction","kind":"mechanical"}` ## When to use it Use it for bearing and air drag that grow with speed. Use Fan Load for drag that grows with speed squared, and Load Torque for a constant load. ## Pins | Pin | Domain | Meaning | |---|---|---| | `shaft` | mechanical | Shaft terminal, the torque always opposes the speed | ## Common parameters - `b`: Friction that grows with speed (Default: required) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `b` | N·m·s/rad | required | | Friction that grows with speed | _Parameter descriptions are in English in both languages._ ## Model The torque is T = b·ω in N·m with ω in rad/s, and it opposes the rotation. The element is a conductance b from the shaft net to the frame. The loss power is b·ω², and there is no static friction or Stribeck effect. The torque is i(B1). ## Common mistakes - b must be greater than zero, and a zero value is refused. To have no friction, leave the part out, and remember that a machine has its own b (default 0) that adds to this one. - Viscous friction does not hold a shaft that is already stopped. A load that needs a breakaway torque also needs a Load Torque part, which still cannot show static friction that reverses with the direction of motion. - The unit is N·m·s/rad, not N·m/rpm. Multiply a value given per rpm by about 9.55 to convert it. Problems rules: `compile.error` ## Datasheet and sources b is the no-load drag torque divided by the speed, in rad/s, at which it was measured. A bearing or fan datasheet gives the drag torque at one speed, so divide it by that speed. ## Example Open the example with the command `file.openExample` and the name `demo:friction`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Gear (`gear`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/gear/ > An ideal gear that links two shafts with a speed ratio and an optional loss. ![gear](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/gear.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/mechanical/gear/) **Group:** Mechanical · **Kind:** `{"element":"gear","kind":"mechanical"}` ## When to use it Use it to couple a motor to a load at a different speed. It does not model elasticity or backlash. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | mechanical | Side a, usually the motor. Speed is n times b | | `b` | mechanical | Side b, usually the load. Torque is n times a | ## Common parameters - `n`: Speed ratio between the two shafts (Default: 1) - `eff`: Share of power that gets through (Default: 1) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `n` | — | 1 | | Speed ratio between the two shafts | | `eff` | — | 1 | | Share of power that gets through | _Parameter descriptions are in English in both languages._ ## Model The gear is ideal, with ωa = n·ωb and Tb = n·Ta, so the power is passed on. A load inertia J on side b acts as J/n² on side a. For eff below 1, a loss torque (1 - eff)·abs(Ta) acts on side a and opposes its rotation. It fades linearly to zero below 0.1 rad/s and uses the torque of the last accepted step. The shaft is rigid, and there is no backlash. ## Common mistakes - The ratio is the speed at a divided by the speed at b, so a reduction gear with the motor on a needs n above 1. With the motor on b the same gear speeds the load up. - Put the two sides on different shaft nets, with different net names for a and b. If both pins share one net and n is not 1, that net is forced to zero speed. - eff must be above 0 and at most 1, or the run is refused. The loss acts on side a, so an efficiency measured at the load side differs a little at partial load. Problems rules: `compile.error` ## Datasheet and sources n is the gear ratio from the nameplate, the input speed divided by the output speed. eff is the gearbox efficiency at the working torque, and the gearbox inertia is added as an Inertia part on the side where it sits. ## Example Open the example with the command `file.openExample` and the name `demo:gear`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Hall Sensors (`hall`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/hall/ > Makes three Hall signals from the shaft angle, 120 degrees apart. ![hall](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/hall.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/mechanical/hall/) **Group:** Mechanical · **Kind:** `{"element":"hall","kind":"mechanical"}` ## When to use it Use it for six-step drives of a machine with no Hall outputs, such as Surface PMSM. BLDC Machine already has them built in. ## Pins | Pin | Domain | Meaning | |---|---|---| | `shaft` | mechanical | Shaft terminal, it reads speed and loads nothing | | `ha` | signal | Hall signal a, 0 or 1 | | `hb` | signal | Same as ha, 120 degrees later | | `hc` | signal | Same as ha, 240 degrees later | ## Common parameters - `poles`: Number of poles of the machine (Default: 2) - `hall0`: Angle where the first Hall signal rises (Default: 0.5236) - `theta0`: Shaft angle at the start (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `poles` | — | 2 | | Number of poles of the machine | | `theta0` | rad | 0 | | Shaft angle at the start | | `hall0` | rad | 0.5236 | | Angle where the first Hall signal rises | _Parameter descriptions are in English in both languages._ ## Model The sensor integrates the shaft speed into a mechanical angle starting at theta0 and forms the electrical angle (poles/2)·angle. The output ha is 1 for an electrical angle in [hall0, hall0 + π), and hb and hc repeat the same pattern 120 and 240 electrical degrees later. Rotating forward, ha hb hc read 101, 100, 110, 010, 011, 001, with a change every 60 electrical degrees. The sensor is ideal, with no delay or noise. ## Common mistakes - theta0 is a mechanical angle, so for a machine with an electrical start angle set it to the machine theta0 divided by the pole pairs. Otherwise the Hall edges are shifted from the back-EMF and the commutation is wrong. - poles is the pole count of the machine, not its pole pairs, and must be even or the run is refused. Do not add this sensor to a BLDC Machine and expect it to replace the built-in outputs, which come from the machine itself. - The default hall0 of 0.5236 rad (30 degrees) puts the edges at the commutation instants of 120 degree conduction. Any other hall0 advances or retards the commutation and lowers the torque per ampere. Problems rules: `compile.error` ## Datasheet and sources poles is the pole count of the motor, and theta0 is the starting rotor angle in mechanical radians. hall0 is the electrical angle where Hall signal ha rises, read from the sensor phasing diagram of the motor datasheet. ## Example Open the example with the command `file.openExample` and the name `demo:hall`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Inertia (`inertia`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/inertia/ > Adds rotating mass to a shaft, with an optional starting speed. ![inertia](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/inertia.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/mechanical/inertia/) **Group:** Mechanical · **Kind:** `{"element":"inertia","kind":"mechanical"}` ## When to use it Use it to add the inertia of a load, coupling or flywheel to a shaft. Do not use it for a machine rotor, because the machine already includes it. ## Pins | Pin | Domain | Meaning | |---|---|---| | `shaft` | mechanical | Shaft terminal, the other side is the frame | ## Common parameters - `j`: How strongly the shaft resists speeding up (Default: required) - `w0`: Initial speed (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `j` | kg·m² | required | | How strongly the shaft resists speeding up | | `w0` | rad/s | 0 | | Initial speed | _Parameter descriptions are in English in both languages._ ## Model The element is J·dω/dt = T, where T is the net torque flowing into the shaft net. It is solved as a capacitor J from the shaft net to the frame, with the speed ω in rad/s. The initial speed is w0, and the kinetic energy is J·ω²/2. The shaft is rigid and there is no loss, so add a Friction part for losses. The torque is i(J1) and the speed is w(net). ## Common mistakes - A machine already carries its own rotor inertia j on the shaft net, and the two add. Enter only the extra load inertia here, or the rotor is counted twice and the acceleration is too slow. - An inertia behind a Gear is scaled by the square of the ratio when seen from the other side. Enter the real value and let the Gear do the scaling. - The unit is kg·m², so divide a datasheet GD² by 4 and multiply 1 g·cm² by 1e-7. w0 is a starting speed in rad/s, and every part on the same net starts at its own w0. ## Datasheet and sources j is the load, coupling or flywheel inertia from the datasheet, in kg·m². w0 is 0 for a start from rest, or the running speed in rad/s for a run that begins at speed. ## Example Open the example with the command `file.openExample` and the name `demo:inertia`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Position Sensor (`positionSensor`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/positionSensor/ > Reads the shaft angle, mechanical and electrical, as signals. ![positionSensor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/positionSensor.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/mechanical/positionSensor/) **Group:** Mechanical · **Kind:** `{"element":"positionSensor","kind":"mechanical"}` ## When to use it Use it to feed the rotor angle to field-oriented control or a Park transform. Use Incremental Encoder for counts, Resolver for sin and cos, and Hall Sensors for six-step drives. ## Pins | Pin | Domain | Meaning | |---|---|---| | `shaft` | mechanical | Shaft terminal, it reads speed and loads nothing | | `out` | signal | Mechanical angle in rad, wraps every turn | | `elec` | signal | Electrical angle in rad, wraps every cycle | ## Common parameters - `poles`: Number of poles of the machine (Default: 2) - `theta0`: Shaft angle at the start (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `poles` | — | 2 | | Number of poles of the machine | | `theta0` | rad | 0 | | Shaft angle at the start | _Parameter descriptions are in English in both languages._ ## Model The sensor integrates the shaft speed by the trapezoidal rule starting at theta0, so the angle is not read from the machine. The outputs are out = angle wrapped to [0, 2π) and elec = (poles/2)·angle, wrapped the same way. The sensor is ideal, with no quantization, offset or noise. ## Common mistakes - The sensor angle starts at its own theta0 in mechanical radians, while the machine theta0 is an electrical angle. For a magnet machine set the sensor theta0 to the machine theta0 divided by the pole pairs, or the dq frame is rotated by the difference. - poles must equal the pole count of the machine, not its pole pairs, and must be even. A mismatch makes the electrical angle run at the wrong rate, and an odd value is refused. - The outputs wrap around every turn. A Park transform accepts the wrapped angle, but a controller that needs a continuous angle must integrate the speed itself. Problems rules: `compile.error` ## Datasheet and sources poles is the pole count of the machine on the shaft, from its datasheet. theta0 is the rotor angle at the start of the run in mechanical radians, a design value that must match the starting position of the machine. ## Example Open the example with the command `file.openExample` and the name `demo:positionSensor`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Resolver (`resolver`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/resolver/ > Outputs the sine and cosine of the shaft's electrical angle. ![resolver](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/resolver.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/mechanical/resolver/) **Group:** Mechanical · **Kind:** `{"element":"resolver","kind":"mechanical"}` ## When to use it Use it to feed sin and cos angle signals to a tracking loop. Use Position Sensor for the angle itself and Incremental Encoder for counts. ## Pins | Pin | Domain | Meaning | |---|---|---| | `shaft` | mechanical | Shaft terminal, it reads speed and loads nothing | | `sin` | signal | amp times the sine of the electrical angle | | `cos` | signal | amp times the cosine of the electrical angle | ## Common parameters - `amp`: Size of the excitation signal (Default: 1) - `poles`: Number of poles of the machine (Default: 2) - `theta0`: Shaft angle at the start (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `amp` | — | 1 | | Size of the excitation signal | | `poles` | — | 2 | | Number of poles of the machine | | `theta0` | rad | 0 | | Shaft angle at the start | _Parameter descriptions are in English in both languages._ ## Model The sensor integrates the shaft speed from theta0 and forms the electrical angle θe = (poles/2)·angle. The outputs are sin = amp·sin(θe) and cos = amp·cos(θe), so sin² + cos² = amp². These are the demodulated outputs, with no excitation carrier. The sensor is ideal, with no error, noise or delay. ## Common mistakes - The outputs are already demodulated, so there is no excitation carrier to see or remove. To recover the angle, use a calculation that knows the quadrant, because plain sin divided by cos loses it. - poles sets how many electrical cycles one turn gives, so a two-speed resolver with two pole pairs needs poles of 4. It must be even, and an odd value is refused. - amp must be above zero, or the run is refused. It is the output amplitude, not the excitation amplitude, so use the transformation ratio times the excitation, and the angle starts at theta0, which does not follow the machine. Problems rules: `compile.error` ## Datasheet and sources amp is the output amplitude, the transformation ratio times the excitation amplitude. poles is twice the number of pole pairs (the speed count, 1X for one pair), and theta0 is the starting angle in mechanical radians. ## Example Open the example with the command `file.openExample` and the name `demo:resolver`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Speed Source (`speed`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/speed/ > Forces a shaft to turn at a fixed speed and supplies any torque needed. ![speed](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/speed.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/mechanical/speed/) **Group:** Mechanical · **Kind:** `{"element":"speed","kind":"mechanical"}` ## When to use it Use it for dynamometer, locked-rotor and constant-speed generator tests. Use a machine with a load when the speed should follow the dynamics. ## Pins | Pin | Domain | Meaning | |---|---|---| | `shaft` | mechanical | Shaft terminal, it holds this shaft at speed w | ## Common parameters - `w`: Speed forced on the shaft (Default: required) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `w` | rad/s | required | | Speed forced on the shaft | _Parameter descriptions are in English in both languages._ ## Model The speed of the shaft net is held at w in rad/s, like a voltage source. The torque it supplies is the result i(WS1), positive when it drives the net. Inertias on the same net no longer accelerate because the speed cannot change, and w is a constant that cannot ramp. ## Common mistakes - With the shaft held at w, the machine speed no longer reacts to its torque, so Te(M1) can look huge. Read it as a measurement, and note that an inertia on the same net has no effect. - Do not put two speed sources with different w on one shaft net, because each tries to force its own speed. A shaft net name may match an electrical net name without conflict, since the two sets of names are separate. - w is in rad/s, not rpm. Multiply rpm by 0.10472, so 1500 rpm is 157.08. ## Datasheet and sources w is the test or running speed in rad/s. It is 0 for a locked-rotor test, and for a rated-speed test it is the nameplate rpm converted to rad/s. ## Example Open the example with the command `file.openExample` and the name `demo:speed`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Speed Sensor (`speedSensor`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/speedSensor/ > Reads shaft speed as a signal without loading the shaft. ![speedSensor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/speedSensor.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/mechanical/speedSensor/) **Group:** Mechanical · **Kind:** `{"element":"speedSensor","kind":"mechanical"}` ## When to use it Use it to feed the speed to a control loop. Use Position Sensor when you need the angle. ## Pins | Pin | Domain | Meaning | |---|---|---| | `shaft` | mechanical | Shaft terminal, it reads speed and loads nothing | | `out` | signal | Speed signal, in rad/s or rpm | ## Common parameters - `unit`: Unit of the speed output: `rad/s` or `rpm` (Default: rad/s) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `unit` | — | rad/s | | Unit of the speed output: `rad/s` or `rpm` | _Parameter descriptions are in English in both languages._ ## Model The output is ω·scale, where the scale is 1 for rad/s and 60/(2π) for rpm. The sensor is ideal, with no delay, noise or quantization, and it does not affect the shaft. The value is the shaft speed after each accepted step. To only look at the speed, the result w(net) already shows it. ## Common mistakes - A speed loop tuned in rad/s must read rad/s. With rpm the signal is about 9.55 times larger than the gains were designed for, so use rpm only for a display. - Put the sensor on the same shaft net as the machine. A sensor on another net reads that net, which is 0 when nothing drives it, and a shaft pin left open is reported as a problem. - unit accepts only rad/s or rpm, and anything else is refused. The speed is not filtered, so a real drive may need a filter after the sensor. Problems rules: `pin.unconnected`, `compile.error` ## Datasheet and sources A tachometer or encoder datasheet gives nothing for this part except the choice of unit. Use rad/s when the control gains were designed in rad/s, and rpm when the signal feeds a display. ## Example Open the example with the command `file.openExample` and the name `demo:speedSensor`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Torsional Spring (`spring`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/spring/ > A torsional spring between two shafts: the torque grows with the twist. ![spring](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/spring.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/mechanical/spring/) **Group:** Mechanical · **Kind:** `{"element":"spring","kind":"mechanical"}` ## When to use it Use it for a shaft or coupling that twists under load, so the motor and the load can turn at different speeds and ring. Use Elastic Shaft to add damping in one part, and Gear for a rigid ratio. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | mechanical | Side a, usually the motor | | `b` | mechanical | Side b, usually the load | ## Common parameters - `k`: Torque per radian of twist between the two sides (Default: required) - `theta0`: Twist at the start, side a ahead of side b (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `k` | N·m/rad | required | | Torque per radian of twist between the two sides | | `theta0` | rad | 0 | | Twist at the start, side a ahead of side b | _Parameter descriptions are in English in both languages._ ## Model The torque from a to b is k·θ, where the twist θ is the integral of ωa - ωb and starts at theta0. In the solver the spring is an inductor of 1/k between the two shaft nodes, so it is integrated with the circuit and never changes the matrix. Two inertias J1 and J2 on a spring ring at ωr = sqrt(k·(J1 + J2)/(J1·J2)). The spring has no mass, damping or limit. ## Common mistakes - A spring with no damping anywhere rings forever. Add a Torsional Damper, friction or an Elastic Shaft with d, or the oscillation never settles. - A stiff spring between small inertias rings fast. Keep the maximum step well below 1/ωr, or the ringing is integrated coarsely. - Put the two sides on different shaft nets. A spring with both pins on one net carries no torque. Problems rules: `pin.unconnected`, `compile.error` ## Datasheet and sources k is the torsional stiffness of the shaft or coupling in N·m/rad. A coupling datasheet gives it directly. For a solid round steel shaft it is G·π·d⁴/(32·L) with the shear modulus G, the diameter d and the length L. ## Example Open the example with the command `file.openExample` and the name `demo:spring`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Load Torque (`torque`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/torque/ > A constant load torque that pushes back against forward rotation. ![torque](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/torque.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/mechanical/torque/) **Group:** Mechanical · **Kind:** `{"element":"torque","kind":"mechanical"}` ## When to use it Use it for constant loads such as hoists, conveyors and lifts. Use Friction, Fan Load or Constant-Power Load when the torque depends on speed. ## Pins | Pin | Domain | Meaning | |---|---|---| | `shaft` | mechanical | Shaft terminal, a positive t opposes forward rotation | ## Common parameters - `t`: Steady load torque that resists turning (Default: required) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `t` | N·m | required | | Steady load torque that resists turning | | `profile` | — | optional (off) | | Torque over time: steps(T0 t1 T1 …), pwl(t T …), pulse(T1 T2 delay rise fall width period), vrstep or workload as for the power load; replaces t | _Parameter descriptions are in English in both languages._ ## Model The element takes the torque t out of the shaft net, like a current source leaving the net, so a positive t opposes forward rotation. A negative t drives the shaft. The value does not depend on speed, and it keeps its sign when the speed reverses. The torque is i(T1). ## Common mistakes - A positive t opposes forward rotation only, and it pushes the shaft forward if it runs backwards. That makes it wrong for Coulomb friction, so use Friction or Fan Load for drag that follows the direction. - A load larger than the machine can make stalls the shaft. Compare t with the peak Te(M1) before blaming the machine, and note that a hoist keeps the same t while the machine brakes. - The unit is N·m. Divide a power in W by the speed in rad/s first, and multiply a value in kgf·m by 9.80665. ## Datasheet and sources t is the load torque the design needs, such as the weight times the drum radius for a hoist, or the shaft power divided by the speed in rad/s. It is a design value, not a datasheet field. ## Example Open the example with the command `file.openExample` and the name `demo:torque`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Torque Sensor (`torqueSensor`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/torqueSensor/ > Joins two shafts and reads the torque passing through. ![torqueSensor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/torqueSensor.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/mechanical/torqueSensor/) **Group:** Mechanical · **Kind:** `{"element":"torqueSensor","kind":"mechanical"}` ## When to use it Use it between a machine and its load to read the shaft torque. For the air-gap torque of the machine itself, use the result Te(M1). ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | mechanical | Source side, usually the motor, torque flows to b | | `b` | mechanical | Load side shaft terminal | | `out` | signal | Torque from a to b, in N·m | ## Model The sensor is a series branch with no impedance, so a and b turn at the same speed and form a rigid coupling. The output is the torque that flows from a to b, positive when the motor on a drives the load on b. It has no parameters, and the same torque is the result i(TS1). The shaft torque differs from Te(M1) by the torque that accelerates the machine inertia and overcomes its friction. ## Common mistakes - Put the motor on a and the load on b, with different net names. Swapping the sides flips the sign, and putting both pins on one net shorts the sensor so it reads 0. - The torque that accelerates the inertia on side a does not pass through the sensor. During acceleration the reading is below Te(M1), and the two agree only at constant speed with no friction. - The coupling is rigid, so the sensor cannot show torsional resonance or backlash. An unconnected a or b is reported as a problem, and that side then has no load. Problems rules: `pin.unconnected` ## Datasheet and sources There are no parameters. A torque transducer datasheet gives only a range and accuracy, which this ideal sensor does not model, so place it where the real transducer sits in the shaft line. ## Example Open the example with the command `file.openExample` and the name `demo:torqueSensor`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Vehicle Load (`vehicle`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/vehicle/ > A road vehicle seen at its wheel shaft: mass, rolling resistance, air drag and road grade. ![vehicle](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/vehicle.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/mechanical/vehicle/) **Group:** Mechanical · **Kind:** `{"element":"vehicle","kind":"mechanical"}` ## When to use it Use it on the wheel side of a Gear to load an electric vehicle drive with a drive cycle's physics, or to size the motor and the battery for a speed and a slope. ## Pins | Pin | Domain | Meaning | |---|---|---| | `shaft` | mechanical | Wheel shaft, ω = v/r | ## Common parameters - `m`: Vehicle mass with its load (Default: required) - `r`: Wheel radius under load (Default: required) - `crr`: Rolling resistance coefficient (Default: 0) - `cda`: Drag coefficient times frontal area (Default: 0) - `grade`: Road slope, rise over run, uphill positive (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `m` | kg | required | | Vehicle mass with its load | | `r` | m | required | | Wheel radius under load | | `crr` | — | 0 | | Rolling resistance coefficient | | `cda` | m² | 0 | | Drag coefficient times frontal area | | `rho` | kg/m³ | 1.225 | | Air density | | `grade` | % | 0 | | Road slope, rise over run, uphill positive | | `v0` | m/s | 0 | | Vehicle speed at the start | _Parameter descriptions are in English in both languages._ ## Model The vehicle mass acts as the inertia m·r² on the wheel shaft, starting at v0/r. The road load torque is r·(m·g·crr·cos α + ½·ρ·CdA·v·abs(v) + m·g·sin α), with v = ω·r, g = 9.80665 m/s² and α = atan(grade/100). Rolling resistance opposes the motion and fades linearly to zero below 0.1 rad/s. Drag and rolling resistance use the speed of the last accepted step. Wheel slip, tyre and wind are not modelled. ## Common mistakes - The part is the whole vehicle at one wheel shaft. Put the final drive ratio in a Gear between the motor and this part, and r is the loaded wheel radius, not the rim. - grade is in percent (rise over run), not degrees. A positive grade is uphill for positive speed, and the vehicle rolls back when nothing holds it. - Rolling resistance fades to zero at standstill, so a vehicle on a slope does not stay parked. Hold it with a Speed Source or the drive. Problems rules: `pin.unconnected`, `compile.error` ## Datasheet and sources m is the test mass from the vehicle homologation document, r the dynamic rolling radius of the tyre size. crr comes from the tyre label (the EU tyre label class gives its range) or a coast-down test, and CdA from the manufacturer or the coast-down test. rho is the ISO 2533 sea-level air density, 1.225 kg/m³. ## Example Open the example with the command `file.openExample` and the name `demo:vehicle`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Ammeter (`ammeter`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/meters/ammeter/ > A zero-volt meter in series that reports the current as a signal on out. ![ammeter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/ammeter.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/meters/ammeter/) **Group:** Meters · **Kind:** `{"kind":"meter","quantity":"current"}` ## When to use it Use it to feed a current into a control block or onto a scope without a shunt resistor. To measure voltage, use Voltmeter. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | One end; positive current flows from p to n | | `n` | electrical | The other end; the current continues from here | | `out` | signal | Signal output with the current in amperes | ## Common parameters - `bandwidth`: How fast the measurement can follow (Default: optional (off)) - `sensitivity`: Output change per unit measured (Default: 1) - `vref`: Output voltage when the input is zero (Default: 0) - `outMin`: Lowest voltage the sensor can output (Default: optional (off)) - `outMax`: Highest voltage the sensor can output (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `bandwidth` | Hz | optional (off) | 1k – 20meg Hz | How fast the measurement can follow | | `delay` | s | 0 | 0 – 10u s | Delay before the reading appears | | `gain` | — | 1 | 900m – 1.1 | Scale error of the reading | | `offset` | — | 0 | | Fixed error added to the reading | | `sensitivity` | — | 1 | 1m – 100 | Output change per unit measured | | `vref` | V | 0 | 100m – 15 V | Output voltage when the input is zero | | `outMin` | V | optional (off) | | Lowest voltage the sensor can output | | `outMax` | V | optional (off) | | Highest voltage the sensor can output | | `noise` | V | 0 | 1u – 100m V | Random noise added to the output | | `seed` | — | 1 | | Number that picks the noise pattern | _Parameter descriptions are in English in both languages._ **Use for:** Current loops · Overcurrent sensing · Real sensor models **Not for:** Measuring a voltage → [`voltmeter`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/meters/voltmeter/) · A Hall sensor with datasheet values → [`hallCurrentSensor`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/hallCurrentSensor/) ## Formulas | Formula | Equation | Source | |---|---|---| | Sensor output | out = vref + sensitivity·i | Allegro MicroSystems, ACS712 data sheet, characteristic definitions (sensitivity, zero-current output voltage) | | Full-scale current | ifs = (outMax − vref) / sensitivity | Allegro MicroSystems, ACS712 data sheet, characteristic definitions (sensitivity, zero-current output voltage) | ## Quick check Inputs: - `i`: Measured current = 10 A - `sensitivity`: Sensitivity = 100m V/A, `sensitivity` - `vref`: Output at zero current = 2.5 V, `vref` - `outMin`: Lowest output = 0 V, `outMin` - `outMax`: Highest output = 5 V, `outMax` Outputs: - `out`: Sensor output = `limit(vref + sensitivity*i, outMin, outMax)` V - `ifs`: Largest positive current = `(outMax - vref)/sensitivity` A - `ineg`: Largest negative current = `(outMin - vref)/sensitivity` A ## Model logic - The meter is a zero-volt source between p and n with its current as an unknown, so it adds no drop and no burden to the circuit. - It counts as a voltage source, so a meter across a source, or in a loop of voltage sources, makes the circuit unsolvable. - The output is vref + sensitivity·gain·i + offset, then the low-pass at bandwidth, the delay, noise and the limits outMin and outMax, each only when set. ## Model The meter is a zero-volt source between p and n with the current as an unknown, so it adds no drop. The output starts as the current i and becomes out = vref + sensitivity * gain * i + offset, then goes through a first-order low-pass at bandwidth, a pure delay, seeded Gaussian noise of noise volts rms, and a limit to outMin ... outMax. With none of these set, the output is the instantaneous current in amperes. ## Common mistakes - The ammeter counts as an ideal voltage source, so putting it across a source, or in a loop of such parts, makes the circuit unsolvable. Place it in series with the branch you want to measure. - Joining out to a power net is flagged. The sign follows p to n, so turn the meter around when the reading is negative. - To model a real current sensor, set sensitivity (V/A), vref (the output at zero current, 1.65 V or 2.5 V for a two-way part) and outMin and outMax (the output swing). A reading stuck at one of these limits is clipped, and noise with a whole-number seed repeats exactly on every run. Problems rules: `loop.voltage_sources`, `pin.domain_mismatch` ## Datasheet and sources The defaults give an ideal meter. For a real sensor, take bandwidth, delay, sensitivity (185 mV/A is 0.185), vref, outMin, outMax, noise, gain and offset from its datasheet, or use a library sensor such as Hall-Effect Current Sensor, which already has them. ## Example Open the example with the command `file.openExample` and the name `demo:ammeter`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # LISN (`lisn`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/meters/lisn/ > One line of the 50 uH network that sits between the supply and the equipment for a conducted-EMI bench. ![lisn](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/lisn.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/meters/lisn/) **Group:** Meters · **Kind:** `{"kind":"lisn"}` ## When to use it Use one on each supply line of a converter to read its conducted noise at the receiver port. For a full pre-compliance scan with limits, use the emi.conducted command instead. ## Pins | Pin | Domain | Meaning | |---|---|---| | `line` | electrical | To the supply | | `eut` | electrical | To the equipment under test | | `meas` | electrical | Receiver port; read v(meas) against gnd | | `gnd` | electrical | Reference ground of the network | ## Common parameters - `l`: Inductance from the supply to the equipment (Default: 50u) - `cm`: Coupling capacitance to the receiver port (Default: 0.1u) - `rm`: Input resistance of the receiver (Default: 50) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `l` | H | 50u | | Inductance from the supply to the equipment | | `csup` | F | 1u | | Capacitance from the supply side to ground | | `cm` | F | 0.1u | | Coupling capacitance to the receiver port | | `rd` | Ω | 1k | | Bleed resistance across the receiver port | | `rm` | Ω | 50 | | Input resistance of the receiver | _Parameter descriptions are in English in both languages._ **Use for:** Conducted-EMI benches · Input filter design **Not for:** Reading the DC line voltage → [`voltmeter`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/meters/voltmeter/) ## Formulas | Formula | Equation | Source | |---|---|---| | Receiver port resistance | R = rd·rm/(rd + rm) | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 3 (resistors in parallel) | | Coupling corner | f = 1/(2π·cm·R) | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 16 (high-pass corner) | | CISPR network impedance | abs(Z) = 50·X/√(50² + X²), X = 2π·f·50 µH | CISPR 16-1-2:2014, 50 Ω ∥ 50 µH artificial mains network | ## Quick check Inputs: - `l`: Line inductance = 50u H, `l` - `cm`: Coupling capacitance = 100n F, `cm` - `rd`: Bleed resistance = 1k Ω, `rd` - `rm`: Receiver input resistance = 50 Ω, `rm` - `f`: Frequency = 1meg Hz Outputs: - `rport`: Receiver port resistance = `rd*rm/(rd + rm)` Ω - `fc`: Coupling corner = `1/(2*pi*cm*rport)` Hz - `zcispr`: CISPR impedance at f = `50*(2*pi*f*50e-6)/sqrt(50^2 + (2*pi*f*50e-6)^2)` Ω - `zline`: This network well above fc = `rport*(2*pi*f*l)/sqrt(rport^2 + (2*pi*f*l)^2)` Ω ## Model logic - The inductor l runs from line to eut and carries the equipment's supply current, i(name); csup goes from line to gnd. - cm couples eut to meas, where the bleed resistor rd and the receiver's rm go to gnd; v(meas) is the receiver reading. - With the supply shorted by csup at noise frequencies, the equipment sees l in parallel with cm and rd ∥ rm, within 12 percent of 50 Ω ∥ 50 µH from 150 kHz to 30 MHz. - All parts are ideal; the receiver's detectors and bandwidth are not modelled, so use emi.conducted for a scan against limits. ## Model The inductor l runs from line to eut and carries the equipment's supply current, i(name). csup goes from line to gnd, and cm couples eut to the receiver port meas, where the bleed resistor rd and the receiver's input resistance rm go to gnd. At the noise frequencies the supply side is shorted by csup, so the equipment sees l in parallel with cm and rd parallel rm. With the defaults this is within 12 percent of the 50 ohm parallel 50 uH of CISPR 16-1-2 from 150 kHz to 30 MHz, and above 1 MHz the receiver port reads nearly the whole line voltage. The parts are ideal. ## Common mistakes - The receiver port only sees noise. The DC line voltage is blocked by cm, so v(meas) settles around zero. - Put the gnd pin on the circuit's ground or chassis net. Left open, the network floats and reads nothing useful. Problems rules: `island.floating` ## Datasheet and sources The defaults are the 50 uH network of Texas Instruments SNVA489C (AN-2162, revised April 2013), Figure 13: 50 uH, 1 uF on the supply side, 0.1 uF to the receiver port, 1000 ohm across it and the 50 ohm receiver. ## Example Open the example with the command `file.openExample` and the name `demo:lisn`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # NTC Temperature Sensor (`ntcSensor`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/meters/ntcSensor/ > A thermistor that reads the temperature of a thermal net as a resistance, by the Steinhart-Hart or the B equation. ![ntcSensor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/ntcSensor.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/meters/ntcSensor/) **Group:** Meters · **Kind:** `{"kind":"ntcSensor"}` ## When to use it Use it to measure a heatsink, a winding or a module baseplate through a divider into an ADC or a comparator, for over-temperature protection or derating. Use NTC Thermistor for inrush limiting. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | One terminal | | `n` | electrical | The other terminal | ## Common parameters - `r25`: Resistance at 25 °C (Default: 10k) - `law`: Resistance law: steinhartHart (a1 to d1) or beta (b only) (Default: steinhartHart) - `b`: B value: how fast the resistance falls with temperature (Default: 3977) - `thermal`: Thermal net for its heat and temperature; replaces delta and cth (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `r25` | Ω | 10k | | Resistance at 25 °C | | `law` | — | steinhartHart | | Resistance law: steinhartHart (a1 to d1) or beta (b only) | | `b` | K | 3977 | | B value: how fast the resistance falls with temperature | | `a1` | 1/K | 3.354016m | | Steinhart–Hart a1: 1/T at R = r25 | | `b1` | 1/K | 256.985u | | Steinhart–Hart b1: coefficient of ln(R/r25) | | `c1` | 1/K | 2.620131u | | Steinhart–Hart c1: coefficient of ln²(R/r25) | | `d1` | 1/K | 63.83091n | | Steinhart–Hart d1: coefficient of ln³(R/r25) | | `delta` | W/K | 7m | | Dissipation factor: heat it loses per kelvin above its surroundings | | `cth` | J/K | 0.105 | | Heat capacity | | `ta` | °C | 25 | | Temperature of its surroundings | | `thermal` | — | optional (off) | | Thermal net for its heat and temperature; replaces delta and cth | _Parameter descriptions are in English in both languages._ **Use for:** Heatsink temperature · Over-temperature protection · Derating inputs **Not for:** Inrush limiting → [`ntc`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/ntc/) ## Formulas | Formula | Equation | Source | |---|---|---| | Resistance by the B equation | R = r25·exp(b·(1/(T + 273.15) − 1/298.15)) | IEC 60539-1:2016, B value | | Divider output, NTC to ground | Vout = Vref·R/(R + Rfix) | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 3 (voltage division) | | Self-heating error | ΔT = P/delta = Vout²/(R·delta) | IEC 60539-1:2016, dissipation factor | ## Quick check Inputs: - `r25`: Resistance at 25 °C = 10k Ω, `r25` - `b`: B value = 3.977k K, `b` - `delta`: Dissipation factor = 7m W/K, `delta` - `tb`: Measured temperature = 85 °C - `rfix`: Divider resistor = 10k Ω - `vref`: Divider supply = 3.3 V Outputs: - `rt`: Resistance at tb = `r25*exp(b*(1/(tb + 273.15) - 1/298.15))` Ω - `vout`: Divider output = `vref*rt/(rt + rfix)` V - `dt`: Self-heating error = `vout^2/rt/delta` K ## Model logic - With law steinhartHart the resistance solves 1/T = a1 + b1·x + c1·x² + d1·x³ for x = ln(R/r25), by Newton's method inside a bracket; with law beta it is r25·exp(b·(1/T - 1/298.15 K)). - With thermal set, T is the temperature of that thermal net and its own small heat flows into it. - Without it, T starts at ta and after each accepted step moves toward ta + P/delta with the time constant cth/delta. - Each step uses the resistance at the temperature reached at the end of the last step. ## Model With law steinhartHart the resistance R solves 1/T = a1 + b1 * x + c1 * x² + d1 * x³ with x = ln(R / r25) and T in kelvin (the classic three-term equation is r25 = 1 Ohm, c1 = 0). With law beta it follows R = r25 * exp(b * (1/T - 1/298.15 K)). With thermal set, T is the temperature of that thermal net and its own small heat flows into it. With no thermal net, its temperature rises with its power over cth and falls toward ta with the dissipation factor delta, and is the waveform T(name). T is updated after each step. ## Common mistakes - Its own power heats it: delta is 7 mW/K, so 1 mW in the divider reads about 0.14 K high. Keep the divider current small. - Without a thermal net it reads only its own body temperature, which stays at ta. Set thermal to the net of the part it measures. ## Datasheet and sources Take r25 and b (B25/85) from the ordering table. The Steinhart-Hart coefficients a1 to d1 come from the table of parameters for the nominal resistance values, in the row of your B value. delta is the dissipation factor and cth is the thermal time constant times delta. The defaults are the Vishay NTCLE100E3103 (10 kOhm, B25/85 = 3977 K), data sheet 29049 of 07-May-2025, pages 1, 2 and 4. ## Example Open the example with the command `file.openExample` and the name `demo:ntcSensor`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Voltmeter (`voltmeter`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/meters/voltmeter/ > Reports the voltage between p and n as a signal on out. ![voltmeter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/voltmeter.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/meters/voltmeter/) **Group:** Meters · **Kind:** `{"kind":"meter","quantity":"voltage"}` ## When to use it Use it to feed a voltage into a control block or put it on a scope. To measure current, use Ammeter. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | Positive sense end; reads v(p) - v(n) | | `n` | electrical | Negative sense end | | `out` | signal | Signal output with the voltage in volts | ## Common parameters - `bandwidth`: How fast the measurement can follow (Default: optional (off)) - `gain`: Scale error of the reading (Default: 1) - `offset`: Fixed error added to the reading (Default: 0) - `delay`: Delay before the reading appears (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `bandwidth` | Hz | optional (off) | 1k – 20meg Hz | How fast the measurement can follow | | `delay` | s | 0 | 0 – 10u s | Delay before the reading appears | | `gain` | — | 1 | 900m – 1.1 | Scale error of the reading | | `offset` | — | 0 | | Fixed error added to the reading | | `sensitivity` | — | 1 | 1m – 100 | Output change per unit measured | | `vref` | V | 0 | 100m – 15 V | Output voltage when the input is zero | | `outMin` | V | optional (off) | | Lowest voltage the sensor can output | | `outMax` | V | optional (off) | | Highest voltage the sensor can output | | `noise` | V | 0 | 1u – 100m V | Random noise added to the output | | `seed` | — | 1 | | Number that picks the noise pattern | _Parameter descriptions are in English in both languages._ **Use for:** Voltage feedback · Scope signals · Real sensor models **Not for:** Measuring a current → [`ammeter`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/meters/ammeter/) · Isolated voltage sensing → [`isolatedVoltageSensor`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/isolatedVoltageSensor/) ## Formulas | Formula | Equation | Source | |---|---|---| | Gain at frequency f | abs(H) = gain / √(1 + (f/bandwidth)²) | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 16 (Bode diagrams) | | Phase lag at frequency f | φ = −atan(f/bandwidth) − 360·f·delay | Ogata, Modern Control Engineering, 5th ed. (2010), ch. 7 (first-order factor and transport lag) | ## Quick check Inputs: - `x`: Measured voltage = 400 V - `gain`: Gain = 1 —, `gain` - `bandwidth`: Bandwidth = 10k Hz, `bandwidth` - `delay`: Delay = 1u s, `delay` - `f`: Signal frequency = 1k Hz Outputs: - `out`: Steady reading = `gain*x` V - `mag`: Gain at f = `gain/sqrt(1 + (f/bandwidth)^2)` — - `phase`: Phase at f = `-atan(f/bandwidth)*180/pi - 360*f*delay` ° ## Model logic - The meter stamps nothing: it draws no current and does not load the circuit, so the reading is v(p) − v(n) exactly. - The output is vref + sensitivity·gain·x + offset, then a first-order low-pass at bandwidth, a delay, noise and the limits outMin and outMax. - Only the stages that are set are added, so with none set the output is the instantaneous voltage; unset bandwidth means no filter. - noise is Gaussian from seed, held for 1 µs per value, so a whole-number seed gives the same noise on every run. ## Model The meter has infinite input resistance, draws no current and adds nothing to the circuit. Its output starts as x = v(p) - v(n) and becomes out = vref + sensitivity * gain * x + offset, then goes through a first-order low-pass at bandwidth, a pure delay, seeded Gaussian noise of noise volts rms, and a limit to outMin ... outMax. With none of these set, the output is the instantaneous voltage. ## Common mistakes - A signal net can have only one writer, so joining out to a net that another block already drives is an error. Joining out to a power net is also flagged. - A low bandwidth or a long delay adds phase lag to the control loop it feeds. Typical values are 1k to 20M Hz and up to 10u s, and a gain outside 0.9 to 1.1 is flagged. Problems rules: `compile.error`, `pin.domain_mismatch`, `param.out_of_range` ## Datasheet and sources The defaults give an ideal meter. To model a real sensor, take bandwidth from its -3 dB bandwidth, delay from its propagation delay, and gain and offset from its gain and offset error. ## Example Open the example with the command `file.openExample` and the name `demo:voltmeter`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Capacitor (`capacitor`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/capacitor/ > Stores energy in its voltage. Can add series resistance, series inductance and leakage. ![capacitor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/capacitor.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/passive/capacitor/) **Group:** Passive · **Kind:** `{"kind":"capacitor"}` ## When to use it Use it for DC links, outputs, snubbers and filters. To store energy in a current, use Inductor. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | One end; positive voltage and current run p to n | | `n` | electrical | The other end | ## Common parameters - `c`: Capacitance (Default: required) - `esr`: ESR: small resistance in series with it (Default: 0) - `v0`: Initial voltage; the voltage across it at the start (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `c` | F | required | | Capacitance | | `v0` | V | 0 | | Initial voltage; the voltage across it at the start | | `esr` | Ω | 0 | 1m – 1 Ω | ESR: small resistance in series with it | | `esl` | H | 0 | 1n – 50n H | ESL: small inductance in series with it | | `rleak` | Ω | optional (off) | 100k – 1g Ω | Resistance that lets charge leak away | | `temp` | °C | 25 | | Part temperature the temperature tables are read at | | `esrTemp` | — | optional (off) | | Temperature (°C) and factor pairs that scale esr, from the datasheet's curve | | `cTemp` | — | optional (off) | | Temperature (°C) and factor pairs that scale the capacitance, from the datasheet's curve | | `part` | — | optional (off) | | Part number; the catalogue part number, such as XAL8080-123MEC or 2 × XAL8080-123MEC for two in series; information only, not simulated | _Parameter descriptions are in English in both languages._ **Use for:** DC links · Output capacitors · Snubbers · Decoupling **Not for:** Bulk energy storage in farads → [`supercap`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/supercap/) ## Formulas | Formula | Equation | Source | |---|---|---| | Output ripple from the ripple current | Δv = Δi / (8·fsw·c) | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), §2.5 | | Output ripple with the series resistance (an upper bound: the two parts peak a quarter period apart) | Δv ≤ Δi·esr + Δi / (8·fsw·c) | Texas Instruments SLVA477B, Basic Calculation of a Buck Converter's Power Stage (2015), Output Capacitor Selection | | Stored energy | E = ½·c·v² | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 7 | | Self-resonant frequency | f = 1 / (2π·√(esl·c)) | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 16 (series resonance) | ## Quick check Inputs: - `c`: Capacitance = 100u F, `c` - `v`: Voltage = 48 V, `v0` - `di`: Ripple current (peak to peak) = 1 A - `fsw`: Switching frequency = 100k Hz - `esl`: Series inductance = 10n H, `esl` - `esr`: Series resistance = 0 Ω, `esr` Outputs: - `dv`: Output ripple (peak to peak, at most) = `di*esr + di/(8*fsw*c)` V - `energy`: Stored energy = `0.5*c*v^2` J - `srf`: Self-resonant frequency = `1/(2*pi*sqrt(esl*c))` Hz ## Model logic - Each step it is a conductance with a current source (trapezoidal rule, backward Euler after a switching event), and the first solve holds v0 across it. - esr and esl are chained in series from p, and rleak sits across the capacitance only; the esl starts with no current. - cTemp and esrTemp scale c and esr once at temp before the run; the capacitance does not change with voltage (no DC bias drop). - Dielectric absorption, ageing, rated voltage and ripple-current rating are not modelled. ## Model The current is i = C * dv/dt, starting from the voltage v0 = v(p) - v(n). Seen from the pins, the parts run in this order: p, esr, esl, then c in parallel with rleak, then n. Each extra parameter is optional, and zero or unset means the ideal part. ## Common mistakes - A capacitor placed straight across an ideal voltage source charges instantly and draws a current spike at the start. Add a small series resistance, or start the capacitor at the source voltage with v0. - esr of 10 means 10 ohm, not 10 milliohm, and values outside 1m to 1 ohm are flagged. Write 10m for ten milliohm. Problems rules: `param.non_positive`, `loop.source_capacitor`, `param.out_of_range` ## Datasheet and sources c is the capacitance at your working voltage and temperature, which can be well below the nominal value for ceramics. esr is the datasheet value at the switching frequency, and esl is worked out from the self-resonant frequency. ## Example Open the example with the command `file.openExample` and the name `demo:capacitor`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Quartz Crystal (`crystal`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/crystal/ > A quartz crystal for oscillators and filters, drawn as its equivalent circuit. ![crystal](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/crystal.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/passive/crystal/) **Group:** Passive · **Kind:** `{"kind":"crystal"}` ## When to use it Use it for crystal oscillators and filters. Use Inductor and Capacitor for an ordinary resonant circuit. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | One electrode | | `n` | electrical | The other electrode | ## Common parameters - `fs`: Frequency where the crystal rings (Default: 10meg) - `q`: How sharp the crystal resonance is (Default: 50k) - `cm`: Capacitance of the vibrating part (Default: 20f) - `c0`: Capacitance across the crystal pins (Default: 5p) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `fs` | Hz | 10meg | | Frequency where the crystal rings | | `q` | — | 50k | | How sharp the crystal resonance is | | `cm` | F | 20f | | Capacitance of the vibrating part | | `c0` | F | 5p | | Capacitance across the crystal pins | | `lm` | H | optional (off) | | Inductance of the vibrating part | | `rm` | Ω | optional (off) | | Resistance of the vibrating part | _Parameter descriptions are in English in both languages._ **Use for:** Crystal oscillators · Crystal filters **Not for:** Ordinary LC resonant circuits → [`inductor`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/inductor/) ## Formulas | Formula | Equation | Source | |---|---|---| | Motional resistance | rm = 1 / (2π·fs·cm·q) | IEEE Std 177-1966, equivalent electrical circuit of a piezoelectric vibrator | | Parallel resonance | fp = fs·√(1 + cm/c0) | IEEE Std 177-1966, equivalent electrical circuit of a piezoelectric vibrator | | Load resonance with cl | fl = fs·(1 + cm / (2·(c0 + cl))) | IEC 60122-1:2002, load resonance frequency offset | ## Quick check Inputs: - `fs`: Series resonance = 10meg Hz, `fs` - `q`: Quality factor = 50k —, `q` - `cm`: Motional capacitance = 20f F, `cm` - `c0`: Shunt capacitance = 5p F, `c0` - `cl`: Load capacitance = 18p F Outputs: - `rm`: Motional resistance = `1/(2*pi*fs*cm*q)` Ω - `fp`: Parallel resonance = `fs*sqrt(1 + cm/c0)` Hz - `fl`: Load resonance = `fs*(1 + cm/(2*(c0 + cl)))` Hz ## Model logic - Before the run the crystal is replaced by rm, lm and cm in series from p to n with c0 across the pins; c0 of 0 leaves it out. - From fs, q and cm it sets lm = 1/((2π·fs)²·cm) and rm = 2π·fs·lm/q; giving lm, cm and rm instead works, but mixing the two sets is refused. - The motional parts start with no current and no charge, so an oscillator builds up from the power-on transient over many Q cycles. - Drive level, overtones, ageing and the temperature curve are not modelled, and the step-size check ignores the crystal. ## Model Before the run, the crystal becomes the resistor rm, inductor lm and capacitor cm in series, with c0 from p to n. The series resonance is fs = 1 / (2 * pi * sqrt(lm * cm)), where the impedance is lowest at about rm. The quality factor is Q = 2 * pi * fs * lm / rm, and the parallel resonance is fp = fs * sqrt(1 + cm / c0), where the impedance peaks. Give fs and q with cm (then lm = 1 / ((2 * pi * fs)^2 * cm) and rm = 2 * pi * fs * lm / q), or give lm, cm and rm directly, but not both. The motional current is the current of the part named name.lm. A parallel-mode oscillator with load capacitance CL runs at f = fs * (1 + cm / (2 * (c0 + CL))). Drive level, aging, overtones and the temperature curve are not modelled. ## Common mistakes - A crystal rings for about Q cycles, so start-up takes tens of thousands of cycles. Check the resonance with impedance analysis, and keep the maximum step under a hundredth of the period yourself, because the step check ignores the crystal. - cm is in femtofarad and c0 in picofarad, so write 20f and 5p. Setting only one of lm and rm, or lm and rm together with fs or q, is refused before the run. Problems rules: `step.too_large`, `param.out_of_range` ## Datasheet and sources Take fs, c0 and cm from the datasheet, and take rm from the series resistance (use a typical value, not the maximum). Without cm, set lm from the motional inductance or set q from a typical value, 10k to 100k for AT-cut crystals and 20k to 100k for 32.768 kHz tuning forks. ## Example Open the example with the command `file.openExample` and the name `demo:crystal`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Ferrite Bead (`ferriteBead`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/ferriteBead/ > A bead that acts as a resistor at noise frequencies and as a small inductor at low frequencies. ![ferriteBead](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/ferriteBead.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/passive/ferriteBead/) **Group:** Passive · **Kind:** `{"kind":"ferriteBead"}` ## When to use it Use it in series with a supply or signal line to soak up noise from tens to hundreds of megahertz. For filtering below 1 MHz, use Inductor or Common-Mode Choke. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | One end | | `n` | electrical | The other end | ## Common parameters - `z`: Impedance at the test frequency (Default: 220) - `zpeak`: Highest impedance on the data sheet's curve (Default: 280) - `fpeak`: Frequency of the highest impedance (Default: 300meg) - `rdc`: DC resistance (Default: 0.1) - `irated`: Rated current; a peak above it raises a warning (Default: 1.4) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `z` | Ω | 220 | | Impedance at the test frequency | | `ftest` | Hz | 100meg | | Frequency of that impedance | | `zpeak` | Ω | 280 | | Highest impedance on the data sheet's curve | | `fpeak` | Hz | 300meg | | Frequency of the highest impedance | | `rdc` | Ω | 0.1 | | DC resistance | | `irated` | A | 1.4 | | Rated current; a peak above it raises a warning | | `isat` | A | optional (off) | | DC bias knee current: above it the inductance is ksat of its value | | `ksat` | — | optional (off) | | Part of the inductance left above isat | _Parameter descriptions are in English in both languages._ **Use for:** Supply-rail noise · Signal-line noise · Noise from 10 MHz up **Not for:** Filtering below 1 MHz → [`inductor`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/inductor/) · Common-mode noise on a pair → [`cmChoke`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/cmChoke/) ## Formulas | Formula | Equation | Source | |---|---|---| | Loss resistance at the peak | R = zpeak − rdc | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 16 (parallel resonance) | | Inductance through the test point | ω·L = abs(f²/fpeak² − 1)/√(1/(z − rdc)² − 1/R²) | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 16 (parallel resonance) | | Capacitance that resonates at fpeak | C = 1/((2π·fpeak)²·L) | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 16 (resonance) | ## Quick check Inputs: - `z`: Impedance at the test frequency = 220 Ω, `z` - `ftest`: Test frequency = 100meg Hz, `ftest` - `zpeak`: Peak impedance = 280 Ω, `zpeak` - `fpeak`: Frequency of the peak = 300meg Hz, `fpeak` - `rdc`: DC resistance = 100m Ω, `rdc` Outputs: - `r`: Loss resistance = `zpeak - rdc` Ω - `lbead`: Inductance = `abs(ftest^2/fpeak^2 - 1)/sqrt(1/(z - rdc)^2 - 1/r^2)/(2*pi*ftest)` H - `cbead`: Capacitance = `1/((2*pi*fpeak)^2*lbead)` F ## Model logic - The bead is rdc in series with an inductor L, a resistor R and a capacitor C in parallel, with R = zpeak - rdc. - C resonates with L at fpeak, and L is solved so that the impedance at ftest is z, so the curve passes through both data-sheet points. - With isat and ksat set, L follows a two-slope knee: its full value below isat and ksat of it above. - A warning appears when the current peaks above irated; the bead does not heat up. ## Model The bead is rdc in series with an inductor L, a resistor R and a capacitor C in parallel. R is zpeak minus rdc, C puts the resonance at fpeak, and L is solved so that the impedance at ftest is z. So the curve passes through the data sheet's test point and its peak. Below the peak it rises like an inductor, and above it falls like a capacitor. One resonance cannot follow a real bead's broad loss, so well below the test frequency the model reads lower than the data sheet's curve. With isat and ksat set, L falls to ksat of its value while the current is above isat, as DC bias does. A warning appears when the current peaks above irated. The current is i(name). ## Common mistakes - A bead with a capacitor after it forms an LC low-pass that can ring at a few megahertz. Check the step response, and add damping if it rings. - The rated current is a heating limit. Near it, DC bias already cuts the impedance a lot, so read the data sheet's impedance against DC current curve for isat and ksat. - The capacitance is well below a picofarad, so the simulation needs a step near a nanosecond to see the peak in time. Use the AC analysis for the impedance. Problems rules: `param.out_of_range` ## Datasheet and sources Take z and ftest from the impedance column and its test frequency, rdc from the DC resistance (maximum) and irated from the rated current. Read zpeak and fpeak from the top of the impedance curve. The defaults are the Murata BLM18PG221SZ1, data sheet last updated 05/25/2024: 220 ohm at 100 MHz, 0.1 ohm and 1.4 A at 85 C from its specifications, and zpeak = 280 ohm at fpeak = 300 MHz read from its impedance curve, so those two are fitted values. The sheet has no DC bias curve, so isat and ksat are unset. ## Example Open the example with the command `file.openExample` and the name `demo:ferriteBead`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Fuse (`fuse`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/fuse/ > A resistor that opens for good once its melting I²t is reached. ![fuse](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/fuse.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/passive/fuse/) **Group:** Passive · **Kind:** `{"kind":"fuse"}` ## When to use it Use it in series with a supply input to cut a short circuit or a failed part. Pick the rating from the steady current and the inrush pulse. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | One terminal | | `n` | electrical | The other terminal | ## Common parameters - `i2t`: Melting I²t (Default: 16) - `imin`: Smallest current that melts it, given time (Default: 3) - `r`: Cold resistance (Default: 30m) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `r` | Ω | 30m | | Cold resistance | | `i2t` | A²s | 16 | | Melting I²t | | `imin` | A | 3 | | Smallest current that melts it, given time | _Parameter descriptions are in English in both languages._ **Use for:** Input protection · Short-circuit cut-off **Not for:** Tripping and reclosing → [`breaker`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/breaker/) · Resettable overcurrent protection → [`ptc`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/ptc/) ## Formulas | Formula | Equation | Source | |---|---|---| | Joule integral | I²t = ∫ i² dt | IEC 60269-1:2006, definitions (Joule integral I²t) | | Melting time of a short pulse | t = i2t / i² | IEC 60269-1:2006, definitions (pre-arcing I²t) | | Loss at the steady current | P = iop²·r | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 2 | ## Quick check Inputs: - `i2t`: Melting I²t = 16 A²s, `i2t` - `imin`: Minimum melting current = 3 A, `imin` - `r`: Cold resistance = 30m Ω, `r` - `i`: Fault current = 10 A - `iop`: Steady current = 2 A Outputs: - `tad`: Melting time without heat loss = `i2t/i^2` s - `tmelt`: Melting time in this model = `(i2t/imin^2)*ln(i^2/(i^2 - imin^2))` s - `p`: Loss at the steady current = `iop^2*r` W ## Model logic - It is the resistance r while whole; after each accepted step a melting integral adds the mean of i² over the step and leaks with the time constant i2t/imin². - A steady current I above imin melts it after (i2t/imin²)·ln(I²/(I² − imin²)); one below imin settles below i2t and never melts it. - When the integral reaches i2t at the end of a step, the fuse becomes 1 GΩ for the rest of the run and a warning says so. - The arc, the arc voltage, the breaking capacity and temperature derating are not modelled. ## Model The fuse is the resistance r until it melts. It adds up the square of its current in a melting integral that leaks away with the time constant i2t / imin². A short pulse melts it when its I²t reaches i2t. A current below imin never melts it. When the integral reaches i2t, the fuse opens and stays open as 1 GΩ for the rest of the run, and a warning says so. The arc while it opens is not modelled. ## Common mistakes - The inrush pulse of a capacitive load can melt a fast fuse. Compare the I²t of the inrush with i2t, or use a time-lag fuse. - Once open, the fuse stays open for the rest of the run. Run the circuit again to start with a whole fuse. ## Datasheet and sources Take i2t from the melting I²t column, r from the cold resistance (or the voltage drop at the rated current divided by that current), and imin from the pre-arcing time table: the largest current that must not melt it, such as 1.5 times the rated current. The defaults are the SCHURTER FST 5x20 T2A (0034.3120), data sheet of 21.07.2026. ## Example Open the example with the command `file.openExample` and the name `demo:fuse`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Gas Discharge Tube (`gdt`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/gdt/ > A tube that is open until its sparkover voltage, then shorts the line through an arc. ![gdt](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/gdt.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/passive/gdt/) **Group:** Passive · **Kind:** `{"kind":"gdt"}` ## When to use it Use it across telecom or signal lines and before a varistor to divert lightning surges. Keep the follow current of the line below ihold, or the arc does not go out. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | One terminal; the part is the same both ways | | `n` | electrical | The other terminal | ## Common parameters - `vs`: DC sparkover voltage: it fires at this voltage (Default: 90) - `varc`: Arc voltage while it fires (Default: 10) - `ihold`: Current below which the arc goes out (Default: 0.5) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `vs` | V | 90 | | DC sparkover voltage: it fires at this voltage | | `varc` | V | 10 | | Arc voltage while it fires | | `ihold` | A | 0.5 | | Current below which the arc goes out | | `rins` | Ω | 1G | | Insulation resistance while it does not fire | | `rarc` | Ω | 1m | | Slope resistance of the arc | _Parameter descriptions are in English in both languages._ **Use for:** Telecom and signal lines · Lightning surges · The first stage before a varistor **Not for:** Mains lines that can feed a follow current → [`varistor`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/varistor/) · Fast low-voltage clamps → [`tvs`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/tvs/) ## Formulas | Formula | Equation | Source | |---|---|---| | Follow current from the line | I = (Vline − varc)/Rs | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 2 (Ohm's law) | | Arc quench margin | m = ihold/I | IEC 61643-311:2013, terms and definitions (arc voltage, glow-to-arc transition current) | | Arc power at the surge peak | P = (varc + rarc·Ipk)·Ipk | IEC 61643-311:2013, terms and definitions (arc voltage) | ## Quick check Inputs: - `vsup`: Line voltage after the surge = 48 V - `rs`: Source resistance of the line = 10 Ω - `varc`: Arc voltage = 10 V, `varc` - `rarc`: Arc slope resistance = 1m Ω, `rarc` - `ihold`: Current that keeps the arc = 500m A, `ihold` - `ipk`: Surge peak current = 1k A Outputs: - `ifollow`: Follow current = `(vsup - varc)/rs` A - `quench`: Quench margin (above 1 it goes out) = `ihold/ifollow` — - `parc`: Arc power at the peak = `(varc + rarc*ipk)*ipk` W ## Model logic - It is rins until abs(v) reaches vs at the end of a step; it fires from the next step. - Firing, it adds an arc knee at varc with the slope resistance rarc, the same both ways, in parallel with rins. - When abs(i) at the end of a step falls below ihold, the arc goes out from the next step. - The glow region, the higher impulse sparkover at fast edges and its capacitance are not modelled. ## Model The tube is the insulation resistance rins until the voltage across it reaches vs. From the next step, it holds the arc voltage varc with the slope resistance rarc, either way. When the current falls below ihold, the arc goes out from the next step. The glow region, the impulse sparkover at fast edges and its capacitance are not modelled. ## Common mistakes - A supply that can feed more than ihold keeps the arc burning after the surge. Add a series resistance or a fuse. - A fast surge fires a real tube far above vs. Check the impulse sparkover on the data sheet for the voltage the next stage sees. ## Datasheet and sources Take vs from the DC sparkover voltage, varc from the arc voltage, ihold from the glow-to-arc transition current, and rins from the insulation resistance. The defaults are the Bourns 2027-09, 2027 series data sheet REV. F. ## Example Open the example with the command `file.openExample` and the name `demo:gdt`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Inductor (`inductor`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/inductor/ > Stores energy in its current. Can add winding resistance, core loss and saturation. ![inductor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/inductor.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/passive/inductor/) **Group:** Passive · **Kind:** `{"kind":"inductor"}` ## When to use it Use it for filters, buck and boost stages and energy storage. For two windings, use Coupled Inductor or Transformer. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | One end; positive current flows from p to n | | `n` | electrical | The other end | ## Common parameters - `l`: Inductance (Default: required) - `i0`: Initial current; the current through it at the start (Default: 0) - `dcr`: Winding resistance; the wire resistance of the winding (Default: 0) - `isat`: Current where the core starts to saturate (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `l` | H | required | | Inductance | | `i0` | A | 0 | | Initial current; the current through it at the start | | `dcr` | Ω | 0 | 1m – 500m Ω | Winding resistance; the wire resistance of the winding | | `isat` | A | optional (off) | 100m – 200 A | Current where the core starts to saturate | | `lsat` | H | optional (off) | 100n – 1m H | Inductance once the core is saturated | | `isatTemp` | — | optional (off) | | Temperature (°C) and factor pairs that scale isat at coreTemp, from the datasheet's curve | | `rcore` | Ω | optional (off) | 1k – 1meg Ω | Resistance that models core loss | | `core` | — | optional (off) | | Core from the catalogue; it sets the inductance curve and the core loss | | `material` | — | optional (off) | | Core material; needed when core names a shape | | `turns` | — | optional (off) | | Turns on the core | | `gap` | m | optional (off) | | Air gap in the core; unset uses the catalogue core's gap | | `fsw` | Hz | optional (off) | | Switching frequency; core and winding losses are worked out once per period | | `coreTemp` | °C | 25 | | Core and winding temperature | | `wire` | — | optional (off) | | Wire from the catalogue; gives the winding's extra resistance at high frequency | | `layers` | — | 1 | | Winding layers; used for the extra resistance at high frequency | | `coreAe` | m² | optional (off) | | Effective area of a core you describe yourself; use with coreLe instead of core | | `coreLe` | m | optional (off) | | Magnetic path length of a core you describe yourself; use with coreAe | | `coreVe` | m³ | optional (off) | | Volume of that core for its core loss; coreAe times coreLe when unset | | `bhCurve` | — | optional (off) | | B-H curve of the core; pairs H:B in A/m and T, such as 0:0, 50:0.3, 200:0.45; replaces the material's curve | | `psiCurve` | — | optional (off) | | Flux linkage of the winding against its current from a field solve; pairs i:λ in A and Wb, such as 0:0, 1:2e-3, 4:5e-3 (odd about zero current), or from a negative current through 0 for a magnet-biased winding, such as -4:-1e-3, 0:2e-3, 4:4e-3; replaces the core's curve | | `steinmetzK` | W/m³ | optional (off) | | Steinmetz k of the core loss k·f^α·B^β, with f in Hz and B the peak flux density in T | | `steinmetzAlpha` | — | optional (off) | | Steinmetz α, the frequency exponent of the core loss | | `steinmetzBeta` | — | optional (off) | | Steinmetz β, the flux-density exponent of the core loss | | `magneticsDesign` | — | optional (off) | | Saved design from magnetics.design; the separate core parameters win over it | | `surface` | m² | optional (off) | | Outside surface of the wound part to the air; design.thermal gives its temperature rise from it and the loss | | `part` | — | optional (off) | | Part number; the catalogue part number, such as XAL8080-123MEC or 2 × XAL8080-123MEC for two in series; information only, not simulated | _Parameter descriptions are in English in both languages._ **Use for:** Buck and boost inductors · LC filters · PFC chokes **Not for:** Two coupled windings → [`coupledInductor`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/coupledInductor/) · Isolation with a turns ratio → [`transformer`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/transformer/) ## Formulas | Formula | Equation | Source | |---|---|---| | Ripple current (peak to peak) | Δi = vl·ton / l | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), §2.2 | | Stored energy at the peak | E = ½·l·(idc + Δi/2)² | Mohan, Undeland & Robbins, Power Electronics, 3rd ed. (2003), ch. 3 | | Saturation margin | isat − (idc + Δi/2) | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), ch. 11 (inductor design, peak current) | ## Quick check Inputs: - `l`: Inductance = 100u H, `l` - `vl`: Voltage across it while on = 36 V - `ton`: On time = 2.5u s - `idc`: DC current = 5 A - `isat`: Saturation current = 8 A, `isat` Outputs: - `di`: Ripple current (peak to peak) = `vl*ton/l` A - `energy`: Stored energy at the peak = `0.5*l*(idc + di/2)^2` J - `margin`: Saturation margin = `isat - (idc + di/2)` A ## Model logic - Each step it is a conductance with a current source (trapezoidal rule, backward Euler on the step after a switching event), starting from the current i0. - dcr is a resistor in series and rcore a resistor across the inductance; zero or unset leaves each one out. - With isat set, a step uses l or lsat (0.2·l when unset) by the current of the previous accepted step: a hard two-slope knee, not iterated. - With core, or coreAe and coreLe, set, the core's curve replaces isat and lsat and its core loss replaces rcore, with a warning. ## Model The voltage is v = L * di/dt, starting from the current i0 (p to n). dcr is a resistance in series, and rcore is a resistance across the inductance for core loss. When isat is set, the inductance is l while the current magnitude stays below isat and lsat above it (0.2 * l when lsat is unset), using the current of the previous accepted step. Saturation is a two-slope knee, not a measured B-H curve. ## Common mistakes - A current source that feeds only inductors leaves its node without a resistive path. Put a large resistor across the source. - Inductance is in henry, so 100 means 100 H, not 100u. Set isat below the peak current only on purpose, because the ripple grows sharply above it. - When the inductor current falls to zero, the converter runs in discontinuous mode. The simulator tells you which mode the inductor ran in. Problems rules: `param.non_positive`, `cutset.inductor_current`, `param.out_of_range`, `inductor.mode` ## Datasheet and sources l is the inductance at the rated DC current, dcr is the maximum DC resistance, and isat is the current where the inductance has dropped by the stated percentage. lsat is the inductance read from the curve at high current, and rcore is a one-frequency estimate of core loss. ## Example Open the example with the command `file.openExample` and the name `demo:inductor`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # NTC Thermistor (`ntc`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/ntc/ > A resistor that falls as it heats, used to limit inrush current. ![ntc](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/ntc.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/passive/ntc/) **Group:** Passive · **Kind:** `{"kind":"ntc"}` ## When to use it Use it in series with a supply input to limit the inrush current into the bulk capacitors. It also works as a temperature sensor on a thermal net. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | One terminal | | `n` | electrical | The other terminal | ## Common parameters - `r25`: Resistance at 25 °C (Default: 10) - `b`: B value: how fast the resistance falls with temperature (Default: 2818) - `delta`: Dissipation factor: heat it loses per kelvin above its surroundings (Default: 10m) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `r25` | Ω | 10 | | Resistance at 25 °C | | `b` | K | 2818 | | B value: how fast the resistance falls with temperature | | `delta` | W/K | 10m | | Dissipation factor: heat it loses per kelvin above its surroundings | | `cth` | J/K | 0.7 | | Heat capacity | | `ta` | °C | 25 | | Temperature of its surroundings | | `thermal` | — | optional (off) | | Thermal net for its heat and temperature; replaces delta and cth | | `imax` | A | 3.5 | | Largest steady current; above it the part is in a surge | | `ct` | F | 300u | | Test capacitance: the capacitor it may charge in one surge from the peak of vt | | `vt` | V | 230 | | RMS mains voltage the test capacitance is given at | _Parameter descriptions are in English in both languages._ **Use for:** Inrush limiting · Temperature sensing **Not for:** Precise temperature sensing → [`ntcSensor`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/meters/ntcSensor/) · Resettable overcurrent protection → [`ptc`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/ptc/) ## Formulas | Formula | Equation | Source | |---|---|---| | Resistance at the body temperature | R = r25·exp(b·(1/(tb + 273.15) − 1/298.15)) | IEC 60539-1:2016, B value | | Power that holds it at tb | P = delta·(tb − ta) | IEC 60539-1:2016, dissipation factor | ## Quick check Inputs: - `r25`: Resistance at 25 °C = 10 Ω, `r25` - `b`: B value = 2.818k K, `b` - `delta`: Dissipation factor = 10m W/K, `delta` - `ta`: Ambient temperature = 25 °C, `ta` - `tb`: Body temperature = 100 °C Outputs: - `rt`: Resistance at tb = `r25*exp(b*(1/(tb + 273.15) - 1/298.15))` Ω - `p`: Power that holds it at tb = `delta*(tb - ta)` W - `ihold`: Steady current at tb = `sqrt(p/rt)` A ## Model logic - Each step it is the resistance r25·exp(b·(1/T − 1/298.15 K)) at the body temperature T reached at the end of the last step. - It starts at ta; after each accepted step T moves toward ta + P/delta with the time constant cth/delta, exact for a constant power. - With thermal set, T is the temperature of that thermal net and its heat goes into the net; delta and cth are then not used. - The energy taken while the current is above imax is compared with ½·ct·(√2·vt)², and more raises a warning; the part does not fail. ## Model The resistance follows R = r25 * exp(b * (1/T - 1/298.15 K)). Its own power heats it: with no thermal net, its temperature T rises with the power over cth and falls toward ta with the dissipation factor delta, so it settles at ta + P / delta. With thermal set, T is the temperature of that thermal net, and its heat flows into that net. T is updated after each step, so the resistance of a step is the one at the end of the last step. With no thermal net, its temperature is the waveform T(name). ## Common mistakes - A hot NTC has a low resistance, so a quick restart sees almost no inrush limit. Run the off time too when that matters. - The resistance changes over seconds. A run of a few milliseconds shows only the cold resistance. ## Datasheet and sources Take r25 from the ordering table, delta (dissipation factor) and cth (heat capacity) from the general technical data, and b from the B value. When the data sheet gives only Rmin at Imax, b = ln(r25 / Rmin) / (1/298.15 K - 1/T), with T = 298.15 K + Imax² * Rmin / delta. Take imax from the maximum current and ct from the test capacitance at the mains voltage vt: one surge may put ½ * ct * (√2 * vt)² into it, and more raises a warning. Only the energy absorbed while the current is above imax counts as the surge. The defaults are the TDK B57236S0100M (S236, 10 Ω), data sheet July 2019, with imax and ct from the TDK Product Center page of B57236S0100M000. ## Example Open the example with the command `file.openExample` and the name `demo:ntc`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Pi-Section Line (`piLine`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/piLine/ > A transmission line as series R-L with half its shunt capacitance at each end, from per-metre values and a length, in one or more pi sections in cascade. ![piLine](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/piLine.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/passive/piLine/) **Group:** Passive · **Kind:** `{"kind":"piLine"}` ## When to use it Use it for an overhead line or a cable between a source and a load: the voltage rise at the open end of a long line, the line drop under load, or the resonance of a cable with the grid. For one phase of a balanced three-phase system use Three-Phase Pi-Section Line. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p1` | electrical | Sending end of the line | | `p2` | electrical | Receiving end of the line | | `g` | electrical | Return of the shunt capacitance: ground or the return conductor | ## Common parameters - `r`: Series resistance per metre of line (per phase for the three-phase line) (Default: required) - `l`: Series inductance per metre of line (per phase, positive sequence) (Default: required) - `c`: Shunt capacitance per metre of line (per phase, positive sequence) (Default: required) - `length`: Length of the line (Default: required) - `sections`: Pi sections in cascade, 1 to 1000; more follow the distributed line to higher frequencies (Default: 1) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `r` | Ω/m | required | | Series resistance per metre of line (per phase for the three-phase line) | | `l` | H/m | required | | Series inductance per metre of line (per phase, positive sequence) | | `c` | F/m | required | | Shunt capacitance per metre of line (per phase, positive sequence) | | `g` | S/m | 0 | | Shunt conductance per metre of line; 0 for none | | `length` | m | required | | Length of the line | | `sections` | — | 1 | | Pi sections in cascade, 1 to 1000; more follow the distributed line to higher frequencies | | `v0` | V | 0 | | Voltage of the line against `g` at the start, on every shunt capacitance: a line that starts charged | _Parameter descriptions are in English in both languages._ **Use for:** Cables and overhead lines · DC cables · Feeders and microgrid links **Not for:** Fast edges and cable reflections → [`tline`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/tline/) ## Formulas | Formula | Equation | Source | |---|---|---| | Characteristic impedance | Z0 = √(L/C) | Pozar, Microwave Engineering, 4th ed. (2012), §2.1 (lossless line) | | One-way delay | td = length·√(L·C) | Pozar, Microwave Engineering, 4th ed. (2012), §2.1 (phase velocity 1/√(L·C)) | | Total series resistance | R = r·length | Grainger & Stevenson, Power System Analysis (1994), ch. 5 (nominal π circuit) | ## Quick check Inputs: - `r`: Resistance per metre = 100u Ω/m, `r` - `l`: Inductance per metre = 1.2u H/m, `l` - `c`: Capacitance per metre = 10p F/m, `c` - `length`: Length = 100k m, `length` - `sections`: Pi sections = 3 —, `sections` Outputs: - `z0`: Characteristic impedance = `sqrt(l/c)` Ω - `td`: One-way delay = `length*sqrt(l*c)` s - `rtot`: Total series resistance = `r*length` Ω - `fmax`: Highest frequency the sections follow = `sections/(5*2*pi*td)` Hz ## Model logic - The line is cut into equal sections of length / sections metres; each is the series r and l of its length. - Half of the shunt c (and g) of a section sits at each end to g; where two sections meet their halves add up. - One section is the nominal pi; a lossless line of n sections matches its input impedance while omega * length * sqrt(l * c) stays below about n / 5. - The parts are named r1, l1, c0 and so on, and the inner nodes line:1, line:2 and so on can be plotted. ## Model Before the run the line becomes resistors, inductors and capacitors. The line is cut into equal sections of length/sections metres. Each section is the series resistance r and inductance l of its length, with half of its shunt capacitance c (and conductance g) from each end to g; where two sections meet, their halves add up. One section is the nominal pi of a short or medium line. With more sections the model follows the distributed line: a lossless line of n sections matches its input impedance while ω·length·√(l·c) stays below about n/5. The parts are named r1, l1, c0 and so on, and the inner nodes line:1, line:2 and so on can be plotted. ## Common mistakes - The values are per metre. A line data sheet usually gives them per kilometre, and the reactance and susceptance at 50 or 60 Hz: divide by 1000, and divide x by 2πf for l and b by 2πf for c. - Too few sections ring at the wrong frequency. A switching event or a harmonic above the frequency where a section is no longer short against the wavelength sees the resonances of the sections, not those of the line: add sections until the result stops changing. - A lossless line (r and g at 0) has no damping: a step at its end rings for ever. Give r its real value. Problems rules: `pin.unconnected` ## Datasheet and sources r, l and c come from the line's or cable's data sheet or a line-constants calculation: the AC resistance per length at the operating temperature, and the positive-sequence inductance and capacitance per length. length is the route length. ## Example Open the example with the command `file.openExample` and the name `demo:piLine`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Three-Phase Pi-Section Line (`piLine3`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/piLine3/ > Three pi-section lines, one per phase, with the positive-sequence values per metre and a length. ![piLine3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/piLine3.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/passive/piLine3/) **Group:** Passive · **Kind:** `{"kind":"piLine3"}` ## When to use it Use it for a three-phase overhead line or cable in a balanced system: the line between a grid and a converter, a STATCOM or an HVDC station, or the Ferranti rise of a long unloaded line. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a1` | electrical | Sending end, phase a | | `b1` | electrical | Sending end, phase b | | `c1` | electrical | Sending end, phase c | | `a2` | electrical | Receiving end, phase a | | `b2` | electrical | Receiving end, phase b | | `c2` | electrical | Receiving end, phase c | | `g` | electrical | Return of the shunt capacitance of all three phases: ground | ## Common parameters - `r`: Series resistance per metre of line (per phase for the three-phase line) (Default: required) - `l`: Series inductance per metre of line (per phase, positive sequence) (Default: required) - `c`: Shunt capacitance per metre of line (per phase, positive sequence) (Default: required) - `length`: Length of the line (Default: required) - `sections`: Pi sections in cascade, 1 to 1000; more follow the distributed line to higher frequencies (Default: 1) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `r` | Ω/m | required | | Series resistance per metre of line (per phase for the three-phase line) | | `l` | H/m | required | | Series inductance per metre of line (per phase, positive sequence) | | `c` | F/m | required | | Shunt capacitance per metre of line (per phase, positive sequence) | | `g` | S/m | 0 | | Shunt conductance per metre of line; 0 for none | | `length` | m | required | | Length of the line | | `sections` | — | 1 | | Pi sections in cascade, 1 to 1000; more follow the distributed line to higher frequencies | | `v0` | V | 0 | | Voltage of the line against `g` at the start, on every shunt capacitance: a line that starts charged | _Parameter descriptions are in English in both languages._ **Use for:** Balanced transmission and distribution lines · Three-phase cables · Line and filter resonance studies **Not for:** A single-phase line or a DC cable → [`piLine`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/piLine/) ## Formulas | Formula | Equation | Source | |---|---|---| | Characteristic impedance | Z0 = √(L/C) | Grainger & Stevenson, Power System Analysis (1994), ch. 5 (surge impedance) | | Surge impedance loading | SIL = Vll²/Z0 | Grainger & Stevenson, Power System Analysis (1994), ch. 5 (surge impedance loading) | | Charging power of the line | Qc = 2π·f·C·length·Vll² | Grainger & Stevenson, Power System Analysis (1994), ch. 5 (nominal π circuit) | ## Quick check Inputs: - `l`: Inductance per metre = 1.2u H/m, `l` - `c`: Capacitance per metre = 10p F/m, `c` - `length`: Length = 100k m, `length` - `vll`: Line voltage, rms = 132k V - `f`: Frequency = 50 Hz Outputs: - `z0`: Characteristic impedance = `sqrt(l/c)` Ω - `sil`: Surge impedance loading = `vll^2/z0` W - `qc`: Charging power = `2*pi*f*c*length*vll^2` var ## Model logic - Before the run each phase becomes the single-phase pi-section line: series r and l per section, half of the shunt c from each end to g. - The phases are not coupled, which is the per-phase model of a transposed line in balanced operation. - The zero-sequence impedance is not modelled, so a ground fault or an unbalanced load sees the positive-sequence values. - The parts are named ar1, al1, ac0 and so on for phase a, and likewise for b and c. ## Model Before the run each phase becomes the single-phase pi-section line: the series r and l of each section, with half of its shunt c (and g) from each end to g. The phases are not coupled, which is the per-phase model of a transposed line in balanced operation. The zero-sequence impedance is not modelled, so a ground fault or an unbalanced load sees the positive-sequence values. The parts are named ar1, al1, ac0 and so on for phase a, and likewise for b and c. ## Common mistakes - The values are per metre and per phase. Convert a data sheet's Ω/km, and its reactance and susceptance at 50 or 60 Hz, to H/m and F/m first. - Do not use it for a single-line-to-ground fault study: without the zero-sequence values the fault current is wrong. Problems rules: `pin.unconnected` ## Datasheet and sources r, l and c are the positive-sequence values per length from the line's data sheet or a line-constants calculation (the AC resistance at the operating temperature); length is the route length. ## Example Open the example with the command `file.openExample` and the name `demo:piLine3`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # PTC Thermistor (`ptc`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/ptc/ > A resistor that climbs steeply when it gets hot, used as a resettable fuse. ![ptc](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/ptc.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/passive/ptc/) **Group:** Passive · **Kind:** `{"kind":"ptc"}` ## When to use it Use it in series with a load to limit a short-circuit or overload current. It resets when it cools down. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | One terminal | | `n` | electrical | The other terminal | ## Common parameters - `r25`: Resistance at 25 °C (Default: 2.3) - `tref`: Reference temperature: the resistance climbs above it (Default: 120) - `ismax`: Largest current it may switch off; more raises a warning (Default: 8) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `r25` | Ω | 2.3 | | Resistance at 25 °C | | `rmin` | Ω | 1.5 | | Lowest resistance | | `tref` | °C | 120 | | Reference temperature: the resistance climbs above it | | `k` | 1/K | 0.167 | | Steepness of the climb above tref, per kelvin | | `rmax` | Ω | 500k | | Highest resistance | | `delta` | W/K | 20m | | Dissipation factor: heat it loses per kelvin above its surroundings | | `cth` | J/K | 0.78 | | Heat capacity | | `ta` | °C | 25 | | Temperature of its surroundings | | `ismax` | A | 8 | | Largest current it may switch off; more raises a warning | | `thermal` | — | optional (off) | | Thermal net for its heat and temperature; replaces delta and cth | _Parameter descriptions are in English in both languages._ **Use for:** Resettable fuses · Overload protection · Motor and transformer guards **Not for:** Cutting a short for good → [`fuse`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/fuse/) · Fast surges → [`tvs`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/tvs/) ## Formulas | Formula | Equation | Source | |---|---|---| | Resistance at the body temperature | R = (r25 + rmin·exp(k·(T − tref))) ∥ rmax | IEC 60738-1:2006, resistance-temperature characteristic | | Power that holds it at T | P = delta·(T − ta) | IEC 60738-1:2006, dissipation factor | | Residual current at T | I = √(P/R) | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 2 (power absorbed by a resistor) | ## Quick check Inputs: - `r25`: Rated resistance at 25 °C = 2.3 Ω, `r25` - `rmin`: Coefficient of the steep rise = 1.5 Ω, `rmin` - `tref`: Reference temperature = 120 °C, `tref` - `k`: Temperature coefficient = 167m 1/K, `k` - `rmax`: Highest resistance = 500k Ω, `rmax` - `delta`: Dissipation factor = 20m W/K, `delta` - `ta`: Ambient temperature = 25 °C, `ta` - `tb`: Body temperature = 140 °C Outputs: - `rt`: Resistance at tb = `1/(1/(r25 + rmin*exp(k*(tb - tref))) + 1/rmax)` Ω - `p`: Power that holds it at tb = `delta*(tb - ta)` W - `ihold`: Residual current at tb = `sqrt(p/rt)` A - `vhold`: Voltage that holds it at tb = `sqrt(p*rt)` V ## Model logic - The resistance is r25 + rmin·exp(k·(T - tref)) in parallel with rmax, so it stays near r25 below tref and levels off at rmax. - Without a thermal net, T starts at ta and after each accepted step moves toward ta + P/delta with the time constant cth/delta. - With thermal set, T is the temperature of that thermal net and its heat goes into the net; each step uses the resistance at the end of the last step. - A warning appears when the current goes above ismax; the part does not fail and resets as it cools. ## Model The resistance is r25 + rmin * exp(k * (T - tref)), levelling off at rmax. Below tref it stays near r25. Above tref it grows by a factor e every 1 / k kelvin. Its temperature comes from its own power as for the NTC thermistor: from delta, cth and ta, or from the thermal net named by thermal. In an overload it heats past tref, its resistance climbs, and the current falls to a small residual current that keeps it hot. A warning appears when the current goes above ismax. ## Common mistakes - A PTC trips in seconds, not microseconds. Use a TVS for fast surges and the PTC for long overloads. - A tripped PTC stays hot on its residual current while the voltage is there. Remove the voltage, or the overload, to let it cool and reset. ## Datasheet and sources Take r25 from the rated resistance RR, rmin from Rmin, tref from the reference temperature, and ismax from ISmax. Read k and rmax from the resistance versus temperature curve. Fit delta so that the residual current at Vmax matches Ir, and cth from a switching time. The defaults are the TDK B59940C0120A070 (C940), 63 V overcurrent protection data sheet, February 2018. ## Example Open the example with the command `file.openExample` and the name `demo:ptc`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Resistor (`resistor`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/resistor/ > Limits current in proportion to the voltage across it. ![resistor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/resistor.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/passive/resistor/) **Group:** Passive · **Kind:** `{"kind":"resistor"}` ## When to use it Use it for loads, dividers and damping. To measure current, use Ammeter instead of a tiny resistor. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | One end; positive current flows from p to n | | `n` | electrical | The other end | ## Common parameters - `r`: Resistance (Default: required) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `r` | Ω | required | | Resistance | _Parameter descriptions are in English in both languages._ **Use for:** Loads · Voltage dividers · Damping · Gate resistors **Not for:** Measuring a current → [`ammeter`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/meters/ammeter/) · Inrush current limiting → [`ntc`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/ntc/) ## Formulas | Formula | Equation | Source | |---|---|---| | Ohm's law | i = v / r | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 2 (Ohm's law) | | Dissipated power | P = v² / r = i²·r | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 2 (power absorbed by a resistor) | ## Quick check Inputs: - `r`: Resistance = 100 Ω, `r` - `v`: Voltage across it = 12 V Outputs: - `i`: Current = `v/r` A - `p`: Dissipated power = `v^2/r` W ## Model logic - It is stamped as the constant conductance 1/r between p and n, and r must be above zero or the run is refused. - It is linear and has no memory: no temperature coefficient, tolerance, stray inductance or stray capacitance. - The power is not limited: a resistor far above its rating simulates without a warning, so check i²·r yourself. ## Model The current is i = (v(p) - v(n)) / r, and r must be above zero. The part has no temperature drift, tolerance, power rating or stray inductance. ## Common mistakes - A missing prefix is easy to make, such as 10 for 10k. Type the prefix with the number, and values outside 1u to 1G ohm are flagged. - A resistor with one end connected to nothing carries no current. Connect both ends or delete it. Problems rules: `param.non_positive`, `param.out_of_range`, `net.dangling` ## Datasheet and sources r is the value printed on the part or taken from your design. The solver does not check the power rating, so check it yourself. ## Example Open the example with the command `file.openExample` and the name `demo:resistor`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Three-Phase R-L-C (`rlc3`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/rlc3/ > The same resistor, inductor and capacitor in series in each of three phases. ![rlc3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/rlc3.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/passive/rlc3/) **Group:** Passive · **Kind:** `{"kind":"rlc3"}` ## When to use it Use it for grid impedance, line reactors, filters and balanced loads. Leave c unset for a series R-L. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a1` | electrical | Phase a, first side | | `b1` | electrical | Phase b, first side | | `c1` | electrical | Phase c, first side | | `a2` | electrical | Phase a, second side | | `b2` | electrical | Phase b, second side | | `c2` | electrical | Phase c, second side | ## Common parameters - `r`: Resistance of each phase (Default: 1) - `l`: Inductance of each phase (Default: 1m) - `c`: Capacitance of each phase (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `r` | Ω | 1 | | Resistance of each phase | | `l` | H | 1m | | Inductance of each phase | | `c` | F | optional (off) | | Capacitance of each phase | _Parameter descriptions are in English in both languages._ **Use for:** Grid impedance · Line reactors · Balanced filters and loads **Not for:** A single-phase or DC impedance → [`resistor`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/resistor/) ## Formulas | Formula | Equation | Source | |---|---|---| | Impedance of one phase | abs(Z) = √(R² + (XL − XC)²) | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 10 (impedance) | | Series resonance | f0 = 1/(2π·√(L·C)) | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 16 (series resonance) | | Copper loss of the three phases | P = 3·I²·R | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 2 (power) | ## Quick check Inputs: - `r`: Resistance per phase = 1 Ω, `r` - `l`: Inductance per phase = 1m H, `l` - `c`: Capacitance per phase = 100u F, `c` - `f`: Frequency = 60 Hz - `i`: Phase current, rms = 10 A Outputs: - `xl`: Inductive reactance = `2*pi*f*l` Ω - `xc`: Capacitive reactance = `1/(2*pi*f*c)` Ω - `z`: Impedance of one phase = `sqrt(r^2 + (xl - xc)^2)` Ω - `f0`: Series resonance = `1/(2*pi*sqrt(l*c))` Hz - `ploss`: Copper loss of the three phases = `3*i^2*r` W ## Model logic - Each phase runs from its first pin through r, l and c to its second pin, and the phases are not coupled. - A value of zero, or c unset, leaves that part out; with r, l and c all left out the run is refused. - The parts are named name.ra, name.la and name.ca for phase a, and the same with b and c. ## Model Each phase runs from its first pin through r, l and c to its second pin. A value of zero (or c unset) leaves that part out. The phases are not coupled to each other. The parts are named name.ra, name.la and name.ca for phase a, and the same with b and c. ## Common mistakes - With r and l both zero and c unset, each phase would be a short circuit, so the run refuses it. - An inductor in series with a current source or an open switch has nowhere to send its current. Give it a path. ## Datasheet and sources r and l are per phase. For a line reactor, take l from the rated inductance and r from the copper loss: r = loss / (3 * current squared). ## Example Open the example with the command `file.openExample` and the name `demo:rlc3`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Supercapacitor (`supercap`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/supercap/ > A very large capacitor with series resistance, leakage and a slow inner branch. ![supercap](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/supercap.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/passive/supercap/) **Group:** Passive · **Kind:** `{"kind":"supercap"}` ## When to use it Use it for short power bursts, backup power, regenerative braking and smoothing a battery current. For an ordinary capacitor, use Capacitor. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | Positive terminal | | `n` | electrical | Negative terminal | ## Common parameters - `c`: Capacitance (Default: required) - `esr`: ESR: small resistance in series with it (Default: 0) - `v0`: Initial voltage; the voltage across it at the start (Default: 0) - `rleak`: Resistance that lets charge leak away (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `c` | F | required | | Capacitance | | `v0` | V | 0 | | Initial voltage; the voltage across it at the start | | `esr` | Ω | 0 | | ESR: small resistance in series with it | | `rleak` | Ω | optional (off) | | Resistance that lets charge leak away | | `r2` | Ω | optional (off) | | Resistance of the slow charge branch | | `c2` | F | optional (off) | | Capacitance of the slow charge branch | _Parameter descriptions are in English in both languages._ **Use for:** Power bursts · Backup power · Regenerative braking **Not for:** Decoupling and filters → [`capacitor`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/capacitor/) · Long-term energy storage → [`battery`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/battery/) ## Formulas | Formula | Equation | Source | |---|---|---| | Usable energy down to vmin | E = ½·c·(v² − vmin²) | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 7 (energy stored in a capacitor) | | Voltage drop on esr | Δv = i·esr | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 2 (Ohm's law) | | Constant-current discharge time | t = c·(v − vmin − i·esr) / i | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 7 (i = C·dv/dt) | ## Quick check Inputs: - `c`: Capacitance = 100 F, `c` - `v`: Start voltage = 2.7 V, `v0` - `vmin`: Lowest usable voltage = 1.35 V - `i`: Discharge current = 10 A - `esr`: Series resistance = 10m Ω, `esr` Outputs: - `energy`: Usable energy = `0.5*c*(v^2 - vmin^2)` J - `drop`: Voltage drop on esr = `i*esr` V - `tdis`: Discharge time = `c*(v - vmin - i*esr)/i` s ## Model logic - From p it is an internal current meter (the part's current), esr, then c to n, with rleak across c; zero esr or unset rleak leaves them out. - With both r2 and c2 set, the slow branch r2 in series with c2 sits across c; setting only one of them is refused. - c and c2 both start at v0, so the slow branch moves charge only after the run changes the voltage. - c is constant: no voltage dependence, temperature, rated-voltage check or cell balancing is modelled. ## Model From p, the parts are esr, then the capacitance c to n, with rleak across c. When r2 and c2 are set, a slow branch (r2 in series with c2) also sits across c, so charge moves inside the part after a fast charge, as in the multi-branch model of Zubieta and Bonert (2000). Every capacitance starts at v0. The current of the part named like the supercapacitor is the current into p. The capacitance does not change with voltage here. ## Common mistakes - c is in farad, so 100 means 100 F, not 100 mF. Write the prefix when you mean a smaller value. - Charging a large capacitance from a voltage source without esr draws a huge current spike. Set esr or a source resistance. ## Datasheet and sources c is the rated capacitance, esr the DC series resistance, and rleak follows from the leakage current: rleak = rated voltage / leakage current. Take r2 and c2 from the slow voltage drift after a charge, if the datasheet shows it. ## Example Open the example with the command `file.openExample` and the name `demo:supercap`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Transmission Line (`tline`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/tline/ > A distributed lossless line given by its characteristic impedance and one-way delay, with an optional series resistance lumped at its ends: waves travel along it and reflect where the impedance changes. ![tline](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/tline.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/passive/tline/) **Group:** Passive · **Kind:** `{"kind":"tline"}` ## When to use it Use it when the travel time of the cable matters: the overvoltage at the terminals of a motor fed by a long cable from a fast-switching inverter, ringing on a gate-drive or sense cable, or a line in a surge study. For a line much shorter than the wavelength of everything that happens on it use Pi-Section Line or a lumped R-L-C. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p1` | electrical | End 1, signal conductor | | `n1` | electrical | End 1, return conductor (shield) | | `p2` | electrical | End 2, signal conductor | | `n2` | electrical | End 2, return conductor (shield) | ## Common parameters - `z0`: Characteristic impedance of the line (Default: required) - `td`: One-way delay of a wave along the line (length / propagation speed); Max time step must not exceed it (Default: required) - `r`: Total series resistance of the line, lumped half at each end; 0 for a lossless line (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `z0` | Ω | required | | Characteristic impedance of the line | | `td` | s | required | | One-way delay of a wave along the line (length / propagation speed); Max time step must not exceed it | | `r` | Ω | 0 | | Total series resistance of the line, lumped half at each end; 0 for a lossless line | _Parameter descriptions are in English in both languages._ **Use for:** Motor cable reflections · Fast signal lines · Overvoltage at the motor terminals **Not for:** Power lines at 50 or 60 Hz → [`piLine`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/piLine/) ## Formulas | Formula | Equation | Source | |---|---|---| | Reflection coefficient | Γ = (ZL − Z0)/(ZL + Z0) | Pozar, Microwave Engineering, 4th ed. (2012), §2.3 (terminated lossless line) | | Length from the delay | length = td·c0·VF | Pozar, Microwave Engineering, 4th ed. (2012), §2.1 (phase velocity) | | First quarter-wave resonance | f = 1/(4·td) | Pozar, Microwave Engineering, 4th ed. (2012), §2.3 (open- and short-circuited lines) | ## Quick check Inputs: - `z0`: Characteristic impedance = 50 Ω, `z0` - `td`: One-way delay = 50n s, `td` - `zl`: Load impedance at the far end = 1k Ω - `vf`: Velocity factor = 660m — Outputs: - `gam`: Reflection coefficient = `(zl - z0)/(zl + z0)` — - `len`: Length = `td*299792458*vf` m - `trt`: Round-trip time = `2*td` s - `fq`: First quarter-wave resonance = `1/(4*td)` Hz ## Model logic - The line is solved by the method of characteristics: each end is a conductance 1 / z0 in parallel with a current source set by the other end td earlier. - A wave launched at one end arrives td later and reflects with the coefficient (Z - z0) / (Z + z0) of what it meets. - The resistance r is split in two, half in series with each end; it does not spread the loss along the line and has no skin effect. - In an AC sweep and at DC the line is its exact chain matrix; the currents into both ends are i(name.1) and i(name.2). ## Model The line is solved by the method of characteristics (Bergeron, after H. W. Dommel, IEEE Trans. PAS-88, 1969): each end is a conductance 1/z0 in parallel with a current source set by the other end td earlier, so a wave launched at one end arrives at the other exactly td later and reflects with the coefficient (Z − z0)/(Z + z0) of what it meets. The resistance r is split in two, half in series with each end; this is accurate while r is small against z0, but it does not spread the loss along the line or make it grow with frequency (no skin effect). In an AC sweep and at DC the line is its exact chain matrix, so a sweep shows the quarter-wave resonances; at DC it is the resistance r between the ends. The currents into both ends are recorded as i(name.1) and i(name.2). ## Common mistakes - Max step must not exceed td, or the run stops with an error: the far end is read one delay back, which must lie before the step being solved. A 10 m motor cable has a delay of about 50 ns; a step of a tenth of td resolves the edges well. - A lossless line between two reflecting ends rings for ever. Give r a value, or terminate one end in z0, to see the decay a real cable has. Problems rules: `pin.unconnected` ## Datasheet and sources z0 is the cable's characteristic impedance from its data sheet. td is the length divided by the propagation speed, which is the speed of light times the velocity factor (the data sheet's nominal velocity of propagation), or √(L·C) per metre times the length. r is the conductor resistance per metre times the length (both conductors), at the frequency that matters. ## Example Open the example with the command `file.openExample` and the name `demo:tline`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Varistor (`varistor`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/varistor/ > A metal-oxide varistor whose current rises steeply above its varistor voltage. ![varistor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/varistor.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/passive/varistor/) **Group:** Passive · **Kind:** `{"kind":"varistor"}` ## When to use it Use it across a mains or supply input to absorb surges with a lot of energy. For a sharper clamp at low voltage, use TVS Diode. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | One terminal; the part is the same both ways | | `n` | electrical | The other terminal | ## Common parameters - `vv`: Varistor voltage at the current iv (Default: 39) - `vc`: Clamping voltage at the current ic (Default: 77) - `ic`: Current of the clamping voltage (Default: 10) - `wmax`: Energy it may absorb in one surge; more raises a warning (Default: 7) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `vv` | V | 39 | | Varistor voltage at the current iv | | `iv` | A | 1m | | Current the varistor voltage is given at | | `vc` | V | 77 | | Clamping voltage at the current ic | | `ic` | A | 10 | | Current of the clamping voltage | | `wmax` | J | 7 | | Energy it may absorb in one surge; more raises a warning | | `c` | F | 5.85n | | Capacitance across it; 0 leaves it out | _Parameter descriptions are in English in both languages._ **Use for:** Mains surge protection · Supply input clamps · Contact and coil protection **Not for:** Sharp clamps at low voltage → [`tvs`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/tvs/) · Lightning on telecom lines → [`gdt`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/gdt/) ## Formulas | Formula | Equation | Source | |---|---|---| | Nonlinearity exponent | α = ln(ic/iv)/ln(vc/vv) | IEC 61051-1:2018, terms and definitions (non-linearity exponent) | | Current at a voltage | I = iv·(V/vv)^α | IEC 61051-1:2018, terms and definitions (varistor voltage, non-linearity exponent) | | Power at that voltage | P = V·I | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 2 (power) | ## Quick check Inputs: - `vv`: Varistor voltage = 39 V, `vv` - `iv`: Current of the varistor voltage = 1m A, `iv` - `vc`: Clamping voltage = 77 V, `vc` - `ic`: Current of the clamping voltage = 10 A, `ic` - `v`: Voltage across it = 60 V Outputs: - `alpha`: Nonlinearity exponent = `ln(ic/iv)/ln(vc/vv)` — - `i`: Current at v = `iv*(v/vv)^alpha` A - `p`: Power at v = `v*i` W ## Model logic - The current is i = iv·(abs(v)/vv)^α, the same both ways, with α fitted so the law passes through vv at iv and vc at ic. - Above four times vc the law goes on along its tangent, and a Newton step away from zero goes only as far as the voltage that carries the current the last linearization predicted. - c, when set, sits across it and is integrated by backward Euler. - It adds up the energy it absorbs and warns once that goes above wmax; it does not age, fail or change its law. ## Model The current follows the power law i = iv * (|v| / vv)^α, the same both ways, with the capacitance c across it when c is set. α is fitted so that the law passes through vv at iv and vc at ic. Far above vc the law goes on along a straight line, so nothing overflows. The part is solved by Newton's method with a limited step. It adds up the energy it absorbs, and a warning appears when that energy goes above wmax. ## Common mistakes - The varistor voltage must be well above the normal peak voltage. Use the maximum DC or rms operating voltage on the data sheet to choose the part. - The clamp of a varistor is soft. The voltage at a surge current can be twice vv, so check the voltage the next stage sees. ## Datasheet and sources Take vv at iv (1 mA) from the varistor voltage column, vc at ic from the maximum clamping voltage column, wmax from the energy column (2 ms), and c from the typical capacitance (0 leaves it out). Across the steep law c is a branch of nanoseconds, so it is integrated by backward Euler. The defaults are the EPCOS SIOV-S14K25 (B72214S0250K101), SIOV leaded StandarD series data sheet, March 2018. ## Example Open the example with the command `file.openExample` and the name `demo:varistor`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Battery (`battery`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/battery/ > A rechargeable battery whose voltage follows its state of charge. ![battery](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/battery.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/battery/) **Group:** Sources · **Kind:** `{"kind":"battery"}` ## When to use it Use it for storage systems, battery chargers, electric vehicles and backup supplies. For a fixed voltage, use DC Voltage Source. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | Positive terminal | | `n` | electrical | Negative terminal | | `soc` | signal | State of charge, 0 to 1 (an output signal) | ## Common parameters - `ah`: Capacity (Default: 2.5) - `soc0`: State of charge at the start, 0 to 1 (Default: 0.8) - `r0`: Resistance that drops the voltage at once (Default: 50m) - `ns`: Cells in series; the voltage table is per cell (Default: 1) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `ah` | Ah | 2.5 | | Capacity | | `soc0` | — | 0.8 | | State of charge at the start, 0 to 1 | | `r0` | Ω | 50m | | Resistance that drops the voltage at once | | `r1` | Ω | 15m | | Resistance of the first RC branch | | `c1` | F | 2k | | Capacitance of the first RC branch | | `r2` | Ω | optional (off) | | Resistance of the second, slower RC branch | | `c2` | F | optional (off) | | Capacitance of the second RC branch | | `ns` | — | 1 | | Cells in series; the voltage table is per cell | | `socs` | — | 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 | | State of charge points of the voltage table | | `ocvs` | — | 3.0 3.45 3.55 3.62 3.68 3.74 3.82 3.91 4.0 4.09 4.2 | | Rest voltage of one cell at each point | | `temp` | °C | 25 | | Battery cell temperature | | `tref` | °C | 25 | | Temperature the table and resistances belong to | | `dOcvDt` | V/K | 0 | | Change of a cell's rest voltage with temperature | | `ea` | J/mol | 0 | | Activation energy that raises the resistances in the cold | | `soh` | — | 1 | | Capacity left after ageing, as a share of ah | | `rAge` | — | 1 | | Growth of the resistances with ageing, 1 when new | | `thermal` | — | optional (off) | | Thermal net of its cells; takes the heat of its resistances, and with ea set its temperature moves them | _Parameter descriptions are in English in both languages._ **Use for:** Energy storage · Battery chargers · Electric vehicles · Backup supplies **Not for:** Fixed supply voltage → [`dcVoltageSource`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/dcVoltageSource/) · Supercapacitor storage → [`supercap`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/supercap/) ## Formulas | Formula | Equation | Source | |---|---|---| | C-rate | C-rate = i/ah | IEC 61960-3:2017, clause 3 | | Run time from full | t = 3600·ah/i | Linden's Handbook of Batteries, 4th ed. (2011), Ch. 1 | | Terminal voltage under load | V = ns·voc − i·r0 | Linden's Handbook of Batteries, 4th ed. (2011), Ch. 2 | ## Quick check Inputs: - `ah`: Capacity = 2.5 Ah, `ah` - `i`: Discharge current = 5 A - `r0`: Series resistance = 50m Ω, `r0` - `ns`: Cells in series = 1 —, `ns` - `voc`: Cell open-circuit voltage = 4 V Outputs: - `crate`: C-rate = `i/ah` — - `trun`: Run time from full = `3600*ah/i` s - `vt`: Terminal voltage at once = `ns*voc - i*r0` V ## Model logic - The part stamps a controlled voltage ns·OCV(soc), then r0, then up to two parallel RC branches and an internal ammeter to p; the RC capacitors start at 0 V. - The state of charge integrates -i/(3600·ah·soh) from soc0 within 0 to 1; the cell OCV is a straight-line lookup in socs and ocvs, held at the ends. - The OCV follows the state of charge through control blocks, so it lags one step; r0, r1 and r2 belong to the whole pack and are not multiplied by ns. - Temperature and ageing scale the resistances and shift the OCV once per run; self-heating, self-discharge, hysteresis and rate-dependent capacity are not modelled. ## Model The battery is an open-circuit voltage, a series resistance r0 and up to two RC branches (r1 with c1, r2 with c2) in series. The open-circuit voltage is ns times the cell voltage, read from the table ocvs at the state of charge, with straight lines between the points of socs. The state of charge starts at soc0 and falls by i / (3600 * ah) per second, where i is the current out of p (the current of the part, named like the battery). It is the signal name:soc, held between 0 and 1, and a warning says when it was held while the current pushed on. The default table is an illustrative curve of the usual shape for one lithium-ion NMC cell, not measured data, and the default resistances and capacity are illustrative too. Temperature and ageing are set once for the run: at the cell temperature temp, every resistance is multiplied by exp(ea / R * (1 / T - 1 / Tref)) (the Arrhenius law, R = 8.314 J/(mol K), temperatures in kelvin) and by rAge, and every table voltage moves by dOcvDt * (temp - tref). Ageing also shrinks the capacity to soh * ah. The defaults (ea and dOcvDt 0, soh and rAge 1) leave a new cell at its table temperature. Self-heating and self-discharge are not modelled. ## Common mistakes - The default table is for one cell. A pack needs ns set to the cells in series, or its voltage stays near 3.7 V. - ah is in ampere-hours, so a 100 ms run hardly moves the state of charge. Use a smaller ah to see the charge change in a short run. - A battery charged when full, or discharged when empty, keeps its voltage at the end of the table. Check the warning after the run. ## Datasheet and sources ah is the rated capacity, and r0 is the DC internal resistance. Take socs and ocvs from the open-circuit voltage curve of the cell, and r1, c1, r2, c2 from a pulse test: the slow recovery of the voltage after a current step. Take ea from the internal resistance measured at two or more temperatures (the slope of ln r against 1/T, times R), dOcvDt from the rest voltage at two temperatures (the entropic coefficient), and soh and rAge from the capacity and resistance of the aged cell against the new one. ## Example Open the example with the command `file.openExample` and the name `demo:battery`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Bracket (`bracket`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/bracket/ > A board-only part: an angle bracket that fixes the board or a heatsink to the chassis. It has no pins and is never simulated. ![bracket](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/bracket.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/bracket/) **Group:** Sources · **Kind:** `{"element":"bracket","kind":"boardPart"}` ## When to use it Put it on the schematic when the bracket is bought with the board, and turn its BOM switch on so the BOM lists it. ## Common parameters - `part`: Part number of a board-only part bought with the board (a standoff, screw or label), for the BOM; information only, not simulated (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `part` | — | optional (off) | | Part number of a board-only part bought with the board (a standoff, screw or label), for the BOM; information only, not simulated | | `footprint` | — | optional (off) | | KiCad library id of the footprint a board-only part sits on, such as MountingHole:MountingHole_3.2mm_M3; board.addFootprints places it; information only, not simulated | _Parameter descriptions are in English in both languages._ ## Model A board-only part is never simulated and never written to the netlist. It starts out of the BOM and on the board, and the schematic tags it board only. ## Common mistakes - A metal bracket shorts whatever copper it touches. Keep tracks and pours out of its footprint. - The simulation never sees a board-only part. When the hardware matters electrically (a Y capacitor to the chassis, a ground strap), draw that as its own electrical part. ## Datasheet and sources Take the dimensions and screw size from the bracket maker's data sheet. ## Example Open the example with the command `file.openExample` and the name `demo:bracket`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Controlled Source (`controlledSource`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/controlledSource/ > Makes a voltage or current equal to a signal times a gain. ![controlledSource](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/controlledSource.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/controlledSource/) **Group:** Sources · **Kind:** `{"kind":"controlledSource"}` ## When to use it Use it to bring a control signal into the power circuit, such as an averaged model or a disturbance. A real switching stage needs a switch with a gate. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | Positive end of the output | | `n` | electrical | Negative end of the output | | `ctrl` | signal | Signal that sets the output; draws no current | ## Common parameters - `gain`: Output size per unit of control signal (Default: 1) - `mode`: Whether the output is voltage or current: `voltage` or `current` (Default: voltage) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `gain` | — | 1 | | Output size per unit of control signal | | `mode` | — | voltage | | Whether the output is voltage or current: `voltage` or `current` | _Parameter descriptions are in English in both languages._ **Use for:** Averaged models · Signals into the power stage · Disturbance injection **Not for:** Real switching stages → [`mosfet`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/mosfet/) · Op-amp circuits → [`opAmp`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/opAmp/) ## Formulas | Formula | Equation | Source | |---|---|---| | Voltage mode output | v(p) − v(n) = gain·ctrl | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), Ch. 2 | | Current mode output | i = gain·ctrl | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), Ch. 2 | | Load current, voltage mode | I = vout/rl | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), Ch. 2 | ## Quick check Inputs: - `gain`: Gain = 1 —, `gain` - `ctrl`: Control signal = 500m — - `rl`: Load resistance = 10 Ω Outputs: - `vout`: Output voltage, voltage mode = `gain*ctrl` V - `iload`: Load current, voltage mode = `vout/rl` A - `pload`: Load power, voltage mode = `vout^2/rl` W ## Model logic - Mode voltage stamps an ideal voltage branch v(p) - v(n) = gain·ctrl; mode current puts the current gain·ctrl from p to n; any other mode text is an error. - When ctrl comes only through meters, gain and sum blocks, the measured quantities go into the matrix, so it acts in the same step like a SPICE E, F, G or H. - Through any other block (filter, limiter, C block) it uses the control value of the previous step, a one-step delay that can make a high-gain loop diverge. - An unconnected ctrl reads 0; output limits, bandwidth and internal resistance are not modelled. ## Model In voltage mode, the part forces v(p) - v(n) = gain * ctrl. In current mode, it forces a current gain * ctrl from p to n through the source. mode must be exactly voltage or current, and an unconnected ctrl reads 0. ## Common mistakes - The ctrl pin belongs on a signal net, and joining it to a power net is flagged. An unconnected ctrl makes the output zero. - A voltage-mode controlled source counts as an ideal voltage source. Two of them across the same nodes form a loop. Problems rules: `pin.domain_mismatch`, `pin.unconnected`, `loop.voltage_sources` ## Datasheet and sources There is no datasheet. gain is the conversion factor you design, in volts or amperes per unit of the signal. ## Example Open the example with the command `file.openExample` and the name `demo:controlledSource`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # DC Current Source (`dcCurrentSource`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/dcCurrentSource/ > Pushes a fixed current through itself. ![dcCurrentSource](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/dcCurrentSource.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/dcCurrentSource/) **Group:** Sources · **Kind:** `{"kind":"dcCurrentSource"}` ## When to use it Use it for constant loads, bias currents and test injections. For a current that follows a signal, use Controlled Source. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | Current enters here and flows to n | | `n` | electrical | Current returns to the circuit here | ## Common parameters - `i`: Current the source pushes (Default: required) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `i` | A | required | | Current the source pushes | | `pwl` | — | optional (off) | | Time and value pairs joined by straight lines; replaces the fixed value | | `profile` | — | optional (off) | | Current over time: vrstep(i0 i1 delay slew in A/µs [width period]), workload, pulse, steps or pwl as for the power load; replaces pwl and i | | `repeat` | — | 0 | | Set to 1 to repeat the pwl pattern over and over | _Parameter descriptions are in English in both languages._ **Use for:** Constant-current loads · Bias currents · Load steps · Test injection **Not for:** Constant-power loads → [`powerLoad`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/powerLoad/) · Current set by a signal → [`controlledSource`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/controlledSource/) ## Formulas | Formula | Equation | Source | |---|---|---| | Voltage across the load | V = i·rl | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), Ch. 2 | | Load power | P = i²·rl | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), Ch. 2 | ## Quick check Inputs: - `i`: Source current = 1 A, `i` - `rl`: Load resistance = 10 Ω Outputs: - `v`: Voltage across the load = `i*rl` V - `p`: Load power = `i^2*rl` W ## Model logic - The part adds the current i from p through itself to n straight into the node equations; the voltage across it is whatever the rest of the circuit sets. - A profile (a load step at a slew rate, a replayed trace) wins over pwl, and pwl wins over i; pwl holds its end values and repeats when repeat is 1. - It is ideal: no shunt resistance and no compliance voltage limit, so a node fed only by it, with no other path, has no defined voltage. ## Model The source forces the current i through itself from p to n, whatever the voltage across it. It takes charge from the net at p and delivers it to the net at n. The part has no voltage limit and no internal resistance. With pwl set to a list of times and values, the output follows straight lines between those points instead of holding i, stays at the last value after the last time, and starts over there when repeat is 1. ## Common mistakes - A node fed by a current source with no resistive path to ground has no defined voltage. Put a large resistor across the source. - The sign is easy to flip. A positive i flows from p through the source to n, so a load on the p side has current taken out of it. Problems rules: `cutset.inductor_current` ## Datasheet and sources There is no datasheet. i is the load current, LED current or bias current you want to hold. ## Example Open the example with the command `file.openExample` and the name `demo:dcCurrentSource`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # DC Voltage Source (`dcVoltageSource`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/dcVoltageSource/ > Holds a fixed voltage between its two terminals. ![dcVoltageSource](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/dcVoltageSource.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/dcVoltageSource/) **Group:** Sources · **Kind:** `{"kind":"dcVoltageSource"}` ## When to use it Use it for batteries, supply rails and DC buses. Use Sine Voltage Source for AC and Pulse Voltage Source for steps. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | Positive end | | `n` | electrical | Negative end, the reference side | ## Common parameters - `v`: Output voltage of the source (Default: required) - `rs`: Resistance inside the source (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `v` | V | required | | Output voltage of the source | | `rs` | Ω | 0 | 1m – 10 Ω | Resistance inside the source | | `pwl` | — | optional (off) | | Time and value pairs joined by straight lines; replaces the fixed value | | `repeat` | — | 0 | | Set to 1 to repeat the pwl pattern over and over | _Parameter descriptions are in English in both languages._ **Use for:** Supply rails · DC buses · Converter inputs **Not for:** Batteries with state of charge → [`battery`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/battery/) · Supply steps and test pulses → [`pulseVoltageSource`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/pulseVoltageSource/) ## Formulas | Formula | Equation | Source | |---|---|---| | Load current | I = v/(rs + rl) | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), §5.2 | | Terminal voltage | Vt = v − I·rs | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), §5.2 | | Load power | P = Vt·I | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), Ch. 2 | ## Quick check Inputs: - `v`: Source voltage = 12 V, `v` - `rs`: Internal resistance = 0 Ω, `rs` - `rl`: Load resistance = 6 Ω Outputs: - `current`: Load current = `v/(rs+rl)` A - `vterm`: Terminal voltage = `v - current*rs` V - `pload`: Load power = `vterm*current` W ## Model logic - The part stamps an ideal voltage branch v(p) - v(n) = v whose current is a circuit unknown, so it sources or sinks any current with no limit. - With rs above 0 a resistor rs is placed inside the part, in series on the n side; rs = 0, the default, leaves the source ideal. - With pwl set the value follows straight lines between the points, holds the end values outside them, and repeats when repeat is 1. - The step control lands on every pwl corner; a current limit, output capacitance, inductance and noise are not modelled. ## Model The source forces v(p) - v(n) = v for any current, and the current through it is an unknown of the circuit. With rs set, a resistor rs sits in series inside the part, so the terminal voltage drops by rs times the load current. The part has no current limit. With pwl set to a list of times and values, the output follows straight lines between those points instead of holding v, stays at the last value after the last time, and starts over there when repeat is 1. ## Common mistakes - Two ideal voltage sources in parallel, or in a loop with other ideal voltage sources and ammeters, leave the current undefined. Break the loop or give one source an rs. - A circuit with no reference node has no defined voltages. Connect the negative end of the source to Ground. Problems rules: `loop.voltage_sources`, `source.shorted`, `ground.missing` ## Datasheet and sources v is the design voltage or the nominal battery or supply voltage. rs is the output resistance, which you can estimate as the voltage change divided by the load current change. ## Example Open the example with the command `file.openExample` and the name `demo:dcVoltageSource`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Water Electrolyzer (`electrolyzer`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/electrolyzer/ > A water electrolyzer stack, a load whose voltage rises with current above the reversible voltage of water. ![electrolyzer](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/electrolyzer.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/electrolyzer/) **Group:** Sources · **Kind:** `{"kind":"electrolyzer"}` ## When to use it Use it as the load of a hydrogen electrolyzer supply: a thyristor or active rectifier, or a DC-DC stage for kiloampere currents. For a load with a fixed back-EMF and resistance, use a DC voltage source with a resistor. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | Positive terminal (anode, O₂ side); the stack current flows in here | | `n` | electrical | Negative terminal (cathode, H₂ side) | ## Common parameters - `ns`: Cells in series in the stack (Default: 1) - `area`: Electrode area of one cell (Default: required) - `temp`: Stack temperature (Default: required) - `erev`: Reversible voltage of one cell (Default: 1.229) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `ns` | — | 1 | | Cells in series in the stack | | `area` | m² | required | | Electrode area of one cell | | `temp` | °C | required | | Stack temperature | | `erev` | V | 1.229 | | Reversible voltage of one cell | | `r1` | Ω·m² | 2.18e-4 | | Ohmic coefficient of the electrolyte and electrodes | | `r2` | Ω·m²/°C | -4.25e-7 | | Change of the ohmic coefficient with temperature | | `s` | V | 117.93m | | Activation slope per decade of current | | `t1` | m²/A | -145.29m | | Activation coefficient, constant part | | `t2` | m²·°C/A | 11.794 | | Activation coefficient, part over temperature | | `t3` | m²·°C²/A | 395.68 | | Activation coefficient, part over temperature squared | _Parameter descriptions are in English in both languages._ **Use for:** Thyristor and active rectifier supplies · Power-to-hydrogen plants on renewables **Not for:** Making electricity from hydrogen → [`fuelCell`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/fuelCell/) ## Formulas | Formula | Equation | Source | |---|---|---| | Cell voltage | v = Erev + (r1 + r2·T)·j + s·log10((t1 + t2/T + t3/T²)·j + 1) | Ulleberg, Int. J. Hydrogen Energy 28(1) (2003), pp. 21-33, cell voltage | | Hydrogen made | ṅ = ns·i/(2F) | Faraday's law of electrolysis; F from CODATA 2018 | | Stack power | P = ns·v·i | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 2 (power) | ## Quick check Inputs: - `ns`: Cells in series = 20 —, `ns` - `area`: Electrode area of one cell = 100m m², `area` - `temp`: Stack temperature = 70 °C, `temp` - `erev`: Reversible voltage per cell = 1.229 V, `erev` - `r1`: Ohmic coefficient = 218u Ω·m², `r1` - `r2`: Ohmic temperature coefficient = -425n Ω·m²/°C, `r2` - `s`: Activation slope = 117.93m V, `s` - `t1`: Activation coefficient t1 = -145.29m m²/A, `t1` - `t2`: Activation coefficient t2 = 11.794 m²·°C/A, `t2` - `t3`: Activation coefficient t3 = 395.68 m²·°C²/A, `t3` - `i`: Stack current = 200 A Outputs: - `j`: Current density = `i/area` A/m² - `vohm`: Ohmic overvoltage per cell = `(r1 + r2*temp)*j` V - `vact`: Activation overvoltage per cell = `s*log10((t1 + t2/temp + t3/temp^2)*j + 1)` V - `vstack`: Stack voltage = `ns*(erev + vohm + vact)` V - `pst`: Stack power = `vstack*i` W - `nh2`: Hydrogen made, at a Faraday efficiency of one = `ns*i/(2*96485.33212)` mol/s ## Model logic - Each cell needs erev plus an ohmic and an activation overvoltage, both driven by the current density. - The activation overvoltage is a diode solved by Newton's method; the temperature is fixed at temp. - The hydrogen made follows Faraday's law, two electrons per molecule; gas lost across the separator is not counted. ## Model Each of the ns cells needs erev plus two overvoltages, both driven by the current density j = i / area: the ohmic overvoltage (r1 + r2 * temp) * j and the activation overvoltage s * log10((t1 + t2 / temp + t3 / temp^2) * j + 1), with temp in °C. This is the empirical law of Ulleberg (2003), as written in Cantisani, Dovits and Jørgensen (2024). The concentration overvoltage is left out, as both do for alkaline cells. The activation overvoltage is a diode solved by Newton's method. The current of the part named like the electrolyzer is the current into p. The temperature is fixed at temp. ## Common mistakes - area and temp have no default, because the published coefficients come with neither; set them for your stack. erev defaults to 1.229 V, the value at 25 °C and 1 atm; it falls as the stack warms, so set it for temp. - Below ns * erev the law runs backwards, so a little current, at most the current where the activation term doubles, can flow out of p. A real stack does not drive its supply; a rectifier in front of it blocks this anyway. ## Datasheet and sources Fit r1, r2, s and t1 to t3 to the polarisation curves of the data sheet at two or more temperatures (cell voltage against current density). The defaults are Table I of Cantisani, Dovits and Jørgensen, arXiv:2311.09882v2 (2024), taken from Rizwan, Alstad and Jäschke, Int. J. Hydrogen Energy 46(75) (2021). ## Example Open the example with the command `file.openExample` and the name `demo:electrolyzer`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Fiducial (`fiducial`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/fiducial/ > A board-only part: a bare copper mark the pick-and-place camera aligns to. It has no pins and is never simulated. ![fiducial](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/fiducial.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/fiducial/) **Group:** Sources · **Kind:** `{"element":"fiducial","kind":"boardPart"}` ## When to use it Put it on the schematic when the assembly house asks for fiducials, so the board and the review list it with the other parts. ## Common parameters - `part`: Part number of a board-only part bought with the board (a standoff, screw or label), for the BOM; information only, not simulated (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `part` | — | optional (off) | | Part number of a board-only part bought with the board (a standoff, screw or label), for the BOM; information only, not simulated | | `footprint` | — | optional (off) | | KiCad library id of the footprint a board-only part sits on, such as MountingHole:MountingHole_3.2mm_M3; board.addFootprints places it; information only, not simulated | _Parameter descriptions are in English in both languages._ ## Model A board-only part is never simulated and never written to the netlist. It starts out of the BOM and on the board, and the schematic tags it board only. ## Common mistakes - Three global fiducials on one line cannot fix the board's rotation. board.addFiducials never puts them on one line. - The simulation never sees a board-only part. When the hardware matters electrically (a Y capacitor to the chassis, a ground strap), draw that as its own electrical part. ## Datasheet and sources There is no datasheet. The pad, mask opening and keep-out are the assembly house's numbers; board.addFiducials takes them. ## Example Open the example with the command `file.openExample` and the name `demo:fiducial`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Fuel Cell (`fuelCell`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/fuelCell/ > A fuel cell stack whose voltage falls with current along its polarisation curve. ![fuelCell](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/fuelCell.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/fuelCell/) **Group:** Sources · **Kind:** `{"kind":"fuelCell"}` ## When to use it Use it for fuel cell vehicles, backup power and hybrid systems with a battery or supercapacitor. For a fixed voltage, use DC Voltage Source. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | Positive terminal (cathode) | | `n` | electrical | Negative terminal (anode) | ## Common parameters - `ns`: Cells in series in the stack (Default: 35) - `e0`: Open-circuit voltage of one cell before losses (Default: 1.1909) - `r`: Resistance of one cell (Default: 2.05m) - `il`: Limiting current, where the voltage collapses (Default: 75.9) - `cdl`: Double-layer capacitance of one cell (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `ns` | — | 35 | | Cells in series in the stack | | `e0` | V | 1.1909 | | Open-circuit voltage of one cell before losses | | `a` | V | 66.2m | | Tafel slope of the activation loss of one cell | | `i0` | A | 16.7m | | Exchange current of the activation loss | | `iCross` | A | 60.7m | | Current lost inside the stack through the membrane | | `r` | Ω | 2.05m | | Resistance of one cell | | `b` | V | 16m | | Slope of the concentration loss of one cell | | `il` | A | 75.9 | | Limiting current, where the voltage collapses | | `cdl` | F | optional (off) | | Double-layer capacitance of one cell | _Parameter descriptions are in English in both languages._ **Use for:** Fuel cell vehicles · Backup power · Hybrids with a battery or supercapacitor **Not for:** Storage that can take current back → [`battery`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/battery/) ## Formulas | Formula | Equation | Source | |---|---|---| | Cell voltage | v = E0 − x·r − a·ln(1 + x/i0) + b·ln(1 − x/il) | Correa, Jatskevich, Lopes & Arnaud, IEEE Trans. Energy Convers. 19(2) (2004), pp. 433-441, polarisation curve | | Activation loss (Tafel) | v_act = a·ln(1 + x/i0) | Bard & Faulkner, Electrochemical Methods, 2nd ed. (2001), ch. 3 (Tafel equation) | | Concentration loss | v_conc = −b·ln(1 − x/il) | Correa, Jatskevich, Lopes & Arnaud, IEEE Trans. Energy Convers. 19(2) (2004), pp. 433-441, concentration loss | | Stack power | P = ns·v·i | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 2 (power) | ## Quick check Inputs: - `ns`: Cells in series = 35 —, `ns` - `e0`: Open-circuit voltage per cell = 1.1909 V, `e0` - `a`: Tafel slope per cell = 66.2m V, `a` - `i0`: Exchange current = 16.7m A, `i0` - `iCross`: Crossover current = 60.7m A, `iCross` - `r`: Resistance per cell = 2.05m Ω, `r` - `b`: Concentration slope per cell = 16m V, `b` - `il`: Limiting current = 75.9 A, `il` - `i`: Load current = 20 A Outputs: - `x`: Current through the losses = `i + iCross` A - `vohm`: Ohmic loss per cell = `x*r` V - `vact`: Activation loss per cell = `a*ln(1 + x/i0)` V - `vconc`: Concentration loss per cell = `-b*ln(1 - x/il)` V - `vstack`: Stack voltage = `ns*(e0 - vohm - vact - vconc)` V - `pst`: Stack power = `vstack*i` W ## Model logic - Each cell gives e0 less an ohmic, an activation and a concentration loss, all driven by the load current plus iCross. - The concentration loss grows without bound as the current nears il, so the stack cannot deliver more than il. - With cdl set, the double-layer capacitance cdl / ns sits across the activation and concentration losses and slows the step. - The activation and concentration losses are diodes solved by Newton's method; temperature, pressure and flow are fixed. ## Model Each of the ns cells gives e0 less three losses, all driven by the load current i plus the crossover current iCross: the ohmic loss (i + iCross) * r, the activation loss a * ln(1 + (i + iCross) / i0) and the concentration loss -b * ln(1 - (i + iCross) / il), which grows without bound as the current nears the limiting current il. This is the electrochemical model of Correa et al. (2004) with stack currents in amperes and the membrane resistance taken at zero current. With cdl set, the double-layer capacitance cdl / ns sits across the activation and concentration losses, so after a load step the voltage first drops by the ohmic loss only and then settles onto the curve. The activation and concentration losses are diodes solved by Newton's method. The current of the part named like the fuel cell is the current out of p. Temperature, gas pressure, fuel flow and humidity are fixed at the values the parameters were worked out for. ## Common mistakes - The stack cannot deliver more than il. A load that asks for more pulls the voltage down to zero instead, so check the current against il. - Without cdl the voltage follows a load step at once. The default has no cdl because no data sheet gives one; set a few farads per cell to see the slow part of the step. - r, a and b are per cell while i0, iCross and il are currents for the whole stack. Scale the currents with the active area when you change the cell size. ## Datasheet and sources Fit e0, a, i0, r, b and il to the polarisation curve of the data sheet (cell voltage against current density, times the active area for the currents). The defaults are the Ballard Mark V cell of Correa et al. (2004), Table I (343 K, 1 atm, 50.6 cm²), 35 cells; see the parameter table for how each value follows from it. ## Example Open the example with the command `file.openExample` and the name `demo:fuelCell`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Three-Phase Grid (`grid3`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/grid3/ > A three-phase voltage source with a neutral, for grid-tied converters. ![grid3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/grid3.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/grid3/) **Group:** Sources · **Kind:** `{"kind":"grid3"}` ## When to use it Use it for grid-tied inverters, rectifiers, chargers and power quality studies. It can add unbalance, harmonics and a voltage sag or swell on some or all phases. For a short circuit on the line, add a Fault. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | electrical | Phase a | | `b` | electrical | Phase b | | `c` | electrical | Phase c | | `n` | electrical | Neutral | ## Common parameters - `vll`: Line-to-line rms voltage (Default: 380) - `freq`: Frequency (Default: 60) - `harmonics`: Harmonic order and percent pairs, such as 5 4 7 3 (Default: optional (off)) - `sagDepth`: How far the voltage drops during the sag, 0 to 1; below 0 it rises (a swell) (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `vll` | V | 380 | | Line-to-line rms voltage | | `freq` | Hz | 60 | | Frequency | | `phase` | ° | 0 | | Angle of phase a at the start | | `ka` | — | 1 | | Size of phase a compared with normal | | `kb` | — | 1 | | Size of phase b compared with normal | | `kc` | — | 1 | | Size of phase c compared with normal | | `harmonics` | — | optional (off) | | Harmonic order and percent pairs, such as 5 4 7 3 | | `sagDepth` | — | 0 | | How far the voltage drops during the sag, 0 to 1; below 0 it rises (a swell) | | `sagStart` | s | 0 | | When the sag starts | | `sagEnd` | s | 0 | | When the sag ends | | `sagPhases` | — | abc | | Phases the sag or swell touches, such as a or abc | | `fDev` | Hz | 0 | | How far the frequency moves in the excursion; below 0 it falls | | `fStart` | s | 0 | | When the frequency starts to move | | `fEnd` | s | 0 | | When the frequency starts back to normal | | `fRate` | Hz/s | optional (off) | | How fast the frequency moves; none steps it at once | | `jumpDeg` | ° | 0 | | How far the phase angle jumps; below 0 it falls behind | | `jumpAt` | s | 0 | | When the phase angle jumps | | `jumpPhases` | — | abc | | Phases the jump touches, such as a or abc | | `rs` | Ω | 0 | | Resistance inside the source | | `ls` | H | 0 | | Inductance inside the source | _Parameter descriptions are in English in both languages._ **Use for:** Grid-tied inverters and chargers · Power quality studies · Voltage ride-through tests **Not for:** An ideal balanced three-phase source → [`sine3VoltageSource`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/sine3VoltageSource/) ## Formulas | Formula | Equation | Source | |---|---|---| | Phase voltage, rms | Vph = Vll/√3 | Grainger & Stevenson, Power System Analysis (1994), ch. 2 (balanced three-phase voltages) | | Phase voltage, peak | Vpk = √2·Vll/√3 | Grainger & Stevenson, Power System Analysis (1994), ch. 2 (balanced three-phase voltages) | | Phase voltage during the sag | Vsag = Vph·(1 − depth) | IEEE Std 1159-2019, voltage sag definition | | Voltage distortion | THD = √(h5² + h7²) in percent | IEEE Std 519-2022, definition of total harmonic distortion | ## Quick check Inputs: - `vll`: Line-to-line voltage, rms = 380 V, `vll` - `sagDepth`: Sag depth = 0 —, `sagDepth` - `h5`: 5th harmonic = 0 % - `h7`: 7th harmonic = 0 % Outputs: - `vph`: Phase voltage, rms = `vll/sqrt(3)` V - `vpk`: Phase voltage, peak = `vll*sqrt(2)/sqrt(3)` V - `vsag`: Phase voltage during the sag = `vph*(1 - sagDepth)` V - `thd`: Voltage distortion = `sqrt(h5^2 + h7^2)` % ## Model logic - Each phase is a voltage from n with the peak vll * sqrt(2) / sqrt(3), scaled by ka, kb or kc. - Phase b lags phase a by 120 degrees and phase c leads it; the 5th harmonic turns the other way and the 3rd is the same in all phases. - From sagStart to sagEnd the phases in sagPhases are multiplied by 1 - sagDepth; a negative sagDepth is a swell. - rs and ls sit in series with each phase, and the current of name.a is the current into the a terminal. ## Model Each phase is a voltage from n with the peak vll * sqrt(2) / sqrt(3), scaled by ka, kb or kc. Phase a starts at the angle phase, phase b lags it by 120 degrees and phase c leads it by 120 degrees. Each harmonic in the list adds its percent of the fundamental at its order, shifted by the order times the phase shift, so the 5th turns the other way and the 3rd is the same in all phases. From sagStart to sagEnd, the phases named in sagPhases (abc for all, a for a single-phase sag) are multiplied by 1 - sagDepth; a negative sagDepth is a swell, so -0.2 raises them to 120 %. rs and ls are a resistance and an inductance in series with each phase. The current of the part named name.a is the current into the a terminal of that phase source. ## Common mistakes - vll is the line-to-line rms voltage, so 380 gives about 220 V rms from each phase to n. Do not enter the phase voltage. - Connect n to ground or to a load neutral, or the source floats and the run fails. - Without rs or ls, a rectifier with a large capacitor draws unrealistic current spikes. Set the grid impedance. ## Datasheet and sources vll and freq come from the supply you connect to. Take harmonics from a measurement or a grid code limit, and the sag depth and time from the ride-through test you want to run. ## Example Open the example with the command `file.openExample` and the name `demo:grid3`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Ground (`ground`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/ground/ > The zero-volt reference of the circuit. ![ground](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/ground.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/ground/) **Group:** Sources · **Kind:** `{"kind":"ground"}` ## When to use it Place at least one in every circuit, usually on the negative side of the main source. Nets named 0, gnd or GND already count as ground. ## Pins | Pin | Domain | Meaning | |---|---|---| | `gnd` | electrical | Ground; every net it touches becomes node 0 | ## Model The part sets the voltage of its net to 0 V and defines the reference for every node voltage. All grounds in a circuit are the same node, including those inside subsystems. ## Common mistakes - A circuit without any ground has no reference. Add a ground to the negative end of the main source. - A part of the circuit with no path to ground floats at an arbitrary level, such as the secondary of a Transformer with nothing tied to ground. Tie one point of that part to ground. Problems rules: `ground.missing`, `island.floating` ## Datasheet and sources There is no datasheet. Choose the ground point from the design, usually the common negative rail or the chassis you measure against. ## Example Open the example with the command `file.openExample` and the name `demo:ground`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Logo (`logo`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/logo/ > A board-only part: a logo, title or marking on the silkscreen. It has no pins and is never simulated. ![logo](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/logo.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/logo/) **Group:** Sources · **Kind:** `{"element":"logo","kind":"boardPart"}` ## When to use it Put it on the schematic so the board carries the mark and the review sees it. ## Common parameters - `part`: Part number of a board-only part bought with the board (a standoff, screw or label), for the BOM; information only, not simulated (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `part` | — | optional (off) | | Part number of a board-only part bought with the board (a standoff, screw or label), for the BOM; information only, not simulated | | `footprint` | — | optional (off) | | KiCad library id of the footprint a board-only part sits on, such as MountingHole:MountingHole_3.2mm_M3; board.addFootprints places it; information only, not simulated | _Parameter descriptions are in English in both languages._ ## Model A board-only part is never simulated and never written to the netlist. It starts out of the BOM and on the board, and the schematic tags it board only. ## Common mistakes - Silkscreen over a pad or a via is clipped by the board house. Keep the logo off copper openings. - The simulation never sees a board-only part. When the hardware matters electrically (a Y capacitor to the chassis, a ground strap), draw that as its own electrical part. ## Datasheet and sources There is no datasheet. ## Example Open the example with the command `file.openExample` and the name `demo:logo`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Mounting Hole (`mountingHole`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/mountingHole/ > A board-only part: a hole for a screw or standoff, shown on the schematic and never simulated. ![mountingHole](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/mountingHole.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/mountingHole/) **Group:** Sources · **Kind:** `{"element":"mountingHole","kind":"boardPart"}` ## When to use it Put one on the schematic for each screw hole the board needs, so the board, the drawings and reviewers see it. Tie its pin to a chassis or PGND net only for a plated hole that grounds through the screw. ## Pins | Pin | Domain | Meaning | |---|---|---| | `mh` | electrical | Optional: the net a plated hole joins (chassis or PGND); leave it open for a bare hole | ## Common parameters - `part`: Part number of a board-only part bought with the board (a standoff, screw or label), for the BOM; information only, not simulated (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `part` | — | optional (off) | | Part number of a board-only part bought with the board (a standoff, screw or label), for the BOM; information only, not simulated | | `footprint` | — | optional (off) | | KiCad library id of the footprint a board-only part sits on, such as MountingHole:MountingHole_3.2mm_M3; board.addFootprints places it; information only, not simulated | _Parameter descriptions are in English in both languages._ ## Model A board-only part is never simulated and never written to the netlist, whatever its simulate switch says. It starts out of the BOM and on the board, and the schematic tags it board only. ## Common mistakes - A hole tied to a net is a copper connection on the board even though the simulation ignores it. Check the creepage to nearby high-voltage nets on the board. - The simulation never sees a board-only part. When the hardware matters electrically (a Y capacitor to the chassis, a ground strap), draw that as its own electrical part. ## Datasheet and sources There is no datasheet. The drill, pad and screw-head keep-out are the engineer's; board.addMountingHoles takes them. ## Example Open the example with the command `file.openExample` and the name `demo:mountingHole`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Pin Header, 2 Pins (`pinHeader2`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/pinHeader2/ > A 2.54 mm pin header with 2 pins: where a gate drive or signal from off the board plugs in. ![pinHeader2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/pinHeader2.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/pinHeader2/) **Group:** Sources · **Kind:** `{"element":"pinHeader2","kind":"connector"}` ## When to use it Put one where a gate or control signal comes from off the board, with a pin for its return next to it. board.interfaceConnectors {apply:true} draws one per gate whose driver is off the board. ## Pins | Pin | Domain | Meaning | |---|---|---| | `1` | electrical | Position 1: the net that enters or leaves the board here | | `2` | electrical | Position 2: the net that enters or leaves the board here | ## Common parameters - `part`: Part number; the catalogue order number of the terminal block or header, such as 1715022, written on the schematic; information only, not simulated (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `part` | — | optional (off) | | Part number; the catalogue order number of the terminal block or header, such as 1715022, written on the schematic; information only, not simulated | _Parameter descriptions are in English in both languages._ ## Model A connector only joins its nets, so it adds nothing to the simulation: each net is simulated as if it were not there. It is in the BOM and on the board; board.addFootprints gives it the footprint of its part number. ## Common mistakes - The gate current is not simulated through the header. Check the gate driver's peak output current against the header's rated current. - board.autoPlace puts a connector at the board edge so the wire or plug can reach it. Keep tall parts out of its insertion path. Problems rules: `pin.unconnected` ## Datasheet and sources The Würth Elektronik WR-PHD data sheet of the order code: pins, pitch, rated current and working voltage (p. 1 and 2). Its part parameter is the order code. ## Example Open the example with the command `file.openExample` and the name `demo:pinHeader2`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Pin Header, 3 Pins (`pinHeader3`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/pinHeader3/ > A 2.54 mm pin header with 3 pins: where a gate drive or signal from off the board plugs in. ![pinHeader3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/pinHeader3.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/pinHeader3/) **Group:** Sources · **Kind:** `{"element":"pinHeader3","kind":"connector"}` ## When to use it Put one where a gate or control signal comes from off the board, with a pin for its return next to it. board.interfaceConnectors {apply:true} draws one per gate whose driver is off the board. ## Pins | Pin | Domain | Meaning | |---|---|---| | `1` | electrical | Position 1: the net that enters or leaves the board here | | `2` | electrical | Position 2: the net that enters or leaves the board here | | `3` | electrical | Position 3: the net that enters or leaves the board here | ## Common parameters - `part`: Part number; the catalogue order number of the terminal block or header, such as 1715022, written on the schematic; information only, not simulated (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `part` | — | optional (off) | | Part number; the catalogue order number of the terminal block or header, such as 1715022, written on the schematic; information only, not simulated | _Parameter descriptions are in English in both languages._ ## Model A connector only joins its nets, so it adds nothing to the simulation: each net is simulated as if it were not there. It is in the BOM and on the board; board.addFootprints gives it the footprint of its part number. ## Common mistakes - The gate current is not simulated through the header. Check the gate driver's peak output current against the header's rated current. - board.autoPlace puts a connector at the board edge so the wire or plug can reach it. Keep tall parts out of its insertion path. Problems rules: `pin.unconnected` ## Datasheet and sources The Würth Elektronik WR-PHD data sheet of the order code: pins, pitch, rated current and working voltage (p. 1 and 2). Its part parameter is the order code. ## Example Open the example with the command `file.openExample` and the name `demo:pinHeader3`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Pin Header, 4 Pins (`pinHeader4`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/pinHeader4/ > A 2.54 mm pin header with 4 pins: where a gate drive or signal from off the board plugs in. ![pinHeader4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/pinHeader4.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/pinHeader4/) **Group:** Sources · **Kind:** `{"element":"pinHeader4","kind":"connector"}` ## When to use it Put one where a gate or control signal comes from off the board, with a pin for its return next to it. board.interfaceConnectors {apply:true} draws one per gate whose driver is off the board. ## Pins | Pin | Domain | Meaning | |---|---|---| | `1` | electrical | Position 1: the net that enters or leaves the board here | | `2` | electrical | Position 2: the net that enters or leaves the board here | | `3` | electrical | Position 3: the net that enters or leaves the board here | | `4` | electrical | Position 4: the net that enters or leaves the board here | ## Common parameters - `part`: Part number; the catalogue order number of the terminal block or header, such as 1715022, written on the schematic; information only, not simulated (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `part` | — | optional (off) | | Part number; the catalogue order number of the terminal block or header, such as 1715022, written on the schematic; information only, not simulated | _Parameter descriptions are in English in both languages._ ## Model A connector only joins its nets, so it adds nothing to the simulation: each net is simulated as if it were not there. It is in the BOM and on the board; board.addFootprints gives it the footprint of its part number. ## Common mistakes - The gate current is not simulated through the header. Check the gate driver's peak output current against the header's rated current. - board.autoPlace puts a connector at the board edge so the wire or plug can reach it. Keep tall parts out of its insertion path. Problems rules: `pin.unconnected` ## Datasheet and sources The Würth Elektronik WR-PHD data sheet of the order code: pins, pitch, rated current and working voltage (p. 1 and 2). Its part parameter is the order code. ## Example Open the example with the command `file.openExample` and the name `demo:pinHeader4`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Electrical Constant-Power Load (`powerLoad`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/powerLoad/ > A load that draws the same power at any voltage, like a regulated converter or an electronic load in CP mode. ![powerLoad](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/powerLoad.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/powerLoad/) **Group:** Sources · **Kind:** `{"kind":"powerLoad"}` ## When to use it Use it for the input of a downstream converter, a motor drive seen from its DC bus, or a pulsed load. Its negative incremental resistance is what makes a filter in front of a converter ring, so it is the load to test input-filter stability with. For a load that follows the voltage, use a resistor. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | Positive terminal; the load current flows in here | | `n` | electrical | Negative terminal | | `pref` | signal | Optional power setpoint signal in watts, for a load that follows the control; it wins over profile and p | ## Common parameters - `p`: Power it draws; the pref input, when connected, sets it instead (Default: 100) - `profile`: Power over time: pwl(t p …), steps(p0 t p …), pulse(p1 p2 delay rise fall width period), workload(pidle ppeak period duty edge [pexc texc]) or vrstep(p0 p1 delay slew/µs [width period]); replaces p (Default: optional (off)) - `von`: Undervoltage lockout: it turns on when the voltage reaches von; 0 means always on (Default: 0) - `voff`: Undervoltage lockout: it turns off when the voltage falls below voff; 0 means never (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `p` | W | 100 | | Power it draws; the pref input, when connected, sets it instead | | `vmin` | V | 1 | | Below this voltage it is a resistor that draws p at vmin, so it stays defined near 0 V | | `von` | V | 0 | | Undervoltage lockout: it turns on when the voltage reaches von; 0 means always on | | `voff` | V | 0 | | Undervoltage lockout: it turns off when the voltage falls below voff; 0 means never | | `profile` | — | optional (off) | | Power over time: pwl(t p …), steps(p0 t p …), pulse(p1 p2 delay rise fall width period), workload(pidle ppeak period duty edge [pexc texc]) or vrstep(p0 p1 delay slew/µs [width period]); replaces p | | `repeat` | — | 0 | | Set to 1 to repeat the profile pattern over and over | _Parameter descriptions are in English in both languages._ **Use for:** Inputs of downstream converters · Input filter stability tests · Pulsed loads **Not for:** A load that follows the voltage → [`resistor`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/resistor/) ## Formulas | Formula | Equation | Source | |---|---|---| | Load current | i = P/v | Erickson & Maksimovic, Fundamentals of Power Electronics, 3rd ed. (2020), ch. 10 (input filter design) | | Incremental resistance | dv/di = −v²/P | Middlebrook, Input filter considerations in design and application of switching regulators, IEEE IAS Annual Meeting (1976), pp. 366-382 | | Filter stability margin | margin = (v²/P)/Z0, below 1 it rings | Middlebrook, Input filter considerations in design and application of switching regulators, IEEE IAS Annual Meeting (1976), pp. 366-382 | | Resistor below vmin | R = vmin²/P | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 2 (power in a resistor) | ## Quick check Inputs: - `p`: Power drawn = 100 W, `p` - `v`: Voltage at the terminals = 48 V - `vmin`: Voltage below which it is a resistor = 1 V, `vmin` - `zo`: Characteristic impedance of the filter before it = 500m Ω Outputs: - `i`: Load current = `p/v` A - `rinc`: Incremental resistance = `-v^2/p` Ω - `margin`: Filter stability margin = `(v^2/p)/zo` — - `rlow`: Resistor below vmin = `vmin^2/p` Ω ## Model logic - Above vmin the load draws i = P / v, so its power is P whatever the voltage; below vmin it is the resistor vmin² / P. - P is the pref signal when connected, else the profile at the time of the step, else p; a negative setpoint draws nothing. - With von set the load starts off and turns on when the voltage reaches von; with voff set it turns off below voff. - The lockout is checked once per accepted step, and the load is solved by Newton's method. ## Model Above vmin it draws i = P / v, so its power is P whatever the voltage. Below vmin it is the resistor vmin² / P, so it stays defined at 0 V and draws P at vmin. P is the value of the pref signal when pref is connected, else the profile at the time of the step when profile is set, else the parameter p; a negative setpoint draws nothing. A profile is pwl(t1 p1 t2 p2 and so on) for straight lines between points, steps(p0 t1 p1 t2 p2 and so on) for levels held from each time on, or pulse(p1 p2 delay rise fall width period) for a pulsed load; repeat set to 1 starts a pwl or steps pattern over after its last time. The fast solver lands a step on every corner of the profile. With von set, the load starts off (only a 1 GΩ leakage) and turns on once the voltage reaches von. With voff set, it turns off again when the voltage falls below voff, and stays off until it reaches von. The lockout is checked once per accepted step. The load is solved by Newton's method, like the protection devices. ## Common mistakes - Without a lockout, a constant-power load draws a large current while its supply ramps up from 0 V. Set von and voff to the thresholds of the converter it stands for, or raise vmin. - A constant-power load fed through an LC filter oscillates when the filter's characteristic impedance is above v² / P. That is a real instability, not a solver problem; damp the filter. - voff must not be above von. Keep a few volts between them so the load does not chatter at the threshold. ## Datasheet and sources p is the power the load draws: the output power of the converter it stands for divided by that converter's efficiency. von and voff are the converter's UVLO turn-on and turn-off thresholds from its data sheet. The defaults are not taken from any part: 100 W, vmin 1 V and no lockout. ## Example Open the example with the command `file.openExample` and the name `demo:powerLoad`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Pulse Voltage Source (`pulseVoltageSource`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/pulseVoltageSource/ > Produces a pulse or square-wave voltage. ![pulseVoltageSource](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/pulseVoltageSource.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/pulseVoltageSource/) **Group:** Sources · **Kind:** `{"kind":"pulseVoltageSource"}` ## When to use it Use it for step tests, load or supply steps and test pulses. For switch gate drive, use PWM Generator instead. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | Positive end | | `n` | electrical | Negative end, the reference side | ## Common parameters - `v1`: Low level before the pulse (Default: 0) - `v2`: High level during the pulse (Default: required) - `width`: How long each pulse stays high (Default: required) - `period`: Time from one pulse to the next (Default: 0) - `delay`: Wait before the first pulse (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `v1` | V | 0 | | Low level before the pulse | | `v2` | V | required | | High level during the pulse | | `delay` | s | 0 | | Wait before the first pulse | | `rise` | s | 0 | | Rise time | | `fall` | s | 0 | | Fall time | | `width` | s | required | | How long each pulse stays high | | `period` | s | 0 | | Time from one pulse to the next | | `rs` | Ω | 0 | 1m – 10 Ω | Resistance inside the source | _Parameter descriptions are in English in both languages._ **Use for:** Step tests · Supply steps · Test pulses **Not for:** Switch gate drive → [`pwm`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/pwm/) · Steps in control signals → [`step`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/step/) ## Formulas | Formula | Equation | Source | |---|---|---| | Duty cycle | D = width/period | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), §2.1 | | Average (sharp edges) | Vavg = v1 + (v2 − v1)·D | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), §2.1 | | RMS (sharp edges) | Vrms = √(v1²·(1 − D) + v2²·D) | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), Appendix A | ## Quick check Inputs: - `v1`: Low level = 0 V, `v1` - `v2`: High level = 5 V, `v2` - `width`: Pulse width = 5u s, `width` - `period`: Period = 20u s, `period` Outputs: - `duty`: Duty cycle = `width/period` — - `vavg`: Average voltage = `v1 + (v2 - v1)*duty` V - `vrms`: RMS voltage = `sqrt(v1^2*(1 - duty) + v2^2*duty)` V ## Model logic - The output is v1 until delay, ramps linearly to v2 over rise, holds v2 for width, ramps back over fall, then stays at v1 until the next cycle, one period later. - width is the flat top only, not counting rise and fall; period 0 or less gives one pulse, and a negative rise, fall or width is read as 0. - The step control lands exactly on every corner in every cycle, so with rise and fall 0 the edge is a clean step and the on-time is the same each cycle. - It is an ideal voltage branch with an optional series rs inside, on the n side; overshoot, ringing and a drive current limit are not modelled. ## Model The output is v1 until delay, rises linearly to v2 over rise, holds v2 for width, falls to v1 over fall, and repeats every period (0 means one pulse). The duty is width / period, and rise + width + fall must fit inside period. The step control lands exactly on the edges. ## Common mistakes - A width longer than the period gives a duty above 100 percent. Set the width to a part of the period. - width and period are in seconds, so 5 means five seconds, not 5u. width has no default and must be set. Problems rules: `duty.pulse`, `param.out_of_range` ## Datasheet and sources There is no datasheet. v1 and v2 are your test levels, period is one divided by the test frequency, and rise and fall follow the edge speed you want to test. ## Example Open the example with the command `file.openExample` and the name `demo:pulseVoltageSource`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Solar Module (`pv`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/pv/ > A photovoltaic module that turns sunlight into current. ![pv](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/pv.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/pv/) **Group:** Sources · **Kind:** `{"kind":"pv"}` ## When to use it Use it for solar inverters, maximum power point tracking and microgrids. Set nser and npar for a whole array instead of placing many modules. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | Positive terminal | | `n` | electrical | Negative terminal | | `g` | signal | Sunlight in W/m² (an input signal); replaces irr when connected | ## Common parameters - `isc`: Short-circuit current at standard test conditions (Default: 9.5) - `voc`: Open-circuit voltage at standard test conditions (Default: 38) - `imp`: Current at the maximum power point (Default: 9) - `vmp`: Voltage at the maximum power point (Default: 31) - `irr`: Sunlight on the module; the g pin replaces it when connected (Default: 1000) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `isc` | A | 9.5 | | Short-circuit current at standard test conditions | | `voc` | V | 38 | | Open-circuit voltage at standard test conditions | | `imp` | A | 9 | | Current at the maximum power point | | `vmp` | V | 31 | | Voltage at the maximum power point | | `irr` | W/m² | 1000 | | Sunlight on the module; the g pin replaces it when connected | | `temp` | °C | 25 | | Cell temperature | | `ns` | — | 60 | | Cells in series inside the module | | `alphaIsc` | %/K | 0.05 | | Change of short-circuit current with temperature | | `betaVoc` | %/K | -0.3 | | Change of open-circuit voltage with temperature | | `nser` | — | 1 | | Modules in series | | `npar` | — | 1 | | Strings of modules in parallel | _Parameter descriptions are in English in both languages._ **Use for:** MPPT converters · Solar inverters · Whole arrays (nser, npar) **Not for:** A fixed DC supply → [`dcVoltageSource`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/dcVoltageSource/) ## Formulas | Formula | Equation | Source | |---|---|---| | Fill factor | FF = Vmp·Imp/(Voc·Isc) | Gray, The Physics of the Solar Cell, in Luque & Hegedus (eds.), Handbook of Photovoltaic Science and Engineering, 2nd ed. (2011), ch. 3 | | Short-circuit current at G and T | Isc(G,T) = Isc·G/1000·(1 + α·(T − 25)) | Villalva, Gazoli & Filho, IEEE Trans. Power Electron. 24(5) (2009), pp. 1198-1208, temperature and irradiance dependence | | Open-circuit voltage at T | Voc(T) = Voc·(1 + β·(T − 25)) | Villalva, Gazoli & Filho, IEEE Trans. Power Electron. 24(5) (2009), pp. 1198-1208, temperature dependence | | Array power at standard test conditions | P = nser·npar·Vmp·Imp | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 2 (power) | ## Quick check Inputs: - `isc`: Short-circuit current = 9.5 A, `isc` - `voc`: Open-circuit voltage = 38 V, `voc` - `imp`: Current at the maximum power point = 9 A, `imp` - `vmp`: Voltage at the maximum power point = 31 V, `vmp` - `irr`: Sunlight = 1k W/m², `irr` - `temp`: Cell temperature = 25 °C, `temp` - `alphaIsc`: Temperature coefficient of isc = 50m %/K, `alphaIsc` - `betaVoc`: Temperature coefficient of voc = -300m %/K, `betaVoc` - `nser`: Modules in series = 1 —, `nser` - `npar`: Strings in parallel = 1 —, `npar` Outputs: - `ff`: Fill factor = `vmp*imp/(voc*isc)` — - `isct`: Short-circuit current now = `isc*irr/1000*(1 + alphaIsc/100*(temp - 25))` A - `voct`: Open-circuit voltage now = `voc*(1 + betaVoc/100*(temp - 25))` V - `pstc`: Array power at standard conditions = `nser*npar*vmp*imp` W ## Model logic - A photocurrent source, a diode and the series resistance rs make the model; there is no shunt resistance. - Before the run the diode and rs are fitted so that the curve passes through isc, voc and the point (vmp, imp). - The photocurrent follows the sunlight, and isc and voc follow the cell temperature by alphaIsc and betaVoc. - The diode is solved by Newton's method, and the current of the part is the current out of p. Shading and bypass diodes are not modelled. ## Model The module is the single-diode model with a series resistance: a photocurrent source, a diode and rs, with no shunt resistance. Before the run, the diode and rs are fitted so that the curve passes exactly through the short-circuit current isc, the open-circuit voltage voc and the maximum power point (vmp, imp), and the power peaks at that point. The photocurrent grows in proportion to the sunlight. At another cell temperature, isc and voc change by alphaIsc and betaVoc. The diode is solved by Newton's method, so its current follows the exponential law exactly. The current of the part named like the module is the current out of p. Partial shading, bypass diodes and the reverse region are not modelled. ## Common mistakes - imp must be below isc, vmp below voc, and vmp more than half of voc. Other values are refused before the run. - A module with nothing connected sits at its open-circuit voltage. Connect a load or a converter to draw power. - Set ns to the cells in series. The run warns when the fitted diode looks unusual, which often means ns or a datasheet value is wrong. ## Datasheet and sources isc, voc, imp and vmp come from the electrical table at standard test conditions (1000 W/m², 25 °C). alphaIsc and betaVoc are the temperature coefficients of isc and voc in %/K, and ns is the number of cells. The default values are an illustrative 60-cell module, not a real product. ## Example Open the example with the command `file.openExample` and the name `demo:pv`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Nonlinear Rectifier Load (`rectifierLoad`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/rectifierLoad/ > A single-phase diode bridge with a smoothing capacitor and a load resistor, the classic load that draws harmonic current from the line. ![rectifierLoad](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/rectifierLoad.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/rectifierLoad/) **Group:** Sources · **Kind:** `{"kind":"rectifierLoad"}` ## When to use it Use it for the front end of an off-line power supply or any capacitor-input rectifier seen from the AC side: to test an inverter or UPS with a nonlinear load, to see the voltage distortion a weak line gets, or as the harmonic source for a filter or power-factor study. For a load that draws a sine, use a resistor. ## Pins | Pin | Domain | Meaning | |---|---|---| | `l` | electrical | Line terminal of the AC input | | `n` | electrical | Neutral terminal of the AC input | ## Common parameters - `c`: Smoothing capacitance on the DC side (Default: required) - `r`: Load resistance across the capacitor (Default: required) - `rs`: Line resistance in series with the bridge input; 0 for none (Default: 0) - `ls`: Line inductance in series with the bridge input; 0 for none (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `c` | F | required | | Smoothing capacitance on the DC side | | `r` | Ω | required | | Load resistance across the capacitor | | `rs` | Ω | 0 | | Line resistance in series with the bridge input; 0 for none | | `ls` | H | 0 | | Line inductance in series with the bridge input; 0 for none | | `ron` | Ω | 1m | | Resistance when it is on | | `roff` | Ω | 1meg | | Resistance when it is off | | `vf` | V | 0 | | Voltage lost while it conducts | | `v0` | V | 0 | | Capacitor voltage at the start | _Parameter descriptions are in English in both languages._ **Use for:** Harmonic studies of a supply · Inrush and crest-factor checks · The input of a switch-mode supply **Not for:** A DC-side constant-power load → [`powerLoad`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/powerLoad/) ## Formulas | Formula | Equation | Source | |---|---|---| | Peak of the line | Vpk = √2·Vrms | Mohan, Undeland & Robbins, Power Electronics, 3rd ed. (2003), ch. 5 (single-phase diode-bridge rectifier with a capacitor filter) | | Peak-to-peak ripple | ΔV ≈ I/(2·f·C) | Mohan, Undeland & Robbins, Power Electronics, 3rd ed. (2003), ch. 5 (single-phase diode-bridge rectifier with a capacitor filter) | | Discharge time constant | τ = R·C | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 8 (RC natural response) | ## Quick check Inputs: - `vac`: Line voltage, rms = 230 V - `f`: Line frequency = 50 Hz - `c`: Smoothing capacitance = 2.2m F, `c` - `r`: Load resistance = 470 Ω, `r` Outputs: - `vpk`: Peak of the line = `vac*sqrt(2)` V - `idc`: DC load current near the peak = `vpk/r` A - `ripple`: Peak-to-peak ripple = `idc/(2*f*c)` V - `tau`: Discharge time constant = `r*c` s ## Model logic - The line goes through rs and ls, each left out when 0, into a bridge of four ideal diodes that charges c with r across it. - The diodes conduct only while the line is above the capacitor voltage, so the current comes in short peaks near each crest. - The DC side runs between the nets NL1:p and NL1:m for a load named NL1, and the capacitor is NL1.c. - The load is expanded into these parts before the solve, so it simulates like the same circuit drawn by hand. ## Model The line goes through rs and ls (each left out when 0) into a bridge of four ideal diodes (ron, roff, vf), which charges c, with r across it. The diodes conduct only while the line voltage is above the capacitor voltage, so the current comes in short peaks near each crest, with a high crest factor and odd harmonics. For a load named NL1 the DC side runs between the nets NL1:p and NL1:m, so the DC voltage is v(NL1:p) − v(NL1:m); the capacitor is NL1.c, and with rs set i(NL1.rs) is the line current. The load is expanded into these parts before it is solved, so it simulates like the same circuit drawn by hand. ## Common mistakes - With rs and ls at 0 the peaks are limited only by the diodes' ron and the source, so they can be far higher than a real line allows. Set the line impedance of the supply you stand for. - The capacitor starts at v0 (0 V by default), so the first half-cycles draw a large inrush. Start c near the line peak, or judge the harmonics after the run has settled. ## Datasheet and sources c and r have no default: they are the load you stand for (the bulk capacitor of the supply and its DC load, about v² / P for a load of P watts). A test standard's reference nonlinear load sizes them from its own rules. The diode defaults are the ideal diodes of the three-phase bridge, not a part. ## Example Open the example with the command `file.openExample` and the name `demo:rectifierLoad`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Three-Phase Sine Voltage Source (`sine3VoltageSource`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/sine3VoltageSource/ > A balanced, ideal three-phase sinusoidal voltage source in star, with its star point brought out. ![sine3VoltageSource](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/sine3VoltageSource.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/sine3VoltageSource/) **Group:** Sources · **Kind:** `{"kind":"sine3VoltageSource"}` ## When to use it Use it for a three-phase grid or generator feeding a rectifier, an active front end or a motor test bench. Use three `sineVoltageSource` parts for an unbalanced or distorted grid, and `sine3` for a three-phase control signal. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | electrical | Phase a terminal; v(a) - v(n) = Vpk*sin(2*pi*freq*t + phase). | | `b` | electrical | Phase b terminal, 120 degrees behind phase a. | | `c` | electrical | Phase c terminal, 120 degrees ahead of phase a. | | `n` | electrical | Star point (neutral); leave it open for a three-wire system or ground it. | ## Common parameters - `vac`: RMS voltage: phase to neutral with mode `phase`, line to line with mode `line` (Default: required) - `mode`: What vac is: `phase` (amplitude = vac·√2) or `line` (amplitude = vac·√2/√3) (Default: phase) - `freq`: Frequency (Default: required) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `vac` | V | required | | RMS voltage: phase to neutral with mode `phase`, line to line with mode `line` | | `mode` | — | phase | | What vac is: `phase` (amplitude = vac·√2) or `line` (amplitude = vac·√2/√3) | | `freq` | Hz | required | | Frequency | | `phase` | ° | 0 | | Phase of phase a at t = 0; b lags it by 120°, c leads it by 120° | _Parameter descriptions are in English in both languages._ **Use for:** Three-phase grids · Rectifier inputs · Motor test benches **Not for:** Grids with harmonics or sags → [`grid3`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/grid3/) · Three-phase control signals → [`sine3`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/sine3/) ## Formulas | Formula | Equation | Source | |---|---|---| | Phase voltage | Vph = vac (phase) or vac/√3 (line) | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), Ch. 12 | | Line-to-line voltage | VLL = √3·Vph | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), Ch. 12 | | Phase peak | Vpk = √2·Vph | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), Ch. 11 | ## Quick check Inputs: - `vac`: RMS voltage = 230 V, `vac` - `lineMode`: vac is line to line (1) or phase (0) = 0 — Outputs: - `vph`: Phase voltage (RMS) = `if(lineMode > 0.5, vac/sqrt(3), vac)` V - `vll`: Line-to-line voltage (RMS) = `sqrt(3)*vph` V - `vpk`: Phase peak = `sqrt(2)*vph` V ## Model logic - Three ideal voltage branches run from n to a, b and c at phase, phase - 120 and phase + 120 degrees, with no offset. - The peak is vac·√2 with mode phase and vac·√2/√3 with mode line; any other mode text stops the run with an error. - There is no rs: the three branches have zero impedance, so line inductance or resistance must be added as series parts in each phase. - The set is always balanced at one frequency: unbalance, harmonics, sags and frequency changes are not modelled. ## Model Three ideal sources from `n`: phase a is Vpk*sin(2*pi*`freq`*t + `phase`), b the same at `phase` - 120 degrees and c at `phase` + 120 degrees (a positive sequence a, b, c). `vac` is an RMS value: with `mode` = `phase` it is the phase-to-neutral voltage and Vpk = vac*sqrt(2); with `mode` = `line` it is the line-to-line voltage and Vpk = vac*sqrt(2)/sqrt(3). The three sources have no internal impedance. ## Common mistakes - A 400 V grid is 400 V line to line: set `mode` = `line` with `vac` = 400, or `mode` = `phase` with `vac` = 230. Entering 400 with the default `phase` mode gives a grid sqrt(3) times too high. - The ideal sources have no impedance, so a rectifier with a capacitor on it draws unlimited current spikes; add a line inductance or resistance in each phase. A `maxStep` longer than 1/50 of the period samples the sine too coarsely, and a run shorter than about six cycles does not reach steady state. Problems rules: `step.too_large`, `run.short` ## Datasheet and sources `vac`, `mode` and `freq` come from the supply specification (for example 400 V line to line, 50 Hz). Model the grid impedance with series parts from the short-circuit power of the connection point. ## Example Open the example with the command `file.openExample` and the name `demo:sine3VoltageSource`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Sine Voltage Source (`sineVoltageSource`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/sineVoltageSource/ > Produces a sine-wave voltage with offset and phase. ![sineVoltageSource](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/sineVoltageSource.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/sineVoltageSource/) **Group:** Sources · **Kind:** `{"kind":"sineVoltageSource"}` ## When to use it Use it for AC mains, test signals and one phase of a three-phase supply. Use DC Voltage Source for DC. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | Positive end | | `n` | electrical | Negative end, the reference side | ## Common parameters - `amp`: Height of the wave peak (Default: required) - `freq`: Frequency (Default: required) - `phase`: Where the wave starts in its cycle (Default: 0) - `offset`: Fixed amount added to the wave (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `amp` | V | required | | Height of the wave peak | | `freq` | Hz | required | | Frequency | | `phase` | ° | 0 | | Where the wave starts in its cycle | | `offset` | V | 0 | | Fixed amount added to the wave | | `rs` | Ω | 0 | 1m – 10 Ω | Resistance inside the source | _Parameter descriptions are in English in both languages._ **Use for:** AC mains · Test signals · One grid phase **Not for:** Balanced three-phase supply → [`sine3VoltageSource`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/sine3VoltageSource/) · Sine references in control → [`sine`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/control/sine/) ## Formulas | Formula | Equation | Source | |---|---|---| | RMS voltage | Vrms = √(offset² + amp²/2) | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), Ch. 11 | | Period | T = 1/freq | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), Ch. 10 | | Highest voltage | Vmax = offset + amp | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), Ch. 10 | ## Quick check Inputs: - `amp`: Peak amplitude = 325 V, `amp` - `freq`: Frequency = 50 Hz, `freq` - `offset`: DC offset = 0 V, `offset` Outputs: - `vrms`: RMS voltage = `sqrt(offset^2 + amp^2/2)` V - `period`: Period = `1/freq` s - `vmax`: Highest voltage = `offset + amp` V ## Model logic - The output is v(t) = offset + amp·sin(2π·freq·t + phase) from t = 0, phase in degrees, so it starts at offset + amp·sin(phase) with no ramp-in. - It is an ideal voltage branch; rs above 0 adds a series resistor inside the part, on the n side. - The sine has no breakpoints, so the step control lands on no point of it and the maximum step alone sets how finely it is sampled. - One fixed frequency and amplitude for the whole run: harmonics, sags and frequency changes are not modelled. ## Model The voltage is v(t) = offset + amp * sin(2 * pi * freq * t + phase), with phase in degrees. amp is the peak value, not the RMS value. With rs set, a resistor rs sits in series inside the part. ## Common mistakes - amp is the peak, so 230 V RMS mains needs about 325 V. Phase is in degrees, and three phases use 0, -120 and -240. - A maximum step longer than 1/50 of the period samples the sine too coarsely. A run shorter than about six cycles never reaches steady state. Problems rules: `step.too_large`, `run.short` ## Datasheet and sources amp and freq come from the supply specification, such as 50 Hz and the peak of the RMS rating. rs is the source resistance of the grid or generator. ## Example Open the example with the command `file.openExample` and the name `demo:sineVoltageSource`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Standoff (`standoff`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/standoff/ > A board-only part: a spacer that holds the board off its chassis. It has no pins and is never simulated. ![standoff](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/standoff.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/standoff/) **Group:** Sources · **Kind:** `{"element":"standoff","kind":"boardPart"}` ## When to use it Put it on the schematic when the standoff is bought with the board, and turn its BOM switch on so the BOM lists it. ## Common parameters - `part`: Part number of a board-only part bought with the board (a standoff, screw or label), for the BOM; information only, not simulated (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `part` | — | optional (off) | | Part number of a board-only part bought with the board (a standoff, screw or label), for the BOM; information only, not simulated | | `footprint` | — | optional (off) | | KiCad library id of the footprint a board-only part sits on, such as MountingHole:MountingHole_3.2mm_M3; board.addFootprints places it; information only, not simulated | _Parameter descriptions are in English in both languages._ ## Model A board-only part is never simulated and never written to the netlist. It starts out of the BOM and on the board, and the schematic tags it board only. ## Common mistakes - A metal standoff shorts whatever copper it touches. Keep tracks and pours out of its footprint. - The simulation never sees a board-only part. When the hardware matters electrically (a Y capacitor to the chassis, a ground strap), draw that as its own electrical part. ## Datasheet and sources Take the height and thread from the standoff maker's data sheet. ## Example Open the example with the command `file.openExample` and the name `demo:standoff`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Terminal Block, 2 Positions (`terminalBlock2`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/terminalBlock2/ > A screw terminal block with 2 positions: where a supply or load wire enters the board. ![terminalBlock2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/terminalBlock2.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/terminalBlock2/) **Group:** Sources · **Kind:** `{"element":"terminalBlock2","kind":"connector"}` ## When to use it Put one where a net leaves the board for a supply or a load: one position per net. board.interfaceConnectors {apply:true} picks a block rated for the simulated current and voltage and draws it here. ## Pins | Pin | Domain | Meaning | |---|---|---| | `1` | electrical | Position 1: the net that enters or leaves the board here | | `2` | electrical | Position 2: the net that enters or leaves the board here | ## Common parameters - `part`: Part number; the catalogue order number of the terminal block or header, such as 1715022, written on the schematic; information only, not simulated (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `part` | — | optional (off) | | Part number; the catalogue order number of the terminal block or header, such as 1715022, written on the schematic; information only, not simulated | _Parameter descriptions are in English in both languages._ ## Model A connector only joins its nets, so it adds nothing to the simulation: each net is simulated as if it were not there. It is in the BOM and on the board; board.addFootprints gives it the footprint of its part number. ## Common mistakes - The block's current rating is per position. A net that carries more than one position's rating needs a bigger block, never two positions in parallel unless the data sheet allows it. - board.autoPlace puts a connector at the board edge so the wire or plug can reach it. Keep tall parts out of its insertion path. Problems rules: `pin.unconnected` ## Datasheet and sources The Phoenix Contact data sheet of the order number: positions and pitch (p. 1), nominal current and voltage per EN-VDE (p. 2) and the UL rating (p. 3). Its part parameter is the order number. ## Example Open the example with the command `file.openExample` and the name `demo:terminalBlock2`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Terminal Block, 3 Positions (`terminalBlock3`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/terminalBlock3/ > A screw terminal block with 3 positions: where a supply or load wire enters the board. ![terminalBlock3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/terminalBlock3.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/terminalBlock3/) **Group:** Sources · **Kind:** `{"element":"terminalBlock3","kind":"connector"}` ## When to use it Put one where a net leaves the board for a supply or a load: one position per net. board.interfaceConnectors {apply:true} picks a block rated for the simulated current and voltage and draws it here. ## Pins | Pin | Domain | Meaning | |---|---|---| | `1` | electrical | Position 1: the net that enters or leaves the board here | | `2` | electrical | Position 2: the net that enters or leaves the board here | | `3` | electrical | Position 3: the net that enters or leaves the board here | ## Common parameters - `part`: Part number; the catalogue order number of the terminal block or header, such as 1715022, written on the schematic; information only, not simulated (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `part` | — | optional (off) | | Part number; the catalogue order number of the terminal block or header, such as 1715022, written on the schematic; information only, not simulated | _Parameter descriptions are in English in both languages._ ## Model A connector only joins its nets, so it adds nothing to the simulation: each net is simulated as if it were not there. It is in the BOM and on the board; board.addFootprints gives it the footprint of its part number. ## Common mistakes - The block's current rating is per position. A net that carries more than one position's rating needs a bigger block, never two positions in parallel unless the data sheet allows it. - board.autoPlace puts a connector at the board edge so the wire or plug can reach it. Keep tall parts out of its insertion path. Problems rules: `pin.unconnected` ## Datasheet and sources The Phoenix Contact data sheet of the order number: positions and pitch (p. 1), nominal current and voltage per EN-VDE (p. 2) and the UL rating (p. 3). Its part parameter is the order number. ## Example Open the example with the command `file.openExample` and the name `demo:terminalBlock3`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Terminal Block, 4 Positions (`terminalBlock4`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/terminalBlock4/ > A screw terminal block with 4 positions: where a supply or load wire enters the board. ![terminalBlock4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/terminalBlock4.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/terminalBlock4/) **Group:** Sources · **Kind:** `{"element":"terminalBlock4","kind":"connector"}` ## When to use it Put one where a net leaves the board for a supply or a load: one position per net. board.interfaceConnectors {apply:true} picks a block rated for the simulated current and voltage and draws it here. ## Pins | Pin | Domain | Meaning | |---|---|---| | `1` | electrical | Position 1: the net that enters or leaves the board here | | `2` | electrical | Position 2: the net that enters or leaves the board here | | `3` | electrical | Position 3: the net that enters or leaves the board here | | `4` | electrical | Position 4: the net that enters or leaves the board here | ## Common parameters - `part`: Part number; the catalogue order number of the terminal block or header, such as 1715022, written on the schematic; information only, not simulated (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `part` | — | optional (off) | | Part number; the catalogue order number of the terminal block or header, such as 1715022, written on the schematic; information only, not simulated | _Parameter descriptions are in English in both languages._ ## Model A connector only joins its nets, so it adds nothing to the simulation: each net is simulated as if it were not there. It is in the BOM and on the board; board.addFootprints gives it the footprint of its part number. ## Common mistakes - The block's current rating is per position. A net that carries more than one position's rating needs a bigger block, never two positions in parallel unless the data sheet allows it. - board.autoPlace puts a connector at the board edge so the wire or plug can reach it. Keep tall parts out of its insertion path. Problems rules: `pin.unconnected` ## Datasheet and sources The Phoenix Contact data sheet of the order number: positions and pitch (p. 1), nominal current and voltage per EN-VDE (p. 2) and the UL rating (p. 3). Its part parameter is the order number. ## Example Open the example with the command `file.openExample` and the name `demo:terminalBlock4`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Test Point (`testPoint`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/testPoint/ > A probe pad on the board, for measuring a net during bring-up. ![testPoint](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/testPoint.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/testPoint/) **Group:** Sources · **Kind:** `{"kind":"testPoint"}` ## When to use it Put one on each net you will probe on the prototype: the switch node, each gate with a ground pad beside it, the input, the output and the current sense. design.debugAids adds them for you. ## Pins | Pin | Domain | Meaning | |---|---|---| | `tp` | electrical | The net to probe | ## Model A test point adds nothing to the simulation: the net it sits on is simulated as if it were not there. KiCad gets a 2 mm test-point pad on that net. ## Common mistakes - A pad alone gives a long ground lead and a ringing waveform. Put a ground test point within a few millimetres of each fast node, so a short spring ground reaches it. - A test point on a gate or a switch node is a stub that picks up noise. Keep it small and on the node itself, not at the end of a trace. Problems rules: `pin.unconnected` ## Datasheet and sources There is no datasheet. Choose the pad size from the probe tip you use. ## Example Open the example with the command `file.openExample` and the name `demo:testPoint`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Wind Turbine (`windTurbine`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/windTurbine/ > A wind turbine rotor that drives a shaft with the torque the wind gives it. ![windTurbine](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/windTurbine.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/windTurbine/) **Group:** Sources · **Kind:** `{"element":"windTurbine","kind":"mechanical"}` ## When to use it Use it for wind energy systems: put it on the shaft of a generator such as a PM synchronous machine (direct drive) or a wound-rotor induction machine (doubly fed), with an inertia for the rotor. For a fixed driving torque, use Load Torque with a negative value. ## Pins | Pin | Domain | Meaning | |---|---|---| | `shaft` | mechanical | Generator shaft, driven forward | | `wind` | signal | Wind speed in m/s (an input signal); replaces v when connected | | `pitch` | signal | Blade pitch angle in degrees (an input signal); replaces beta when connected | ## Common parameters - `r`: Blade tip radius (Default: 63) - `v`: Wind speed; the wind pin replaces it when connected (Default: 11.4) - `beta`: Blade pitch angle; the pitch pin replaces it when connected (Default: 0) - `gear`: Gearbox ratio, generator speed over rotor speed (Default: 97) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `r` | m | 63 | | Blade tip radius | | `v` | m/s | 11.4 | | Wind speed; the wind pin replaces it when connected | | `beta` | ° | 0 | | Blade pitch angle; the pitch pin replaces it when connected | | `gear` | — | 97 | | Gearbox ratio, generator speed over rotor speed | | `rho` | kg/m³ | 1.225 | | Air density | | `c1` | — | 0.5176 | | Coefficient c1 of the Cp(λ, β) fit | | `c2` | — | 116 | | Coefficient c2 of the Cp(λ, β) fit | | `c3` | — | 0.4 | | Coefficient c3 of the Cp(λ, β) fit | | `c4` | — | 5 | | Coefficient c4 of the Cp(λ, β) fit | | `c5` | — | 21 | | Coefficient c5 of the Cp(λ, β) fit | | `c6` | — | 0.0068 | | Coefficient c6 of the Cp(λ, β) fit | _Parameter descriptions are in English in both languages._ **Use for:** Direct-drive generators · Doubly fed generators · Maximum power point studies **Not for:** A fixed driving torque → [`torque`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/torque/) ## Formulas | Formula | Equation | Source | |---|---|---| | Tip-speed ratio | λ = ω·R/v | Heier, Grid Integration of Wind Energy Conversion Systems, 2nd ed. (2006), ch. 2 (tip-speed ratio) | | Power coefficient fit | Cp = c1·(c2/λi − c3·β − c4)·exp(−c5/λi) + c6·λ | Heier, Grid Integration of Wind Energy Conversion Systems, 2nd ed. (2006), ch. 2 (Cp(λ, β) fit) | | Power taken from the wind | P = ½·ρ·π·R²·v³·Cp | Heier, Grid Integration of Wind Energy Conversion Systems, 2nd ed. (2006), ch. 2 (power of the wind) | | Torque on the generator shaft | T = P/(ω·gear) | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 2 (power) | ## Quick check Inputs: - `r`: Blade tip radius = 63 m, `r` - `v`: Wind speed = 11.4 m/s, `v` - `beta`: Pitch angle = 0 °, `beta` - `gear`: Gearbox ratio = 97 —, `gear` - `rho`: Air density = 1.225 kg/m³, `rho` - `c1`: Coefficient c1 = 517.6m —, `c1` - `c2`: Coefficient c2 = 116 —, `c2` - `c3`: Coefficient c3 = 400m —, `c3` - `c4`: Coefficient c4 = 5 —, `c4` - `c5`: Coefficient c5 = 21 —, `c5` - `c6`: Coefficient c6 = 6.8m —, `c6` - `wr`: Rotor speed (an example, not a data sheet value) = 1.2 rad/s Outputs: - `lam`: Tip-speed ratio = `wr*r/v` — - `li`: Helper 1/(1/(λ + 0.08β) − 0.035/(β³ + 1)), inverted = `1/(1/(lam + 0.08*beta) - 0.035/(beta^3 + 1))` — - `cp`: Power coefficient = `c1*(c2/li - c3*beta - c4)*exp(-c5/li) + c6*lam` — - `pwind`: Power taken from the wind = `0.5*rho*pi*r^2*v^3*cp` W - `tq`: Torque on the generator shaft = `pwind/wr/gear` N·m ## Model logic - The rotor turns at the shaft speed divided by gear, and its tip-speed ratio is the rotor speed times r over v. - The power taken from the wind is 0.5 * rho * pi * r^2 * v^3 * Cp(lambda, beta), with the Cp fit of Heier. - The torque is that power over the rotor speed, then over gear. Below lambda = 1 it is held at its value there. - The torque uses the speed of the last accepted step. The rotor inertia is not included: add an Inertia on the shaft. ## Model The rotor turns at the shaft speed divided by gear. Its tip-speed ratio is lambda = rotor speed * r / v, and the power it takes from the wind is 0.5 * rho * pi * r^2 * v^3 * Cp(lambda, beta), with Cp = c1 * (c2 / li - c3 * beta - c4) * exp(-c5 / li) + c6 * lambda and 1 / li = 1 / (lambda + 0.08 * beta) - 0.035 / (beta^3 + 1), the fit of Heier (1998). The default coefficients give a highest Cp of 0.48 at lambda = 8.1 with flat blades. The torque on the shaft is that power divided by the rotor speed, then by gear. Below lambda = 1 the torque is held at its value there, so it stays finite at standstill. Like the speed-dependent loads, the torque uses the speed of the last accepted step. The torque is i(name) and the power coefficient the signal name:cp. The rotor's inertia is not included: add an Inertia on the shaft. ## Common mistakes - With flat blades the fit gives almost no torque at low tip-speed ratios, so a turbine at rest against a friction load may never start. Start the shaft turning (w0 of the inertia) or pitch the blades for the start. - gear multiplies the speed the generator sees. The default 97 is for a geared multi-megawatt turbine; set gear to 1 for a direct-drive generator. - The rotor's own inertia is large (tens of thousands of tonne square metres for a multi-megawatt rotor). Seen from a geared generator shaft it is divided by gear squared. ## Datasheet and sources r is half the rotor diameter, v a wind speed of interest (the rated one by default) and gear the gearbox ratio. The defaults are the NREL 5-MW reference turbine (NREL/TP-500-38060, Tables 1-1 and 5-1: 126 m rotor, 11.4 m/s rated wind, 97:1 gearbox) and the Cp coefficients of Heier as given by MathWorks. Fit c1 to c6 to a manufacturer's Cp curve when you have one. ## Example Open the example with the command `file.openExample` and the name `demo:windTurbine`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Circuit Breaker (`breaker`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/breaker/ > A three-pole breaker that opens at a set time or on overcurrent after a delay, and may close again. ![breaker](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/breaker.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/switches/breaker/) **Group:** Switches · **Kind:** `{"kind":"breaker"}` ## When to use it Use it to protect a line, to clear a fault in a protection study, or to connect and disconnect a source at a set time. For a switch that a gate signal drives, use Ideal Switch. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a1` | electrical | Pole a, first side | | `b1` | electrical | Pole b, first side | | `c1` | electrical | Pole c, first side | | `a2` | electrical | Pole a, second side | | `b2` | electrical | Pole b, second side | | `c2` | electrical | Pole c, second side | ## Common parameters - `topen`: Time when it opens (Default: optional (off)) - `tclose`: Time when it closes again after opening at topen (Default: optional (off)) - `itrip`: Peak current that makes it open (Default: optional (off)) - `tdelay`: How long an overcurrent lasts before it opens (Default: 0) - `treclose`: Time after a trip when it closes again (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `topen` | s | optional (off) | | Time when it opens | | `tclose` | s | optional (off) | | Time when it closes again after opening at topen | | `itrip` | A | optional (off) | | Peak current that makes it open | | `tdelay` | s | 0 | | How long an overcurrent lasts before it opens | | `treclose` | s | optional (off) | | Time after a trip when it closes again | | `thold` | s | 12m | | How long an overcurrent is remembered; keep it above half a cycle so a wave counts as one overcurrent | | `ron` | Ω | 1m | | Resistance when it is on | | `roff` | Ω | 100meg | | Resistance when it is off | _Parameter descriptions are in English in both languages._ **Use for:** Feeder protection · Fault clearing studies · Reclosing sequences **Not for:** Gate-controlled switching → [`idealSwitch`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/idealSwitch/) ## Formulas | Formula | Equation | Source | |---|---|---| | Peak of an rms current | Ipk = √2·Irms | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 10 (effective value) | | Conduction loss | P = Irms²·ron | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 2 (power in a resistor) | | Leakage across the open gap | I = V/roff | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 2 (Ohm's law) | ## Quick check Inputs: - `irms`: Current, rms = 100 A - `itrip`: Trip setting, peak = 200 A, `itrip` - `ron`: On resistance = 1m Ω, `ron` - `roff`: Off resistance = 100meg Ω, `roff` - `v`: Voltage across the open breaker, rms = 400 V - `f`: Line frequency = 50 Hz Outputs: - `ipk`: Peak current = `irms*sqrt(2)` A - `margin`: Trip setting over the peak current = `itrip/ipk` — - `pcond`: Conduction loss = `irms^2*ron` W - `ileak`: Leakage current when open = `v/roff` A - `thmin`: Shortest sensible thold = `1/(2*f)` s ## Model logic - Before the run each connected pole becomes an ideal switch with an ammeter in series that gives name:ia, name:ib and name:ic. - All poles open and close together: at topen and tclose, or after an overcurrent above itrip that lasts tdelay. - The current is compared as a magnitude, and thold keeps the signal up between the peaks of an alternating current. - After a trip it stays open or closes treclose later; name:closed is 1 while closed. There is no arc and no wait for a current zero. ## Model Before the run the breaker becomes one ideal switch for each connected pole, with an ammeter in series that gives the signals name:ia, name:ib and name:ic. All poles open and close together. With topen set, it opens at that time, and with tclose set too, it closes again at that time. With itrip set, it opens when the peak current of any pole stays above itrip for tdelay. The current is compared as a magnitude, and thold keeps the signal up between the peaks of an alternating current, so a steady overcurrent counts as one. After a trip it stays open, or closes treclose later when that is set; if the fault is still there it trips again. The signal name:closed is 1 while the breaker is closed. There is no arc and no wait for a current zero: an inductive current is cut at once, and a voltage spike can follow. ## Common mistakes - itrip is a peak value. A trip level of 100 A rms is about 141 A peak. - Set tdelay longer than thold. An overcurrent is remembered for thold after each peak, so with a shorter delay the breaker cannot tell a short overcurrent from a long one and opens after a single peak. - A pole whose two pins have no net is left out, so a single-phase breaker uses only a1 and a2. A breaker with no pole connected is refused. - A breaker that closes onto a fault that is still there trips again each time and never settles. Set treclose only when the fault is gone by then. - Opening an inductive current at once puts a large voltage across the open breaker, because roff is large. Add a snubber or a path for the current if the spike matters. Problems rules: `compile.error` ## Datasheet and sources itrip is the pickup setting of the protection as a peak current, and tdelay is its time delay. ron is the resistance of the closed main contacts and roff the leakage of the open gap; both are modelling values, not catalogue data. ## Example Open the example with the command `file.openExample` and the name `demo:breaker`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # DIAC (`diac`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/diac/ > A trigger diode that breaks over at vbo in either direction, then conducts at a lower voltage until its current dies away. ![diac](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/diac.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/switches/diac/) **Group:** Switches · **Kind:** `{"kind":"diac"}` ## When to use it Use it to fire a TRIAC from an R-C phase-shift network, as in lamp dimmers, and in relaxation oscillators. Use TRIAC or Thyristor for the power path itself. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a1` | electrical | Terminal 1; positive current flows from a1 to a2 | | `a2` | electrical | Terminal 2; the part is symmetric, so the two ends can be swapped | ## Common parameters - `vbo`: Breakover voltage: above it the part conducts, either way (Default: 32) - `vf`: Voltage lost while it conducts (Default: 27) - `ih`: Current below which it stops conducting (Default: 50u) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `ron` | Ω | 1 | | Resistance when it is on | | `roff` | Ω | 1.8meg | | Resistance when it is off | | `vf` | V | 27 | | Voltage lost while it conducts | | `device` | — | optional (off) | | Device name used to look up losses | | `thermal` | — | optional (off) | | Where the lost heat goes | | `eon` | J | 0 | | Energy lost each time it turns on | | `eoff` | J | 0 | | Energy lost each time it turns off | | `err` | J | 0 | | Energy lost when the diode recovers | | `vref` | V | 0 | | Voltage used to measure those energies | | `iref` | A | 0 | | Current used to measure those energies | | `tc` | 1/K | 0 | | How on-resistance changes with heat | | `tj` | °C | 25 | | Junction temperature for the loss tables | | `nParallel` | — | 1 | | Identical devices this one switch stands for: the current is shared, the losses add up, each device keeps its own junction | | `tjMax` | °C | optional (off) | | Highest junction temperature allowed; overrides the device's rating | | `ls` | H | 0 | 500p – 50n H | Unwanted inductance in series with it | | `coss` | F | 0 | 10p – 5n F | Capacitance across the device | | `cj` | F | 0 | 5p – 2n F | Extra capacitance across the junction | | `tdon` | s | 0 | 1n – 500n s | Delay before it turns on | | `tdoff` | s | 0 | 1n – 500n s | Delay before it turns off | | `qrr` | C | 0 | 1n – 5u C | Charge released as the diode recovers | | `trr` | s | 100n | 10n – 1u s | How long the diode takes to recover | | `qrrTemp` | — | optional (off) | | Junction temperature (°C) and factor pairs that scale qrr, from the datasheet's curve | | `part` | — | optional (off) | | Part number; the catalogue part number, such as BSC070N10NS5, written on the schematic; information only, not simulated | | `vRating` | V | optional (off) | | Voltage rating; the largest blocking voltage of the data sheet's maximum ratings (VDS, VCES, VRRM), written on the schematic; information only, not simulated | | `iRating` | A | optional (off) | | Current rating; the continuous current of the data sheet's maximum ratings (ID, IC, IF), written on the schematic; information only, not simulated | | `vbo` | V | 32 | | Breakover voltage: above it the part conducts, either way | | `ih` | A | 50u | | Current below which it stops conducting | _Parameter descriptions are in English in both languages._ **Use for:** TRIAC triggering · Lamp dimmers · Relaxation oscillators **Not for:** Switching the load current → [`triac`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/triac/) ## Formulas | Formula | Equation | Source | |---|---|---| | Charging time constant | τ = Rt·Ct | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 8 (basic RC circuits) | | Time to breakover from a DC supply | t = τ·ln(Vdc/(Vdc − vbo)) | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 8 (driven RC circuits) | | Charge in the trigger pulse | Q = Ct·(vbo − vf) | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 7 (capacitors) | ## Quick check Inputs: - `vdc`: Supply that charges the capacitor = 100 V - `rt`: Charging resistance = 100k Ω - `ct`: Trigger capacitance = 100n F - `vbo`: Breakover voltage = 32 V, `vbo` - `vf`: On-state voltage = 27 V, `vf` Outputs: - `tau`: Charging time constant = `rt*ct` s - `tfire`: Time to breakover = `tau*ln(vdc/(vdc - vbo))` s - `qpulse`: Charge in the pulse = `ct*(vbo - vf)` C ## Model logic - It blocks through roff until abs(v(a1) - v(a2)) exceeds vbo, then turns on in that direction; there is no gate. - On, it conducts i = (v - vf)/ron forward or i = (v + vf)/ron backwards, so the drop from vbo to vf is a jump, not a negative-resistance curve. - It turns off when the current in its conducting direction falls below ih, and then blocks again until the next breakover. - Its capacitance, the breakover current and the temperature drift of vbo are not modelled. ## Model The DIAC blocks through roff until |v(a1) - v(a2)| exceeds vbo. It then conducts i = (v - vf) / ron forward or i = (v + vf) / ron backwards, where vf is the breakover voltage less the breakback. It stops when |i| falls below ih. The negative-resistance region between the two is a jump, not a curve. ## Common mistakes - A DIAC fed through a large resistor from a slowly rising source, with no capacitor, cannot carry ih after breakover, so in the model it flips on and off in one step and the solver may not settle. Fire it from a capacitor, as real trigger circuits do. - vbo must be above vf, or it would turn off as soon as it fires. The compiler refuses such a part. ## Datasheet and sources The defaults are the STMicroelectronics DB3 (data sheet DS2125 Rev 3, December 2018, Table 2). vbo is VBO typ = 32 V. vf is VBO typ less the dynamic breakover voltage, 32 - 5 V (dV min, at 10 mA). roff is 0.5 x VBO max / IR max = 18 V / 10 uA. The data sheet gives no holding current, and its conducting branch starts at the breakover current, so ih is IBO max = 50 uA. It gives no on-state slope, so ron = 1 Ohm is a modelling value, small next to the gate resistor it drives. ## Example Open the example with the command `file.openExample` and the name `demo:diac`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Diode (`diode`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/diode/ > Lets current flow one way, with a forward drop when it conducts. ![diode](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/diode.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/switches/diode/) **Group:** Switches · **Kind:** `{"kind":"diode"}` ## When to use it Use it for rectifiers, freewheeling paths and clamps. Use Ideal Switch to control turn-on, or Thyristor for gate-triggered turn-on. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | electrical | Anode; forward current flows from a to k | | `k` | electrical | Cathode; the other end | ## Common parameters - `vf`: Voltage lost while it conducts (Default: 0) - `ron`: Resistance when it is on (Default: 1m) - `qrr`: Charge released as the diode recovers (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `ron` | Ω | 1m | | Resistance when it is on | | `roff` | Ω | 1meg | | Resistance when it is off | | `vf` | V | 0 | | Voltage lost while it conducts | | `device` | — | optional (off) | | Device name used to look up losses | | `thermal` | — | optional (off) | | Where the lost heat goes | | `eon` | J | 0 | | Energy lost each time it turns on | | `eoff` | J | 0 | | Energy lost each time it turns off | | `err` | J | 0 | | Energy lost when the diode recovers | | `vref` | V | 0 | | Voltage used to measure those energies | | `iref` | A | 0 | | Current used to measure those energies | | `tc` | 1/K | 0 | | How on-resistance changes with heat | | `tj` | °C | 25 | | Junction temperature for the loss tables | | `nParallel` | — | 1 | | Identical devices this one switch stands for: the current is shared, the losses add up, each device keeps its own junction | | `tjMax` | °C | optional (off) | | Highest junction temperature allowed; overrides the device's rating | | `ls` | H | 0 | 500p – 50n H | Unwanted inductance in series with it | | `coss` | F | 0 | 10p – 5n F | Capacitance across the device | | `cj` | F | 0 | 5p – 2n F | Extra capacitance across the junction | | `tdon` | s | 0 | 1n – 500n s | Delay before it turns on | | `tdoff` | s | 0 | 1n – 500n s | Delay before it turns off | | `qrr` | C | 0 | 1n – 5u C | Charge released as the diode recovers | | `trr` | s | 100n | 10n – 1u s | How long the diode takes to recover | | `qrrTemp` | — | optional (off) | | Junction temperature (°C) and factor pairs that scale qrr, from the datasheet's curve | | `part` | — | optional (off) | | Part number; the catalogue part number, such as BSC070N10NS5, written on the schematic; information only, not simulated | | `vRating` | V | optional (off) | | Voltage rating; the largest blocking voltage of the data sheet's maximum ratings (VDS, VCES, VRRM), written on the schematic; information only, not simulated | | `iRating` | A | optional (off) | | Current rating; the continuous current of the data sheet's maximum ratings (ID, IC, IF), written on the schematic; information only, not simulated | | `level` | — | ideal | | Diode model: `ideal` is piecewise linear (ron, vf); `exponential` follows the Shockley law with is, n and rs | | `is` | A | 10f | | Saturation current of the exponential law; exponential level only | | `n` | — | 1 | | Ideality factor of the exponential law; exponential level only | | `rs` | Ω | 0 | | Series resistance of the exponential diode; exponential level only | | `cjo` | F | 0 | | Junction capacitance at zero volts; exponential level only | | `vj` | V | 1 | | Junction potential of the junction capacitance; exponential level only | | `m` | — | 0.5 | | Grading coefficient; how the junction capacitance falls with the reverse voltage; exponential level only | | `fc` | — | 0.5 | | Forward-bias coefficient; above fc·vj the junction capacitance continues as a straight line; exponential level only | | `tt` | s | 0 | | Transit time; the stored charge is tt times the diode current, as in SPICE; exponential level only, instead of qrr and trr | | `bv` | V | optional (off) | | Reverse breakdown voltage; past it the reverse current grows exponentially, as in SPICE; exponential level only | | `ibv` | A | 1m | | Reverse current at the breakdown voltage bv; exponential level only | | `nbv` | — | optional (off) | | Emission coefficient of the breakdown; the reverse current grows e-fold every nbv·k·T/q past bv; defaults to n; exponential level only | | `ikf` | A | 0 | | Forward knee current; above it the forward current grows half as steeply (high injection), as in SPICE; 0 for none; exponential level only | | `isr` | A | 0 | | Recombination saturation current; adds isr·(exp(v/(nr·Vt)) − 1), scaled by the depletion width through vj and m, as in SPICE; 0 for none; exponential level only | | `nr` | — | 2 | | Emission coefficient of the recombination current isr; exponential level only | | `isw` | A | 0 | | Sidewall saturation current: the perimeter junction's own exponential law, isw·(exp(v/(ns·Vt)) − 1), added to the bottom junction's, as in SPICE (JSW times the perimeter pj); 0 for none; exponential level only | | `ns` | — | optional (off) | | Emission coefficient of the sidewall current isw; defaults to n; exponential level only | | `cjsw` | F | 0 | | Sidewall junction capacitance at zero volts, as in SPICE (CJP times the perimeter pj); exponential level only | | `vjsw` | V | 1 | | Junction potential of the sidewall capacitance; exponential level only | | `mjsw` | — | 0.33 | | Grading coefficient of the sidewall capacitance; exponential level only | | `fcs` | — | 0.5 | | Forward-bias coefficient of the sidewall capacitance; above fcs·vjsw it continues as a straight line; exponential level only | _Parameter descriptions are in English in both languages._ **Use for:** Rectifiers · Freewheeling paths · Clamps **Not for:** Voltage references and clamps at a set voltage → [`zener`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/zener/) · Gate-triggered rectifiers → [`thyristor`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/thyristor/) ## Formulas | Formula | Equation | Source | |---|---|---| | Forward drop | V = vf + ron·I | IEC 60747-2:2016 (threshold voltage and forward slope resistance of rectifier diodes) | | Conduction loss | P = vf·Iavg + ron·Irms² | Mohan, Undeland & Robbins, Power Electronics, 3rd ed. (2003), ch. 2 (on-state power loss) | ## Quick check Inputs: - `vf`: Threshold voltage = 700m V, `vf` - `ron`: Slope resistance = 20m Ω, `ron` - `iavg`: Average forward current = 5 A - `irms`: RMS forward current = 7 A Outputs: - `vdrop`: Drop at the average current = `vf + ron*iavg` V - `pcond`: Conduction loss = `vf*iavg + ron*irms^2` W ## Model logic - At the default level ideal it turns on once v(a) - v(k) exceeds vf, then conducts i = (v - vf)/ron; it turns off when its current goes negative. - Off means the resistor roff, 1 Mohm by default; vf defaults to 0, so an unset diode has no forward drop. - The state is settled by iteration inside each step, so the turn-off lands on a step end; a smaller step places the zero crossing closer. - With qrr above 0 a charge fills toward qrr with time constant trr, and reverse current must remove it before turn-off; level exponential uses the Shockley law. ## Model The diode turns on when v(a) - v(k) exceeds vf and then follows i = (v - vf) / ron. It turns off when its current goes negative, and it blocks through roff. With qrr above zero, a stored charge builds toward qrr with the time constant trr, and the diode keeps conducting in reverse until that charge is removed, which gives the reverse-recovery spike. ## Common mistakes - vf defaults to 0, so a diode without vf has no forward loss. Set vf to about 0.4 V for a Schottky diode or 0.7 V for silicon. - A diode in series with an ideal current source, or switches arranged in a loop, may never settle on one state. Add a resistance or a snubber across the part. - trr here is a charge time constant, not the recovery time on the datasheet. With a library device set, a warning appears when the current nears its rating. Problems rules: `solver.not_settled`, `param.out_of_range`, `device.rating` ## Datasheet and sources vf and ron come from the forward curve, with vf at a low current and ron as the slope near your working current. qrr is the reverse-recovery charge, and vref and iref are the test point of the loss energies (or name a library device for table losses). ## Example Open the example with the command `file.openExample` and the name `demo:diode`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Three-Phase Diode Bridge (`diodeBridge3`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/diodeBridge3/ > Six diodes that turn a three-phase AC input into a DC output. ![diodeBridge3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/diodeBridge3.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/switches/diodeBridge3/) **Group:** Switches · **Kind:** `{"kind":"diodeBridge3"}` ## When to use it Use it for a three-phase rectifier, the front end of a drive or a charger. For a controlled rectifier, use Six-Switch Module. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | electrical | AC input, line a | | `b` | electrical | AC input, line b | | `c` | electrical | AC input, line c | | `p` | electrical | DC output, positive | | `n` | electrical | DC output, negative | ## Common parameters - `vf`: Voltage lost while it conducts (Default: 0) - `ron`: Resistance when it is on (Default: 1m) - `roff`: Resistance when it is off (Default: 1meg) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `ron` | Ω | 1m | | Resistance when it is on | | `roff` | Ω | 1meg | | Resistance when it is off | | `vf` | V | 0 | | Voltage lost while it conducts | _Parameter descriptions are in English in both languages._ **Use for:** Uncontrolled three-phase rectifiers · DC links of drives · Front ends with a capacitor **Not for:** A bridge whose output you control → [`thyristor`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/thyristor/) ## Formulas | Formula | Equation | Source | |---|---|---| | Average output, no load | Vdo = 3·√2·Vll/π | Mohan, Undeland & Robbins, Power Electronics, 3rd ed. (2003), ch. 5 (three-phase diode-bridge rectifiers) | | Average output under load | Vdc = Vdo − 2·Vf − 2·ron·Idc | Mohan, Undeland & Robbins, Power Electronics, 3rd ed. (2003), ch. 5 (three-phase diode-bridge rectifiers) | | Peak-to-peak ripple of the output | ΔV = √2·Vll·(1 − cos 30°) | Mohan, Undeland & Robbins, Power Electronics, 3rd ed. (2003), ch. 5 (three-phase diode-bridge rectifiers) | ## Quick check Inputs: - `vll`: Line voltage, rms = 380 V - `vf`: Diode forward voltage = 700m V, `vf` - `ron`: Diode on resistance = 1m Ω, `ron` - `idc`: DC current = 20 A - `f`: Line frequency = 50 Hz Outputs: - `vdo`: Average output, no load = `3*sqrt(2)/pi*vll` V - `vdc`: Average output under load = `vdo - 2*vf - 2*ron*idc` V - `vrip`: Peak-to-peak ripple = `sqrt(2)*vll*(1 - cos(pi/6))` V - `fr`: Ripple frequency = `6*f` Hz ## Model logic - Before the run the bridge becomes six diodes: one from each line to p and one from n to each line. - The line with the highest voltage feeds p and the line with the lowest voltage is fed from n, so the output has six humps per cycle. - vf is the voltage each diode loses, so the output is lower by about twice vf; ron and roff are the diode resistances. - The parts are named dap, dan, dbp, dbn, dcp and dcn. ## Model Before the run the bridge becomes six diodes: one from each line to p and one from n to each line. At any moment the line with the highest voltage feeds p and the line with the lowest voltage is fed from n, so the output is six humps per cycle of the line voltage. vf is the voltage each diode loses, so the output is lower by about twice vf, and ron and roff are the resistances of the diodes when on and off. The parts are named dap, dan, dbp, dbn, dcp and dcn. ## Common mistakes - The bridge has no filter. Add a capacitor across p and n, or the output follows the humps of the line voltage. - The output needs a load or a path to ground. With neither, the DC side has no reference. Problems rules: `island.floating` ## Datasheet and sources vf is the forward voltage of one diode at the working current, and ron is the slope of its forward curve. Both come from the diode datasheet; for a bridge in one package, use the value of one diode in it. ## Example Open the example with the command `file.openExample` and the name `demo:diodeBridge3`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Fault (`fault`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/fault/ > A short circuit that joins chosen lines of a three-phase system, or those lines and ground, during a time window. ![fault](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/fault.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/switches/fault/) **Group:** Switches · **Kind:** `{"kind":"fault"}` ## When to use it Use it to see the fault current, to test a breaker or a protection scheme, or to study a voltage dip. To short any other part of a circuit, use Ideal Switch. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | electrical | Line a | | `b` | electrical | Line b | | `c` | electrical | Line c | | `g` | electrical | Ground; needed by the types that end in g | ## Common parameters - `type`: Which lines are joined: ag, bg, cg, ab, bc, ca, abg, bcg, cag, abc or abcg (Default: ag) - `rf`: Resistance of the fault in each joined line (Default: 10m) - `tstart`: Time when the fault starts (Default: 0) - `tend`: Time when the fault ends (Default: optional (off)) - `rg`: Resistance between the joined lines and ground (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `type` | — | ag | | Which lines are joined: ag, bg, cg, ab, bc, ca, abg, bcg, cag, abc or abcg | | `rf` | Ω | 10m | | Resistance of the fault in each joined line | | `rg` | Ω | 0 | | Resistance between the joined lines and ground | | `tstart` | s | 0 | | Time when the fault starts | | `tend` | s | optional (off) | | Time when the fault ends | | `roff` | Ω | 100meg | | Resistance when it is off | _Parameter descriptions are in English in both languages._ **Use for:** Short-circuit studies · Protection settings · Voltage sag causes **Not for:** Opening a line on a trip or at a time → [`breaker`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/breaker/) ## Formulas | Formula | Equation | Source | |---|---|---| | Three-phase fault current per line | I = Vph/(Zs + Rf) | Grainger & Stevenson, Power System Analysis (1994), ch. 10 (symmetrical faults) | | Line-to-line fault current | I = Vll/(2·(Zs + Rf)) | Grainger & Stevenson, Power System Analysis (1994), ch. 12 (unsymmetrical faults) | | Line-to-ground fault current | I = Vph/(Zs + Rf + Rg) | Grainger & Stevenson, Power System Analysis (1994), ch. 12 (unsymmetrical faults) | ## Quick check Inputs: - `vll`: Line-to-line voltage, rms = 380 V - `zs`: Source impedance per phase = 500m Ω - `rf`: Fault resistance = 10m Ω, `rf` - `rg`: Resistance to ground = 100m Ω, `rg` Outputs: - `vph`: Phase voltage, rms = `vll/sqrt(3)` V - `i3`: Three-phase fault current per line = `vph/(zs + rf)` A - `ill`: Line-to-line fault current = `vll/(2*(zs + rf))` A - `ig`: Line-to-ground fault current = `vph/(zs + rf + rg)` A ## Model logic - Before the run the fault becomes one ideal switch for each joined line, with the resistance rf when on, to one common point. - For a type with g the common point goes to ground through rg; without g it floats, so two lines are joined through two rf. - The switches close at tstart and open at tend; without tend the fault stays on. - The current of a joined line is the current of the part named name.sw_a, name.sw_b or name.sw_c. ## Model Before the run the fault becomes one ideal switch for each joined line, with the resistance rf when on, from the line to one common point. For a type with g, the common point goes to ground through rg. Without g the common point floats, so two lines are joined through two rf. The switches close at tstart and open at tend, and without tend the fault stays. The types are ag, bg and cg for one line to ground, ab, bc and ca for line to line, abg, bcg and cag for two lines to ground, abc for three lines, and abcg for three lines to ground. The current of a joined line is the current of the part named name.sw_a, name.sw_b or name.sw_c. ## Common mistakes - A fault to ground needs pin g on a ground net. Without it the run is refused. - A very small rf gives a very large current. The default of 10 milliohm is close to a bolted fault. Use a larger value for an arc or a high-impedance fault. - An ideal source with no impedance in front of the fault gives an unrealistic current. Add the line impedance, for example with Three-Phase R-L-C. Problems rules: `compile.error` ## Datasheet and sources The fault values come from the study, not from a datasheet. rf is the fault resistance, such as an arc or an earth contact, and tstart and tend are the times when the fault begins and is cleared. ## Example Open the example with the command `file.openExample` and the name `demo:fault`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # GTO Thyristor (`gto`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/gto/ > A thyristor that a positive gate turns on and a negative gate turns off. ![gto](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/gto.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/switches/gto/) **Group:** Switches · **Kind:** `{"kind":"gto"}` ## When to use it Use it for high-power choppers and inverters built from gate turn-off thyristors, such as traction drives and older medium-voltage converters. Use IGCT for its hard-driven successor, and Thyristor when turn-off by gate is not needed. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | electrical | Anode; forward current flows from a to k | | `k` | electrical | Cathode; the other end | | `gate` | signal | Signal input; above 0.5 fires it, below -0.5 turns it off | ## Common parameters - `vf`: Voltage lost while it conducts (Default: 2.2) - `ron`: Resistance when it is on (Default: 0.6m) - `ih`: Holding current: below it, with no gate, the part turns off (Default: 50) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `ron` | Ω | 0.6m | | Resistance when it is on | | `roff` | Ω | 75k | | Resistance when it is off | | `vf` | V | 2.2 | | Voltage lost while it conducts | | `device` | — | optional (off) | | Device name used to look up losses | | `thermal` | — | optional (off) | | Where the lost heat goes | | `eon` | J | 0 | | Energy lost each time it turns on | | `eoff` | J | 0 | | Energy lost each time it turns off | | `err` | J | 0 | | Energy lost when the diode recovers | | `vref` | V | 0 | | Voltage used to measure those energies | | `iref` | A | 0 | | Current used to measure those energies | | `tc` | 1/K | 0 | | How on-resistance changes with heat | | `tj` | °C | 25 | | Junction temperature for the loss tables | | `nParallel` | — | 1 | | Identical devices this one switch stands for: the current is shared, the losses add up, each device keeps its own junction | | `tjMax` | °C | optional (off) | | Highest junction temperature allowed; overrides the device's rating | | `ls` | H | 0 | 500p – 50n H | Unwanted inductance in series with it | | `coss` | F | 0 | 10p – 5n F | Capacitance across the device | | `cj` | F | 0 | 5p – 2n F | Extra capacitance across the junction | | `tdon` | s | 0 | 1n – 500n s | Delay before it turns on | | `tdoff` | s | 0 | 1n – 500n s | Delay before it turns off | | `qrr` | C | 0 | 1n – 5u C | Charge released as the diode recovers | | `trr` | s | 100n | 10n – 1u s | How long the diode takes to recover | | `qrrTemp` | — | optional (off) | | Junction temperature (°C) and factor pairs that scale qrr, from the datasheet's curve | | `part` | — | optional (off) | | Part number; the catalogue part number, such as BSC070N10NS5, written on the schematic; information only, not simulated | | `vRating` | V | optional (off) | | Voltage rating; the largest blocking voltage of the data sheet's maximum ratings (VDS, VCES, VRRM), written on the schematic; information only, not simulated | | `iRating` | A | optional (off) | | Current rating; the continuous current of the data sheet's maximum ratings (ID, IC, IF), written on the schematic; information only, not simulated | | `ih` | A | 50 | | Holding current: below it, with no gate, the part turns off | _Parameter descriptions are in English in both languages._ **Use for:** Traction choppers · Medium-voltage inverters · Legs turned off by the gate **Not for:** Hard-driven medium-voltage legs → [`igct`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/igct/) · Line-commutated converters → [`thyristor`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/thyristor/) ## Formulas | Formula | Equation | Source | |---|---|---| | On-state voltage | VT = vf + ron·I | IEC 60747-6:2016 (threshold voltage and on-state slope resistance) | | Conduction loss | P = D·(vf·I + ron·I²) | IEC 60747-6:2016 (threshold voltage and on-state slope resistance) | ## Quick check Inputs: - `it`: Anode current while on = 1k A - `duty`: On-time fraction = 500m — - `vf`: Threshold voltage = 2.2 V, `vf` - `ron`: Slope resistance = 600u Ω, `ron` Outputs: - `vt`: On-state voltage = `vf + ron*it` V - `pcond`: Conduction loss = `duty*(vf*it + ron*it^2)` W ## Model logic - A gate above 0.5 fires it once v(a) - v(k) exceeds vf; it then conducts i = (v - vf)/ron, forward only. - A gate below -0.5 turns it off at once, before the step, whatever its current. - With the gate between, it stays on while i is at least ih; with the gate held above 0.5 it stays on below ih too, and it turns off when the current reverses. - Off is roff both ways; the tail current, the controllable-current limit ITGQM and the snubber a real part needs are not modelled. ## Model The GTO turns on when the gate is above 0.5 and v(a) - v(k) exceeds vf, then conducts i = (v - vf) / ron. A gate below -0.5 turns it off. With the gate between, it stays on while i is at least ih, and with the gate held above 0.5 it stays on below ih too, as the continuous gate current of a GTO gate unit keeps it. It also turns off when its current reverses. Blocking is through roff in both directions. The storage time, the tail current and the turn-off snubber a real GTO needs are not modelled. ## Common mistakes - The 5SGA 30J4502's holding current is 50 A. Below it a short gate pulse does not latch the part, so it turns off when the pulse ends. Hold the gate high for the whole on-time, as GTO gate units do, or lower ih for a smaller part. - A real GTO cannot turn off more than its maximum controllable current, ITGQM = 3000 A for the default part, and needs a turn-off snubber. The model turns off any current at once, so check the current at each turn-off yourself. ## Datasheet and sources The defaults are the ABB 5SGA 30J4502 (data sheet 5SYA1202-03, Jan. 2003). vf is VT0 = 2.2 V and ron is rT = 0.6 mOhm (On-state, Tvj = 125 C). ih is IH = 50 A (On-state, Tvj = 25 C). roff is VDRM / IDRM = 4500 V / 60 mA (Blocking). For your part, take VT0 and rT from the on-state approximation and IH from the same table. ## Example Open the example with the command `file.openExample` and the name `demo:gto`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Ideal Switch (`idealSwitch`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/idealSwitch/ > Opens or closes a path when its gate signal goes low or high. ![idealSwitch](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/idealSwitch.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/switches/idealSwitch/) **Group:** Switches · **Kind:** `{"kind":"idealSwitch"}` ## When to use it Use it for two-way switches driven straight from a signal. Use Relay when a coil matters, or MOSFET when a body diode matters. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | One end; current flows both ways | | `n` | electrical | The other end | | `gate` | signal | Signal input; above 0.5 turns it on | ## Common parameters - `ron`: Resistance when it is on (Default: 1m) - `roff`: Resistance when it is off (Default: 1meg) - `tdon`: Delay before it turns on (Default: 0) - `tdoff`: Delay before it turns off (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `ron` | Ω | 1m | | Resistance when it is on | | `roff` | Ω | 1meg | | Resistance when it is off | | `vf` | V | 0 | | Voltage lost while it conducts | | `device` | — | optional (off) | | Device name used to look up losses | | `thermal` | — | optional (off) | | Where the lost heat goes | | `eon` | J | 0 | | Energy lost each time it turns on | | `eoff` | J | 0 | | Energy lost each time it turns off | | `err` | J | 0 | | Energy lost when the diode recovers | | `vref` | V | 0 | | Voltage used to measure those energies | | `iref` | A | 0 | | Current used to measure those energies | | `tc` | 1/K | 0 | | How on-resistance changes with heat | | `tj` | °C | 25 | | Junction temperature for the loss tables | | `nParallel` | — | 1 | | Identical devices this one switch stands for: the current is shared, the losses add up, each device keeps its own junction | | `tjMax` | °C | optional (off) | | Highest junction temperature allowed; overrides the device's rating | | `ls` | H | 0 | 500p – 50n H | Unwanted inductance in series with it | | `coss` | F | 0 | 10p – 5n F | Capacitance across the device | | `cj` | F | 0 | 5p – 2n F | Extra capacitance across the junction | | `tdon` | s | 0 | 1n – 500n s | Delay before it turns on | | `tdoff` | s | 0 | 1n – 500n s | Delay before it turns off | | `qrr` | C | 0 | 1n – 5u C | Charge released as the diode recovers | | `trr` | s | 100n | 10n – 1u s | How long the diode takes to recover | | `qrrTemp` | — | optional (off) | | Junction temperature (°C) and factor pairs that scale qrr, from the datasheet's curve | | `part` | — | optional (off) | | Part number; the catalogue part number, such as BSC070N10NS5, written on the schematic; information only, not simulated | | `vRating` | V | optional (off) | | Voltage rating; the largest blocking voltage of the data sheet's maximum ratings (VDS, VCES, VRRM), written on the schematic; information only, not simulated | | `iRating` | A | optional (off) | | Current rating; the continuous current of the data sheet's maximum ratings (ID, IC, IF), written on the schematic; information only, not simulated | _Parameter descriptions are in English in both languages._ **Use for:** Ideal PWM legs · Signal-driven switches · Load steps **Not for:** Switches with a body diode → [`mosfet`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/mosfet/) · Coil-driven contacts → [`relay`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/relay/) ## Formulas | Formula | Equation | Source | |---|---|---| | Conduction loss | P = ron·Irms² | Mohan, Undeland & Robbins, Power Electronics, 3rd ed. (2003), ch. 2 (on-state power loss of a switch) | | Off-state leakage loss | P = V²/roff | Mohan, Undeland & Robbins, Power Electronics, 3rd ed. (2003), ch. 2 (off-state leakage of a switch) | ## Quick check Inputs: - `irms`: RMS current while on = 5 A - `ron`: On resistance = 1m Ω, `ron` - `vblock`: Blocking voltage while off = 48 V - `roff`: Off resistance = 1meg Ω, `roff` Outputs: - `pcond`: Conduction loss = `ron*irms^2` W - `poff`: Off-state loss = `vblock^2/roff` W ## Model logic - A gate signal above 0.5 makes it the resistor ron, in both directions with no drop; at or below 0.5, or unconnected, it is the resistor roff. - A PWM edge from a control block ends the time step on its instant, so the switch changes state there and not at the next grid point. - tdon and tdoff delay the gate signal, ls adds a series inductance, and coss and cj add capacitors across the switch; all default to 0. - eon and eoff are booked into the loss report at each transition, scaled by (V/vref)·(I/iref); they do not change the waveforms. ## Model The switch is a resistor ron while the gate is above 0.5 and a resistor roff otherwise, in both current directions and with no voltage drop (vf has no effect). It changes state at the step boundary. The optional ls, coss, cj, tdon and tdoff add a series inductance, parallel capacitances and gate delays. ## Common mistakes - Two switches of one leg on at the same time connect the rails through ron. Leave dead time between the two gate signals. - ron is in ohm, so a tiny value or a prefix slip is flagged. The solver also keeps ron at 1 nohm or above, and a huge roff to ron ratio makes the equations stiff. - An unconnected gate keeps the switch off. Opening the switch while an inductor carries current gives a voltage of that current times roff, so add a diode or a snubber. Problems rules: `shoot-through`, `param.out_of_range` ## Datasheet and sources ron comes from the contact or channel resistance, and roff from the leakage at the working voltage. To count losses, set eon, eoff, vref and iref from the switching-energy table, and put the heat sink node name in thermal. ## Example Open the example with the command `file.openExample` and the name `demo:idealSwitch`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # IGBT (`igbt`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/igbt/ > A gate-controlled switch that passes current one way, with a fixed drop. ![igbt](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/igbt.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/switches/igbt/) **Group:** Switches · **Kind:** `{"kind":"igbt"}` ## When to use it Use it for high-voltage, high-current legs where a collector-emitter drop is fine. Use MOSFET when you want a body diode or a purely resistive drop. ## Pins | Pin | Domain | Meaning | |---|---|---| | `d` | electrical | Collector; forward current flows from d to s | | `s` | electrical | Emitter; the other end | | `gate` | signal | Signal input; above 0.5 allows conduction | ## Common parameters - `vf`: Voltage lost while it conducts (Default: 0) - `ron`: Resistance when it is on (Default: 10m) - `eon`: Energy lost each time it turns on (Default: 0) - `eoff`: Energy lost each time it turns off (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `ron` | Ω | 10m | | Resistance when it is on | | `roff` | Ω | 1meg | | Resistance when it is off | | `vf` | V | 0 | | Voltage lost while it conducts | | `device` | — | optional (off) | | Device name used to look up losses | | `thermal` | — | optional (off) | | Where the lost heat goes | | `eon` | J | 0 | | Energy lost each time it turns on | | `eoff` | J | 0 | | Energy lost each time it turns off | | `err` | J | 0 | | Energy lost when the diode recovers | | `vref` | V | 0 | | Voltage used to measure those energies | | `iref` | A | 0 | | Current used to measure those energies | | `tc` | 1/K | 0 | | How on-resistance changes with heat | | `tj` | °C | 25 | | Junction temperature for the loss tables | | `nParallel` | — | 1 | | Identical devices this one switch stands for: the current is shared, the losses add up, each device keeps its own junction | | `tjMax` | °C | optional (off) | | Highest junction temperature allowed; overrides the device's rating | | `ls` | H | 0 | 500p – 50n H | Unwanted inductance in series with it | | `coss` | F | 0 | 10p – 5n F | Capacitance across the device | | `cj` | F | 0 | 5p – 2n F | Extra capacitance across the junction | | `tdon` | s | 0 | 1n – 500n s | Delay before it turns on | | `tdoff` | s | 0 | 1n – 500n s | Delay before it turns off | | `qrr` | C | 0 | 1n – 5u C | Charge released as the diode recovers | | `trr` | s | 100n | 10n – 1u s | How long the diode takes to recover | | `qrrTemp` | — | optional (off) | | Junction temperature (°C) and factor pairs that scale qrr, from the datasheet's curve | | `part` | — | optional (off) | | Part number; the catalogue part number, such as BSC070N10NS5, written on the schematic; information only, not simulated | | `vRating` | V | optional (off) | | Voltage rating; the largest blocking voltage of the data sheet's maximum ratings (VDS, VCES, VRRM), written on the schematic; information only, not simulated | | `iRating` | A | optional (off) | | Current rating; the continuous current of the data sheet's maximum ratings (ID, IC, IF), written on the schematic; information only, not simulated | _Parameter descriptions are in English in both languages._ **Use for:** High-voltage legs · Motor drives · Inverter legs **Not for:** Low-voltage fast switching → [`mosfet`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/mosfet/) ## Formulas | Formula | Equation | Source | |---|---|---| | On-state voltage | Vce = vf + ron·I | IEC 60747-9:2019 (collector-emitter saturation voltage of IGBTs) | | Conduction loss | P = D·(vf·I + ron·I²) | Mohan, Undeland & Robbins, Power Electronics, 3rd ed. (2003), ch. 2 (on-state power loss) | ## Quick check Inputs: - `ic`: Collector current while on = 50 A - `duty`: On-time fraction = 500m — - `vf`: Saturation threshold voltage = 1.2 V, `vf` - `ron`: Slope resistance = 15m Ω, `ron` Outputs: - `vce`: On-state voltage = `vf + ron*ic` V - `pcond`: Conduction loss = `duty*(vf*ic + ron*ic^2)` W ## Model logic - With the gate above 0.5 it turns on once v(d) - v(s) exceeds vf and then conducts i = (v - vf)/ron, forward only. - It turns off at once when the gate falls to 0.5 or below or the current reverses, and then blocks through roff; there is no tail current. - There is no antiparallel diode and no reverse recovery; vf defaults to 0, so an unset part has no saturation voltage. - eon and eoff are added to the loss report per transition, scaled by (V/vref)·(I/iref), and do not change the waveforms. ## Model With the gate above 0.5, the part turns on once v(d) - v(s) exceeds vf and then follows i = (v - vf) / ron. It turns off when the current reverses or the gate drops, and it blocks through roff. There is no antiparallel diode and no reverse conduction, and the turn-off tail current is not modelled. ## Common mistakes - An inductive load needs a freewheeling Diode antiparallel to the IGBT. Without it, turn-off pushes the voltage up to the current times roff, and a rating warning appears. - Both switches of a leg on together short the supply. vf defaults to 0, so leaving it unset makes the conduction loss too low; set it to the saturation voltage. Problems rules: `shoot-through`, `device.rating` ## Datasheet and sources vf is the collector-emitter saturation voltage at a low current, and ron is the slope of the output curve near your working current, both at hot junction temperature. eon and eoff come from the switching-energy table with its test voltage vref and current iref, while the diode energy err belongs to the freewheeling diode. ## Example Open the example with the command `file.openExample` and the name `demo:igbt`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # IGCT (`igct`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/igct/ > A thyristor with an integrated gate unit that conducts forward while its on/off command is high. ![igct](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/igct.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/switches/igct/) **Group:** Switches · **Kind:** `{"kind":"igct"}` ## When to use it Use it for medium-voltage inverters, STATCOMs and other converters built from integrated gate-commutated thyristors. Use GTO for the older pulse-driven part and IGBT for lower voltages. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | electrical | Anode; forward current flows from a to k | | `k` | electrical | Cathode; the other end | | `gate` | signal | Signal input, the gate unit's command; above 0.5 is on | ## Common parameters - `vf`: Voltage lost while it conducts (Default: 1.4) - `ron`: Resistance when it is on (Default: 0.325m) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `ron` | Ω | 0.325m | | Resistance when it is on | | `roff` | Ω | 90k | | Resistance when it is off | | `vf` | V | 1.4 | | Voltage lost while it conducts | | `device` | — | optional (off) | | Device name used to look up losses | | `thermal` | — | optional (off) | | Where the lost heat goes | | `eon` | J | 0 | | Energy lost each time it turns on | | `eoff` | J | 0 | | Energy lost each time it turns off | | `err` | J | 0 | | Energy lost when the diode recovers | | `vref` | V | 0 | | Voltage used to measure those energies | | `iref` | A | 0 | | Current used to measure those energies | | `tc` | 1/K | 0 | | How on-resistance changes with heat | | `tj` | °C | 25 | | Junction temperature for the loss tables | | `nParallel` | — | 1 | | Identical devices this one switch stands for: the current is shared, the losses add up, each device keeps its own junction | | `tjMax` | °C | optional (off) | | Highest junction temperature allowed; overrides the device's rating | | `ls` | H | 0 | 500p – 50n H | Unwanted inductance in series with it | | `coss` | F | 0 | 10p – 5n F | Capacitance across the device | | `cj` | F | 0 | 5p – 2n F | Extra capacitance across the junction | | `tdon` | s | 0 | 1n – 500n s | Delay before it turns on | | `tdoff` | s | 0 | 1n – 500n s | Delay before it turns off | | `qrr` | C | 0 | 1n – 5u C | Charge released as the diode recovers | | `trr` | s | 100n | 10n – 1u s | How long the diode takes to recover | | `qrrTemp` | — | optional (off) | | Junction temperature (°C) and factor pairs that scale qrr, from the datasheet's curve | | `part` | — | optional (off) | | Part number; the catalogue part number, such as BSC070N10NS5, written on the schematic; information only, not simulated | | `vRating` | V | optional (off) | | Voltage rating; the largest blocking voltage of the data sheet's maximum ratings (VDS, VCES, VRRM), written on the schematic; information only, not simulated | | `iRating` | A | optional (off) | | Current rating; the continuous current of the data sheet's maximum ratings (ID, IC, IF), written on the schematic; information only, not simulated | _Parameter descriptions are in English in both languages._ **Use for:** Medium-voltage drives · STATCOMs · Medium-voltage inverters **Not for:** Legs below a few kilovolts → [`igbt`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/igbt/) · Pulse-driven gate units → [`gto`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/gto/) ## Formulas | Formula | Equation | Source | |---|---|---| | On-state voltage | VT = vf + ron·I | IEC 60747-6:2016 (threshold voltage and on-state slope resistance) | | Conduction loss | P = D·(vf·I + ron·I²) | IEC 60747-6:2016 (threshold voltage and on-state slope resistance) | ## Quick check Inputs: - `it`: Anode current while on = 2k A - `duty`: On-time fraction = 500m — - `vf`: Threshold voltage = 1.4 V, `vf` - `ron`: Slope resistance = 325u Ω, `ron` Outputs: - `vt`: On-state voltage = `vf + ron*it` V - `pcond`: Conduction loss = `duty*(vf*it + ron*it^2)` W ## Model logic - The gate is the gate unit's command: above 0.5 it fires once v(a) - v(k) exceeds vf, then conducts i = (v - vf)/ron, forward only. - A command at 0.5 or below turns it off at once, before the step, whatever its current; there is no holding current. - It also turns off when its current reverses, and off it blocks any voltage, either way, through roff. - The gate unit's delays and minimum on and off times are not modelled unless tdon and tdoff are set; eon and eoff only add to the loss report. ## Model The IGCT turns on when the command is above 0.5 and v(a) - v(k) exceeds vf, then conducts i = (v - vf) / ron. It turns off when the command falls to 0.5 or below, or when its current reverses. Blocking is through roff in both directions. The gate unit's delays (td(on) = 3.5 us, td(off) = 7 us for the default part), its minimum on and off times of 40 us and the turn-off losses are not modelled; use tdon, tdoff and the loss parameters for them. ## Common mistakes - The asymmetric IGCT blocks only 17 V backwards (VRRM). The model blocks any reverse voltage through roff, so in a bridge put a diode across it, as the real converter does. - Commands shorter than the gate unit's 40 us minimum on or off time are carried out here but would be stretched or ignored by the real gate unit. Keep the switching frequency and the narrowest pulse within the data sheet. ## Datasheet and sources The defaults are the ABB 5SHY 35L4520 (data sheet 5SYA1248-01, July 2014). vf is VT0 = 1.4 V and ron is rT = 0.325 mOhm (On-state, Tj = 125 C). roff is VDRM / IDRM = 4500 V / 50 mA (Blocking, gate unit energized). For your part, take VT0 and rT from the on-state approximation. ## Example Open the example with the command `file.openExample` and the name `demo:igct`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # LED String (`ledString`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/ledString/ > A string of LEDs in series, with strings in parallel, as the load of an LED driver. ![ledString](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/ledString.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/switches/ledString/) **Group:** Switches · **Kind:** `{"kind":"ledString"}` ## When to use it Use it as the load of a constant-current buck, boost or flyback LED driver, to see the LED current, its ripple and the string voltage. For a single indicator LED a Diode with vf is enough. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | electrical | Anode of the string; current flows from a to k | | `k` | electrical | Cathode of the string | ## Common parameters - `ns`: LEDs in series in each string (Default: 1) - `np`: Strings in parallel (Default: 1) - `vth`: Threshold of one LED; its fit's forward voltage at zero current (Default: required) - `rd`: Dynamic resistance of one LED; the slope of its fit (Default: required) - `tcVf`: Temperature coefficient of one LED's forward voltage (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `ns` | — | 1 | | LEDs in series in each string | | `np` | — | 1 | | Strings in parallel | | `vth` | V | required | | Threshold of one LED; its fit's forward voltage at zero current | | `rd` | Ω | required | | Dynamic resistance of one LED; the slope of its fit | | `tcVf` | V/K | 0 | | Temperature coefficient of one LED's forward voltage | | `tj` | °C | 25 | | LED junction temperature | | `tref` | °C | 25 | | Junction temperature the fit belongs to | | `imax` | A | optional (off) | | Largest current of one LED; a peak above it raises a warning | | `thermal` | — | optional (off) | | Thermal net of its junction; takes its heat and sets its temperature in place of tj | | `wpe` | — | 0 | | Light out per power in (wall-plug efficiency); this share does not heat the junction | _Parameter descriptions are in English in both languages._ **Use for:** LED driver loads · Backlights · Luminaires **Not for:** Single indicator LEDs → [`diode`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/diode/) ## Formulas | Formula | Equation | Source | |---|---|---| | String voltage | V = ns·(vth + rd·I) | Sedra & Smith, Microelectronic Circuits, 7th ed. (2015), §4.3 (diode forward characteristic models) and §4.7 (light-emitting diodes) | | Series resistor | R = (Vs − V)/I | Sedra & Smith, Microelectronic Circuits, 7th ed. (2015), §4.7 (light-emitting diodes) | | Resistor dissipation | P = (Vs − V)·I | Sedra & Smith, Microelectronic Circuits, 7th ed. (2015), §4.7 | ## Quick check Inputs: - `ns`: LEDs in series = 10 —, `ns` - `vth`: Threshold of one LED = 2.7 V, `vth` - `rd`: Dynamic resistance of one LED = 600m Ω, `rd` - `iled`: Current of one string = 100m A - `vs`: Supply voltage = 36 V Outputs: - `vstring`: String voltage = `ns*(vth + rd*iled)` V - `rser`: Series resistor = `(vs - vstring)/iled` Ω - `pres`: Resistor dissipation = `(vs - vstring)*iled` W ## Model logic - The array is one piecewise-linear diode: it turns on above ns·vth (shifted by ns·tcVf·(tj - tref)) and then has slope resistance ns·rd/np. - Below the threshold it blocks through a fixed 100 Mohm, and the knee at very low current is not modelled. - vth and rd have no defaults and must be set; tcVf defaults to 0, so the voltage does not change with tj. - With thermal set, the power less the wpe share heats that net and its temperature replaces tj; a current above imax per LED raises a warning. ## Model Each LED is a straight line through its forward curve: vf = vth + rd·i + tcVf·(tj − tref). The array is ns of them in series and np strings in parallel, so it conducts above ns·vth with a slope of ns·rd/np, and blocks below that. It simulates as a piecewise-linear diode. The knee at very low current is not modelled. With thermal naming a thermal net, the string's power less its light (wpe) heats that net, and the threshold follows the net's temperature in place of tj; without it tj is a fixed value. A warning appears when the current of one LED goes above imax. ## Common mistakes - An LED string straight across a voltage source has nothing to set its current. Drive it from a current-controlled converter or put a resistor in series. - The fit holds over the current range its two points came from. Deep analog dimming far below that range needs points read at the low current. ## Datasheet and sources Read two points of the typical forward voltage versus forward current curve in the working range, for example at half and at full rated current. rd is the voltage difference over the current difference, and vth is the first voltage minus rd times the first current. tcVf comes from the relative forward voltage versus junction temperature curve (negative). tref is the temperature of the forward curve, usually 25 °C or 85 °C. imax is the maximum DC forward current. wpe is the radiant flux over the electrical power at the working point (the wall-plug efficiency); leave it at 0 to count all power as heat, the safe side. There are no defaults: enter the values of your LED. ## Example Open the example with the command `file.openExample` and the name `demo:ledString`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # MMC Arm (`mmcArm`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/mmcArm/ > One arm of a modular multilevel converter: n half- or full-bridge submodules in series, each with its own capacitor, inserted by the signal m. ![mmcArm](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/mmcArm.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/switches/mmcArm/) **Group:** Switches · **Kind:** `{"kind":"mmcArm"}` ## When to use it Use it to build an MMC inverter, a STATCOM or one end of an HVDC link: two arms per phase leg, each with an arm inductor. Use level switched to see the submodule voltages, the balance and the switching ripple; use level averaged for a long arm or a long run. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | Arm end where the arm current counts as positive going in | | `n` | electrical | Other arm end | | `m` | signal | Insertion index (an input signal): 0 bypasses every submodule, 1 inserts all of them; −1 to 0 inserts full-bridge submodules reversed | ## Common parameters - `n`: Submodules in series in the arm: 1 to 8 when switched, up to a million when averaged (Default: 4) - `c`: Capacitance of each submodule (Default: required) - `v0`: Voltage of each submodule capacitor at the start (Default: 0) - `level`: Level of detail: `switched` (every submodule with its switches, picked by the sorting balance) or `averaged` (the arm-averaged model: no ripple, any n) (Default: switched) - `fc`: Carrier frequency of the phase-shifted PWM; 0 inserts the nearest level. Switched level only (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `n` | — | 4 | | Submodules in series in the arm: 1 to 8 when switched, up to a million when averaged | | `c` | F | required | | Capacitance of each submodule | | `v0` | V | 0 | | Voltage of each submodule capacitor at the start | | `level` | — | switched | | Level of detail: `switched` (every submodule with its switches, picked by the sorting balance) or `averaged` (the arm-averaged model: no ripple, any n) | | `bridge` | — | half | | Submodule type: `half` (inserted or bypassed, m from 0 to 1) or `full` (also inserted reversed, m from −1 to 1) | | `fc` | Hz | 0 | | Carrier frequency of the phase-shifted PWM; 0 inserts the nearest level. Switched level only | | `sorting` | — | 1 | | Set to 0 to switch the sorting balance off: submodules go in by index, lowest first, and the capacitor voltages drift apart. Switched level only | | `ron` | Ω | 1m | | Resistance of a submodule switch when on | | `roff` | Ω | 1meg | | Resistance of a submodule switch when off | _Parameter descriptions are in English in both languages._ **Use for:** Modular multilevel converters · HVDC converter studies · Capacitor balancing studies **Not for:** A two-level converter leg → [`sixSwitch`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/sixSwitch/) ## Formulas | Formula | Equation | Source | |---|---|---| | Capacitor voltage at the operating point | Vc = Vdc/n | Lesnicar & Marquardt, IEEE Bologna PowerTech (2003), modular multilevel converter | | Arm voltage | v = m·n·Vc | Hagiwara & Akagi, IEEE Trans. Power Electron. 24(7) (2009), pp. 1737-1746, arm voltage from the insertion index | | Energy in the arm capacitors | E = n·½·C·Vc² | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 7 (energy in a capacitor) | ## Quick check Inputs: - `vdcb`: DC bus voltage = 800 V - `n`: Submodules in the arm = 4 —, `n` - `c`: Capacitance of a submodule = 4.7m F, `c` - `m`: Insertion index = 500m — Outputs: - `vc0`: Capacitor voltage = `vdcb/n` V - `varm`: Arm voltage = `m*n*vc0` V - `earm`: Energy in the arm capacitors = `n*0.5*c*vc0^2` J ## Model logic - Switched: each half-bridge submodule is an upper switch to its capacitor and a lower switch that bypasses it; a full bridge has two legs. - An mmcBalance block picks round(m * n) submodules, or with fc above 0 a phase-shifted PWM, inserting the lowest capacitors while charging. - Averaged: a voltage source m * vsum in series with the on-resistance, where vsum charges by m * i through c / n. - The signals arm:i, arm:vsum and, switched, the capacitor voltages and the selection can be plotted. ## Model Before the run the arm becomes primitives. Switched: each half-bridge submodule is an upper switch to its capacitor and a lower switch that bypasses it, and a full-bridge submodule has two such legs, so it can also be inserted reversed. An mmcBalance block reads m, the arm current and every capacitor voltage and picks the submodules: round(m·n) of them (nearest level), or with fc above 0 a phase-shifted PWM of n carriers. It inserts the lowest capacitors while the arm current charges them and the highest while it discharges them, and changes only the submodules that a change of level needs; with sorting 0 it inserts them by index instead, lowest first, and the capacitor voltages drift apart. Averaged: a voltage source m·vsum in series with the on-resistance of the conducting switches, where vsum is the sum of the capacitor voltages charged by m·i through C/n. The signals arm:i (arm current), arm:vsum and, switched, arm:v1 to arm:vn (capacitor voltages) and arm:g1 to arm:gn (the selection) can be plotted. ## Common mistakes - An arm needs an arm inductor in series. Two arms of a leg straight across the DC bus fight each other through their capacitors and the current jumps without limit. - Start the capacitors charged: set v0 to the DC bus voltage divided by n. With v0 at 0 the arm makes no voltage until the bus has charged it through the arm inductors. - The switched level holds at most 8 submodules, and its submodule switches are ideal switches with no switching loss and no blocked state. Use level averaged for a longer arm. - The two arms of a leg share the DC current and carry a second-harmonic circulating current. Without a circulating-current controller this current makes the capacitor ripple and the losses larger; see the mmcInverter example. ## Datasheet and sources c is the capacitance of one submodule's capacitor bank and v0 its starting voltage, from your own design (DC bus voltage divided by n is the usual operating point). ron is the on-state resistance of one submodule switch at the working current; for an IGBT module, its saturation voltage divided by that current. ## Example Open the example with the command `file.openExample` and the name `demo:mmcArm`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # MOSFET (`mosfet`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/mosfet/ > A gate-controlled switch with a body diode. Can add stray parts and losses. ![mosfet](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/mosfet.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/switches/mosfet/) **Group:** Switches · **Kind:** `{"kind":"mosfet"}` ## When to use it Use it for converter legs, inverter legs and synchronous rectifiers. Use IGBT for high-voltage one-way switching, and Ideal Switch when you want no body diode. ## Pins | Pin | Domain | Meaning | |---|---|---| | `d` | electrical | Drain; forward current flows from d to s | | `s` | electrical | Source; the body diode conducts from s to d | | `gate` | signal | Signal input; above 0.5 turns it on | ## Common parameters - `ron`: Resistance when it is on (Default: 10m) - `vf`: Voltage lost while it conducts (Default: 0) - `coss`: Capacitance across the device (Default: 0) - `eon`: Energy lost each time it turns on (Default: 0) - `eoff`: Energy lost each time it turns off (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `ron` | Ω | 10m | | Resistance when it is on | | `roff` | Ω | 1meg | | Resistance when it is off | | `vf` | V | 0 | | Voltage lost while it conducts | | `device` | — | optional (off) | | Device name used to look up losses | | `thermal` | — | optional (off) | | Where the lost heat goes | | `eon` | J | 0 | | Energy lost each time it turns on | | `eoff` | J | 0 | | Energy lost each time it turns off | | `err` | J | 0 | | Energy lost when the diode recovers | | `vref` | V | 0 | | Voltage used to measure those energies | | `iref` | A | 0 | | Current used to measure those energies | | `tc` | 1/K | 0 | | How on-resistance changes with heat | | `tj` | °C | 25 | | Junction temperature for the loss tables | | `nParallel` | — | 1 | | Identical devices this one switch stands for: the current is shared, the losses add up, each device keeps its own junction | | `tjMax` | °C | optional (off) | | Highest junction temperature allowed; overrides the device's rating | | `ls` | H | 0 | 500p – 50n H | Unwanted inductance in series with it | | `coss` | F | 0 | 10p – 5n F | Capacitance across the device | | `cj` | F | 0 | 5p – 2n F | Extra capacitance across the junction | | `tdon` | s | 0 | 1n – 500n s | Delay before it turns on | | `tdoff` | s | 0 | 1n – 500n s | Delay before it turns off | | `qrr` | C | 0 | 1n – 5u C | Charge released as the diode recovers | | `trr` | s | 100n | 10n – 1u s | How long the diode takes to recover | | `qrrTemp` | — | optional (off) | | Junction temperature (°C) and factor pairs that scale qrr, from the datasheet's curve | | `part` | — | optional (off) | | Part number; the catalogue part number, such as BSC070N10NS5, written on the schematic; information only, not simulated | | `vRating` | V | optional (off) | | Voltage rating; the largest blocking voltage of the data sheet's maximum ratings (VDS, VCES, VRRM), written on the schematic; information only, not simulated | | `iRating` | A | optional (off) | | Current rating; the continuous current of the data sheet's maximum ratings (ID, IC, IF), written on the schematic; information only, not simulated | | `level` | — | ideal | | Switching model: `ideal` switches at once; `dynamic` follows the gate drive, the gate charge and the device capacitances | | `tech` | — | si | | Device technology: `si` and `sic` have a body diode; `gan` is a GaN HEMT with no body diode, conducting in reverse at vth − voff without recovery; `ganCascode` has the body diode of its silicon MOSFET | | `dvdt` | V/s | optional (off) | | Turn-on slew rate set by a driver in the package, such as an integrated GaN FET's drive-strength pin: the drain-source voltage falls at this rate instead of at once; the device's default setting when unset; ideal level only, with steps shorter than the ramp | | `rdsDyn` | — | 1 | | Dynamic on-resistance of a GaN device: the factor on ron after blocking a high voltage, from the datasheet's dynamic RDS(on) figure; 1 is off | | `vgsMax` | V | optional (off) | | Largest gate-source voltage of the datasheet's maximum ratings; a drive above it is an error | | `vgsMin` | V | optional (off) | | Most negative gate-source voltage of the datasheet's maximum ratings; a drive below it is an error | | `von` | V | 15 | | Gate drive voltage while on; dynamic level, and the gate-charge loss estimate (10 V when unset) | | `voff` | V | 0 | | Gate drive voltage while off; dynamic level, the gate-charge loss estimate and the reverse drop of a GaN HEMT | | `rgon` | Ω | 10 | | Gate resistance while turning on; driver and external resistor; dynamic level, and the gate-charge loss estimate (2 Ω when unset) | | `rgoff` | Ω | optional (off) | | Gate resistance while turning off; same as rgon when unset | | `rgint` | Ω | optional (off) | | Gate resistance inside the device; from the device data when unset, else 0 | | `vth` | V | optional (off) | | Gate voltage where the channel starts to conduct; dynamic level, and the reverse drop vth − voff of a GaN HEMT | | `gfs` | S | optional (off) | | Drain current gained per volt of gate drive; dynamic level only | | `vplateau` | V | optional (off) | | Miller plateau voltage; the gate voltage held while the drain voltage swings | | `iplateau` | A | optional (off) | | Drain current at which vplateau was measured | | `ciss` | F | optional (off) | | Input capacitance; gate to source with the drain shorted to the source, dynamic level only | | `crss` | F | optional (off) | | Reverse transfer capacitance; gate to drain, dynamic level only | | `cissTable` | — | optional (off) | | Input capacitance over drain voltage; voltage and capacitance pairs, dynamic level only | | `cossTable` | — | optional (off) | | Output capacitance over drain voltage; voltage and capacitance pairs, dynamic level only | | `crssTable` | — | optional (off) | | Reverse transfer capacitance over drain voltage; voltage and capacitance pairs, dynamic level only | | `qgd` | C | optional (off) | | Gate to drain charge from the datasheet; scales the gate to drain capacitance to carry it | | `vdsq` | V | optional (off) | | Drain voltage of the test that gave qgd | | `lcs` | H | 0 | | Source inductance shared by gate and power loops; dynamic level only | | `lg` | H | 0 | | Gate loop inductance of the driver, gate trace and return, less lcs; dynamic level only | _Parameter descriptions are in English in both languages._ **Use for:** Converter legs · Synchronous rectifiers · Inverter legs **Not for:** High-voltage high-current legs → [`igbt`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/igbt/) · Switches without a body diode → [`idealSwitch`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/idealSwitch/) ## Formulas | Formula | Equation | Source | |---|---|---| | Conduction loss | P = ron·Irms² | Mohan, Undeland & Robbins, Power Electronics, 3rd ed. (2003), ch. 2 (on-state power loss) | | Switching loss | P = ½·V·I·(tr + tf)·fs | Mohan, Undeland & Robbins, Power Electronics, 3rd ed. (2003), ch. 2 (switching power loss with linearized transitions) | | Total loss | P = Pcond + Psw | Mohan, Undeland & Robbins, Power Electronics, 3rd ed. (2003), ch. 2 | ## Quick check Inputs: - `id`: Drain current (switched and rms) = 10 A - `ron`: On resistance = 10m Ω, `ron` - `vds`: Blocking voltage = 48 V - `tsw`: Rise plus fall time = 40n s - `fs`: Switching frequency = 100k Hz Outputs: - `pcond`: Conduction loss = `ron*id^2` W - `psw`: Switching loss = `0.5*vds*id*tsw*fs` W - `ptot`: Total loss = `pcond + psw` W ## Model logic - At the default level ideal a gate above 0.5 makes the channel the resistor ron in both directions with no drop; the switch changes at once. - With the gate low it blocks through roff, but the body diode turns on once v(s) - v(d) exceeds vf, through the same ron. - qrr and trr give the body diode a stored-charge reverse recovery; eon and eoff only add to the loss report and do not shape the edges. - Level dynamic charges the gate through rgon and rgoff and follows vth, the capacitances and the Miller plateau; tech gan removes the body diode. ## Model With the gate above 0.5, the channel is a resistor ron in both directions with no drop. With the gate low, the part blocks through roff, but the body diode conducts from s to d once v(s) - v(d) exceeds vf. qrr and trr give the body diode its reverse recovery, coss and cj add capacitances across the part, and ls adds a series inductance. At the default level ideal the gate is a logic level, so threshold voltage, gate charge and the linear region are not modelled. Set level to dynamic for real edges: a gate driver (von, voff, rgon, rgoff) charges the gate, the channel follows the gate above vth, and the device capacitances (ciss, crss and coss or their tables, or a library device with gate data) set the Miller plateau, the dv/dt and the switching loss. That level needs a variable step, or a fixed step well below the gate time constant. Set tech to gan for a GaN HEMT: it has no body diode and no reverse recovery, and with the gate off the channel itself conducts from s to d once v(s) - v(d) exceeds vth - voff, so a negative turn-off voltage raises the reverse drop and the dead-time loss. tech ganCascode keeps the body diode and recovery of a cascode's silicon MOSFET. ## Common mistakes - The two MOSFETs of a leg on together short the supply. Add dead time between the gate signals, and expect the body diode to conduct during it. - An unconnected gate keeps the channel off, but the body diode still conducts, so the part then acts as a rectifier. The simulator warns about the open gate. - ron defaults to 10 mohm, which is only an example value. Take it from the datasheet at your gate voltage and hot junction. - A GaN gate tolerates only a few volts, and the 15 V default drive of the dynamic level destroys it. Take vgsMax and vgsMin from the datasheet's maximum ratings, and turn it off below 0 V when a fast drain edge could lift the gate past vth through the Miller capacitance. Problems rules: `shoot-through`, `param.out_of_range`, `device.rating`, `gate.overvoltage`, `gate.false_turn_on` ## Datasheet and sources ron comes from RDS(on) at your gate voltage and temperature, and tc from how much it rises with temperature. vf is the body-diode drop, coss the output capacitance and qrr the body-diode recovery charge, and eon and eoff come from the switching-energy table with its test voltage vref and current iref. vgsMax and vgsMin are the gate-source maximum ratings; for a GaN HEMT vth is VGS(th), and its reverse drop is the source-drain voltage curve at your turn-off gate voltage. ## Example Open the example with the command `file.openExample` and the name `demo:mosfet`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # N-channel MOSFET (level 1) (`nmos`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/nmos/ > An n-channel MOSFET whose current follows its gate voltage. ![nmos](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/nmos.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/switches/nmos/) **Group:** Switches · **Kind:** `{"kind":"nmos"}` ## When to use it Use it where the gate voltage matters, such as linear regulators, amplifiers and SPICE netlists. For a converter leg driven by a logic signal, MOSFET is faster and simpler. ## Pins | Pin | Domain | Meaning | |---|---|---| | `d` | electrical | Drain; current flows from d to s | | `g` | electrical | Gate; draws no current | | `s` | electrical | Source; the reference of the gate voltage | ## Common parameters - `vto`: Gate voltage where it starts to conduct (Default: 1) - `kp`: How strongly the gate controls current (Default: 20u) - `w`: Width of the channel (Default: 100u) - `l`: Length of the channel (Default: 100u) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `vto` | V | 1 | | Gate voltage where it starts to conduct | | `kp` | A/V² | 20u | | How strongly the gate controls current | | `w` | m | 100u | | Width of the channel | | `l` | m | 100u | | Length of the channel | | `lambda` | 1/V | 0 | | How much current grows with drain voltage | | `level` | — | 1 | | MOSFET model; `1` is the level-1 square law (vto, kp, w, l, lambda), `2` the SPICE level-2 Grove–Frohman model, `3` the SPICE level-3 short-channel model, `vdmos` the VDMOS power MOSFET of vendor SPICE models, with its capacitances and body diode | | `theta` | 1/V | 0 | | How much the gate voltage lowers the mobility; VDMOS level and level 3 | | `mtriode` | — | 1 | | Conductance multiplier in the triode region; VDMOS level only | | `ksubthres` | V | 0.1 | | Slope of the subthreshold current below vto; 0 for none; VDMOS level only | | `rd` | Ω | 0 | | Resistance in series with the drain; VDMOS level and levels 2 and 3 | | `rs` | Ω | 0 | | Resistance in series with the source; VDMOS level and levels 2 and 3 | | `rg` | Ω | 0 | | Resistance in series with the gate; VDMOS level only | | `rds` | Ω | optional (off) | | Drain-source shunt resistance; VDMOS level only | | `cgs` | F | 0 | | Gate-source capacitance, constant; VDMOS level only | | `cgdmax` | F | 0 | | Largest gate-drain capacitance; with the gate above the drain; VDMOS level only | | `cgdmin` | F | 0 | | Smallest gate-drain capacitance; with the drain far above the gate; VDMOS level only | | `a` | 1/V | 1 | | Slope of the gate-drain capacitance; how fast it falls from cgdmax to cgdmin with the drain-gate voltage; VDMOS level only | | `is` | A | 10f | | Saturation current of the body diode; VDMOS level and levels 2 and 3 | | `n` | — | 1 | | Ideality factor of the body diode; VDMOS level only | | `rb` | Ω | 0 | | Resistance in series with the body diode; VDMOS level only | | `cjo` | F | 0 | | Body diode junction capacitance at zero volts; the drain-source capacitance; VDMOS level and levels 2 and 3 | | `vj` | V | 0.8 | | Body diode junction potential; at level 2 also the bound on the shortest channel; VDMOS level and levels 2 and 3 | | `m` | — | 0.5 | | Body diode grading coefficient; how the junction capacitance falls with the reverse voltage; VDMOS level and levels 2 and 3 | | `fc` | — | 0.5 | | Forward-bias coefficient of the junction capacitance; above fc·vj it continues as a straight line; VDMOS level and levels 2 and 3 | | `tt` | s | 0 | | Body diode transit time; the stored charge is tt times the diode current; VDMOS level only | | `bv` | V | optional (off) | | Drain-source breakdown voltage of the body diode; past it the reverse current grows exponentially, clamping the drain in avalanche; VDMOS level only | | `ibv` | A | 100p | | Body diode current at the breakdown voltage bv; VDMOS level only | | `nbv` | — | 1 | | Emission coefficient of the body diode breakdown; the current grows e-fold every nbv·k·T/q past bv; VDMOS level only | | `tnom` | °C | 27 | | Temperature the model's values belong to; the VDMOS level and levels 2 and 3 are evaluated there | | `uo` | m²/V·s | 0.06 | | Surface mobility; gives kp with tox when kp is unset; levels 2 and 3 | | `tox` | m | optional (off) | | Gate oxide thickness; with it the Meyer gate capacitances are modelled; levels 2 and 3 | | `nsub` | 1/m³ | 0 | | Substrate doping; sets the depletion width of the short-channel and channel-length effects; levels 2 and 3 | | `gamma` | √V | optional (off) | | Body-effect coefficient; from nsub and tox when unset; levels 2 and 3 | | `phi` | V | optional (off) | | Surface potential; from nsub when unset, else 0.6 V; levels 2 and 3 | | `eta` | — | 0 | | Drain-induced threshold lowering; level 3 only | | `vmax` | m/s | 0 | | Saturation velocity of the carriers; 0 for none; levels 2 and 3 | | `kappa` | — | 0.2 | | Saturation field factor of the channel-length modulation; level 3 only | | `xj` | m | 0 | | Metallurgical junction depth, for the short-channel threshold; levels 2 and 3 | | `ld` | m | 0 | | Lateral diffusion; the channel is l − 2·ld long; levels 2 and 3 | | `wd` | m | 0 | | Width narrowing; the channel is w − 2·wd wide; level 3 only | | `delta` | — | 0 | | Width effect on the threshold; levels 2 and 3 | | `nfs` | 1/m² | 0 | | Fast surface state density; 0 for no subthreshold current; levels 2 and 3 | | `cgso` | F/m | 0 | | Gate-source overlap capacitance per metre of width; levels 2 and 3 | | `cgdo` | F/m | 0 | | Gate-drain overlap capacitance per metre of width; levels 2 and 3 | | `cgbo` | F/m | 0 | | Gate-body overlap capacitance per metre of length; levels 2 and 3 | | `ucrit` | V/m | 1e6 | | Critical field of the mobility degradation; level 2 only | | `uexp` | — | 0 | | Exponent of the mobility degradation; 0 for none; level 2 only | | `neff` | — | 1 | | Channel charge coefficient of the velocity-saturated channel-length modulation; level 2 only | _Parameter descriptions are in English in both languages._ **Use for:** Linear regulators · Amplifier stages · Imported SPICE netlists **Not for:** Converter legs driven by a logic signal → [`mosfet`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/mosfet/) ## Formulas | Formula | Equation | Source | |---|---|---| | Transconductance parameter | β = kp·W/L | Sedra & Smith, Microelectronic Circuits, 7th ed. (2015), ch. 5 (MOSFET current-voltage characteristics) | | Saturation drain current | Id = ½·β·(Vgs − vto)²·(1 + λ·Vds) | Sedra & Smith, Microelectronic Circuits, 7th ed. (2015), ch. 5 (saturation region and channel-length modulation) | | Small-Vds on resistance | rDS = 1/(β·(Vgs − vto)) | Sedra & Smith, Microelectronic Circuits, 7th ed. (2015), ch. 5 (the MOSFET as a voltage-controlled resistance) | ## Quick check Inputs: - `kp`: Process transconductance = 20u A/V², `kp` - `w`: Channel width = 100u m, `w` - `l`: Channel length = 10u m, `l` - `vto`: Threshold voltage = 1 V, `vto` - `lambda`: Channel-length modulation = 20m 1/V, `lambda` - `vgs`: Gate-source voltage = 5 V - `vds`: Drain-source voltage = 10 V Outputs: - `beta`: Transconductance parameter = `kp*w/l` A/V² - `idsat`: Saturation drain current = `0.5*beta*(vgs - vto)^2*(1 + lambda*vds)` A - `rds`: On resistance at small Vds = `1/(beta*(vgs - vto))` Ω ## Model logic - At level 1, beta = kp·w/l and vov = vgs - vto; below the threshold no current flows. - In triode (vds below vov) id = beta·(vov·vds - vds²/2)·(1 + lambda·vds), in saturation id = beta/2·vov²·(1 + lambda·vds); drain and source swap when vds is negative. - The solver linearizes the law at the operating point and repeats within each step until the point stops moving. - Level 1 has no body diode and no capacitances; level 3 and vdmos add short-channel effects, a body diode and capacitances. ## Model Shichman-Hodges level 1 with beta = kp * w / l and vov = vgs - vto. Below the threshold no current flows. In triode (vds < vov), id = beta * (vov * vds - vds^2 / 2) * (1 + lambda * vds). In saturation, id = beta / 2 * vov^2 * (1 + lambda * vds). Drain and source swap roles when vds is negative. The solver linearizes the law at an operating point and repeats within each step until the point stops moving. There is no body effect, capacitance or body diode. To fit beta from a datasheet, use beta = 2 * ID / (VGS - VTO)^2 at one point in saturation, and take lambda as the slope of the output curves divided by their current. ## Common mistakes - The default kp, with w equal to l, is a small-signal SPICE value. A power MOSFET needs a much larger kp, w and l combination, or it will hardly conduct. - A gate connected to nothing floats at 0 V and keeps the part off. There is no body diode, so add a Diode from s to d when the circuit needs one. ## Datasheet and sources vto is the gate threshold on the datasheet. Fit kp, w and l from one point of the transfer curve in saturation, and take lambda from the slope of the output curves. ## Example Open the example with the command `file.openExample` and the name `demo:nmos`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # NPN Transistor (`npn`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/npn/ > A bipolar transistor where a small base current controls a larger collector current. ![npn](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/npn.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/switches/npn/) **Group:** Switches · **Kind:** `{"kind":"npn"}` ## When to use it Use it for base-driven switches, gate drivers, current sources and linear stages. For gate-driven power switching, use IGBT or MOSFET. ## Pins | Pin | Domain | Meaning | |---|---|---| | `c` | electrical | Collector; collector current flows in | | `b` | electrical | Base; a small current in controls the part | | `e` | electrical | Emitter; base and collector current leave here | ## Common parameters - `bf`: Current gain in normal use (Default: 100) - `vbeOn`: Base-emitter voltage when it turns on (Default: 0.7) - `vceSat`: Collector-emitter voltage when fully on (Default: 0.2) - `ron`: Resistance of each junction when on (Default: 10m) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `bf` | — | 100 | | Current gain in normal use | | `br` | — | 1 | | Current gain when used backwards | | `vbeOn` | V | 0.7 | | Base-emitter voltage when it turns on | | `vceSat` | V | 0.2 | | Collector-emitter voltage when fully on | | `ron` | Ω | 10m | | Resistance of each junction when on | | `roff` | Ω | 10g | | Resistance of each junction when off | | `rb` | Ω | 0 | | Resistance in series with the base | | `rbm` | Ω | optional (off) | | Base resistance at high current, where rb falls to; rb when not set; Gummel–Poon level only | | `irb` | A | 0 | | Base current where rb falls halfway to rbm; 0 to follow the base charge instead; Gummel–Poon level only | | `rc` | Ω | 0 | | Resistance in series with the collector | | `re` | Ω | 0 | | Resistance in series with the emitter | | `level` | — | pwl | | Transistor model; `pwl` is the fast piecewise-linear model (bf, br, vbeOn, vceSat, ron, roff), `gp` the SPICE Gummel–Poon model of vendor models (is, bf, br, nf, nr, vaf, var, ikf, ikr, ise, ne, isc, nc, temperature, junction capacitances and transit times) | | `is` | A | 1e-16 | | Transport saturation current; Gummel–Poon level only | | `nf` | — | 1 | | Forward emission coefficient; Gummel–Poon level only | | `nr` | — | 1 | | Reverse emission coefficient; Gummel–Poon level only | | `vaf` | V | 0 | | Forward Early voltage; how much the collector current grows with the collector voltage; 0 for none; Gummel–Poon level only | | `var` | V | 0 | | Reverse Early voltage; 0 for none; Gummel–Poon level only | | `ikf` | A | 0 | | High-current corner of the forward gain; the collector current where the gain starts to fall; 0 for none; Gummel–Poon level only | | `ikr` | A | 0 | | High-current corner of the reverse gain; 0 for none; Gummel–Poon level only | | `ise` | A | 0 | | Base-emitter leakage saturation current; lowers the gain at small currents; Gummel–Poon level only | | `ne` | — | 1.5 | | Base-emitter leakage emission coefficient; Gummel–Poon level only | | `isc` | A | 0 | | Base-collector leakage saturation current; Gummel–Poon level only | | `nc` | — | 2 | | Base-collector leakage emission coefficient; Gummel–Poon level only | | `xtb` | — | 0 | | Temperature exponent of the current gains; Gummel–Poon level only | | `eg` | eV | 1.11 | | Energy gap for the temperature effect on is; Gummel–Poon level only | | `xti` | — | 3 | | Temperature exponent of is; Gummel–Poon level only | | `tnom` | °C | 27 | | Temperature the model's values belong to; Gummel–Poon level only | | `cje` | F | 0 | | Base-emitter zero-bias depletion capacitance; Gummel–Poon level only | | `vje` | V | 0.75 | | Base-emitter built-in potential; Gummel–Poon level only | | `mje` | — | 0.33 | | Base-emitter grading coefficient; Gummel–Poon level only | | `cjc` | F | 0 | | Base-collector zero-bias depletion capacitance; Gummel–Poon level only | | `vjc` | V | 0.75 | | Base-collector built-in potential; Gummel–Poon level only | | `mjc` | — | 0.33 | | Base-collector grading coefficient; Gummel–Poon level only | | `xcjc` | — | 1 | | Base-collector capacitance share inside rb; the rest is at the base pin, outside rb; Gummel–Poon level only | | `fc` | — | 0.5 | | Forward-bias depletion capacitance coefficient; Gummel–Poon level only | | `tf` | s | 0 | | Forward transit time; the charge stored while it conducts; Gummel–Poon level only | | `xtf` | — | 0 | | Bias coefficient of the forward transit time; Gummel–Poon level only | | `vtf` | V | 0 | | Collector voltage scale of the transit time; how fast xtf's effect grows with the base-collector voltage; 0 for none; Gummel–Poon level only | | `itf` | A | 0 | | Current where the transit time starts to grow; Gummel–Poon level only | | `tr` | s | 0 | | Reverse transit time; the charge stored in saturation, which sets the turn-off delay; Gummel–Poon level only | | `temp` | °C | 27 | | Device temperature the model is evaluated at; Gummel–Poon level only | | `kf` | — | 0 | | Flicker (1/f) noise coefficient of the base current, for the noise analysis; 0 for none; Gummel–Poon level only | | `af` | — | 1 | | Flicker noise exponent of the base current; Gummel–Poon level only | | `part` | — | optional (off) | | Part number; the catalogue part number, such as XAL8080-123MEC or 2 × XAL8080-123MEC for two in series; information only, not simulated | _Parameter descriptions are in English in both languages._ **Use for:** Base-driven switches · Gate driver stages · Current sources · Linear stages **Not for:** High-side switching → [`pnp`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/pnp/) · Gate-driven power switching → [`mosfet`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/mosfet/) ## Formulas | Formula | Equation | Source | |---|---|---| | Base current | Ib = (Vdrv − vbeOn)/Rb | Sedra & Smith, Microelectronic Circuits, 7th ed. (2015), ch. 6 (BJT circuits at DC) | | Largest active-mode collector current | Ic = bf·Ib | Sedra & Smith, Microelectronic Circuits, 7th ed. (2015), ch. 6 (active mode, Ic = β·Ib) | | Overdrive factor | k = bf·Ib/Ic(load) | Sedra & Smith, Microelectronic Circuits, 7th ed. (2015), ch. 6 (saturation mode and forced β) | ## Quick check Inputs: - `vdrv`: Base drive voltage = 5 V - `rbase`: Base resistance = 1k Ω - `vbeOn`: Base-emitter on voltage = 700m V, `vbeOn` - `bf`: Current gain = 100 —, `bf` - `iload`: Collector current the load needs = 200m A Outputs: - `ib`: Base current = `(vdrv - vbeOn)/rbase` A - `icmax`: Largest collector current = `bf*ib` A - `overdrive`: Overdrive (above 1 saturates) = `bf*ib/iload` — ## Model logic - It is piecewise-linear Ebers-Moll: two junction diodes with drop vbeOn and resistance ron, and a source c to e of bf times the base-emitter current. - When the circuit cannot take bf·Ib, the base-collector junction (drop vbeOn - vceSat) turns on and holds VCE near vceSat. - The junction states are settled by iteration within each step, one flip at a time if they cycle; an off junction is roff, 10 Gohm by default. - There is no exponential law, no charge storage, no Early effect and no switching time; i(name) is the collector current. ## Model Piecewise-linear Ebers-Moll. The base-emitter junction is a diode with drop vbeOn and resistance ron, and the base-collector junction is a diode with drop vbeOn - vceSat. A source from c to e carries bf times the base-emitter current minus br times the base-collector current. In the active region IC = bf * IB. When the circuit cannot supply that much, the base-collector junction turns on and holds VCE at vceSat. rb, rc and re add series resistances, and i(name) is the collector current. There is no exponential law, charge storage or Early effect. ## Common mistakes - Without a base resistor, a voltage source on the base sees only ron and drives a very large base current. Always feed the base through a resistor or a current source. - Switching speed is not modelled, so turn-off is instant. Losses are counted only in the two junctions, so the collector-emitter heat of a linear stage is not in the loss report. ## Datasheet and sources bf is hFE at your collector current, vbeOn is VBE(on), and vceSat is VCE(sat) at your forced gain. ron comes from the slope of the VBE curve, and SPICE models give BF and BR directly. ## Example Open the example with the command `file.openExample` and the name `demo:npn`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # P-channel MOSFET (level 1) (`pmos`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/pmos/ > The N-channel MOSFET with every voltage and current reversed. ![pmos](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/pmos.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/switches/pmos/) **Group:** Switches · **Kind:** `{"kind":"pmos"}` ## When to use it Use it for high-side switches, current mirrors and stages that pair with an N-channel MOSFET. ## Pins | Pin | Domain | Meaning | |---|---|---| | `d` | electrical | Drain; current flows from s to d | | `g` | electrical | Gate; draws no current | | `s` | electrical | Source; the reference, usually at the supply | ## Common parameters - `vto`: Gate voltage where it starts to conduct (Default: -1) - `kp`: How strongly the gate controls current (Default: 20u) - `w`: Width of the channel (Default: 100u) - `l`: Length of the channel (Default: 100u) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `vto` | V | -1 | | Gate voltage where it starts to conduct | | `kp` | A/V² | 20u | | How strongly the gate controls current | | `w` | m | 100u | | Width of the channel | | `l` | m | 100u | | Length of the channel | | `lambda` | 1/V | 0 | | How much current grows with drain voltage | | `level` | — | 1 | | MOSFET model; `1` is the level-1 square law (vto, kp, w, l, lambda), `2` the SPICE level-2 Grove–Frohman model, `3` the SPICE level-3 short-channel model, `vdmos` the VDMOS power MOSFET of vendor SPICE models, with its capacitances and body diode | | `theta` | 1/V | 0 | | How much the gate voltage lowers the mobility; VDMOS level and level 3 | | `mtriode` | — | 1 | | Conductance multiplier in the triode region; VDMOS level only | | `ksubthres` | V | 0.1 | | Slope of the subthreshold current below vto; 0 for none; VDMOS level only | | `rd` | Ω | 0 | | Resistance in series with the drain; VDMOS level and levels 2 and 3 | | `rs` | Ω | 0 | | Resistance in series with the source; VDMOS level and levels 2 and 3 | | `rg` | Ω | 0 | | Resistance in series with the gate; VDMOS level only | | `rds` | Ω | optional (off) | | Drain-source shunt resistance; VDMOS level only | | `cgs` | F | 0 | | Gate-source capacitance, constant; VDMOS level only | | `cgdmax` | F | 0 | | Largest gate-drain capacitance; with the gate above the drain; VDMOS level only | | `cgdmin` | F | 0 | | Smallest gate-drain capacitance; with the drain far above the gate; VDMOS level only | | `a` | 1/V | 1 | | Slope of the gate-drain capacitance; how fast it falls from cgdmax to cgdmin with the drain-gate voltage; VDMOS level only | | `is` | A | 10f | | Saturation current of the body diode; VDMOS level and levels 2 and 3 | | `n` | — | 1 | | Ideality factor of the body diode; VDMOS level only | | `rb` | Ω | 0 | | Resistance in series with the body diode; VDMOS level only | | `cjo` | F | 0 | | Body diode junction capacitance at zero volts; the drain-source capacitance; VDMOS level and levels 2 and 3 | | `vj` | V | 0.8 | | Body diode junction potential; at level 2 also the bound on the shortest channel; VDMOS level and levels 2 and 3 | | `m` | — | 0.5 | | Body diode grading coefficient; how the junction capacitance falls with the reverse voltage; VDMOS level and levels 2 and 3 | | `fc` | — | 0.5 | | Forward-bias coefficient of the junction capacitance; above fc·vj it continues as a straight line; VDMOS level and levels 2 and 3 | | `tt` | s | 0 | | Body diode transit time; the stored charge is tt times the diode current; VDMOS level only | | `bv` | V | optional (off) | | Drain-source breakdown voltage of the body diode; past it the reverse current grows exponentially, clamping the drain in avalanche; VDMOS level only | | `ibv` | A | 100p | | Body diode current at the breakdown voltage bv; VDMOS level only | | `nbv` | — | 1 | | Emission coefficient of the body diode breakdown; the current grows e-fold every nbv·k·T/q past bv; VDMOS level only | | `tnom` | °C | 27 | | Temperature the model's values belong to; the VDMOS level and levels 2 and 3 are evaluated there | | `uo` | m²/V·s | 0.06 | | Surface mobility; gives kp with tox when kp is unset; levels 2 and 3 | | `tox` | m | optional (off) | | Gate oxide thickness; with it the Meyer gate capacitances are modelled; levels 2 and 3 | | `nsub` | 1/m³ | 0 | | Substrate doping; sets the depletion width of the short-channel and channel-length effects; levels 2 and 3 | | `gamma` | √V | optional (off) | | Body-effect coefficient; from nsub and tox when unset; levels 2 and 3 | | `phi` | V | optional (off) | | Surface potential; from nsub when unset, else 0.6 V; levels 2 and 3 | | `eta` | — | 0 | | Drain-induced threshold lowering; level 3 only | | `vmax` | m/s | 0 | | Saturation velocity of the carriers; 0 for none; levels 2 and 3 | | `kappa` | — | 0.2 | | Saturation field factor of the channel-length modulation; level 3 only | | `xj` | m | 0 | | Metallurgical junction depth, for the short-channel threshold; levels 2 and 3 | | `ld` | m | 0 | | Lateral diffusion; the channel is l − 2·ld long; levels 2 and 3 | | `wd` | m | 0 | | Width narrowing; the channel is w − 2·wd wide; level 3 only | | `delta` | — | 0 | | Width effect on the threshold; levels 2 and 3 | | `nfs` | 1/m² | 0 | | Fast surface state density; 0 for no subthreshold current; levels 2 and 3 | | `cgso` | F/m | 0 | | Gate-source overlap capacitance per metre of width; levels 2 and 3 | | `cgdo` | F/m | 0 | | Gate-drain overlap capacitance per metre of width; levels 2 and 3 | | `cgbo` | F/m | 0 | | Gate-body overlap capacitance per metre of length; levels 2 and 3 | | `ucrit` | V/m | 1e6 | | Critical field of the mobility degradation; level 2 only | | `uexp` | — | 0 | | Exponent of the mobility degradation; 0 for none; level 2 only | | `neff` | — | 1 | | Channel charge coefficient of the velocity-saturated channel-length modulation; level 2 only | _Parameter descriptions are in English in both languages._ **Use for:** High-side switches · Current mirrors · Stages paired with an n-channel MOSFET **Not for:** Low-side stages → [`nmos`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/nmos/) · Converter legs driven by a logic signal → [`mosfet`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/mosfet/) ## Formulas | Formula | Equation | Source | |---|---|---| | Transconductance parameter | β = kp·W/L | Sedra & Smith, Microelectronic Circuits, 7th ed. (2015), ch. 5 (the p-channel MOSFET) | | Saturation drain current | Id = ½·β·(Vsg − abs(vto))²·(1 + λ·Vsd) | Sedra & Smith, Microelectronic Circuits, 7th ed. (2015), ch. 5 (the p-channel MOSFET) | | Small-Vsd on resistance | rDS = 1/(β·(Vsg − abs(vto))) | Sedra & Smith, Microelectronic Circuits, 7th ed. (2015), ch. 5 (the MOSFET as a voltage-controlled resistance) | ## Quick check Inputs: - `kp`: Process transconductance = 20u A/V², `kp` - `w`: Channel width = 100u m, `w` - `l`: Channel length = 10u m, `l` - `vto`: Threshold voltage (negative) = -1 V, `vto` - `lambda`: Channel-length modulation = 20m 1/V, `lambda` - `vsg`: Source-gate voltage = 5 V - `vsd`: Source-drain voltage = 10 V Outputs: - `beta`: Transconductance parameter = `kp*w/l` A/V² - `idsat`: Saturation current, s to d = `0.5*beta*(vsg - abs(vto))^2*(1 + lambda*vsd)` A - `rds`: On resistance at small Vsd = `1/(beta*(vsg - abs(vto)))` Ω ## Model logic - It is the level-1 law of the n-channel part with vgs, vds and the current negated; beta = kp·w/l. - The channel opens when vgs falls below vto, which is negative for an enhancement part; a positive vto conducts at vgs = 0. - The solver linearizes the law at the operating point and repeats within each step until the point stops moving. - i(name) is the current from d to s, negative while it conducts; level 1 has no body diode and no capacitances. ## Model The level-1 law of the n-channel part with vgs, vds and the current negated. The channel opens when vgs falls below vto, which is negative, and beta = kp * w / l. i(name) is the current from d to s, so it is negative while the part conducts. ## Common mistakes - vto is negative for a p-channel enhancement device, as in SPICE. A positive vto makes a depletion device that conducts at vgs = 0. - There is no body diode, so a high-side switch whose drain is pulled above its source by an inductor needs its own Diode. ## Datasheet and sources vto is the gate threshold on the datasheet, with its sign. Fit kp, w and l from one point of the transfer curve in saturation, using magnitudes. ## Example Open the example with the command `file.openExample` and the name `demo:pmos`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # PNP Transistor (`pnp`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/pnp/ > The NPN Transistor with every current and voltage reversed. ![pnp](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/pnp.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/switches/pnp/) **Group:** Switches · **Kind:** `{"kind":"pnp"}` ## When to use it Use it for high-side switches, current mirrors and stages that pair with an NPN Transistor. ## Pins | Pin | Domain | Meaning | |---|---|---| | `c` | electrical | Collector; collector current flows out | | `b` | electrical | Base; current flows out when the emitter is higher | | `e` | electrical | Emitter; base and collector current flow in | ## Common parameters - `bf`: Current gain in normal use (Default: 100) - `vbeOn`: Base-emitter voltage when it turns on (Default: 0.7) - `vceSat`: Collector-emitter voltage when fully on (Default: 0.2) - `ron`: Resistance of each junction when on (Default: 10m) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `bf` | — | 100 | | Current gain in normal use | | `br` | — | 1 | | Current gain when used backwards | | `vbeOn` | V | 0.7 | | Base-emitter voltage when it turns on | | `vceSat` | V | 0.2 | | Collector-emitter voltage when fully on | | `ron` | Ω | 10m | | Resistance of each junction when on | | `roff` | Ω | 10g | | Resistance of each junction when off | | `rb` | Ω | 0 | | Resistance in series with the base | | `rbm` | Ω | optional (off) | | Base resistance at high current, where rb falls to; rb when not set; Gummel–Poon level only | | `irb` | A | 0 | | Base current where rb falls halfway to rbm; 0 to follow the base charge instead; Gummel–Poon level only | | `rc` | Ω | 0 | | Resistance in series with the collector | | `re` | Ω | 0 | | Resistance in series with the emitter | | `level` | — | pwl | | Transistor model; `pwl` is the fast piecewise-linear model (bf, br, vbeOn, vceSat, ron, roff), `gp` the SPICE Gummel–Poon model of vendor models (is, bf, br, nf, nr, vaf, var, ikf, ikr, ise, ne, isc, nc, temperature, junction capacitances and transit times) | | `is` | A | 1e-16 | | Transport saturation current; Gummel–Poon level only | | `nf` | — | 1 | | Forward emission coefficient; Gummel–Poon level only | | `nr` | — | 1 | | Reverse emission coefficient; Gummel–Poon level only | | `vaf` | V | 0 | | Forward Early voltage; how much the collector current grows with the collector voltage; 0 for none; Gummel–Poon level only | | `var` | V | 0 | | Reverse Early voltage; 0 for none; Gummel–Poon level only | | `ikf` | A | 0 | | High-current corner of the forward gain; the collector current where the gain starts to fall; 0 for none; Gummel–Poon level only | | `ikr` | A | 0 | | High-current corner of the reverse gain; 0 for none; Gummel–Poon level only | | `ise` | A | 0 | | Base-emitter leakage saturation current; lowers the gain at small currents; Gummel–Poon level only | | `ne` | — | 1.5 | | Base-emitter leakage emission coefficient; Gummel–Poon level only | | `isc` | A | 0 | | Base-collector leakage saturation current; Gummel–Poon level only | | `nc` | — | 2 | | Base-collector leakage emission coefficient; Gummel–Poon level only | | `xtb` | — | 0 | | Temperature exponent of the current gains; Gummel–Poon level only | | `eg` | eV | 1.11 | | Energy gap for the temperature effect on is; Gummel–Poon level only | | `xti` | — | 3 | | Temperature exponent of is; Gummel–Poon level only | | `tnom` | °C | 27 | | Temperature the model's values belong to; Gummel–Poon level only | | `cje` | F | 0 | | Base-emitter zero-bias depletion capacitance; Gummel–Poon level only | | `vje` | V | 0.75 | | Base-emitter built-in potential; Gummel–Poon level only | | `mje` | — | 0.33 | | Base-emitter grading coefficient; Gummel–Poon level only | | `cjc` | F | 0 | | Base-collector zero-bias depletion capacitance; Gummel–Poon level only | | `vjc` | V | 0.75 | | Base-collector built-in potential; Gummel–Poon level only | | `mjc` | — | 0.33 | | Base-collector grading coefficient; Gummel–Poon level only | | `xcjc` | — | 1 | | Base-collector capacitance share inside rb; the rest is at the base pin, outside rb; Gummel–Poon level only | | `fc` | — | 0.5 | | Forward-bias depletion capacitance coefficient; Gummel–Poon level only | | `tf` | s | 0 | | Forward transit time; the charge stored while it conducts; Gummel–Poon level only | | `xtf` | — | 0 | | Bias coefficient of the forward transit time; Gummel–Poon level only | | `vtf` | V | 0 | | Collector voltage scale of the transit time; how fast xtf's effect grows with the base-collector voltage; 0 for none; Gummel–Poon level only | | `itf` | A | 0 | | Current where the transit time starts to grow; Gummel–Poon level only | | `tr` | s | 0 | | Reverse transit time; the charge stored in saturation, which sets the turn-off delay; Gummel–Poon level only | | `temp` | °C | 27 | | Device temperature the model is evaluated at; Gummel–Poon level only | | `kf` | — | 0 | | Flicker (1/f) noise coefficient of the base current, for the noise analysis; 0 for none; Gummel–Poon level only | | `af` | — | 1 | | Flicker noise exponent of the base current; Gummel–Poon level only | | `part` | — | optional (off) | | Part number; the catalogue part number, such as XAL8080-123MEC or 2 × XAL8080-123MEC for two in series; information only, not simulated | _Parameter descriptions are in English in both languages._ **Use for:** High-side switches · Current mirrors · Complementary push-pull stages **Not for:** Low-side switching → [`npn`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/npn/) · Gate-voltage-driven high-side switches → [`pmos`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/pmos/) ## Formulas | Formula | Equation | Source | |---|---|---| | Base current | Ib = (Vdrv − vbeOn)/Rb | Sedra & Smith, Microelectronic Circuits, 7th ed. (2015), ch. 6 (BJT circuits at DC) | | Largest active-mode collector current | Ic = bf·Ib | Sedra & Smith, Microelectronic Circuits, 7th ed. (2015), ch. 6 (active mode, Ic = β·Ib) | | Overdrive factor | k = bf·Ib/Ic(load) | Sedra & Smith, Microelectronic Circuits, 7th ed. (2015), ch. 6 (saturation mode and forced β) | ## Quick check Inputs: - `vdrv`: Emitter to drive-low voltage = 5 V - `rbase`: Base resistance = 1k Ω - `vbeOn`: Emitter-base on voltage = 700m V, `vbeOn` - `bf`: Current gain = 100 —, `bf` - `iload`: Collector current the load needs = 200m A Outputs: - `ib`: Base current = `(vdrv - vbeOn)/rbase` A - `icmax`: Largest collector current = `bf*ib` A - `overdrive`: Overdrive (above 1 saturates) = `bf*ib/iload` — ## Model logic - It is the npn model mirrored: the emitter-base junction conducts through ron once v(e) - v(b) exceeds vbeOn. - A source from e to c carries bf times the emitter-base current; when the circuit cannot take it, the collector-base junction (drop vbeOn - vceSat) holds VEC near vceSat. - The parameters are magnitudes, and i(name) is the current into c, so it is negative while the part conducts. - There is no exponential law, no charge storage, no Early effect and no switching time. ## Model The npn model mirrored. The emitter-base junction conducts when v(e) - v(b) exceeds vbeOn, the source carries bf times that current from e to c, and saturation holds VEC at vceSat. The parameters are magnitudes, so the same values serve both types. ## Common mistakes - A PNP switch turns off only when the base is pulled up to the emitter level. A base driven to 0 V while the emitter sits at the supply keeps it fully on. - Do not enter negative values for vbeOn or vceSat, because the part type sets the signs. i(name) is the collector current, which is negative because it flows out of c. ## Datasheet and sources Take bf from hFE, vbeOn from VBE(on) and vceSat from VCE(sat), all as magnitudes. SPICE models give BF and BR directly. ## Example Open the example with the command `file.openExample` and the name `demo:pnp`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Relay (`relay`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/relay/ > Uses a small coil current to switch another circuit. ![relay](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/relay.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/switches/relay/) **Group:** Switches · **Kind:** `{"kind":"relay"}` ## When to use it Use it when a control signal must switch a bigger load. Use Ideal Switch when no coil is needed. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a1` | electrical | Coil, one end | | `a2` | electrical | Coil, other end; either direction works | | `com` | electrical | Common contact | | `no` | electrical | Open until the coil is on | | `nc` | electrical | Closed until the coil is on | ## Common parameters - `vrated`: Coil voltage the relay is made for (Default: 12) - `rcoil`: Coil resistance (Default: 400) - `tOperate`: Delay before the contacts move (Default: 5m) - `tRelease`: Delay before the contacts move back (Default: 3m) - `ron`: Resistance of a closed contact (Default: 50m) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `vrated` | V | 12 | 1 – 400 V | Coil voltage the relay is made for | | `rcoil` | Ω | 400 | 1 – 100k Ω | Coil resistance | | `lcoil` | H | 200m | 100u – 10 H | Inductance of the coil | | `vpull` | V | optional (off) | 500m – 300 V | Coil voltage that pulls the relay in | | `vdrop` | V | optional (off) | 50m – 100 V | Coil voltage where the relay lets go | | `tOperate` | s | 5m | 100u – 100m s | Delay before the contacts move | | `tRelease` | s | 3m | 100u – 100m s | Delay before the contacts move back | | `ron` | Ω | 50m | 100u – 1 Ω | Resistance of a closed contact | | `roff` | Ω | 1meg | 1k – 1000t Ω | Resistance of an open contact | | `bounce` | s | 0 | 100u – 10m s | How long a closing contact chatters | _Parameter descriptions are in English in both languages._ **Use for:** Switching bigger loads · Galvanic isolation · Precharge bypass **Not for:** Signal-driven switching without a coil → [`idealSwitch`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/idealSwitch/) · Overcurrent protection → [`breaker`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/breaker/) ## Formulas | Formula | Equation | Source | |---|---|---| | Coil current | I = Vcoil/rcoil | IEC 61810-1:2015 (rated coil voltage and coil resistance) | | Coil power | P = Vcoil²/rcoil | IEC 61810-1:2015 (coil power) | | Time to contact closure | t = (lcoil/rcoil)·ln(Vcoil/(Vcoil − vpull)) + tOperate | Sedra & Smith, Microelectronic Circuits, 7th ed. (2015), Appendix E (single-time-constant circuits) | ## Quick check Inputs: - `vcoil`: Coil drive voltage = 12 V - `rcoil`: Coil resistance = 400 Ω, `rcoil` - `lcoil`: Coil inductance = 200m H, `lcoil` - `vpull`: Pull-in voltage = 9 V, `vpull` - `tOperate`: Operate delay = 5m s, `tOperate` Outputs: - `icoil`: Coil current = `vcoil/rcoil` A - `pcoil`: Coil power = `vcoil^2/rcoil` W - `tclose`: Time to contact closure = `lcoil/rcoil*ln(vcoil/(vcoil - vpull)) + tOperate` s ## Model logic - The coil is rcoil in series with lcoil, so its current rises with the time constant lcoil/rcoil; the logic reads abs(coil current). - An SR latch sets above vpull/rcoil and resets below vdrop/rcoil (reset wins); vpull and vdrop default to 75 % and 10 % of vrated. - The contacts move tOperate after the pull-in crossing and tRelease after the drop-out crossing; no and nc are ideal switches of ron and roff, always opposite. - With bounce above 0 a closing contact opens once, from a third to two thirds of bounce after closing; contact arcing and wear are not modelled. ## Model The coil is rcoil in series with lcoil, so its current rises with the time constant lcoil / rcoil. The relay operates when the coil current magnitude rises above vpull / rcoil and releases when it falls below vdrop / rcoil, and between the two it keeps its state. The contacts move tOperate after the pull-in crossing and tRelease after the drop-out crossing. The no and nc contacts are switches with resistance ron when closed and roff when open, always in opposite states. vpull and vdrop default to 75 % and 10 % of vrated. With bounce above zero, a closing contact opens again for the middle third of that time. The coil current is the signal name:i and the contact state is name:no. ## Common mistakes - A coil driven below vpull never operates, and a coil that is not driven back below vdrop never releases. Check that your drive covers 75 % and 10 % of vrated, or set vpull and vdrop from the datasheet. - Cutting the coil drive while the coil carries current puts a high voltage across the coil, as in a real relay. Add a freewheeling Diode across a1 and a2, and note that it slows the release. - The times are in seconds, so tOperate of 5 means five seconds, not 5m. A vdrop at or above vpull, a vpull above 1.5 times vrated or a negative time is refused before the run. Problems rules: `param.out_of_range` ## Datasheet and sources Take vrated and rcoil from the coil table, vpull from the must-operate voltage, vdrop from the must-release voltage, and tOperate and tRelease from the operate and release times. Take ron from the initial contact resistance and roff from the insulation resistance, and estimate lcoil or keep the default, since it is rarely listed. ## Example Open the example with the command `file.openExample` and the name `demo:relay`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Six-Switch Module (`sixSwitch`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/sixSwitch/ > Six switches in three legs with a diode across each, for a three-phase inverter or an active rectifier. ![sixSwitch](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/sixSwitch.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/switches/sixSwitch/) **Group:** Switches · **Kind:** `{"kind":"sixSwitch"}` ## When to use it Use it to build a three-phase inverter, motor drive or active rectifier quickly. To study switching loss, place MOSFETs or IGBTs with a device model instead. ## Pins | Pin | Domain | Meaning | |---|---|---| | `p` | electrical | DC bus, positive | | `n` | electrical | DC bus, negative | | `a` | electrical | Phase a, the middle of leg a | | `b` | electrical | Phase b, the middle of leg b | | `c` | electrical | Phase c, the middle of leg c | | `ah` | signal | Gate of the high switch of leg a (an input signal) | | `bh` | signal | Gate of the high switch of leg b (an input signal) | | `ch` | signal | Gate of the high switch of leg c (an input signal) | | `al` | signal | Gate of the low switch of leg a (an input signal) | | `bl` | signal | Gate of the low switch of leg b (an input signal) | | `cl` | signal | Gate of the low switch of leg c (an input signal) | ## Common parameters - `ron`: Resistance when it is on (Default: 1m) - `roff`: Resistance when it is off (Default: 1meg) - `vf`: Voltage lost while it conducts (Default: 0) - `diodes`: Set to 0 to leave out the diodes across the switches (Default: 1) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `ron` | Ω | 1m | | Resistance when it is on | | `roff` | Ω | 1meg | | Resistance when it is off | | `vf` | V | 0 | | Voltage lost while it conducts | | `diodes` | — | 1 | | Set to 0 to leave out the diodes across the switches | _Parameter descriptions are in English in both languages._ **Use for:** Three-phase inverters · Motor drives · Active rectifiers **Not for:** One device with its own switching model → [`igbt`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/igbt/) ## Formulas | Formula | Equation | Source | |---|---|---| | Phase voltage peak, sine PWM | Vpk = m·Vdc/2 | Mohan, Undeland & Robbins, Power Electronics, 3rd ed. (2003), ch. 8 (three-phase inverters) | | Line voltage, rms | Vll = (√3/√2)·m·Vdc/2 | Mohan, Undeland & Robbins, Power Electronics, 3rd ed. (2003), ch. 8 (three-phase inverters) | | Conduction loss of the three legs | P = 3·Iph²·ron | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 2 (power in a resistor) | | Shoot-through current | I = Vdc/(2·ron) | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 2 (Ohm's law) | ## Quick check Inputs: - `vdc`: DC bus voltage = 400 V - `m`: Modulation index = 800m — - `ron`: On resistance = 1m Ω, `ron` - `iph`: Phase current, rms = 10 A Outputs: - `vpk`: Phase voltage peak = `m*vdc/2` V - `vll`: Line voltage, rms = `sqrt(3)/sqrt(2)*m*vdc/2` V - `pcond`: Conduction loss = `3*iph^2*ron` W - `ishoot`: Shoot-through current = `vdc/(2*ron)` A ## Model logic - Before the run the module becomes six ideal switches and six diodes, so it simulates like that circuit drawn by hand. - Each high switch runs from p to its phase and each low switch from its phase to n; a gate above one half turns its switch on. - Each diode lies across its switch and carries the current when the load is inductive; with diodes set to 0 they are left out. - ron and roff are the resistances of the switches and the diodes, and vf is the voltage each diode loses. ## Model Before the run the module becomes the six ideal switches and the six diodes that one would place by hand, so it simulates like that circuit. Each high switch runs from p to its phase and each low switch from its phase to n, and a high gate above one half turns its switch on. Each diode lies across its switch, from the phase to p for a high switch and from n to the phase for a low one, and carries the current when the load is inductive. The parts are named sah, dah, sal and dal for leg a, and likewise for b and c. ron and roff are the resistances of the switches and the diodes, and vf is the voltage each diode loses. With diodes set to 0 the diodes are left out. ## Common mistakes - Never drive the high and the low gate of one leg high together. That shorts the DC bus through ron. Use a dead time between the two gates. - The gates are signals. Connect each one to the output of a control block such as PWM, not to a power net. - The switches are ideal and have no switching loss. The module cannot show the heat of a real power stage. Problems rules: `shoot-through`, `pin.unconnected` ## Datasheet and sources ron is the on-state resistance of the switch at the working current, and for an IGBT module it is the saturation voltage divided by that current. vf is the forward voltage of the diode at the working current, taken from its datasheet. ## Example Open the example with the command `file.openExample` and the name `demo:sixSwitch`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Thyristor (`thyristor`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/thyristor/ > Turns on with a gate pulse and stays on until its current reverses. ![thyristor](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/thyristor.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/switches/thyristor/) **Group:** Switches · **Kind:** `{"kind":"thyristor"}` ## When to use it Use it for phase-controlled rectifiers and AC switches. Use Diode when no gate is needed, and IGBT or MOSFET when you must command turn-off. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | electrical | Anode; forward current flows from a to k | | `k` | electrical | Cathode; the other end | | `gate` | signal | Signal input; above 0.5 can trigger it | ## Common parameters - `vf`: Voltage lost while it conducts (Default: 0) - `ron`: Resistance when it is on (Default: 1m) - `roff`: Resistance when it is off (Default: 1meg) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `ron` | Ω | 1m | | Resistance when it is on | | `roff` | Ω | 1meg | | Resistance when it is off | | `vf` | V | 0 | | Voltage lost while it conducts | | `device` | — | optional (off) | | Device name used to look up losses | | `thermal` | — | optional (off) | | Where the lost heat goes | | `eon` | J | 0 | | Energy lost each time it turns on | | `eoff` | J | 0 | | Energy lost each time it turns off | | `err` | J | 0 | | Energy lost when the diode recovers | | `vref` | V | 0 | | Voltage used to measure those energies | | `iref` | A | 0 | | Current used to measure those energies | | `tc` | 1/K | 0 | | How on-resistance changes with heat | | `tj` | °C | 25 | | Junction temperature for the loss tables | | `nParallel` | — | 1 | | Identical devices this one switch stands for: the current is shared, the losses add up, each device keeps its own junction | | `tjMax` | °C | optional (off) | | Highest junction temperature allowed; overrides the device's rating | | `ls` | H | 0 | 500p – 50n H | Unwanted inductance in series with it | | `coss` | F | 0 | 10p – 5n F | Capacitance across the device | | `cj` | F | 0 | 5p – 2n F | Extra capacitance across the junction | | `tdon` | s | 0 | 1n – 500n s | Delay before it turns on | | `tdoff` | s | 0 | 1n – 500n s | Delay before it turns off | | `qrr` | C | 0 | 1n – 5u C | Charge released as the diode recovers | | `trr` | s | 100n | 10n – 1u s | How long the diode takes to recover | | `qrrTemp` | — | optional (off) | | Junction temperature (°C) and factor pairs that scale qrr, from the datasheet's curve | | `part` | — | optional (off) | | Part number; the catalogue part number, such as BSC070N10NS5, written on the schematic; information only, not simulated | | `vRating` | V | optional (off) | | Voltage rating; the largest blocking voltage of the data sheet's maximum ratings (VDS, VCES, VRRM), written on the schematic; information only, not simulated | | `iRating` | A | optional (off) | | Current rating; the continuous current of the data sheet's maximum ratings (ID, IC, IF), written on the schematic; information only, not simulated | _Parameter descriptions are in English in both languages._ **Use for:** Phase-controlled rectifiers · AC switches · Crowbars **Not for:** Gate turn-off → [`gto`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/gto/) · Bidirectional AC switching → [`triac`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/triac/) ## Formulas | Formula | Equation | Source | |---|---|---| | Half-wave average output | Vavg = (√2·Vs/(2π))·(1 + cos α) | Rashid, Power Electronics, 4th ed. (2014), ch. 10 (controlled rectifiers, single-phase half-wave) | | Average load current | Iavg = Vavg/R | Rashid, Power Electronics, 4th ed. (2014), ch. 10 | | Conduction loss | P = vf·Iavg + ron·Irms² | IEC 60747-6:2016 (threshold voltage and on-state slope resistance of thyristors) | ## Quick check Inputs: - `vs`: Supply RMS voltage = 230 V - `alpha`: Firing angle in degrees = 60 — - `rload`: Load resistance = 50 Ω - `vf`: Threshold voltage = 1 V, `vf` - `ron`: Slope resistance = 5m Ω, `ron` Outputs: - `vavg`: Average output voltage = `sqrt(2)*vs/(2*pi)*(1 + cos(alpha*pi/180))` V - `iavg`: Average current = `vavg/rload` A - `ploss`: Conduction loss = `vf*iavg + ron*(sqrt(2)*vs/rload)^2*(pi - alpha*pi/180 + sin(alpha*pi/90)/2)/(4*pi)` W ## Model logic - It fires when the gate is above 0.5 while v(a) - v(k) exceeds vf, then conducts i = (v - vf)/ron and stays on with the gate low. - It turns off only when its current goes negative; no holding or latching current is modelled, so on DC it never turns off. - Off means the resistor roff, 1 Mohm by default; vf defaults to 0 and ron to 1 mohm. - The firing is checked at the end of each step, so a gate pulse must last at least one step inside the positive half-wave; there is no reverse recovery. ## Model The thyristor turns on when the gate is above 0.5 and v(a) - v(k) exceeds vf. It then conducts i = (v - vf) / ron and stays on, even with the gate low, until its current goes negative. Blocking is through roff. A holding current and forced commutation are not modelled. ## Common mistakes - In a DC circuit the current never reverses, so the thyristor never turns off once it fires. Use it on AC, or add a path that forces the current negative. - The gate must be high while the anode is above the cathode. A pulse shorter than one step, or one that arrives while v(a) - v(k) is below vf, does nothing, so make it several steps long and time it inside the positive half-wave. ## Datasheet and sources vf and ron come from the on-state curve, with the voltage at a low current and the slope near your working current. The gate trigger level on the datasheet does not matter here, because the gate is a logic signal. ## Example Open the example with the command `file.openExample` and the name `demo:thyristor`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # TRIAC (`triac`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/triac/ > A bidirectional thyristor: a gate current fires it either way, and it stays on until its current falls below the holding current. ![triac](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/triac.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/switches/triac/) **Group:** Switches · **Kind:** `{"kind":"triac"}` ## When to use it Use it for AC phase control (lamp dimmers, soft starters, fan speed) and for switching AC loads in whole cycles (heaters). Use Thyristor for one direction only, and two antiparallel thyristors for large currents. ## Pins | Pin | Domain | Meaning | |---|---|---| | `mt2` | electrical | Main terminal 2; positive current flows from mt2 to mt1 | | `mt1` | electrical | Main terminal 1; the gate is referred to it | | `gate` | signal | Signal input read as the gate current into the gate, in amperes; its sign is the current's direction | ## Common parameters - `igt`: Gate signal that fires it; read as the gate current, so a logic 1 fires it too (Default: 50m) - `ih`: Holding current: below it the part turns off (Default: 50m) - `quadrants`: Gate quadrants that fire it: 1234 for a standard part, 123 for a three-quadrant one (Default: 1234) - `vf`: Voltage lost while it conducts (Default: 0.85) - `ron`: Resistance when it is on (Default: 25m) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `ron` | Ω | 25m | | Resistance when it is on | | `roff` | Ω | 120meg | | Resistance when it is off | | `vf` | V | 0.85 | | Voltage lost while it conducts | | `device` | — | optional (off) | | Device name used to look up losses | | `thermal` | — | optional (off) | | Where the lost heat goes | | `eon` | J | 0 | | Energy lost each time it turns on | | `eoff` | J | 0 | | Energy lost each time it turns off | | `err` | J | 0 | | Energy lost when the diode recovers | | `vref` | V | 0 | | Voltage used to measure those energies | | `iref` | A | 0 | | Current used to measure those energies | | `tc` | 1/K | 0 | | How on-resistance changes with heat | | `tj` | °C | 25 | | Junction temperature for the loss tables | | `nParallel` | — | 1 | | Identical devices this one switch stands for: the current is shared, the losses add up, each device keeps its own junction | | `tjMax` | °C | optional (off) | | Highest junction temperature allowed; overrides the device's rating | | `ls` | H | 0 | 500p – 50n H | Unwanted inductance in series with it | | `coss` | F | 0 | 10p – 5n F | Capacitance across the device | | `cj` | F | 0 | 5p – 2n F | Extra capacitance across the junction | | `tdon` | s | 0 | 1n – 500n s | Delay before it turns on | | `tdoff` | s | 0 | 1n – 500n s | Delay before it turns off | | `qrr` | C | 0 | 1n – 5u C | Charge released as the diode recovers | | `trr` | s | 100n | 10n – 1u s | How long the diode takes to recover | | `qrrTemp` | — | optional (off) | | Junction temperature (°C) and factor pairs that scale qrr, from the datasheet's curve | | `part` | — | optional (off) | | Part number; the catalogue part number, such as BSC070N10NS5, written on the schematic; information only, not simulated | | `vRating` | V | optional (off) | | Voltage rating; the largest blocking voltage of the data sheet's maximum ratings (VDS, VCES, VRRM), written on the schematic; information only, not simulated | | `iRating` | A | optional (off) | | Current rating; the continuous current of the data sheet's maximum ratings (ID, IC, IF), written on the schematic; information only, not simulated | | `igt` | A | 50m | | Gate signal that fires it; read as the gate current, so a logic 1 fires it too | | `ih` | A | 50m | | Holding current: below it the part turns off | | `quadrants` | — | 1234 | | Gate quadrants that fire it: 1234 for a standard part, 123 for a three-quadrant one | _Parameter descriptions are in English in both languages._ **Use for:** Lamp dimmers · Soft starters · Fan speed control · Heater switching **Not for:** One-direction phase control → [`thyristor`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/thyristor/) · Breakover trigger devices → [`diac`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/diac/) ## Formulas | Formula | Equation | Source | |---|---|---| | Load RMS voltage | Vo = Vs·√((π − α + sin(2α)/2)/π) | Rashid, Power Electronics, 4th ed. (2014), ch. 11 (AC voltage controllers, single-phase full-wave) | | Load RMS current | Io = Vo/R | Rashid, Power Electronics, 4th ed. (2014), ch. 11 | | Conduction loss | P = vf·(√2·Vs/(π·R))·(1 + cos α) + ron·Io² | IEC 60747-6:2016 (threshold voltage and on-state slope resistance) | ## Quick check Inputs: - `vs`: Supply RMS voltage = 230 V - `alpha`: Firing angle in degrees = 90 — - `rload`: Load resistance = 100 Ω - `vf`: Threshold voltage = 850m V, `vf` - `ron`: Slope resistance = 25m Ω, `ron` Outputs: - `vrms`: Load RMS voltage = `vs*sqrt((pi - alpha*pi/180 + sin(alpha*pi/90)/2)/pi)` V - `irms`: Load RMS current = `vrms/rload` A - `ploss`: Conduction loss = `vf*sqrt(2)*vs/(pi*rload)*(1 + cos(alpha*pi/180)) + ron*irms^2` W ## Model logic - The gate signal is read as a current: it fires when abs(gate) exceeds igt in an allowed quadrant and abs(v(mt2) - v(mt1)) exceeds vf. - The quadrant comes from the signs of v(mt2) - v(mt1) and of the gate; quadrants 123 ignores a positive gate while mt2 is negative. - It then conducts i = (v - vf)/ron or i = (v + vf)/ron and stays on until abs(i) falls below ih, or past it while the gate still fires it. - Off is roff, 120 Mohm by default; latching current, turn-on time, dv/dt firing and commutating dv/dt are not modelled. ## Model The TRIAC fires when |gate| exceeds igt in a quadrant it allows: quadrant I is mt2 positive with a positive gate, II mt2 positive with a negative gate, III mt2 negative with a negative gate, IV mt2 negative with a positive gate. It must also have |v(mt2) - v(mt1)| above vf. It then conducts i = (v - vf) / ron forward or i = (v + vf) / ron backwards, and stays on, gate or not, until |i| falls below ih. While the gate still fires it, it stays on below ih. Blocking is through roff. The latching current, turn-on time and false firing by dv/dt are not modelled. ## Common mistakes - A three-quadrant part (quadrants = 123, the Snubberless and logic-level types) does not fire from a positive gate while mt2 is negative. A positive-only gate pulse then fires it in the positive half cycle only. Drive the gate negative, or with the sign of the line voltage. - The gate is read in amperes. A logic signal of 1 fires a part with igt below 1, but a gate signal from a current meter must exceed igt, so put the meter in the gate branch of the trigger circuit. In quadrant IV the BTA16-600B needs twice the trigger current (100 mA), so set igt for the quadrant you use. - With an inductive load the current lags, so the TRIAC turns off after the voltage zero and the voltage across it jumps at once. The data sheet's commutating limit, (dV/dt)c = 10 V/us at (dI/dt)c = 7 A/ms for the BTA16-600B, and its static dV/dt of 400 V/us are not checked: a real part may fire falsely or fail to turn off where the model does. Read v(mt2) - v(mt1) after turn-off and add an RC snubber if it rises faster. ## Datasheet and sources The defaults are the STMicroelectronics BTA16-600B (data sheet DS2114 Rev 11, May 2018). vf is VT0 = 0.85 V and ron is RD = 25 mOhm (Table 2, 125 C max). roff is VDRM / IDRM = 600 V / 5 uA (Table 2, 25 C). igt is IGT = 50 mA in quadrants I to III and ih is IH = 50 mA (Table 3, B version max). quadrants is 1234 because the B and C versions are four-quadrant parts (Table 3), while BW, CW and SW are three-quadrant parts (Table 4). For your part, take VT0 and RD from the on-state table, IGT for your quadrants and IH. ## Example Open the example with the command `file.openExample` and the name `demo:triac`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # TVS Diode (`tvs`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/tvs/ > A surge suppressor diode that clamps a voltage spike above its stand-off voltage. ![tvs](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/tvs.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/switches/tvs/) **Group:** Switches · **Kind:** `{"kind":"tvs"}` ## When to use it Use it across a supply input or a signal line to absorb fast surges and inductive kicks. For long overloads, add a fuse or a PTC in series. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | electrical | Anode; forward current flows from a to k | | `k` | electrical | Cathode; it clamps when k is above a by more than vbr | ## Common parameters - `vwm`: Stand-off voltage (Default: 24) - `vbr`: Breakdown voltage at the test current (Default: 28.1) - `vc`: Clamping voltage at the peak pulse current (Default: 38.9) - `ipp`: Peak pulse current; more raises a warning (Default: 15.4) - `bidirectional`: Set to 1 for a part that breaks down both ways (Default: 0) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `vbr` | V | 28.1 | | Breakdown voltage at the test current | | `it` | A | 1m | | Test current of the breakdown voltage | | `vwm` | V | 24 | | Stand-off voltage | | `ir` | A | 1u | | Leakage current at the stand-off voltage | | `vc` | V | 38.9 | | Clamping voltage at the peak pulse current | | `ipp` | A | 15.4 | | Peak pulse current; more raises a warning | | `vf` | V | 3.5 | | Forward voltage at the forward test current | | `ifw` | A | 50 | | Forward test current | | `bidirectional` | — | 0 | | Set to 1 for a part that breaks down both ways | _Parameter descriptions are in English in both languages._ **Use for:** Supply input protection · Inductive kick clamps · Signal line protection **Not for:** High-energy mains surges → [`varistor`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/varistor/) · Long overloads → [`fuse`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/passive/fuse/) ## Formulas | Formula | Equation | Source | |---|---|---| | Clamping slope resistance | Rdyn = (vc − vbr)/ipp | IEC 61643-321:2001 (avalanche breakdown diode ratings VBR, VC and IPP) | | Surge peak current | Ipk = (Vs − vbr)/(Rsrc + Rdyn) | IEC 61000-4-5:2014 (surge generator source impedance) | | Peak clamp power | P = (vbr + Rdyn·Ipk)·Ipk | IEC 61643-321:2001 (peak pulse power of an avalanche breakdown diode) | ## Quick check Inputs: - `vbr`: Breakdown voltage = 28.1 V, `vbr` - `vc`: Clamping voltage at ipp = 38.9 V, `vc` - `ipp`: Peak pulse current = 15.4 A, `ipp` - `vsurge`: Surge open-circuit voltage = 50 V - `rsrc`: Surge source resistance = 2 Ω Outputs: - `ipk`: Peak current = `(vsurge - vbr)/(rsrc + (vc - vbr)/ipp)` A - `vclamp`: Clamped voltage = `vbr + (vc - vbr)/ipp*ipk` V - `ppk`: Peak power = `vclamp*ipk` W ## Model logic - It is a continuous current law solved by Newton's method; there is no on/off state and nothing flips at a step boundary. - The reverse knee is fitted through ir at vwm and it at vbr, and its slope is searched so that it carries ipp at vc. - In forward it follows a line from 0.7 V through vf at ifw; with bidirectional set to 1 the reverse knee is used both ways. - A current above ipp raises a warning, but pulse energy does not heat the part and the clamp voltage does not drift with temperature. ## Model In reverse, the current follows a soft knee with a straight line above it. The knee is fitted through three points from the data sheet: ir at vwm, it at vbr, and ipp at vc. So the part clamps at vc when it carries its peak pulse current. In forward, the current follows a line from 0.7 V through vf at ifw. With bidirectional set to 1, the reverse knee is used both ways. A warning appears when the current goes above ipp. The clamping voltage does not change with temperature, and the pulse energy does not heat the part here. ## Common mistakes - vwm must be at or above the highest normal voltage of the line. Otherwise the part conducts all the time and gets hot. - A TVS straight across a stiff source has nothing to limit the current. Keep the source resistance or a fuse in the circuit. ## Datasheet and sources Take vbr and it from the breakdown voltage columns (the middle of the minimum and maximum), vwm and ir from the stand-off voltage and its leakage, and vc and ipp from the clamping voltage and peak pulse current columns. vf and ifw come from the forward voltage note. The defaults are the Vishay SMBJ24A, document 88392, revision 09-Jan-2024. ## Example Open the example with the command `file.openExample` and the name `demo:tvs`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Zener Diode (`zener`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/zener/ > A diode that holds its reverse voltage near the Zener voltage. ![zener](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/zener.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/switches/zener/) **Group:** Switches · **Kind:** `{"kind":"zener"}` ## When to use it Use it for voltage references, gate clamps and small shunt regulators. For surge currents of amperes, use TVS Diode. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | electrical | Anode; forward current flows from a to k | | `k` | electrical | Cathode; it breaks down when k is vz above a | ## Common parameters - `vz`: Zener voltage at the test current (Default: 24) - `zz`: Dynamic resistance above the knee (Default: 25) - `izm`: Largest regulator current; a peak above it raises a warning (Default: 38m) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `vz` | V | 24 | | Zener voltage at the test current | | `izt` | A | 10.5m | | Test current of the Zener voltage | | `vr` | V | 18.2 | | Reverse voltage where the leakage is given | | `ir` | A | 5u | | Leakage current at that reverse voltage | | `zz` | Ω | 25 | | Dynamic resistance above the knee | | `vf` | V | 1.2 | | Forward voltage at the forward test current | | `ifw` | A | 0.2 | | Forward test current | | `izm` | A | 38m | | Largest regulator current; a peak above it raises a warning | _Parameter descriptions are in English in both languages._ **Use for:** Voltage references · Gate clamps · Small shunt regulators **Not for:** Surge currents of amperes → [`tvs`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/switches/tvs/) · Precision references → [`voltageReference`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/ic/voltageReference/) ## Formulas | Formula | Equation | Source | |---|---|---| | Zener current through a series resistor | Iz = (Vin − vz + zz·izt)/(Rs + zz) | Sedra & Smith, Microelectronic Circuits, 7th ed. (2015), §4.4 (Zener diode model and shunt regulator) | | Zener voltage at that current | V = vz + zz·(Iz − izt) | Sedra & Smith, Microelectronic Circuits, 7th ed. (2015), §4.4 (Zener diode model) | | Zener dissipation | P = V·Iz | Sedra & Smith, Microelectronic Circuits, 7th ed. (2015), §4.4 | ## Quick check Inputs: - `vin`: Supply voltage = 30 V - `rs`: Series resistance = 470 Ω - `vz`: Zener voltage at izt = 24 V, `vz` - `zz`: Dynamic resistance = 25 Ω, `zz` - `izt`: Test current = 10.5m A, `izt` Outputs: - `iz`: Zener current = `(vin - vz + zz*izt)/(rs + zz)` A - `vout`: Zener voltage = `vz + zz*(iz - izt)` V - `pz`: Dissipation = `vout*iz` W ## Model logic - It is a continuous current law solved by Newton's method, with no on/off state and no step-boundary flips. - In reverse a soft knee passes through ir at vr and izt at vz, then continues as a straight line of slope 1/zz. - In forward the current follows a line from 0.7 V through vf at ifw, rounded over about 50 mV. - A peak above izm raises a warning; the Zener voltage has no temperature coefficient and no junction capacitance. ## Model In reverse, the current follows a soft knee: almost nothing below the knee, then a straight line of slope 1 / zz. The knee is fitted so that the diode carries ir at vr and izt at vz. In forward, the current follows a line from 0.7 V through vf at ifw. The diode is solved by Newton's method, so the knee is smooth and no state flips. A warning appears when the current peaks above izm. The Zener voltage does not change with temperature here. ## Common mistakes - Without a series resistance, a Zener across a voltage source above vz carries a huge current. Add a resistor that sets the current. - The cathode goes to the positive side. A Zener placed the wrong way conducts like an ordinary diode at about 0.7 V. ## Datasheet and sources Take vz and izt from the Zener voltage column and its test current, vr and ir from the reverse leakage column, zz from ZZT, vf and ifw from the forward voltage row, and izm from the regulator current column. The defaults are the Vishay 1N4749A (24 V), document 85816, rev. 2.7. ## Example Open the example with the command `file.openExample` and the name `demo:zener`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Ambient Temperature (`ambient`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/ambient/ > Holds a thermal node at a fixed temperature, like ground for heat. ![ambient](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/ambient.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/thermal/ambient/) **Group:** Thermal · **Kind:** `{"element":"ambient","kind":"thermal"}` ## When to use it Place at least one in every thermal network, on the air or coolant node where your thermal resistances end. Use Thermal Resistance and Thermal Capacitance between it and the device. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | thermal | Thermal node held at the temperature t | ## Common parameters - `t`: Fixed temperature it holds (Default: 25) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `t` | °C | 25 | | Fixed temperature it holds | | `pwlTime` | s | optional (off) | | Times of a temperature profile, rising strictly, with commas; with pwlTemp the profile replaces t | | `pwlTemp` | °C | optional (off) | | Temperature at each of those times; straight lines between them, held before the first and after the last | _Parameter descriptions are in English in both languages._ **Use for:** Room or enclosure air · Coolant or cold plate · Worst-case ambient **Not for:** A body that warms up → [`cth`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/cth/) ## Formulas | Formula | Equation | Source | |---|---|---| | Heat sink temperature | Ts = Ta + P·Rsa | Mohan, Undeland & Robbins, Power Electronics, 3rd ed. (2003), ch. 29 (heat sinks) | | Headroom to the limit | Tmax − Ts | Mohan, Undeland & Robbins, Power Electronics, 3rd ed. (2003), ch. 29 (heat sinks) | ## Quick check Inputs: - `ta`: Ambient temperature = 25 °C, `t` - `p`: Heat into the sink = 30 W - `rsa`: Sink-to-ambient resistance = 1.5 K/W - `tmax`: Highest allowed sink temperature = 100 °C Outputs: - `tsink`: Heat sink temperature = `ta + p*rsa` °C - `headroom`: Headroom to the limit = `tmax - tsink` K ## Model logic - Its node is held at t by replacing that node's row of the thermal network, so any heat flows into it without changing its temperature. - The t of the first ambient in the circuit is also the starting temperature of every thermal node. - With pwlTime and pwlTemp (equally many values, times rising strictly) the temperature follows that profile instead of t: straight lines between the points, held before the first and after the last, set at the end of every thermal step. No pin or signal drives it. ## Model The part holds its net at t in degC (default 25) whatever heat flows into it. The t of the first ambient in the circuit also sets the starting temperature of all thermal nodes. ## Common mistakes - A thermal network with no ambient does not compile. Add one on the node where the heat leaves. - t is in degC, so 298 means 298 degC, not 25 degC. A node cut off from the ambient is reported. Problems rules: `compile.error`, `solver.thermal` ## Datasheet and sources t is the worst-case ambient of your application, such as 40 or 85 degC inside an enclosure, not the 25 degC of the datasheet test. ## Example Open the example with the command `file.openExample` and the name `demo:ambient`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Cauer Chain (`cauer`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/cauer/ > A ladder of thermal resistances with a heat capacity at every node, between two thermal nodes. ![cauer](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/cauer.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/thermal/cauer/) **Group:** Thermal · **Kind:** `{"element":"cauer","kind":"thermal"}` ## When to use it Use it for a physical model of the layers between a die and a case or a cold plate (die, solder, copper, substrate), or for the Cauer values a module's data sheet gives. Use Foster Chain for a Foster table. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | thermal | Hot side: holds the first heat capacity | | `b` | thermal | Cold side: the last resistance ends here | ## Common parameters - `r`: Ladder resistances from pin a towards pin b, with commas (Default: optional (off)) - `c`: Heat capacity of each ladder node to the reference, the first at pin a (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `r` | K/W | optional (off) | | Ladder resistances from pin a towards pin b, with commas | | `c` | J/K | optional (off) | | Heat capacity of each ladder node to the reference, the first at pin a | _Parameter descriptions are in English in both languages._ **Use for:** Die, solder and substrate layers · A module's Cauer values · Chains into a heat sink **Not for:** A data sheet's Foster table → [`foster`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/foster/) ## Formulas | Formula | Equation | Source | |---|---|---| | Resistance of a layer | R = d / (k·A) | Incropera, DeWitt, Bergman & Lavine, Fundamentals of Heat and Mass Transfer, 7th ed. (2011), §3.1 (thermal resistance of a plane wall) | | Heat capacity of a layer | C = ρ·cp·d·A | Incropera, DeWitt, Bergman & Lavine, Fundamentals of Heat and Mass Transfer, 7th ed. (2011), §5.1 (lumped capacitance method) | | Time constant of a layer | τ = R·C | Incropera, DeWitt, Bergman & Lavine, Fundamentals of Heat and Mass Transfer, 7th ed. (2011), §5.1 (lumped capacitance method) | ## Quick check Inputs: - `d`: Layer thickness = 1m m - `k`: Thermal conductivity = 401 W/(m·K) - `area`: Area the heat crosses = 100u m² - `rho`: Density = 8.933k kg/m³ - `cp`: Specific heat = 385 J/(kg·K) Outputs: - `r`: Resistance of the layer = `d/(k*area)` K/W - `c`: Heat capacity of the layer = `rho*cp*d*area` J/K - `tau`: Time constant of the layer = `r*c` s ## Model logic - c1 runs from a to the 0 degC reference, then r1 leads to node .n1 with c2 to the reference, and so on; the last resistance ends at b. - Each heat capacity is stepped by backward Euler with the rest of the thermal network, so every inner node is a real temperature. - r and c need equally many positive values, 1 to 16, and have no default; the values are fixed and do not change with temperature. ## Model a has heat capacity c1 to the reference, then r1 to node .n1 with c2, then r2, and so on; the last resistance ends at b. Every node is a real temperature, and the chain can be cascaded into any further network. ## Common mistakes - r and c must have the same number of positive values, at most 16. The part has no default values. - Do not enter a Foster table as a Cauer chain: the two sets of numbers differ. Use Foster Chain, which converts when it has to. Problems rules: `solver.thermal`, `compile.error` ## Datasheet and sources Some module data sheets give a Cauer network; otherwise each layer's R is its thickness over conductivity times area and its C its volume times volumetric heat capacity. ## Example Open the example with the command `file.openExample` and the name `demo:cauer`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Cooling Fan (`coolingFan`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/coolingFan/ > A fan that blows across heatsinks: in the thermal simulation it makes them use their data sheet's resistance at its airflow, and it goes on the BOM and the board. ![coolingFan](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/coolingFan.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/thermal/coolingFan/) **Group:** Thermal · **Kind:** `{"element":"coolingFan","kind":"thermal"}` ## When to use it Use it when a fan cools one or more catalogue heatsinks. Place it with thermal.placeFan {part, airflow, cools}, which reads each heatsink's data sheet again at the fan's airflow. Use a variant or DNP to compare the board with and without the fan. ## Common parameters - `part`: Order number: the fan's, from its data sheet; it puts the fan on the bill of materials, and the solver never reads it (Default: optional (off)) - `airflow`: Airflow across the heatsinks: the air speed the fan drives across them, from its data sheet's curve and the duct; thermal.placeFan reads them at it (Default: optional (off)) - `cools`: Heatsinks it cools: the names of the heatsinks the fan blows across, with commas (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `part` | — | optional (off) | | Order number: the fan's, from its data sheet; it puts the fan on the bill of materials, and the solver never reads it | | `airflow` | m/s | optional (off) | | Airflow across the heatsinks: the air speed the fan drives across them, from its data sheet's curve and the duct; thermal.placeFan reads them at it | | `cools` | — | optional (off) | | Heatsinks it cools: the names of the heatsinks the fan blows across, with commas | | `footprint` | — | optional (off) | | KiCad library id of the footprint the fan mounts on, from its data sheet's drawing; board.addFootprints places it with every pad on no net; information only, not simulated | _Parameter descriptions are in English in both languages._ **Use for:** Forced-air cooling **Not for:** A fan load on a motor shaft → [`fan`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/mechanical/fan/) ## Model logic - The netlist stamps nothing for it. Before the thermal network is built, every fitted, simulated fan marks the heatsinks in cools, looked up beside it; a name that is no simulated heatsink is a warning. - DNP, simulate off or a variant that leaves the fan out leaves every heatsink at its own rth, so the electrical result never changes and the thermal result follows the variant. ## Model No pins and no net: the fan joins nothing. While it is fitted and simulated, each heatsink named in cools uses fanRth (and fanCurveW, fanCurveK) instead of rth (and curveW, curveK). thermal.placeFan wrote those from the heatsink's data sheet, on the fastest listed airflow not above the fan's airflow. ## Common mistakes - airflow is the air speed across the heatsink, not the fan's free-air flow: take it from the fan's curve and the duct, or from a measurement. A heatsink named in cools without fanRth stops the build; place the fan with thermal.placeFan. - The fan's own power and noise are not modelled, and fanRth was read at the heatsink's watts: placing the heatsink again at another heat or airflow leaves fanRth as it was, so place the fan again after it. Problems rules: `solver.thermal`, `compile.error` ## Datasheet and sources part names the fan's order number; a fan in the thermal catalogue (parts library, fans) gets its maker and data sheet on the BOM. The heatsink values come from parts/heatsinks.json, which cites each data sheet. ## Example Open the example with the command `file.openExample` and the name `demo:coolingFan`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Thermal Capacitance (`cth`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/cth/ > Stores heat at a thermal node, in J/K. ![cth](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/cth.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/thermal/cth/) **Group:** Thermal · **Kind:** `{"element":"cth","kind":"thermal"}` ## When to use it Use it to give a node thermal inertia, such as a case, a heat sink or a junction. Use Thermal Resistance for the paths between nodes. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | thermal | Thermal node; its temperature rises as heat is stored | ## Common parameters - `c`: How much heat it can store (Default: required) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `c` | J/K | required | | How much heat it can store | _Parameter descriptions are in English in both languages._ **Use for:** Thermal mass of a body · Heat sink warm-up · Junction and case inertia **Not for:** Conduction paths between nodes → [`rth`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/rth/) ## Formulas | Formula | Equation | Source | |---|---|---| | Heat capacity of a body | C = m·cp | Incropera, DeWitt, Bergman & Lavine, Fundamentals of Heat and Mass Transfer, 7th ed. (2011), §5.1 (lumped capacitance method) | | Thermal time constant | τ = Rth·C | Incropera, DeWitt, Bergman & Lavine, Fundamentals of Heat and Mass Transfer, 7th ed. (2011), §5.1 (lumped capacitance method) | | Rise after a heat step | ΔT(t) = P·Rth·(1 − e^(−t/τ)) | Incropera, DeWitt, Bergman & Lavine, Fundamentals of Heat and Mass Transfer, 7th ed. (2011), §5.1 (lumped capacitance method) | ## Quick check Inputs: - `c`: Heat capacity = 50 J/K, `c` - `r`: Thermal resistance to ambient = 500m K/W - `p`: Heat step = 20 W - `t`: Time after the step = 10 s Outputs: - `tau`: Thermal time constant = `r*c` s - `tss`: Rise once settled = `p*r` K - `rise`: Rise at time t = `p*r*(1 - exp(-t/tau))` K ## Model logic - It is a heat capacity c from its node to the 0 degC reference; each backward Euler step of length h adds a conductance c/h to the node and a heat source from the last temperature. - Every thermal node starts at the first Ambient Temperature's t, unless the run's thermalStart finds other starting temperatures. - c is fixed: the specific heat does not change with temperature. ## Model The part stores heat so that c * dT/dt equals the net heat flowing into the node. It is referenced to 0 degC, and every thermal node starts at the temperature of the first Ambient Temperature part. Each step uses backward Euler, which is stable for the slow thermal behaviour. ## Common mistakes - A node with a heat capacity but no thermal resistance to an ambient cannot lose heat, so its temperature climbs without limit. Always connect it through a thermal resistance to an Ambient Temperature part. - Thermal time constants run to seconds or minutes, while switching steps are microseconds. Covering several time constants with a small maximum step can exceed the step limit. Problems rules: `solver.limits` ## Datasheet and sources c is the mass of the body times its specific heat, about 0.9 joule per gram per kelvin for aluminium. For a device junction, divide the time constant of each stage in the transient thermal impedance curve by its resistance. ## Example Open the example with the command `file.openExample` and the name `demo:cth`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Foster Chain (`foster`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/foster/ > A device's transient thermal impedance from its data sheet's Foster table: R and tau stages between two thermal nodes. ![foster](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/foster.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/thermal/foster/) **Group:** Thermal · **Kind:** `{"element":"foster","kind":"thermal"}` ## When to use it Use it for the junction-to-case Zth of a MOSFET, IGBT or diode whose data sheet lists r_i and tau_i. Use Cauer Chain for a ladder of physical R and C, and Zth Curve when the sheet only draws the curve. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | thermal | Hot side: the junction, where the device's losses go | | `b` | thermal | Cold side: the case | ## Common parameters - `r`: Stage resistances of the data sheet's Foster table, with commas (Default: optional (off)) - `tau`: Stage time constants of the same table, one per resistance (Default: optional (off)) - `form`: auto: a Foster chain into a side with no heat capacity, else the equivalent Cauer ladder; foster or cauer forces one (Default: auto) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `r` | K/W | optional (off) | | Stage resistances of the data sheet's Foster table, with commas | | `tau` | s | optional (off) | | Stage time constants of the same table, one per resistance | | `form` | — | auto | | auto: a Foster chain into a side with no heat capacity, else the equivalent Cauer ladder; foster or cauer forces one | _Parameter descriptions are in English in both languages._ **Use for:** Junction-to-case Zth · Rise in short pulses · A data sheet's r_i and tau_i **Not for:** Physical layer ladders → [`cauer`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/cauer/) · A curve with no table → [`zth`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/zth/) ## Formulas | Formula | Equation | Source | |---|---|---| | Transient thermal impedance | Zth(t) = Σ r_i·(1 − e^(−t/τ_i)) | JEDEC JESD51-14 (2010), transient thermal impedance and its Foster network | | Heat capacity of a stage | C_i = τ_i / r_i | JEDEC JESD51-14 (2010), Foster network | | Steady-state resistance | Rth = Σ r_i | JEDEC JESD51-14 (2010), Foster network | | Junction rise in a pulse | ΔTj = P·Zth(tp) | Mohan, Undeland & Robbins, Power Electronics, 3rd ed. (2003), ch. 29 (transient thermal impedance) | ## Quick check Inputs: - `r1`: First stage resistance = 100m K/W - `tau1`: First stage time constant = 1m s - `r2`: Second stage resistance = 300m K/W - `tau2`: Second stage time constant = 50m s - `p`: Heat in the pulse = 100 W - `t`: Pulse length = 10m s Outputs: - `zt`: Zth at the pulse length = `r1*(1 - exp(-t/tau1)) + r2*(1 - exp(-t/tau2))` K/W - `rth`: Steady-state resistance = `r1 + r2` K/W - `c1`: Heat capacity of the first stage = `tau1/r1` J/K - `dtj`: Junction rise in the pulse = `p*zt` K ## Model logic - With form auto it looks at the nets past b: when none stores heat (only resistances, heatsinks and fixed temperatures), it stamps r_i ∥ C_i stages in series with C_i = tau_i / r_i. - Into a side that stores heat it stamps the Cauer ladder with the same Zth, found by continued-fraction synthesis; form foster or cauer forces one. - r and tau need equally many positive values, at most 16, and have no default; inner nodes are named .n1, .n2 and so on. - The stages are linear and fixed: Zth does not change with temperature. ## Model Zth(t) = sum of r_i·(1 − e^(−t/tau_i)) from a to b for a step of heat. With form auto the stages are R ∥ C in series (C = tau/R) when everything past b has no heat capacity of its own: a fixed temperature, or thermal resistances and heatsinks on to fixed temperatures, which add to Zth exactly. Into a side that stores heat (a Thermal Capacitance, a Cauer Chain, a device's own junction ladder) a Foster chain would pass the heat on at once, so the part becomes the Cauer ladder with the same Zth (continued-fraction synthesis). form foster or cauer forces one. Inner nodes are named .n1, .n2 and so on; in a Foster chain they are not temperatures. ## Common mistakes - r and tau must have the same number of positive values, at most 16. The part has no default values: copy them from the data sheet, or the build stops. - Only the temperature at a means something. Do not read the inner nodes as case or die temperatures, and do not give the device both this part and a device file with its own thermal chain, or the impedance counts twice. Problems rules: `solver.thermal`, `compile.error` ## Datasheet and sources The transient thermal impedance section of a power device data sheet lists the Foster stages as r_i (K/W) and tau_i (s), next to the Zth,jc curve. Enter them in the same order. ## Example Open the example with the command `file.openExample` and the name `demo:foster`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Heatsink (`heatsink`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/heatsink/ > A catalogue heatsink's sink-to-ambient thermal resistance, read off its data sheet at a heat and an airflow. ![heatsink](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/heatsink.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/thermal/heatsink/) **Group:** Thermal · **Kind:** `{"element":"heatsink","kind":"thermal"}` ## When to use it Use it between a device's case (through the interface pad's resistance) and the ambient. Place it with thermal.placeHeatsink, which copies the resistance from parts/heatsinks.json; design.thermal names the part, the heat and the airflow to pass. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | thermal | Mounting surface, the sink's hot spot | | `b` | thermal | Ambient side: connect an Ambient Temperature here | ## Common parameters - `part`: Catalogue part number the resistance was read from (Default: optional (off)) - `rth`: Sink-to-ambient resistance, read off the catalogue by thermal.placeHeatsink (Default: optional (off)) - `airflow`: Airflow the resistance was read at; 0 is natural convection (Default: 0) - `watts`: Heat the resistance was read at; the data sheet's resistance falls as the heatsink gets hotter (Default: optional (off)) - `massG`: Weight from the data sheet; with material it gives the heatsink its heat capacity, so it warms over its own time constant (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `rth` | K/W | optional (off) | | Sink-to-ambient resistance, read off the catalogue by thermal.placeHeatsink | | `part` | — | optional (off) | | Catalogue part number the resistance was read from | | `airflow` | m/s | 0 | | Airflow the resistance was read at; 0 is natural convection | | `watts` | W | optional (off) | | Heat the resistance was read at; the data sheet's resistance falls as the heatsink gets hotter | | `lengthMm` | mm | optional (off) | | Extrusion cut length the resistance was read at | | `curveW` | W | optional (off) | | Heat at each point of the data sheet's temperature-rise table, rising, with commas; with curveK the run reads the resistance at the heat the heatsink carries | | `curveK` | K | optional (off) | | Temperature rise at each of those points, from the same table | | `massG` | g | optional (off) | | Weight from the data sheet; with material it gives the heatsink its heat capacity, so it warms over its own time constant | | `material` | — | aluminium | | Metal of the heatsink for its specific heat: aluminium or copper | | `fanRth` | K/W | optional (off) | | Resistance under the cooling fan: sink to ambient at the airflow of the fan that names it, read off the catalogue by thermal.placeFan; used while that fan is fitted and simulated | | `fanCurveW` | W | optional (off) | | Rise table under the fan, heat: each point's heat in the data sheet's table at the fan's airflow, rising, with commas; used with fanCurveK while that fan is fitted and simulated | | `fanCurveK` | K | optional (off) | | Rise table under the fan, rise: the temperature rise at each of those points, from the same table | | `footprint` | — | optional (off) | | KiCad library id of the footprint the heatsink sits on, such as Heatsink:Heatsink_Fischer_SK104-STC-STIC_35x13mm; board.addFootprints places it with every pad on no net; information only, not simulated | _Parameter descriptions are in English in both languages._ **Use for:** Catalogue heat sinks · Forced-air cooling · Natural convection **Not for:** A thermal pad or interface → [`rth`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/rth/) ## Formulas | Formula | Equation | Source | |---|---|---| | Heat sink temperature | Ts = Ta + P·Rsa | Mohan, Undeland & Robbins, Power Electronics, 3rd ed. (2003), ch. 29 (heat sinks) | | Junction temperature | Tj = Ta + P·(Rjc + Rcs + Rsa) | Mohan, Undeland & Robbins, Power Electronics, 3rd ed. (2003), ch. 29 (series thermal resistances) | | Largest sink resistance allowed | Rsa = (Tjmax − Ta)/P − Rjc − Rcs | Mohan, Undeland & Robbins, Power Electronics, 3rd ed. (2003), ch. 29 (heat sink selection) | ## Quick check Inputs: - `p`: Heat of the device = 20 W, `watts` - `rsa`: Sink-to-ambient resistance = 2 K/W, `rth` - `ta`: Ambient temperature = 40 °C - `rjc`: Junction-to-case resistance = 500m K/W - `rcs`: Case-to-sink resistance = 300m K/W - `tjmax`: Highest allowed junction temperature = 125 °C Outputs: - `tsink`: Heat sink temperature = `ta + p*rsa` °C - `tj`: Junction temperature = `ta + p*(rjc + rcs + rsa)` °C - `rneed`: Largest sink resistance allowed = `(tjmax - ta)/p - rjc - rcs` K/W ## Model logic - It is a plain thermal resistance rth from a to b, stamped like Thermal Resistance. - With curveW and curveK it reads rth again off the table at the heat it carries after every thermal step and in each round of a steady-state solve; above the last point it holds the last point's value and the run warns. part, airflow, watts and lengthMm only record where the value was read. - massG of material (aluminium 903 or copper 385 J/(kg·K), Çengel & Ghajar, Heat and Mass Transfer 5th ed., Table A-3) is a heat capacity from a to the reference; without it the sink settles in the same step. An unset rth with no table, or a non-positive one, stops the build. ## Model A thermal resistance rth from a to b. thermal.placeHeatsink reads it as the data sheet's temperature rise at watts divided by watts, on the fastest listed airflow not above airflow (straight lines between the table's points). Convection makes a heatsink's resistance fall as it gets hotter, so the part also keeps the sheet's rise table (curveW, curveK) and the run reads the resistance at the heat the sink carries. massG (the sheet's weight) gives it a heat capacity m·cp on a. ## Common mistakes - With massG the heatsink warms over minutes (τ = rth·m·cp): a run of milliseconds shows almost none of its rise. Use thermalStart steady or a multi-rate run, and do not also add a Thermal Capacitance on a, or the mass counts twice. - A heatsink placed from the library has no rth and stops the build; place it with thermal.placeHeatsink or enter the resistance from your own heatsink's data sheet. Problems rules: `solver.thermal`, `compile.error` ## Datasheet and sources Every value comes from parts/heatsinks.json, which cites each heatsink's data sheet, revision and the table read. ## Example Open the example with the command `file.openExample` and the name `demo:heatsink`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Heat Source (`qsource`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/qsource/ > Puts a fixed heat into a thermal node, for a part that is not simulated. ![qsource](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/qsource.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/thermal/qsource/) **Group:** Thermal · **Kind:** `{"element":"qsource","kind":"thermal"}` ## When to use it Use it for the losses of parts the circuit does not simulate, such as a controller, a gate driver, a shunt or the resistors of the bill of materials, on the node of the heatsink or board they warm. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | thermal | Thermal node the heat goes into | ## Common parameters - `w`: Heat it puts into its node, such as a controller's or a resistor's loss from the bill of materials; negative takes heat out (Default: optional (off)) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `w` | W | optional (off) | | Heat it puts into its node, such as a controller's or a resistor's loss from the bill of materials; negative takes heat out | | `tOn` | °C | optional (off) | | Thermostat: its node's temperature at which the heat turns on; below tOff it heats when cold, above tOff it acts when hot; give both or neither | | `tOff` | °C | optional (off) | | Thermostat: its node's temperature at which the heat turns off again; the source starts off and switches on the thermal step | _Parameter descriptions are in English in both languages._ **Use for:** Losses of parts not simulated · A gate driver or controller · Heat into a board or a heatsink **Not for:** A fixed temperature → [`ambient`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/ambient/) ## Formulas | Formula | Equation | Source | |---|---|---| | Rise over the ambient | ΔT = P·Rth | Mohan, Undeland & Robbins, Power Electronics, 3rd ed. (2003), ch. 29 (series thermal resistances) | ## Quick check Inputs: - `p`: Heat of the source = 2 W, `w` - `r`: Thermal resistance to ambient = 5 K/W Outputs: - `rise`: Rise over the ambient = `p*r` K ## Model logic - Its w is added to the heat into node a before each thermal step, so it acts like a device's loss that does not change with time or temperature. - w may be an expression of the circuit's variables, evaluated once when the circuit compiles. ## Model A constant heat flow w in W into node a, added to the devices' losses at every thermal step and in a steady-state solve. ## Common mistakes - w has no default: take it from the part's data sheet (its power dissipation at your operating point) or from a loss you computed; a negative w takes heat out. - The node needs a path to an Ambient Temperature, or the network does not compile. Problems rules: `solver.thermal`, `compile.error` ## Datasheet and sources The power dissipation of an IC at your supply and frequency, or I²·R of a resistor at its current, from your own loss budget. ## Example Open the example with the command `file.openExample` and the name `demo:qsource`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Thermal Resistance (`rth`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/rth/ > Slows the flow of heat between two thermal nodes, in K/W. ![rth](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/rth.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/thermal/rth/) **Group:** Thermal · **Kind:** `{"element":"rth","kind":"thermal"}` ## When to use it Use it for case-to-sink, sink-to-ambient and other conduction paths. Use Thermal Capacitance for stored heat and Ambient Temperature for a fixed temperature. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | thermal | Thermal node; heat flows to b when a is hotter | | `b` | thermal | The other thermal node | ## Common parameters - `r`: Resistance to heat flowing through (Default: required) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `r` | K/W | required | | Resistance to heat flowing through | | `part` | — | optional (off) | | Catalogue thermal pad, grease or phase-change material the resistance was read from; it puts the interface on the bill of materials, and the solver never reads it | | `footprint` | — | optional (off) | | KiCad library id of the footprint a thermal pad sits on, when the board holds it; board.addFootprints places it with every pad on no net; information only, not simulated | _Parameter descriptions are in English in both languages._ **Use for:** Case-to-sink paths · Sink-to-ambient paths · Conduction through a layer **Not for:** Heat stored in a body → [`cth`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/cth/) ## Formulas | Formula | Equation | Source | |---|---|---| | Temperature rise across it | ΔT = P·Rth | Incropera, DeWitt, Bergman & Lavine, Fundamentals of Heat and Mass Transfer, 7th ed. (2011), §3.1 (thermal resistance) | | Temperature of the hot side | Ta + P·Rth | Mohan, Undeland & Robbins, Power Electronics, 3rd ed. (2003), ch. 29 (heat sinks, series thermal resistances) | ## Quick check Inputs: - `p`: Heat flowing through = 10 W - `r`: Thermal resistance = 500m K/W, `r` - `ta`: Temperature of the cold side = 25 °C Outputs: - `dt`: Temperature rise across it = `p*r` K - `tj`: Temperature of the hot side = `ta + dt` °C ## Model logic - It is a conductance 1/r between two nodes of the thermal network, a linear system of its own, apart from the electrical matrix. - The thermal network takes one backward Euler step after each accepted circuit step, with that step's losses as heat, or steps on its own grid when thermalStep is set. - A switch reads its loss tables at its thermal node's temperature from the step before, so heating and losses are coupled one step apart. - r is fixed: it does not change with temperature or airflow. ## Model The thermal domain follows the electrical analogy. Temperature in degC plays the part of voltage and heat flow in W plays the part of current, so the heat flow from a to b is (T(a) - T(b)) / r. Thermal nets are separate from electrical nets, and a switch sends its losses into the net named in its thermal parameter. ## Common mistakes - Every thermal network needs a path to an Ambient Temperature part. A node with no path to a fixed temperature or a heat capacity is reported, and a network with no ambient at all does not compile. - Thermal pins connect to thermal nets only. Joining one to an electrical net is flagged. Problems rules: `solver.thermal`, `pin.domain_mismatch` ## Datasheet and sources r comes from the datasheet thermal resistances: junction-to-case from the device, case-to-sink from the interface material, and sink-to-ambient from the heat sink. Resistances in series add up. ## Example Open the example with the command `file.openExample` and the name `demo:rth`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Zth Curve (`zth`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/zth/ > A transient thermal impedance fitted from points read off a data sheet's Zth(t) curve. ![zth](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/zth.svg) [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/thermal/zth/) **Group:** Thermal · **Kind:** `{"element":"zth","kind":"thermal"}` ## When to use it Use it when the data sheet draws the single-pulse Zth,jc curve but lists no Foster table. Use Foster Chain when the table is given. ## Pins | Pin | Domain | Meaning | |---|---|---| | `a` | thermal | Hot side: the junction | | `b` | thermal | Cold side: the case | ## Common parameters - `t`: Times of points on the data sheet's Zth(t) curve, rising (Default: optional (off)) - `z`: Transient thermal impedance at those times (Default: optional (off)) - `terms`: Foster stages fitted to the curve, 1 to 8 (Default: 4) ## Parameters | Key | Unit | Default | Typical range | Description | |---|---|---|---|---| | `t` | s | optional (off) | | Times of points on the data sheet's Zth(t) curve, rising | | `z` | K/W | optional (off) | | Transient thermal impedance at those times | | `terms` | — | 4 | | Foster stages fitted to the curve, 1 to 8 | | `form` | — | auto | | auto: a Foster chain into a side with no heat capacity, else the equivalent Cauer ladder; foster or cauer forces one | _Parameter descriptions are in English in both languages._ **Use for:** A sheet with only the curve · Junction-to-case Zth · Rise in short pulses **Not for:** A data sheet's Foster table → [`foster`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/thermal/foster/) ## Formulas | Formula | Equation | Source | |---|---|---| | Junction rise in a pulse | ΔTj = P·Zth(tp) | Mohan, Undeland & Robbins, Power Electronics, 3rd ed. (2003), ch. 29 (transient thermal impedance) | | Junction temperature | Tj = Tc + P·Zth(tp) | Mohan, Undeland & Robbins, Power Electronics, 3rd ed. (2003), ch. 29 (transient thermal impedance) | | The fitted curve | Zth(t) = Σ r_i·(1 − e^(−t/τ_i)) | Lawson & Hanson, Solving Least Squares Problems (1974), ch. 23 (NNLS) | ## Quick check Inputs: - `tc`: Case temperature = 25 °C - `p`: Heat in the pulse = 50 W - `zp`: Zth read at the pulse length = 200m K/W - `tf`: First time on the curve = 10u s - `tl`: Last time on the curve = 1 s Outputs: - `dtj`: Junction rise in the pulse = `p*zp` K - `tj`: Junction temperature = `tc + dtj` °C - `cands`: Candidate time constants (about) = `8*log10(tl/(4*tf))` - ## Model logic - When the circuit is built it fits a Foster chain: candidate time constants eight per decade from the first time to a quarter of the last, resistances by non-negative least squares (Lawson and Hanson). - When more than terms stages come out, the ones with the largest resistances are fitted again on their own; stages whose resistance is zero are dropped. terms is a whole number from 1 to 8. - The fitted chain then behaves like Foster Chain, with the same form choice and the same conversion to a Cauer ladder into a side that stores heat. ## Model When the circuit is built, a Foster chain of up to terms stages is fitted to the points: candidate time constants eight per decade from the first time to a quarter of the last, resistances by non-negative least squares (Lawson and Hanson), and when more than terms stages come out, the largest are fitted again on their own. The chain then acts like Foster Chain, including the conversion to a Cauer ladder into a side that stores heat. ## Common mistakes - The last point must be where the curve has levelled off, at the steady-state Rth,jc: the slowest stage is fitted to settle by then. Points must rise in time and must not fall in value. - Read at least two points per decade; a fit through a few points can bend between them. Use the single-pulse curve (D = 0), not the duty-cycle curves. Problems rules: `solver.thermal`, `compile.error` ## Datasheet and sources Read t (s) and Zth (K/W) off the data sheet's transient thermal impedance graph, single pulse, junction to case. ## Example Open the example with the command `file.openExample` and the name `demo:zth`. --- Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand. --- # Field Calculator (`field.calculator`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-calculator/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-calculator/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** a job, with progress and Cancel > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. Solves the model as magnetics.fieldSolve meshes it (magnetostatic, linear materials) with the currents given, all at once, and evaluates each quantity on the solved field. Variables (SI): x, y (m; in an axisymmetric model also r = x and z = y), Bx, By, B = |B| (T; axisymmetric also Br, Bz), Hx, Hy, H = |H| (A/m, from each region's μr, a magnet's on its recoil line; axisymmetric also Hr, Hz), A (Wb/m: A\_z planar, A\_φ = ψ/r axisymmetric), J (A/m², the source current density along z, or φ), muR (the region's relative permeability), mu0 (4π·1e-7 H/m), and on a surface nx, ny (the unit normal to the right of travel along the path) and tx, ty (the unit tangent). dV is the element area times the model's depth, or 2πr times it when axisymmetric; dS is the path length times the depth, or 2πr times it. The integrals are exact for the element field up to degree 5 in the position (a 7-point triangle rule, 3-point Gauss along the path), so B\*H/2 over every region is the region table's energy, Bx\*nx+By\*ny along a line is the flux across it, and Hx\*tx+Hy\*ty round a closed path divided by the depth (or by 2\*pi\*r) is the current it encloses. A piece of a path along an edge between two elements takes both sides' mean; a part outside the mesh counts for nothing (insideMm says how much was inside). A quantity that is not finite somewhere is refused with the point and the region. Changes nothing. With "dimension":3 (#3069) the model (a sketch or an E-type design, not an axisymmetric sketch) is extruded as magnetics.fieldSolve {dimension: 3} extrudes it, meshed whole (a ring design is revolved a whole turn about the z axis, "stepDeg" its step, each winding a current sheet on the core named after its circuit; it takes no magnets or layers), solved once linear with the currents given and any magnets (each label's body through the depth on its recoil line, magnetized in the drawing's plane; a drawing of magnets alone has no winding), and each quantity is a volume integral (regions, default every region), a point value (at:\[x,y,z\] mm, z = 0 the middle plane; no path) or a surface integral (surface:{corner:\[x,y,z\],u:\[dx,dy,dz\],v:\[dx,dy,dz\]} mm, a flat parallelogram; its unit normal u × v / |u × v| is nx, ny, nz) of the variables x, y, z (m), Bx, By, Bz, B, Hx, Hy, Hz, H, muR, mu0; B and H are constant in each tetrahedron and the 4-point rule of degree 2 integrates expr exactly up to degree 2 in the position, so B\*H/2 over every region is the 3D energy (model.energyJ; with magnets H = (B − Br)/(μ0 μrec) in a magnet and mu0\*muR\*H^2/2 is the energy); a surface row gives value (∫ expr dS, exact up to degree 2 in the position: Bx\*nx+By\*ny+Bz\*nz is the flux, zero out of a closed box of six surfaces), areaMm2 (the part inside the mesh), surfaceMm2, mean and normal, and a piece on a face between two tetrahedra takes both sides' mean; the reply adds dimension:3, with magnets magnets (each one's demagnetization check at the currents given, as field.force {dimension: 3} gives it) and warnings, and model {family,construction,revolveStepDeg,depthMm,elementMm,layers,nodes,elements,regions,iterations,residual,energyJ,estimatedPeakMemoryBytes}. ## Parameters - `design`: object? (a magnetics.design reply, or its best design) - `sketch`: object? (instead of design: the planar drawing magnetics.fieldSolve takes, in mm; field.lineProfile, field.regionTable and field.calculator also take an axisymmetric (r, z) section, axisymmetric: true with no depthMm, revolved a full turn, its magnets' direction \[r, z\] in the section) - `muR`: number? (design only) - `clearanceMm`: number=0.1 (design only) - `elementMm`: number? (largest element in the core and the windings, 0.01 to 50 mm) - `currents`: object? ({circuit: amperes}; default 1 A in every circuit; a circuit left out carries none) - `magnets`: \[{region:str (the name of a region of the drawing that is not a coil; with a design, \\"centre-leg gap\\" draws the centre leg's gap as its own region, a slot the magnet fills, refused for a ring or a gapless design),direction:\[x,y\] (the magnetization direction, any length; \[r, z\] in an axisymmetric section),temperatureC:number,grade:str (a built-in grade: Arnold N35, Arnold N42, Arnold N42H or Arnold N42UH, sintered NdFeB, each from its Arnold Magnetic Technologies data sheet) | {name:str,source:str (the data sheet the values come from: document, revision, table),recoilMuR:number (≥ 1),points:\[{temperatureC,brT (remanence),hcjAPerM (intrinsic coercivity),hkAPerM (knee field, H\_k ≤ H\_cJ)}\] (1 to 64, rising temperature)}}\]? (permanent magnets, at most 64: each region becomes a magnet on its recoil line B = μ0 μrec H + Br at the temperature, Br, H\_cJ and H\_k linear between the sheet's points and the nearest point outside them with an outsideMaterialData warning; any other grade's values are the caller's, and the grade must name its sheet; demagCurve:\[\[H,B\]\]? (field.lineProfile, field.regionTable, magnetics.fieldFluxMap, magnetics.fieldSolve {dimension: 3} and field.force {dimension: 3} only, every other command refuses it: the grade's normal demagnetization curve at temperatureC from the same data sheet, A/m and T, 2 to 200 points from \[0, Br\] with H and B both falling through the knee, its Br within 1 % of the grade's; the magnet is then solved by Newton's method on it, a reverse field along the magnetization on the curve and a forward or crosswise one on the recoil line, reversibly, with Br from the curve)) - `quantities`: \[{"name":str? (default q1, q2, …; unique, up to 64 characters),"expr":str (the quantity, an expression of the variables below in SI units, e.g. "B^2/(2\*mu0\*muR)" or "Bx\*nx+By\*ny"; the functions of parameter expressions: sqrt, abs, pow, hypot, if, min, max, sin, …),"regions":\[str\]? (a volume integral over the regions of these label names; the default when neither path nor at is given, over every region),"path":\[\[x,y\]\]? (mm, 2 to 10000 points: a surface integral over the surface the polyline sweeps, through the model's depth, or round the axis when axisymmetric; repeat the first point to close it),"at":\[x,y\]? (mm: the quantity at one point)}\] (1 to 16) - `dimension`: int=2 (3: the 3D calculator, below) - `layers`: int? (dimension 3: element layers through the depth, as magnetics.fieldSolve takes them) - `stepDeg`: num? (dimension 3, a ring design: the revolve step, 1 to 30 degrees, as magnetics.fieldSolve takes it) ## Reply - currents - quantities:\[{name,expr,kind:"volume"|"surface"|"point",value (volume: ∫ expr dV, the unit of expr times m³; surface: ∫ expr dS, times m²; point: expr, null outside the mesh),regions? (volume: the region names),volumeMm3?,mean? (volume: value / volume),areaMm2?,lengthMm?,insideMm?,closed? (surface),atMm?,region? (point: the region name, null outside the mesh)}\] - model - notes --- # DC Conduction (`field.dcConduction`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-dcConduction/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-dcConduction/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** a job, with progress and Cancel > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. Solves ∇·(σ∇V) = 0 on an automatic mesh of the conductors and electrodes (the insulators' edges carry no current), with Voltecx's own 2D solver: the electrostatic one with σ in place of ε. A conductance comes out two ways (from the electrode currents and from the dissipated power), which agree to the solver tolerance. Planar values are for the sheet depthMm thick (a uniform sheet: no current across its thickness), axisymmetric ones for the full revolution. DC only: no skin or proximity effect (magnetics.fieldSolve {mode: "harmonic"} has them). A job: progress counts the solves, and cancel stops before the next. Changes nothing. ## Parameters - `sketch`: object (a drawing in mm as magnetics.fieldSolve takes it: planar {depthMm, …}, a sheet depthMm thick seen from above with the current in its plane (a copper pour, busbar or trace: 1 oz copper is 0.035), or {axisymmetric:true, …} about x = 0, revolved a full turn; labels \[{name?, at:\[x,y\], maxSizeMm?, conductivity:number (S/m, above 0 and at most 1e9: a conductor; take σ from the material's data sheet, at its temperature) | electrode:str (a perfect conductor where the current enters or leaves, a pad, terminal or via; labels with one name are one electrode) | neither (an insulator: no current crosses it)}\]; every conducting part must touch an electrode, and electrodes must not touch each other) - `elementMm`: number? (largest element in every conductor and electrode, 0.01 to 50 mm; default the automatic mesher's) - `reference`: str? (the electrode taken as 0 V for the conductance matrix; default the last in label order) - `voltagesV`: {electrode: V}? (every electrode's potential, within ±1e6 V, for one more solve with currents, loss and current density) - `ignoreMemoryCheck`: bool=false ## Reply - electrodes:\[{name,labels}\] - conductance:{names (the electrodes but the reference, in label order),reference,byCurrentS:\[\[S\]\],byPowerS:\[\[S\]\],twoWaysRelative} (I = G V with the reference at 0 V: the nodal matrix of the resistor network the conductor is) - resistances:\[{between:\[a,b\],ohm}\] (every pair, the other electrodes floating: no net current) - solution?:{voltagesV,currentsA:{electrode: A into it},powerW (∫σ|∇V|² dV),powerFromElectrodesW (Σ V I, the same to the solver tolerance),regions:\[{region,lossW}\],peakCurrentDensity:{aPerMm2,region,atMm}} - model:{form:planar|axisymmetric,depthMm,elementMm,nodes,elements,conductingElements,solves,solverVersion} - notes - preview - previewNote --- # Delete Field Study (`field.deleteStudy`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-deleteStudy/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-deleteStudy/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Removes a field study with its drawing and results; the last one cannot go. Not undoable. ## Parameters - `index`: int ## Reply - deleted - active - studies --- # 3D Electrostatics (`field.electrostatic3d`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-electrostatic3d/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-electrostatic3d/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** a job, with progress and Cancel > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. Solves −∇·(ε∇V) = 0 on the bodies meshed on a lattice with Voltecx's own 3D electrostatic solver, one solve per conductor at 1 V with the others at 0 V, and gives the Maxwell capacitance matrix two ways (from the conductor charges and from the field energy, which agree to the solver tolerance). A face that does not lie on a lattice plane is cut through the cells, so curved faces are less accurate than flat ones. With component, each pair of windings gets one capacitor CIW\ between their starts (p1 and p2) at its interwindingF, which the EMI commands then measure; a winding modelled as one body has no self-capacitance, so none goes across a winding; the part is checked before any solve. A job: progress counts the solves, and cancel stops before the next. Without component it changes nothing. ## Parameters - `import`: {path:str (an STL, STEP or IGES file, read as magnetics.fieldSolve's import reads it),unitMm:number? (mm per file unit: 1 by default for STL; a STEP or IGES file states its own),bodies:\[{name?:str, conductor:str (a conductor, meshed as metal; bodies with one conductor name are one conductor) | epsR:number (a dielectric, 1e-3 to 1e5)}\] (each solid of the file, in its order),boxMm?:{lo:\[x,y,z\],hi:\[x,y,z\]} (the box of air round the bodies, εr 1, its sides the ground at 0 V; no conductor may touch them; default the bodies' bounds grown by half their largest extent on every side)} - `elementMm`: number? (largest cell side, 0.01 to 50 mm; default a twentieth of the box's largest side) - `voltagesV`: {\:V}? (the conductors' voltages for fieldStress, each 0 V when not named) - `strengthKVPerMm`: {\:kV/mm}? (needs voltagesV: each material's dielectric strength from its data sheet, none assumed) - `windings`: \[str\]? (the conductors that are a part's windings, in the order of its pins, each modelled as one body with its turns joined) - `component`: str? (needs windings: the coupled inductor, common-mode choke or transformer (p1–n1, p2–n2) whose windings they are; the interwinding capacitor goes into the circuit as a pending proposal) - `apply`: bool=false (with component: add it at once, in ONE history step, instead of a proposal) - `ignoreMemoryCheck`: bool=false ## Reply - conductors:\[{name,bodies:\[str\]}\] - matrix:{names,byChargeF:\[\[F\]\],byEnergyF:\[\[F\]\],twoWaysRelative} (the Maxwell matrix, the ground the reference) - fieldStress?:\[{body,peakVPerM,element,atMm:\[x,y,z\],strengthVPerM?,margin?}\] (with voltagesV: the largest |E| in each dielectric body and the air, the mean over the tetrahedron it is in, and where (that tetrahedron's centroid, mm); with a strength, margin = strength / peak) - hotSpot?:{body,peakVPerM,atMm,margin?} (with voltagesV: the row with the least margin, or the largest |E| when no strength is given) - windings?:\[str\] - interwindingF?:\[\[F\]\] (with windings: between two windings with every other conductor and the ground floating; 0 on the diagonal) - capacitors?:\[{part,kind:interwinding,between,component,nets,cF}\] (with component: the parts planned) - apply? - proposal?|applied? - model:{construction:"imported",elementMm,nodes,elements,dihedralDeg:\[min,max\],solves,iterations,solverVersion} - notes - preview - previewNote --- # Export Field CSV (`field.exportCsv`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-exportCsv/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-exportCsv/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. Writes a field result as RFC 4180 CSV that spreadsheets, pandas, MATLAB and R read as it is: one header line naming each column with its SI unit (x\_m, b\_T, h\_A\_per\_m, loss\_W\_per\_m3, temperature\_C), the same number of fields on every line, text quoted when it holds a comma or a quote, numbers in their shortest round-trip form, an empty field where a value does not exist. Changes nothing. ## Parameters - `result`: object? (a reply of magnetics.fieldSolve, field.openExample, magnetics.fieldCoreLoss or field.thermalSolve with field:true, field.lineProfile, field.regionTable, or field.thermalSolve with line; default the latest result of this session that has the table) - `table`: "elements|profile|regions|line"? (elements: one line per mesh element with its region, centroid, area, then per winding bx, by, |B| and |H| at 1 A, and the loss density or the temperature when the result has them; profile: field.lineProfile's points; regions: field.regionTable's rows; line: the temperature along field.thermalSolve's line; default the result's own) - `path`: str? (the .csv file to write, through the host's file service) ## Reply - table - columns - rows - bytes - csv? (without path) - path - written - source:{command,kind} - notes - preview - previewNote --- # Export Field Solve Diagnostics (`field.exportDiagnostics`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-exportDiagnostics/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-exportDiagnostics/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Checks the record (format powercraft-fem-diagnostics version 1: solverVersion, inputHash, mesh {nodes, elements, freeNodes, regions, minAngleDeg}, iterations, residual, adaptive \[{elements, energy, change}\], newton \[{residual, damping}\], timeS, estimatedPeakMemoryBytes) and writes it as one JSON file for a bug report. Reading the file back gives the same record, every number bit for bit. The file holds counts, the solver's numbers and a hash of the input, no coordinates, names or materials; it leaves the machine only if the user sends it. Changes nothing. ## Parameters - `diagnostics`: object (a field solve's diagnostics, or a reply that carries them under \`diagnostics\`) - `path`: str? (the .json file to write, through the host's file service) ## Reply - diagnostics - file - path - bytes - written - notes --- # Export Field Image (`field.exportImage`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-exportImage/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-exportImage/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. Renders a field result's map as the field view draws it (smooth colours in the sequential ramp, the legend with the quantity, unit and both ends, flux lines as contours of A\_z or isotherms, region outlines, a round scale bar and, on a thermal solve's temperature map, its hot spot), at print resolution in the design-token colours of the palette. Changes nothing. ## Parameters - `result`: object? (a reply of magnetics.fieldSolve {field:true}, field.openExample, magnetics.fieldCoreLoss {field:true} or field.thermalSolve {field:true}; default the latest such result of this session that has the quantity's map) - `quantity`: "b|h|lossDensity|temperature"? (default the result's first: lossDensity for a core loss, b for a solve, temperature for a thermal solve) - `circuit`: str? (b and h: the winding whose field at 1 A is drawn; default the first) - `currents`: {circuit:A}? (b and h: draw the field of the windings at these currents instead, the 1 A fields superposed, windings not named at 0 A; not with circuit; each within ±1e6 A, not all zero) - `at`: "peak"|s? (b and h, default b: draw the field at an instant of a magnetics.fieldCoreLoss {field: true} result's period: "peak" for the instant of the core's peak |B| (its peak.timeS and peakCurrents), or a time in s within the period, the currents linear between its samples; default the latest such result; not with circuit or currents) - `from`: {circuit:A}? (b and h, with currents or at: draw the change of the field from these currents to those, B and H of each end subtracted element by element, windings not named at 0 A, each within ±1e6 A: the ripple of a corner is at "peak" from its mean currents) - `range`: {"min":number,"max":number}? (the colour scale's ends in the map's unit, so several images share one scale; values outside take the end colours; default 0 to the core's 99th percentile of the element values by area, as the field window scales (the core: the regions with a loss, else with μr \> 1; the largest value without a core), and the coldest to the hottest node for a temperature) - `format`: "png|svg"? (default the path's extension, else png) - `widthPx`: int=2400 (256 to 4096) - `heightPx`: int=1800 (256 to 4096) - `dpi`: int=300 (72 to 1200: the PNG's resolution, and the SVG's size in mm) - `palette`: "light|dark|print"="light" (the export palette: the light or dark canvas, or Print in black and white with a grey map; the app passes its theme for Follow the app theme) - `lines`: bool=true (flux lines, or isotherms on a temperature map) - `outlines`: bool=true (region outlines) - `mesh`: bool=false - `path`: str? (the .png or .svg file to write, through the host's file service) ## Reply - quantity - unit - legend - range:{min,max} - clipped (some value lies above range.max: the legend's top reads ≥) - circuit - currents? ({circuit:A} of every winding when currents or at were given) - from? ({circuit:A} of every winding when from was given) - solved (the b or h map is drawn from the result's field.solved, a solve on the core's B-H curve at exactly those currents (at either end of from): magnetics.fieldCoreLoss {field: true} on a B-H curve holds its peak instant's and its period mean currents', so at "peak" and at the mean currents a saturating core is drawn saturated, H from each element's secant μr; otherwise the 1 A linear fields superposed) - at? ({timeS}) - largest:{value,element} (the map's largest element value and its element: at "peak" it is the core-loss reply's peak.b when the peak lies in the core) - format - widthPx - heightPx - dpi - widthMm - heightMm - palette - lines (segments drawn) - scaleBarM - hotSpot ({temperatureC,atMm,region} of a field.thermalSolve result, marked on its temperature map as a ring with its line on a plate; null otherwise) - bytes - path - written - svg? (svg without path) - base64? (png without path) - source:{command,kind} - notes - preview - previewNote --- # Export 3D Field Model as STEP (`field.exportModelStep`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-exportModelStep/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-exportModelStep/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** a job, with progress and Cancel > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Writes the meshed 3D model of the design, sketch or import as STEP, so the core, windings and magnets open in a mechanical CAD tool. Each solid is a closed piece of a region's tetrahedra: curved faces come out as the mesh's flat facets, and a region in several pieces gives one solid per piece (named 'primary 2'…). A piece that encloses other regions (the air box around a wound core) is a solid with voids (BREP\_WITH\_VOIDS, each void's shell oriented .F.), which the STEP import reads back. Solves nothing and changes nothing; save the text with the extension .step. ## Parameters - `design`: object? or "sketch":object? or "import":object? (the model as magnetics.fieldSolve {dimension: 3} builds it, with "muR","clearanceMm","elementMm","layers","stepDeg","endTurns" and "cache" as there) - `whole`: bool=true (reflect a part meshed for its symmetry (the wound E core's eighth, an extrusion's half or quarter) into the whole model; false writes the meshed part as the solve meshes it) - `regions`: \[str\]? (the regions to write, by name; default every region) - `fileName`: str="field-model.step" (the name in the file's header, and its product's name without the extension) ## Reply - step (ISO 10303-21 text, AP214: one FACETED\_BREP per piece of each region, a BREP\_WITH\_VOIDS for a piece that encloses other regions, in metres) - solids:\[{region,name,facets,vertices,voids,volumeM3 (the material: the outer shell less its voids)}\] - model:{construction,family,nodes,elements,symmetry,whole} - notes:\[{en,zh-Hant}\] --- # Export 3D Field Model as STL (`field.exportModelStl`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-exportModelStl/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-exportModelStl/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** a job, with progress and Cancel > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Writes the meshed 3D model of the design, sketch or import as STL, so its bodies can be checked in a CAD or mesh viewer or taken on into another tool. Each region's solid is the boundary of its tetrahedra: curved faces come out as the mesh's flat facets, and two regions that touch both have the faces between them, turned opposite ways. A ring design is revolved whole. Solves nothing and changes nothing; save the text with the extension .stl. ## Parameters - `design`: object? or "sketch":object? or "import":object? (the model as magnetics.fieldSolve {dimension: 3} builds it, with "muR","clearanceMm","elementMm","layers","stepDeg","endTurns" and "cache" as there) - `unit`: "mm|m"="mm" (the file's unit; STL has none of its own) - `whole`: bool=true (reflect a part meshed for its symmetry (the wound E core's eighth, an extrusion's half or quarter) into the whole model; false writes the meshed part as the solve meshes it) - `regions`: \[str\]? (the regions to write, by name; default every region, the air box included) ## Reply - stl (ASCII STL text, one solid per region named after it, each closed and facing outward) - unit - solids:\[{region,facets,vertices,volumeM3}\] - model:{construction,family,nodes,elements,symmetry,whole (the file is the whole model)} - notes:\[{en,zh-Hant}\] --- # Field Force and Torque (`field.force`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-force/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-force/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** a job, with progress and Cancel > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. Solves the model as magnetics.fieldSolve meshes it (magnetostatic, linear materials, or the core on its B-H curve with nonlinear) with the currents given, all at once, and gives the force and torque on the body by the weighted stress tensor (the Maxwell stress tensor over the air around the body, weighted by a function that is 1 on the body and 0 on every other part, as FEMM's block integral), through the model's depth. The torque is positive anticlockwise (+z). virtualWork checks it by the derivative of the co-energy (on the B-H curve with nonlinear: each moved problem is a Newton solve, so it takes longer; a magnet's co-energy is the one on its recoil line, and a magnet in the body turns its magnetization with the body, 2d.md §13.7); lorentzN checks it for a coil in air. An axisymmetric sketch (axisymmetric: true, an (r, z) section about x = 0) gives the axial force F\_z on the body for the full turn, the same three ways (2d.md §13.5), with nonlinear too (Newton's method on the (r, z) section, virtual work on the curve), and with magnets (direction \[r, z\], a ring magnetized in the section, on its recoil line in the body or outside it); the body may reach the axis; not with centreMm. With dimension 3, forceN and torqueNm are \[x, y, z\] for the whole 3D model (z along the extrusion, z = 0 its middle plane; centreMm may be \[x, y, z\]), the weighting held at 0 on the model's sides and free on its caps (3d.md §9.8), and lorentzN \[x, y, z\] on a non-magnetic body that carries current. Changes nothing. ## Parameters - `design`: object? (a magnetics.design reply, or its best design) - `sketch`: object? (instead of design: the planar drawing magnetics.fieldSolve takes, in mm; field.lineProfile, field.regionTable and field.calculator also take an axisymmetric (r, z) section, axisymmetric: true with no depthMm, revolved a full turn, its magnets' direction \[r, z\] in the section) - `muR`: number? (design only) - `clearanceMm`: number=0.1 (design only) - `elementMm`: number? (largest element in the core and the windings, 0.01 to 50 mm) - `currents`: object? ({circuit: amperes}; default 1 A in every circuit; a circuit left out carries none) - `magnets`: \[{region:str (the name of a region of the drawing that is not a coil; with a design, \\"centre-leg gap\\" draws the centre leg's gap as its own region, a slot the magnet fills, refused for a ring or a gapless design),direction:\[x,y\] (the magnetization direction, any length; \[r, z\] in an axisymmetric section),temperatureC:number,grade:str (a built-in grade: Arnold N35, Arnold N42, Arnold N42H or Arnold N42UH, sintered NdFeB, each from its Arnold Magnetic Technologies data sheet) | {name:str,source:str (the data sheet the values come from: document, revision, table),recoilMuR:number (≥ 1),points:\[{temperatureC,brT (remanence),hcjAPerM (intrinsic coercivity),hkAPerM (knee field, H\_k ≤ H\_cJ)}\] (1 to 64, rising temperature)}}\]? (permanent magnets, at most 64: each region becomes a magnet on its recoil line B = μ0 μrec H + Br at the temperature, Br, H\_cJ and H\_k linear between the sheet's points and the nearest point outside them with an outsideMaterialData warning; any other grade's values are the caller's, and the grade must name its sheet; demagCurve:\[\[H,B\]\]? (field.lineProfile, field.regionTable, magnetics.fieldFluxMap, magnetics.fieldSolve {dimension: 3} and field.force {dimension: 3} only, every other command refuses it: the grade's normal demagnetization curve at temperatureC from the same data sheet, A/m and T, 2 to 200 points from \[0, Br\] with H and B both falling through the knee, its Br within 1 % of the grade's; the magnet is then solved by Newton's method on it, a reverse field along the magnetization on the curve and a forward or crosswise one on the recoil line, reversibly, with Br from the curve)) - `regions`: \[str\] (the body: the names of the labels whose regions it is made of, e.g. \["core"\]; every one must be surrounded by air, or touch only the body's other regions) - `centreMm`: \[x,y\]=\[0,0\] (mm, the point the torque is about; planar only) - `virtualWork`: bool=false (also find the force by virtual work: six more solves, the body moved by ±1e-3 of its size along x and y and turned by ±1e-4 rad; axisymmetric: two solves, moved along z) - `nonlinear`: bool=false (solve the core regions on their material's catalogue B-H curve by Newton's method: N87, N97, 3C90 and 3C95 have data-sheet curves; another material stays linear, with a note; a magnet stays on its recoil line) - `material`: str? (nonlinear with a sketch, required there: the catalogue material of its core regions; a design uses its own) - `temperatureC`: number? (nonlinear: the core temperature for the curve, -40 to 200; default the design's, else 25) - `dimension`: 2|3=2 (3: the 3D model magnetics.fieldSolve {dimension: 3} extrudes from a sketch or an E-type design, meshed as its half through the depth with even layers (the quarter when the body is its own mirror across x = 0; never with magnets) and whole with odd layers, the part's force unfolded into the whole body's and the planes named in mirrorPlanes; nonlinear and material as in 2D; magnets as in 2D, each its region through the depth magnetized in the drawing's plane, the model then never quartered, with magnets rows by volume (volumeMm3, direction \[x,y,0\], worstAtMm \[x,y,z\]) and their warnings, a drawing of magnets alone (no coil) extruded with no winding, its only source the magnets, and no currents; virtualWork as in 2D (six more solves, linear or Newton's with nonlinear: F\_x, F\_y and τ\_z; on the quarter two, the move along y only, F\_x then 0 by symmetry and τ\_z = −c\_x F\_y; F\_z, τ\_x and τ\_y null, since the extrusion's ends hold the body along z; 3d.md (9.8d)); not with an axisymmetric sketch; not a ring design) - `layers`: int? (dimension 3: element layers through the depth, 1 to the solver's limit; default 8) ## Reply - currents - regions - dimension? (3 for the 3D force) - axisymmetric - forceN:\[x,y\] (axisymmetric: \[0, F\_z\], the radial force cancelling round the axis) - torqueNm (null when axisymmetric) - method:"weightedStressTensor" - virtualWork:{forceN:\[x,y\],torqueNm,stepMm,angleRad}|null (dimension 3: forceN \[x,y,null\], torqueNm \[null,null,z\]) - mirrorPlanes? (dimension 3: the mirror planes the part was unfolded across, e.g. \["z"\]) - lorentzN:\[x,y\]|null (the Lorentz force on the body's current; only when every region of it is non-magnetic) - nonlinear (true when the core was solved on a curve) - material:{name,temperatureC}|null (with nonlinear) - model (with newtonSteps when solved on a curve) - notes - preview - previewNote --- # Field Line Profile (`field.lineProfile`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-lineProfile/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-lineProfile/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** a job, with progress and Cancel > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. Solves the model as magnetics.fieldSolve meshes it (magnetostatic, linear materials) with the currents given, all at once, and reads the field along a line: B and H at evenly spaced points (H from each region's μr; a point outside the mesh has region null and zero field), the flux across the line per metre of depth and through the model's depth (positive with the normal to the right of travel; null when an end lies outside the mesh), and ∫H·dl along the path, exact for the element field (a closed path gives the ampere-turns it encloses, Ampère's law). The CSV is in SI units (m, T, A/m). Changes nothing. ## Parameters - `design`: object? (a magnetics.design reply, or its best design) - `sketch`: object? (instead of design: the planar drawing magnetics.fieldSolve takes, in mm; field.lineProfile, field.regionTable and field.calculator also take an axisymmetric (r, z) section, axisymmetric: true with no depthMm, revolved a full turn, its magnets' direction \[r, z\] in the section) - `muR`: number? (design only) - `clearanceMm`: number=0.1 (design only) - `elementMm`: number? (largest element in the core and the windings, 0.01 to 50 mm) - `currents`: object? ({circuit: amperes}; default 1 A in every circuit; a circuit left out carries none) - `magnets`: \[{region:str (the name of a region of the drawing that is not a coil; with a design, \\"centre-leg gap\\" draws the centre leg's gap as its own region, a slot the magnet fills, refused for a ring or a gapless design),direction:\[x,y\] (the magnetization direction, any length; \[r, z\] in an axisymmetric section),temperatureC:number,grade:str (a built-in grade: Arnold N35, Arnold N42, Arnold N42H or Arnold N42UH, sintered NdFeB, each from its Arnold Magnetic Technologies data sheet) | {name:str,source:str (the data sheet the values come from: document, revision, table),recoilMuR:number (≥ 1),points:\[{temperatureC,brT (remanence),hcjAPerM (intrinsic coercivity),hkAPerM (knee field, H\_k ≤ H\_cJ)}\] (1 to 64, rising temperature)}}\]? (permanent magnets, at most 64: each region becomes a magnet on its recoil line B = μ0 μrec H + Br at the temperature, Br, H\_cJ and H\_k linear between the sheet's points and the nearest point outside them with an outsideMaterialData warning; any other grade's values are the caller's, and the grade must name its sheet; demagCurve:\[\[H,B\]\]? (field.lineProfile, field.regionTable, magnetics.fieldFluxMap, magnetics.fieldSolve {dimension: 3} and field.force {dimension: 3} only, every other command refuses it: the grade's normal demagnetization curve at temperatureC from the same data sheet, A/m and T, 2 to 200 points from \[0, Br\] with H and B both falling through the knee, its Br within 1 % of the grade's; the magnet is then solved by Newton's method on it, a reverse field along the magnetization on the curve and a forward or crosswise one on the recoil line, reversibly, with Br from the curve)) - `from`: \[x,y\] (mm) - `to`: \[x,y\] (mm) - `points`: int=101 (2 to 10000, both ends included) - `path`: \[\[x,y\]\]? (mm, a polyline for ∫H·dl; default the line from→to; repeat the first point to close it) - `csvPath`: str? (the .csv file to write, through the host's file service) ## Reply - currents - points:\[{sMm,xMm,yMm,region,bT,bxT,byT,hAPerM,hxAPerM,hyAPerM}\] - peakBT - flux:{wbPerM,wb}|null (axisymmetric: wb through the surface the line sweeps round the axis, the full turn, and wbPerM null) - mmf:{a,lengthMm,insideMm,closed} - csv - path - written - model - notes - preview - previewNote --- # New Field Study (`field.newStudy`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-newStudy/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-newStudy/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Adds a field study to the open circuit and makes it the live one: geometry.\* draws in it and the field solves run in it. The study before keeps its drawing, setup and results. At most 32 per circuit. ## Parameters - `dimension`: int=2 (2 or 3) - `name`: str? (default "Field 2D", or "L1 · 3D" for a part; made unique) - `part`: str? (the magnetic part it models, e.g. L1) - `from`: int? (a study to build it from: its part and setup are copied with the new dimension, so a 3D study opens from the 2D one without redrawing) - `setup`: object? (the solve params to start from, as magnetics.fieldSolve takes them) ## Reply - index - study --- # Open Field Example (`field.openExample`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-openExample/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-openExample/) **Menu:** **Design › Field Solver › Open Field Example** · **Runs as:** a job, with progress and Cancel > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. Opens a field-solver example solved: the drawing, the automatic mesh and Voltecx's own 2D solve, one winding at a time, then the example's check against its row of the accuracy report (docs/accuracy.md). e25BuckInductor is the gapped E 25/13/7 N87 reference inductor (34 turns, 1 mm gap; row mesher\_independence, L within 0.5 % of the Richardson-extrapolated 91.83 µH). e25FlybackTransformer winds the same core as a 1:1 coupled inductor, 25 turns each (row reciprocity, M12 within 0.5 % of M21). ringCoreChoke is a 30/20/5 mm ring core with 20 turns at μr 2208, drawn as an axisymmetric (r, z) section with a toroidal winding (row analytic\_toroid\_axisym, L within 1 % of the closed form 358.1 µH); its model also carries bAt, B in the core at 11 and 14 mm, and its field is the (r, z) section with symmetry "axisymmetric", ψ = 0 and toroidal:{regions,turns} (a toroidal winding's B is along φ, which ψ cannot carry, so the field view draws |B\_φ| = μ0 μr N I / (2π r) and no flux lines). potCore is a Ferroxcube P26/16 pot core (data sheet nominal dimensions) with a 1 mm centre-post gap and 34 turns at μr 2208, drawn as an axisymmetric (r, z) section and solved for ψ = r A\_φ (row energy\_vs\_flux\_linkage: L from flux linkage within 1e-6 of L from stored energy); its model carries lFromEnergy, lFromFieldEnergy, lFromFluxLinkage (H), gapMm, iterations, residual and provenance, and its field is ψ with symmetry "axisymmetric". twoWireLine is two round wires of 1 mm radius 20 mm apart, 1 m deep, go and return, with no core, drawn inside an open boundary (a circle of air of radius 60 mm and 4 graded-permeability shells, as magnetics.fieldSolve's sketch.openBoundary; model.openBoundary says so and the shells are regions of its field) (row open\_boundary\_two\_wire: L per metre in µH/m within 0.5 % of the closed form (μ0/π) arccosh(D/2a) + 2 μ0/(8π) = 1.297 µH/m). A job like magnetics.fieldSolve. Changes nothing in the circuit. ## Parameters - `name`: "e25BuckInductor|e25FlybackTransformer|ringCoreChoke|potCore|twoWireLine" - `field`: bool=true (also return the solved field, for the field view: A\_z of the planar examples, ψ = r A\_φ of potCore with symmetry "axisymmetric"; ringCoreChoke's section with ψ = 0 and its winding in toroidal:{regions,turns}, from which B\_φ is read) ## Reply magnetics.fieldSolve's reply plus example:{name,title:{en,zh-Hant},summary:{en,zh-Hant},row,metric,ours,reference,unit,errorPct,targetPct,pass} (with its warnings:\[{code,message,messageZh,data}\] as magnetics.fieldSolve gives them; the axisymmetric ringCoreChoke and potCore are not planarModel, and each warns linearMaterial for its core) --- # Open Field Study (`field.openStudy`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-openStudy/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-openStudy/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Makes a field study of the open circuit the live one; the one before keeps its drawing, setup and results. ## Parameters - `index`: int? | "name":str? ## Reply - index - study --- # Extract Conductor Impedance (PEEC) (`field.peec`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-peec/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-peec/) **Menu:** **Design › Field Solver › Extract Conductor Impedance (PEEC)** · **Runs as:** a job, with progress and Cancel > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. Partial-element (PEEC) extraction of straight conductors: each segment split into filaments across its section, the self and mutual partial inductances of parallel rectangular filaments from Hoer and Love's exact equations (1965) in their own frame, of filaments at an angle (45° tracks, the chords of an arc) from Neumann's integral (Grover 1946) over Gauss points of their sections, round sections as coaxial shells (a round segment beside a parallel rectangular one by Neumann's integral averaged over both sections, its logarithm exact at the geometric mean distance of the round one's axis from the rectangle, Grover 1946), each filament's resistance ρl/A, every mutual kept, and the network solved by modified nodal analysis (Ruehli 1972; Kamon, Tsuk and White 1994): by dense LU up to 2000 filaments, and up to 5000 by GMRES (Saad and Schultz 1986) with a preconditioner of each segment's own filaments, to a relative residual of 1e-11. A segment without its split gets the fewest filaments, graded by the ratio from the surface, whose surface filament is thinner than the skin depth at the highest frequency. Segments may run in any direction. A ground plane is a grid of nodes joined by segments as wide as the node spacing (FastHenry's uniform reference plane, User's Guide 3.0 §1.3.9), with holes cut as that guide cuts them; a nonuniform plane is a tree of cells halved only where its refinements ask (Kamon 1996). A busbar is a path of straight legs with one rectangular section, each leg a segment joined at the path's points as FastHenry joins segments at nodes. No capacitance in the port matrices, no magnetic material; \`capacitance\` gives the Maxwell matrix of the nets apart, by the moment method with rectangular panels (Ruehli and Brennan 1973). A \`current\` waveform gives its loss in the conductors as the sum over its harmonics of I² R(f) (Hurley, Gath and Breslin 2000). \`segmentCurrents\` gives each segment's share of a port's current, its loss and its peak current density. \`materialThresholds\` classifies the conductors as perfect, conducting or insulating by their conductivity. \`modelCheck\` finds gaps, small edges and slivers against given tolerances and heals them before the solve. Each conductor's \`skin\` names its skin-effect regime at the highest frequency. \`passivity\` checks every frequency's R and L for negative energy and asymmetry. \`sParameters\` gives the scattering matrix against a reference resistance (Pozar 2012, §4.3). \`export\` broadband fits one rational model over every solved frequency and writes it as a SPICE subcircuit (Gustavsen and Semlyen 1999). Checked against Hoer and Love's table 1, the round-wire Bessel impedance and FastHenry's output, including its ground-plane examples. Changes nothing. ## Parameters - `nodes`: \[{"name":str,"at":\[x,y,z\] (m)}\] - `segments`: \[{"name":str? (default S1, S2, …),"from":str (node name),"to":str (node name; the segment runs straight from \`from\` to \`to\`, in any direction),"width":m?,"height":m? (a rectangular section; the width lies along widthAxis),"widthAxis":"x|y|z"|\[x,y,z\]? (an axis or any vector, FastHenry's wx wy wz; at right angles to the segment; default in the x-y plane at right angles to it, as FastHenry: y for a segment along x, x for one along y or z),"nw":int?,"nh":int? (filaments across the width and the height; both or neither; default automatic),"radius":m? (a round section, instead of width and height),"shells":int? (coaxial shells of a round section; default automatic),"ratio":number=2 (each filament this much thicker than the one nearer the surface, at least 1; FastHenry's default),"resistivity":Ω·m? (default annealed copper at temperatureC, IEC 60028; 0 is a perfect conductor: no resistance, its current takes the distribution of least magnetic energy at every frequency, the high-frequency limit of a real metal; give its split (nw and nh, or shells), as it has no skin depth to choose one from; a model mixing perfect and resistive conductors or contacts is refused at 0 Hz),"temperatureC":°C=20 (copper only)}\] (nodes and segments may be left out when busbars or planes are given) - `busbars`: \[{"name":str,"path":\[\[x,y,z\] | {"arcTo":\[x,y,z\],"center":\[x,y,z\],"chords":int? (1 to 360; default from faceting)}\] (2 to 1000 entries along its centre line, m, the first a point; one straight leg from each point to the next; an arc runs from the point before it to arcTo about center, the shorter way round (more than 0° and less than 180°; both ends the same distance from center), as equal chords through points on the circle; the given points are nodes named \.1, \.2, … for segments, shorts and ports, the points between an arc's chords from given point k \.k.1, \.k.2, …; at most 1000 points with the chords),"width":m,"thickness":m,"normal":"x|y|z"|\[x,y,z\]? (the thickness direction, at right angles to the flat face; default z; each leg's width lies along normal × leg, and a leg along the normal keeps the width of the leg before it),"nw":int?,"nh":int? (filaments across the width and the thickness; both or neither; default automatic),"ratio":number=2,"resistivity":Ω·m? (0 is a perfect conductor, as for segments),"temperatureC":°C=20,"faceting":{"surfaceDeviationM":m?,"normalDeviationDeg":deg? (0.001 to 90; at least one)}? (its arcs' faceting, over the model's)}\]? (at most 64; a laminated busbar is one busbar per layer) - `planes`: \[{"name":str,"corners":\[\[x,y,z\],\[x,y,z\],\[x,y,z\]\] (three corners in order around a rectangle, on its mid-thickness; the edges may run in any direction, at right angles to 1e-5; the segments along one edge have their width along the other),"thickness":m,"seg1":int,"seg2":int (segments along the edges from corner 1 to 2 and from 2 to 3),"nh":int=1 (filaments across the thickness),"sheet":bool|"twoSided"|"oneSided"=false (a thin sheet, docs/specs/q3d-workflow R11; true is "twoSided": one filament across the thickness (nh left out or 1, also in a convergence pass) and each segment's resistance the internal impedance of a slab with equal fields on both faces, ρl/(wt)·x coth x with x = (1+j)t/(2δ) (Ramo, Whinnery and Van Duzer): ρl/(wt) at DC, half the surface impedance (1+j)ρl/(2wδ) once t ≫ δ, so its skin effect through the thickness costs no filaments; the partial inductance keeps the thickness, less the slab's DC internal part μ0·t·l/(12w) as the field leaves the slab; right for a plane whose current runs on both faces (far from its return); a plane over a close return carries it on the facing side only, where a two-sided sheet gives about half that loss: give it "oneSided" there, the slab driven from one face, ρl/(wt)·y coth y with y = (1+j)t/δ (Dowell 1966, one layer): ρl/(wt) at DC, the full surface impedance (1+j)ρl/(wδ) once t ≫ δ, less the one-sided DC internal part μ0·t·l/(3w); exact for the parallel-plate line as w/d grows (1 % from plates split through their thickness at w/d 1000, 5 % at 100, the fringe at the edges), wrong for a plane far from its return; not with resistivity 0; segment losses (segmentCurrents, current) use the same resistance; the reply's planes\[\].sheet and sheetSides),"ratio":number=2,"resistivity":Ω·m? (0 is a perfect conductor, as for segments),"temperatureC":°C=20,"nodes":\[{"name":str,"at":\[x,y,z\],"width":m?,"height":m?}\]? (each names the grid node nearest its point, for segments, shorts and ports; a point whose nearest node is in a hole is refused; on a nonuniform plane, \`width\` and \`height\` (both or neither, along the plane's first and second edges) join every plane node in that rectangle centred at \`at\` as one node, FastHenry's equipotential contact),"holes":\[{"kind":"point","at":\[x,y,z\]} (takes out the grid node nearest the point) | {"kind":"rect","corners":\[\[x,y,z\],\[x,y,z\]\]} (the nodes from the one nearest the first corner to the one nearest the second) | {"kind":"circle","at":\[x,y,z\],"radius":m} (the nodes within the radius of the point) | {"kind":"polygon","points":\[\[x,y,z\],…\]} (3 to 10000 points, projected onto the plane: the nodes inside it, even-odd rule) | {"kind":"outline","polygons":\[\[\[x,y,z\],…\],…\]} (1 to 4096 polygons, 100000 points in all: the nodes outside every one, so the plane keeps copper only inside its outline, a zone fill of any shape or in islands)\]? (at most 256; each takes out its nodes and every segment at them, FastHenry's hole point/rect/circle; polygon and outline are Voltecx's own),"nonuniform":{"hierarchy":str? (the cell tree as text: the number of cells, then one line per cell, \`\ NONE\` for a leaf or \`\ B EW|NS \ \\` for one halved by a line of constant x (east child first) or of constant y (north child first); the first cell is the root, the whole plane),"grid":{"rows":int,"columns":int,"mesh":bool=false (holes at every cell of even row from the north and even column from the west)}? (a starting grid of equal cells; not with hierarchy; neither gives one cell),"refinements":\[{"name":str? (default refinement \),"kind":"point|line|rect|decay","at":\[x,y,z\] (point, rect and decay: the point or centre),"from":\[x,y,z\],"to":\[x,y,z\] (line),"width":m,"height":m (rect, along the first and second edges),"dx":m,"dy":m (point, line and rect: halve every cell the point is in, the line touches or the rectangle overlaps until it is at most dx by dy),"size":\[m,m\],"cell":\[m,m\],"stop":\[m,m\] (decay: full sizes, cell limits and stop sizes along the two edges; rectangles grow from size, each with its cells up to a limit growing in proportion (cell over size below 1), until the half cell limit would pass half of stop, or the plane is covered; at most 64)}\]? (at most 256, in order)}? (a nonuniformly discretized plane, FastHenry 3.0's nonuniform reference plane: the cells start from the hierarchy, the grid or one root and are halved where the refinements ask; nodes at every leaf corner, hanging nodes included, and each segment as wide as half of each conductor cell beside it, with no overhang; instead of seg1, seg2 and holes; a convergence pass doubles the grid's rows and columns and halves every cell limit)}\]? - `shorts`: \[\[str,str\] | {"nodes":\[str,str\],"resistanceOhm":Ω (0 to 1; 0 is a plain short)}\]? (node names joined with no impedance, FastHenry's .equiv: a trace's end tied to the plane below it; the object form joins them through a contact resistance instead, a bolted or pressed busbar joint, a lumped resistor with no inductance in the network; Voltecx has no default for it: give the joint's measured value or its maker's figure) - `ports`: \[{"name":str,"plus":str,"minus":str} (node names; the current goes in at plus and out at minus)\] - `frequencies`: \[Hz | {"kind":"linearStep","start":Hz,"stop":Hz,"step":Hz} | {"kind":"linearCount","start":Hz,"stop":Hz,"count":int (2 or more, both ends)} | {"kind":"perDecade","start":Hz (above 0),"stop":Hz,"points":int (per decade)} | {"kind":"logCount","start":Hz (above 0),"stop":Hz,"count":int (2 or more, both ends, even on a log scale)}\] (values and generators, each generator expanded in place in the order given; 1 to 1000 frequencies in all, each at least 0; 0 gives the DC limit) - `export`: \["touchstone"|"table"|"spice"|"broadband"\]? (touchstone: the Z = R + jωL matrices as a Touchstone 1.1 file, \`# Hz Z RI R 1\`, the numbers in ohms, which needs the frequencies in increasing order; table: tab-separated, a header row, then the frequency and R(k,l) Ohm and L(k,l) H of every port pair, row-major; spice: a Berkeley SPICE .subckt of the R and L matrices at one frequency, a single-frequency lumped model: pins 1..N the ports' plus nodes, N+1..2N their minus nodes, each port a 0 V sense source, its self-resistance with a current-controlled current source per mutual resistance across it, and its self-inductance, every inductor pair coupled by a K element; broadband: a broadband rational-fit SPICE .subckt over every solved frequency, Z(s) ≈ D + sE + Σ R\_k/(s − a\_k) with one common set of real poles and complex pairs, fitted to Z = R + jωL itself by relaxed vector fitting (Gustavsen and Semlyen 1999; Gustavsen 2006; Deschrijver et al. 2008), unstable poles flipped, and drawn as its state-space model with controlled sources and one 1 F capacitor per state and port (Neumayer et al. 2002), pins as spice's; needs the frequencies in increasing order and at least two above 0 Hz; then made passive by default: where Re Z(jω) or D has a negative eigenvalue (on a dense grid, at the Hamiltonian's crossings and at ω → ∞) the residues and D, never the poles, take the least change that lifts it, pass after pass (an iterated fitting of passivity violations: Gustavsen and Semlyen 2001; Grivet-Talocia and Ubolli 2008), and a negative eigenvalue of E is clipped) - `broadband`: {"name":str="peec\_broadband" (1 to 64 characters, as spice's),"poles":int? (1 to 60, a pair counting 2; default 2 per decade of the band, 4 to 30, at most what the frequencies determine: each entry needs 2·poles + 3 real equations, 2 per frequency above 0 Hz and 1 at 0 Hz),"initialPoles":"complex|real"="complex" (complex pairs spread over the band with real parts 1/100 of their imaginary parts, or real poles spread over it),"iterations":int=10 (1 to 100; pole relocation passes, stopping early when the poles stop moving),"passivity":"enforce|check"="enforce" (enforce: make the fit passive, the reply's passivity.enforcement gives passes, passiveOnGrid, largestChange (over the largest entry at the solved frequencies), inductanceClipped and the fit's passivity and error before; check: only check it),"passes":int=30 (1 to 100; enforcement passes, with passivity enforce)}? (with broadband in export) - `spice`: {"frequencyHz":Hz? (one of the solved frequencies; default the only one, required with several),"name":str="peec\_ports" (the model name, 1 to 64 characters; any character but letters, digits and \_ becomes \_),"nets":\[str|null\]? (one capacitance signal net per port, in port order, or null for none; needs capacitance: the model then carries that Maxwell capacitance, a capacitor from each port's node to node 0 (the row sum) and one between each pair of ports' nodes (minus the Maxwell entry); signal nets no port names are held at 0 V; solved in a lossy dielectric, the export frequency's C and G, each conductance a resistor of 1/G beside its capacitor, RG to node 0 and RM between),"cells":int=1 (1 to 1000, needs nets: 1 is a T model, half R and L either side of one shunt block; more is a ladder of cells shunt blocks of C/cells between cells+1 series blocks, the two end ones R and L/(2 cells), the others R and L/cells)}? (with spice in export) - `converge`: {"targetPercent":number=1 (0.001 to 50),"maxPasses":int=4 (2 to 8)}? (a filament convergence study: solve as given, then with every split twice as fine (nw, nh and shells of each segment and busbar, seg1, seg2 and nh of each plane; each grading ratio its square root) until R and L change by less than targetPercent between passes, 100·max|ΔX|/max|X| over the entries of each matrix at every frequency; stops before a pass past 5000 filaments; the reply is the last pass) - `current`: {"port":str? (the port the current goes in at, the other ports open; default the only port),"waveform":\[\[t s,i A\]\] (one period, piecewise linear, 2 to 100000 points; a repeated time is a step) | "signal":str (a branch current of the last result, e.g. i(L1), instead of waveform),"periodS":s (with signal: the period to take),"t1":s? (with signal: where the period ends; default the run's end),"harmonics":int=15 (1 to 100)}? (PWM loss: the period's DC part and harmonics, each solved at its own frequency, 0 and n/T, and its loss I² R(f) summed by Parseval; the automatic splits are made for the highest harmonic) - `segmentCurrents`: {"port":str? (the port the current goes in at, the other ports open; default the only port),"amps":A=1 (rms, above 0, at most 1e6)}? (per-segment current and loss at every frequency of \`frequencies\`; at most 20000 rows, segments × frequencies) - `materialThresholds`: {"perfectSPerM":S/m?,"insulatorSPerM":S/m? (each above 0, at most 1e12; at least one; perfect above insulator)}? (what is a conductor, as a Q3D-class extractor classifies materials: a segment, busbar or plane whose conductivity 1/resistivity is at or above perfectSPerM is a perfect conductor (resistivity 0; an automatic split is still chosen from its own resistivity), at or below insulatorSPerM it is no conductor and carries no current (it leaves the network, its nodes stay for ports and shorts), strictly between it carries volume current as given; no defaults) - `modelCheck`: {"gapM":m?,"smallEdgeM":m?,"sliverM":m? (each above 0, at most 1000; at least one; no defaults),"heal":bool=true}? (small features of the drawn conductors before the solve, each check against its own tolerance, as a Q3D-class extractor analyses and heals geometry before meshing: two used nodes nearer than gapM that nothing joins are a gap, healed by a short between them; a segment or busbar leg shorter than smallEdgeM is a small edge, healed by taking the segment out and shorting its ends; a segment or busbar leg whose thinnest dimension (the smaller side of a rectangle, a round section's diameter, a tube's wall) is under sliverM is a sliver, healed by taking it out when other conductors still join its ends; small edges first, then gaps, then slivers; a heal that would short a port, a busbar leg and a sliver that is the only path are reported and kept; a plane's mesh is not checked; heal false only reports) - `passivityTolerance`: number=1e-6 (0 to 0.1; the passivity check's relative tolerance) - `sParameters`: {"z0Ohm":Ω=50 (above 0, at most 1e6; Touchstone 1.1's default reference)}? (the scattering matrix S = (Z + Z0·U)⁻¹(Z − Z0·U) of every frequency's Z = R + jωL, every port referred to z0Ohm; with it a touchstone export holds S, \`# Hz S RI R \\`, in place of Z) - `uniformCurrent`: "all"|\[str\]? (Uniform Current terminals, a Q3D-class extractor's terminal excitation: each named node, a port's plus or minus node and the end of exactly one segment, joined by no short, spreads the port's current over that conductor's section in proportion to each filament's cross-section, a uniform density approximating a point port, its voltage the filaments' end potentials averaged the same way; "all" makes every port end one; the others stay Constant Voltage, the default: every filament joined at one potential; a uniform terminal's self-inductance usually comes out higher) - `meshStatistics`: bool=false (the solve's profile and mesh statistics, a Q3D-class extractor's per-object element counts, edge lengths and areas) - `rlBlend`: {"acHz":Hz (above 0),"transition":true|{"relError":number=0.1 (1e-4 to 0.5),"maxPoints":int=16 (2 to 64)}?}? (q3d-mesh-sweep R9: solve at 0 Hz and acHz only and give R and L at every frequency asked from Z = Z1 + Z2‖Z3, Z1 = R\_dc + jωL\_ac, Z2 = jω(L\_dc − L\_ac), Z3 = R\_ac·√(jω/(π·acHz)): R\_dc and L\_dc at low frequency, L\_ac and R growing as √f at high frequency; a rough estimate for two solves; when L\_dc is not above L\_ac every frequency is solved instead and rlBlend.reason says why; not with segmentCurrents; the reply rlBlend has acHz, solvedHz, blended, the dc and ac matrices, minEigenDeltaLH and reason; with \`transition\` (q3d-mesh-sweep R10, power electronics; needs acHz above 1 kHz) extra points are solved between 1 kHz and 1 MHz (or acHz if lower), each interval's geometric middle tested widest first until the curve is within relError in R and L or maxPoints are solved, and every frequency asked, the exports included, comes from the blend corrected through every solve (monotone cubic in ln f); rlBlend.transition gives relError, maxPoints, applied (false when the blend was not made), bandHz, converged and points \[{frequencyHz, errorBefore}\], and solvedHz lists every solve) - `magneticHalfSpace`: {"axis":"x|y|z","at":m,"muR":number,"thickness":m?}? (a half-space of non-conducting magnetic material, a ferrite plate or a core face, filling everything beyond the plane axis = at from the conductors, which must all lie on one side of it and may touch it; muR above 0 and at most 1e6; solved by the magnetostatic image, Jackson Problem 5.17: each partial inductance gains k = (muR − 1)/(muR + 1) times its mutual with the other conductor's mirror image, whose current along the interface runs the same way and across it the other way; infinite and non-conducting, so a plate thick and wide against the conductors' distance, and steel only below its eddy range; with thickness (above 0) the material is a plate of that thickness beyond the interface and free space past it, solved by its image series (the plate's reflection k(1 − e^(−2κt))/(1 − k² e^(−2κt)), Jackson §5.9: the mirror image, then images n·thickness farther of strength −(1 − k²)k^(2n−1), cut when the rest is below 1e-9 of the first image's scale or at 512 images); the reply's magneticHalfSpace gives imageCoefficient k, and for a plate imageTerms and seriesBound (0 unless the cap stopped the series); muR 1 is free space) - `meshOperations`: \[{"kind":"length","objects":\[str\]? (plane names; default every uniform plane),"maxLengthM":m (above 0, at most 1000; the longest a plane segment may be),"maxAdded":int? (1 to 20000; the most plane segments, before holes, the operation may add)} | {"kind":"resolution","objects":\[str\]? (plane names; default every uniform plane),"lengthM":m (above 0, at most 1000; the model resolution)}\]? (at most 64; a Q3D-class extractor's mesh operations. length: each named uniform plane's seg1 and seg2 are raised to the fewest that keep every segment along that edge at most maxLengthM, never lowered; with maxAdded both move together toward that only as far as the cap allows; where several operations name a plane the finer count wins along each edge. resolution: each named uniform plane's holes whose drawn size (a circle's diameter, a rectangle's or polygon's smaller extent along the plane's edges, 0 for a point hole; an outline is never dropped) is under lengthM are dropped, the copper kept there; where several name a plane the smallest length wins. A segment, busbar or nonuniform plane named is refused, as straight conductors cut along their length add up to the same R and L, their small features are modelCheck's, and a nonuniform plane has its own refinements) - `faceting`: {"surfaceDeviationM":m? (the farthest a chord may lie from its arc, its sagitta; above 0, at most 1000),"normalDeviationDeg":deg? (the largest angle between neighbouring chords; 0.001 to 90)}? (at least one; a Q3D-class extractor's curved-surface faceting by surface and normal deviation: each busbar arc without chords takes the fewest equal chords keeping both, a busbar's own faceting over this one; no default, so an arc with neither chords nor faceting is refused) - `capacitance`: true|{"nets":\[{"name":str (1 to 64 characters),"objects":\[str\] (segment, busbar and plane names),"type":"signal|ground|floating"="signal" (a Q3D-class extractor's net types: a signal net is a row of the matrix; a ground net is held at 0 V in the solve and leaves the matrix, its rows and columns deleted; a floating net carries no net charge and leaves it by the Schur complement; not every net ground or floating)}\]? (1 to 64; default every connected piece of the model one net, named after its first object),"unnetted":"omit|ground"="omit" (with nets: the conductors named in no net are left out of the field (omit) or sit in it at 0 V as one ground net (ground), a Q3D-class extractor's un-netted conductor; a conductor joined to a net's conductor cannot be grounded apart and is refused),"priority":\["signal|ground|floating"\]? (with nets: the net types, highest first, that settle an object named in nets of two types: the higher type's net keeps it; without it, or for two nets of one type, an object in two nets is refused),"epsR":number=1 (1 to 1e4; one homogeneous dielectric everywhere),"maxPanelM":m? (the longest panel side on a box face, above 0, at most 1000; default a tenth of the conductors' largest extent),"panelsPerEdge":int=4 (1 to 200; the fewest panels along each side of a face, cut points graded to its edges),"roundFacets":int=16 (4 to 64; the flat facets round a round or tube section, its corners placed where the polygon has the circle's own 2D logarithmic capacity, Pólya and Szegő 1951, and a tube's bore where its inner conformal radius is the bore's; one panel across each facet, graded panels along it, the end faces in rings),"lossTangent":number? (0 to 1; the dielectric's tanδ, at every frequency or, with causal, at atHz),"conductivitySPerM":S/m? (0 to 1000; the dielectric's DC conductivity, a leaky insulator),"causal":{"atHz":Hz (between the corners),"upperCornerRadS":rad/s (no default),"lowerCornerRadS":rad/s=1e4 (1e-3 to 1e18, below upper),"epsStatic":number? (the DC permittivity ε(0), above epsR; solves the lower corner instead, so not with lowerCornerRadS)}? (a Q3D-class extractor's causal lossy dielectric: epsR and lossTangent become the values at atHz of the wide-band model of Djordjevic, Biljić, Likar-Smiljanić and Sarkar (2001), ε∞ + a·ln((ω2 + jω)/(ω1 + jω)), its ε′ and ε″ a Kramers–Kronig pair; a lossless material (lossTangent 0) or epsR 1 is left constant; a fit with ε∞ below 1 is refused),"dielectrics":\[{"name":str? (1 to 64 characters; default dielectric \),"min":\[x,y,z\],"max":\[x,y,z\] (m; opposite corners of an axis-aligned box, within ±1e4 m),"epsR":number (1 to 1e4),"lossTangent":number?,"conductivitySPerM":S/m?,"causal":{...}? (the block's loss, as the background's; without them the block is lossless)}\]? (1 to 16 dielectric blocks in the background epsR; blocks of one material (the same epsR and loss) may overlap, the smaller one winning and the larger cut around it into touching pieces (q3d-mesh-sweep R6's material override; reply dielectrics.materialOverride \[{kept, cut}\] and a cut block's pieces), blocks of two materials must not; blocks may touch face to face, a stack of laminates of different εr, each shared face one interface between the two blocks' εr: a non-homogeneous dielectric, a laminated busbar's film or a board's laminate, solved with bound charge on the block faces, normal D continuous across them (Rao, Sarkar and Harrington 1984); block faces on or inside a conductor are left out; with a lossy block or a lossy background, each frequency's C and G come from the same solve with every medium's complex permittivity ε′ − j(ε″ + σ/(ω ε0)), C = Re K and G = −ω Im K of its complex matrix K, the grounded and floating nets reduced over K; one solve per distinct set of permittivities, at most 64; a conductivity at 0 Hz is refused),"bodies":\[{"name":str (1 to 64 characters; not a drawn conductor's name),"path":str (an STL, STEP or IGES file, read through the host's file service as magnetics.fieldSolve's import reads it),"unitMm":number? (millimetres per file unit, 1e-6 to 1e6; default 1 for STL, the file's own unit for STEP and IGES)}\]? (1 to 16 imported bodies, conductors of their own in the capacitance only (a heatsink, a baseplate; no current in the R/L network): every closed solid of the file is part of the one conductor, named in nets like any drawn object (without nets each body is a net of its own); its facets are cut into flat triangular panels of uniform charge, each side at most maxPanelM, with the closed-form potential of a uniformly charged triangle (Wilton et al. 1984); a curved body is the polyhedron its file draws; with dielectrics its facets are cut at the blocks' face planes and each piece faces the medium it touches, and block faces on a body or inside it are left out; with a lossy block or a lossy background its triangles take the complex permittivity they face in each frequency's C and G solve)}? (the Maxwell capacitance matrix between the nets, a Q3D-class extractor's C solve, by the moment method with rectangular panels of uniform charge (Ruehli and Brennan 1973), the zero of potential at infinity; rectangular and round segments, busbars, uniform planes (their holes cut) and nonuniform planes (their conductor cells, walls on the outline and round hole cells); at most 2500 panels) ## Reply - ports:\[str\] - terminals:\[{port,end:"plus|minus",node,excitation:"constantVoltage|uniformCurrent"}\] - filaments:int - splitAtHz:number|null (the frequency the automatic splits were made for) - segments:\[{name,axis:"x|y|z|oblique",section:"rect|round",nw,nh,shells,ratio,auto,resistivity,skin:{frequencyHz (the highest of the solve),skinDepthM|null (√(ρ/(π f μ0)); null at 0 Hz; 0 for a perfect conductor),depthM:\[least,most\] (how deep the current must reach: a round radius, a tube wall, half of each side of a rectangle, half a plane thickness),depthOverSkin:\[least,most\]|null,regime:"dc|mixed|ac|perfect" (dc: every depth under δ, the current fills the section; ac: every depth over δ, it crowds into the skin; mixed: one each way; perfect: resistivity 0, no skin depth, at every frequency)}}\] - busbars:\[{name,nodes:\[str\],legs:int,nw,nh,auto,skin,arcs:\[{from,to (the given points it joins, from 1),radiusM,angleDeg,chords,chordsGiven,surfaceDeviationM (each chord's sagitta, r(1 − cos(θ/2n))),normalDeviationDeg (θ/n, the angle between neighbouring chords)}\]}\] - planes:\[{name,discretization:"uniform|nonuniform",segments:int (after its holes),leaves:int|null (a nonuniform plane's leaf cells, holes included),nodes:\[{name,gridNode}\],skin,sheet:bool,sheetSides:"twoSided|oneSided"|null}\] - frequencies:\[{frequencyHz,resistanceOhm:\[\[Ω\]\],inductanceH:\[\[H\]\],inductanceNh:\[\[nH\]\]}\] (row k, column l: the voltage at port k for a current into port l) - exports:{touchstone:{extension:"s\p",text},table:{text},spice:{frequencyHz,name,pins:\[{pin,port,terminal:"plus|minus",node}\],extension:"cir",text},broadband:{name,order,initialPoles,iterations (passes run),poles:\[{kind:"real|pair",re,im} (rad/s; a pair by its member with im above 0)\],states (all ports' state nodes),constantOhm:\[\[Ω\]\] (D),inductanceH:\[\[H\]\] (E),rmsError,worstError (the fit against the solved rows: max over the entries of |Z\_fit − Z| over the largest |Z| entry, its rms over the frequencies and its worst),worstAtHz,bandHz:\[lowest,highest\],passivity:{passive,relativeMinEigen (the smallest eigenvalue of Re Z\_fit over its largest magnitude, the worst on a grid from 0 Hz and 20 per decade from a decade below the band to a decade above),atHz,inductanceRelativeMinEigen (E's)},pins,extension:"cir",text}}|null (the formats asked for in \`export\`) - convergence:{targetPercent,converged:bool,stop:"converged|maxPasses|filamentLimit|cancelled",deltaPercent:number|null (the last change),passes:\[{refine (the split multiplier: 1, 2, 4, …),filaments,deltaPercent|null,resistanceDeltaPercent|null,inductanceDeltaPercent|null}\]}|null (with \`converge\`) - current:{port,trace:{signal,window:\[t0,t1\],samples}|null (with signal: the period taken, its ends interpolated),periodS,fundamentalHz,dcA,rmsA,capturedPct (the share of the mean square the DC part and the harmonics taken carry),dcResistanceOhm,harmonics:\[{n,frequencyHz,rmsA,resistanceOhm,acFactor (R(n/T)/R(0)),lossW}\],dcLossW,harmonicLossW,totalLossW,effectiveResistanceOhm (totalLossW over the captured mean square),acFactor,dcOnlyLossW (rmsA² R(0))}|null (with \`current\`) - segmentCurrents:{port,amps,frequencies:\[{frequencyHz,totalLossW (the segments' losses: amps² Re Z of the port, less any contact resistance's loss),segments:\[{name,currentA (rms, the filaments' sum from its first node to its second),phaseDeg (against the port current),lossW (Σ |I|² R over its filaments),lossPct,peakDensityAPerMm2 (its densest filament)}\]}\],hotSpot:{segment,frequencyHz,peakDensityAPerMm2}|null}|null (with \`segmentCurrents\`) - materials:{perfectSPerM,insulatorSPerM,conductors:\[{name,kind:"segment|busbar|plane",conductivitySPerM|null (null for resistivity 0),class:"perfect|conductor|insulator"}\]}|null (with \`materialThresholds\`) - modelCheck:{gapM,smallEdgeM,sliverM,heal,findings:\[{kind:"gap|smallEdge|sliver",segment:str|null,nodes:\[str,str\],sizeM (the gap, the length or the thinnest dimension),fix:"joined|collapsed|removed|kept",why:"healingOff|shape|wouldShortPort|onlyPath"|null}\],healed:int,kept:int}|null (with \`modelCheck\`; the segments taken out are not in segments) - passivity:{tolerance,passive:bool,frequencies:\[{frequencyHz,passive,resistance:{minEigenOhm,maxEigenOhm,relativeMinEigen,asymmetry,passive},inductance:{minEigenH,maxEigenH,relativeMinEigen,asymmetry,passive}}\]} (always: a passive network of conductors has R and L positive semidefinite and symmetric; a matrix passes when its symmetric part's smallest eigenvalue is at least -tolerance times its largest magnitude and max|M - Mt|/max|M| is at most the tolerance) - sParameters:{z0Ohm,frequencies:\[{frequencyHz,real:\[\[number\]\],imag:\[\[number\]\],magnitudeDb:\[\[number|null\]\] (20·log10|S|; null for 0)}\]}|null (with \`sParameters\`; row k, column l: the wave out of port k for a wave into port l) - meshStatistics:{solver:"denseLu|gmres" (the dense LU up to 2000 filaments, GMRES past them),filaments,unknowns (one current per filament and contact, one potential per electrical node that is not a reference),objects:\[{name,kind:"segment|busbar|plane",segments (a busbar's legs, a plane's mesh segments; 0 for an insulator),filaments,lengthM:\[least,most\]|null (its segments' lengths),filamentSideM:\[least,most\]|null (filament sides across the section: a rectangle's smaller and larger side, a shell's radial thickness),filamentAreaM2:\[least,most\]|null (filament cross-sections)}\] (the params' segments, then the busbars, then the planes, as given)}|null (with \`meshStatistics\` true) - meshOperations:{operations:\[{kind:"length",objects:\[str\] (the uniform planes it applied to),maxLengthM,maxAdded|null} | {kind:"resolution",objects:\[str\],lengthM}\],planes:\[{name,given:\[seg1,seg2\],used:\[seg1,seg2\] (before a convergence pass multiplies them),addedSegments (before holes),capped:bool (a maxAdded stopped it short)}\] (the planes a length operation names),droppedHoles:\[{plane,hole (its place in the plane's holes, from 1),kind:"point|rect|circle",sizeM (its drawn size),lengthM (the resolution that dropped it)}\]}|null (with \`meshOperations\`) - capacitance:{reference:"infinity|infinity and the grounded nets",epsR,maxPanelM,panelsPerEdge,roundFacets,panels,asymmetry (the largest |C\_ij − C\_ji| of the point-matched matrix over its largest diagonal entry; the reply is its symmetric part),nets:\[{name,objects:\[str\],kinds:\["segment|busbar|plane"\],panels}\],maxwellF:\[\[F\]\],maxwellPf:\[\[pF\]\] (C\_ij: the charge on net i with net j at 1 V and the others at 0 V),toInfinityF:\[F\] (each row's sum),pairs:\[{a,b,mutualF,mutualPf (−C\_ab),betweenF,betweenPf (the capacitance between a and b with every other net floating)}\],leftOut:\[str\] (objects in no net, left out of the field),groundedNets,floatingNets:\[{name,objects,kinds,panels}\] (the nets held at 0 V and those with no net charge, which are not rows of maxwellF; the objects unnetted ground puts at 0 V are the net (unnetted)),groundedObjects:\[str\],resolved:\[{object,nets:\[str,str\],kept}\] (each object priority settled) (these four only with a ground or floating net, or a priority that settled one),dielectric:{model:"constant|wideband",epsR,lossTangent,conductivitySPerM,atHz?,lowerCornerRadS?,upperCornerRadS?,epsInf?,epsStatic? (ε at 0 Hz),slope? (a),causalUntouched? (true: causal asked, the material lossless)},frequencies:\[{frequencyHz,epsR (ε′),epsRImag (ε″, without σ),lossTangent|null ((ω ε0 ε″ + σ)/(ω ε0 ε′); null at 0 Hz with σ),maxwellF:\[\[F\]\],conductanceS:\[\[S\]\] (in one dielectric C(f) = ε′(f)/εr · C and G(f) = (ω ε0 ε″(f) + σ)/(ε0 εr) · C, C the solved maxwellF; at most 200000 entries, nets² × frequencies),toInfinityF:\[F\],toInfinityS:\[S\],pairs:\[{a,b,betweenF,betweenS}\]}\] (these two only with lossTangent, conductivitySPerM or causal, or a lossy block; beside blocks, a row's epsR, epsRImag and lossTangent are the background's and only when it is lossy),dielectrics:{blocks:\[{name,min,max,epsR,interfacePanels,dielectric? (a lossy block's model, as dielectric)}\],interfacePanels,droppedFacePanels (block-face panels on or inside a conductor)} (only with dielectrics)}|null (with \`capacitance\`) - notes - warnings:\[{code (noMagneticMaterial, noCapacitance, aboveQuasiStaticLimit: the highest frequency is above c0 / (10 · the nodes' bounding-box diagonal), where the structure in air is a tenth of a wavelength; data extentM, epsilonR, limitHz, highestHz; notPassive: R or L fails the passivity check, at its worst frequency; data matrix, failing, frequencyHz, relativeMinEigen, asymmetry, tolerance; fitNotPassive: the broadband fit's Re Z or E has a negative eigenvalue below -1e-6 of its largest; data relativeMinEigen, frequencyHz, eRelativeMinEigen),message,messageZh,data}\] - sources --- # Import DXF Conductors for PEEC (`field.peecImportDxf`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-peecImportDxf/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-peecImportDxf/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. Reads a 2D DXF layout (LINE, ARC, CIRCLE, LWPOLYLINE, POLYLINE in model space) and places each stackup layer at its elevation and thickness, as a Q3D-class extractor imports layout with a layer map: each closed rectangular outline becomes one rectangular field.peec segment along its longer side (width the shorter side, height the layer thickness, at the middle of the copper), ends on one layer within the join tolerance are one node, each stackup layer is joined apart from the others (they overlap in the plane), and every outline that is not a rectangle, is on a layer the stackup leaves out, or overlaps another on its layer, and every edge that closes no outline, is listed in skipped with its reason. Adds to the model given, never replaces it; a non-ASCII layer name fails the import. Changes nothing. ## Parameters - `text`: str (the DXF file's text) | "path":str (a .dxf file, through the host's file service) - `unit`: "mm|m|cm|dm|um|in|mil|ft"="mm" (the unit of a drawing whose header gives no $INSUNITS) - `toleranceM`: m? (ends nearer than this are joined; default a millionth of the drawing's diagonal) - `stackup`: \[{"layer":str (a DXF layer name, ASCII),"elevationM":m (the bottom of its copper),"thicknessM":m (above 0),"resistivity":Ω·m?,"temperatureC":°C? (copied to each segment, as field.peec takes them; default annealed copper at 20 °C)}\] (1 to 64 layers, each once; the layer map) - `model`: object? (field.peec params to add to; their nodes and segments are kept and the import's appended, everything else is left as given) - `prefix`: str="dxf" (ASCII; segments are named \1, \2, … and nodes \.n1, …, numbered past the names the model already has) ## Reply - model (the field.peec params with the import added; give it ports and frequencies and run field.peec) - imported:\[{segment,atM:\[x,y\] (a corner of its outline),layer,from,to,lengthM,widthM,thicknessM}\] - skipped:\[{atM:\[x,y\]|null (a point of the outline or edge),line|null,entity|null,layers,reason}\] - unit - unitFromFile - toleranceM - notes --- # Import GDSII Conductors for PEEC (`field.peecImportGds`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-peecImportGds/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-peecImportGds/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. Reads a GDSII layout, flattens the picked structure (SREF and AREF with reflection, magnification and rotation) and places each stackup row at its elevation and thickness, as a Q3D-class extractor imports layout with a layer map: each rectangular BOUNDARY, BOX or NODE becomes one rectangular field.peec segment along its longer side, each straight PATH leg one segment of the path's width from vertex to vertex (path types 0, 2 and 4; the first and last legs run on by the extensions), every other BOUNDARY, BOX or NODE becomes one field.peec plane (a pour of any outline: a uniform plane over its bounding box with nodes at the centres of planeCells equal cells and an outline hole taking out every node whose centre is outside the polygon, so it carries exactly the cells inside, at most 16 planes in the model), ends on one row within the join tolerance are one node, an end inside a pour on its row is shorted to the pour's nearest kept node (joined), a leg or rectangle wholly on one pour is left out, each polygon on a vias layer is one via (a field.peec segment at right angles to the board from the lower row's copper mid-plane to the upper row's; a rectangle keeps its section, any other polygon is a round section of its own area at its centroid; each end lands on a track end inside the via, else splits the track under its centre there, else is shorted to the pour under it, else lands on nothing, and a via node off its landing point is joined to it by a short), rows are joined only by vias, and everything else (overlapping vias, paths on a via layer, overlapping pours, pours holding fewer than two cell centres, round-ended paths, layers the stackup leaves out, overlapping rectangles, TEXT) is listed in skipped with its reason. Adds to the model given, never replaces it; a non-ASCII structure name fails the import. Changes nothing. ## Parameters - `path`: str (a GDSII stream file, .gds/.gdsii, through the host's file service) - `structure`: str? (the structure to import; default the file's one top structure, and a file with several asks for one) - `nodes`: "boundaries|ignore"="boundaries" (NODE records become boundaries, or are left out) - `toleranceM`: m? (ends nearer than this are joined; default half a database unit) - `stackup`: \[{"layer":int (0 to 32767, a GDSII layer number),"datatype":int? (0 to 32767; default every data type of the layer),"elevationM":m (the bottom of its copper),"thicknessM":m (above 0),"resistivity":Ω·m?,"temperatureC":°C? (copied to each segment, as field.peec takes them; default annealed copper at 20 °C)}\] (1 to 64 rows, no two matching one element; the layer map) - `vias`: \[{"layer":int (0 to 32767, a GDSII layer holding via cuts, not a stackup row),"datatype":int? (default every data type),"from":int,"to":int (the layer numbers of the two stackup rows it joins, each layer with one row, at different heights),"resistivity":Ω·m?,"temperatureC":°C? (as a stackup row; default annealed copper at 20 °C)}\]? (at most 64 rows; segments named \.via1, …) - `model`: object? (field.peec params to add to; their nodes and segments are kept and the import's appended, everything else is left as given) - `prefix`: str="gds" - `planeCells`: int=16 (2 to 64; cells along the longer side of each pour's bounding box) (ASCII; segments are named \1, \2, … and nodes \.n1, …, numbered past the names the model already has) ## Reply - model (the field.peec params with the import added; give it ports and frequencies and run field.peec) - imported:\[{segment,atM:\[x,y\],layer,datatype,structure,element,from,to,lengthM,widthM,thicknessM} | {via,atM,layer,datatype,structure,element,from,to,rows:\[lower,upper\] (stackup layer numbers),lengthM,section:"round|rect",radiusM,widthM,heightM,areaM2,lands:\[lower,upper\] ("trackEnd|track|plane|nothing")} | {plane,atM,layer,datatype,structure,element,points,areaM2,cells:\[nx,ny\],cellM:\[hx,hy\],nodesKept,thicknessM}\] - skipped:\[{atM:\[x,y\]|null,layer|null,datatype|null,structure,element,reason}\] - joined:\[{node,plane,planeNode,offsetM}\] (segment ends shorted to a pour) - structure - structures (the file's top structures) - metresPerUnit - toleranceM - notes --- # Insert Conductor Impedance into Circuit (`field.peecInsert`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-peecInsert/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-peecInsert/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. Puts the conductor impedance a field.peec solve gave into the open circuit as one undo step: each port in series with the part's terminal (the terminal moves to a new net peec\_\\_\, the winding joins it back). One port becomes an inductor (L, dcr = R); two become one coupled inductor (l1, l2, rw1, rw2 and k = M/√(L1 L2), the second winding turned round when M is negative). The ports left out are open, so the inserted matrix is the solved one's rows and columns for them. The mutual resistance has no place in a coupled inductor: it is left out and its size is given. Three or more ports: use field.peec's export spice. With \`capacitance\`, the solved Maxwell capacitance goes in as two-terminal capacitors Cpeec\_\ to ground and Cpeec\_\\_\ between nets, whose nodal matrix is the solved one; a lossy dielectric's conductance goes in beside them as resistors Rpeec\_\ and Rpeec\_\\_\ of 1/G (Pozar 2012, §2.1). A second run updates the parts of the same names. ## Parameters - `peec`: object (a field.peec reply, or its \`ports\` and \`frequencies\`) - `frequencyHz`: number? (the solved row to insert; required when the reply has several frequencies) - `at`: \[{"port":str (a port of the reply),"part":str (a part of the open circuit),"pin":str (its terminal the port goes in series with),"reverse":bool=false (the port current flows out of the terminal into the net, not in)}\] (1 or 2 ports, each once; may be left out when \`capacitance\` is given) - `capacitance`: \[{"net":str (a signal net of the reply's \`capacitance\`, from field.peec {capacitance}),"circuitNet":str (a net of the open circuit, not a ground net)}\]? (1 to 16, each net and circuit net once: one capacitor from each net to the circuit's ground, its Maxwell row sum over the nets listed, and one between each pair, minus the Maxwell entry; a solved net left out is held at 0 V; solved in a lossy dielectric, the C and G of the capacitance row at frequencyHz, each capacitor with a resistor Rpeec\_… of 1/G in parallel) ## Reply - frequencyHz - inserted:\[{name, kind:"inductor|coupledInductor", ports, nets:\[\[from, to\]\], valueH|{l1H, l2H, k}, dcrOhm|{rw1Ohm, rw2Ohm}, mutualResistanceOhm|null, updated, at} | {name, kind:"capacitor", capacitanceNets:\[str\], nets:\[\[from, to\]\], valueF, valuePf, updated, at} | {name, kind:"resistor", capacitanceNets:\[str\], nets:\[\[from, to\]\], valueOhm, conductanceS, updated, at}\] - notes:\[{en, zh}\] --- # Reduce Conductor Impedance Matrix (`field.peecReduce`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-peecReduce/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-peecReduce/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. Runs the matrix reductions of a Q3D-class extractor (docs/specs/q3d-matrices/SPEC.md R2 to R6, R10) on the port matrix a field.peec solve gave, without solving again: return path (loop L from partials), join in series or parallel (parallel dies or terminals), reverse, float, ground, move and add sink; and gives the coupling coefficients k = |Xij| / √(Xii Xjj) of the result (R12). With field.peec's other ports open, each is exact for the structure it describes. The reply has field.peec's ports and frequencies, so it goes on to field.peecInsert. Changes nothing. ## Parameters - `peec`: object (a field.peec reply, or its \`ports\` and \`frequencies\`; or a field.peecReduce reply) - `frequencyHz`: number? (one solved row; default every row) - `ops`: \[{"op":"returnPath","port":str (this port carries the others' return current: each other port k becomes the loop out through k and back through it, L'ij = Lij − Lip − Ljp + Lpp, the same for R; the port is removed)} | {"op":"joinSeries","ports":\[str,str\] (the second port's minus joined to the first's plus: one port named after the first, L = L11 + L22 + 2 L12)} | {"op":"reverse","port":str (plus and minus swapped: its mutual terms change sign)} | {"op":"joinParallel","ports":\[str,str\] (both plus nodes joined and both minus nodes joined, one port named after the first; a 3-port matrix only, as SPEC R5 gives it; a lossy row through Z = R + jωL at its frequency)} | {"op":"float","ports":\[str\] (left open: removed, every other entry unchanged)} | {"op":"ground","port":str (shorted: one elimination step on Z = R + jωL, which needs a frequency above 0 when R is not 0)} | {"op":"moveSink","port":str (a 3-port matrix: this port's terminal becomes the common sink, L'ij = Lij − Lik − Ljk + Lkk, L'ik = Lkk − Lik; R carried over)} | {"op":"addSink","ports":\[str\] (each shorted to the sink, for L; R's rows and columns dropped)}\] (1 to 64, applied in order) ## Reply - ports:\[str\] - frequencies:\[{frequencyHz,resistanceOhm:\[\[Ω\]\],inductanceH:\[\[H\]\],inductanceNh:\[\[nH\]\],couplingL:\[\[k\]\],couplingR:\[\[k\]\]|null (null when a self-resistance is 0)}\] - ops:\[str\] - notes - sources --- # Field Region Table (`field.regionTable`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-regionTable/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-regionTable/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** a job, with progress and Cancel > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. Solves the model as magnetics.fieldSolve meshes it (magnetostatic, linear materials) with the currents given, all at once, and integrates over each region (one per label, in label order): its meshed area, the current through it (turns × amperes), the mean vector potential (a one-turn coil side's flux linkage per metre), the stored energy ½∫B·H through the model's depth (in a magnet ½μ|H|², its energy on the recoil line from the remanent state H = 0) and the co-energy ∫B·dH (equal to the energy in a linear region; ½μ|H|² + Br·H in a magnet), the Lorentz force on its current, and the peak |J×B| and |B| on one element, with the 99th percentile by area (bP99BT: the |B| below which 99 % of the region's area lies, the rule the saturation check and the corner warning read), the 99th percentile by element count (p99BT: the element at index ⌊0.99 n⌋ of the ascending list, which moves with the mesh) and the area-weighted mean of element |B| beside it and whether that peak is on a corner of the drawing (a singularity of the field that grows as the mesh is refined). With no magnet the energies add up to ½ Σ L I² of the windings; energy plus co-energy over the model is always the current term ∫J·A dV. The CSV is in SI units. Changes nothing. ## Parameters - `design`: object? (a magnetics.design reply, or its best design) - `sketch`: object? (instead of design: the planar drawing magnetics.fieldSolve takes, in mm; field.lineProfile, field.regionTable and field.calculator also take an axisymmetric (r, z) section, axisymmetric: true with no depthMm, revolved a full turn, its magnets' direction \[r, z\] in the section) - `muR`: number? (design only) - `clearanceMm`: number=0.1 (design only) - `elementMm`: number? (largest element in the core and the windings, 0.01 to 50 mm) - `currents`: object? ({circuit: amperes}; default 1 A in every circuit; a circuit left out carries none) - `magnets`: \[{region:str (the name of a region of the drawing that is not a coil; with a design, \\"centre-leg gap\\" draws the centre leg's gap as its own region, a slot the magnet fills, refused for a ring or a gapless design),direction:\[x,y\] (the magnetization direction, any length; \[r, z\] in an axisymmetric section),temperatureC:number,grade:str (a built-in grade: Arnold N35, Arnold N42, Arnold N42H or Arnold N42UH, sintered NdFeB, each from its Arnold Magnetic Technologies data sheet) | {name:str,source:str (the data sheet the values come from: document, revision, table),recoilMuR:number (≥ 1),points:\[{temperatureC,brT (remanence),hcjAPerM (intrinsic coercivity),hkAPerM (knee field, H\_k ≤ H\_cJ)}\] (1 to 64, rising temperature)}}\]? (permanent magnets, at most 64: each region becomes a magnet on its recoil line B = μ0 μrec H + Br at the temperature, Br, H\_cJ and H\_k linear between the sheet's points and the nearest point outside them with an outsideMaterialData warning; any other grade's values are the caller's, and the grade must name its sheet; demagCurve:\[\[H,B\]\]? (field.lineProfile, field.regionTable, magnetics.fieldFluxMap, magnetics.fieldSolve {dimension: 3} and field.force {dimension: 3} only, every other command refuses it: the grade's normal demagnetization curve at temperatureC from the same data sheet, A/m and T, 2 to 200 points from \[0, Br\] with H and B both falling through the knee, its Br within 1 % of the grade's; the magnet is then solved by Newton's method on it, a reverse field along the magnetization on the curve and a forward or crosswise one on the recoil line, reversibly, with Br from the curve)) - `csvPath`: str? (the .csv file to write, through the host's file service) ## Reply - currents - rows:\[{region,name,areaMm2,currentA,meanAWbPerM,energyJ,coenergyJ,forceN:\[x,y\],peakForceDensityNPerM3,peakBT,p99BT,bP99BT,meanBT,peakAtCorner}\] - energyJ - coenergyJ - csv - path - written - model - warnings?:\[{code,message,messageZh,data}\] (cornerPeak for a core region whose peak is on a corner; left out when there is none) - notes - preview - previewNote --- # Rename Field Study (`field.renameStudy`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-renameStudy/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-renameStudy/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Renames a field study. ## Parameters - `index`: int? (default the live study) - `name`: str (1 to 200 bytes, unique in the circuit) ## Reply - index - study --- # Set Up Field Study (`field.setStudy`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-setStudy/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-setStudy/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Sets a field study's setup, view or part; each at most 64 KiB of JSON. A solve sets the live study's setup by itself. ## Parameters - `index`: int? (default the live study) - `setup`: object? (replaces the solve params: design, component, dimension, currents, mesh and stopping options as the solving command takes them) - `view`: object? (replaces how the app shows it: zoom, camera, section, quantity, views kept for the report; a view alone does not mark the circuit unsaved, the next save writes it) - `part`: str|null? ## Reply - index - study --- # Field Studies (`field.studies`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-studies/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-studies/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does The open circuit's field studies, in order, and which one is live. Read-only. ## Parameters None. ## Reply - active - studies:\[{index, name, dimension (2|3), part, active, drawing (bool: it has a drawing), results:\[kind\], setup, view, saved:{values, solverVersion, fromOlderSolver}|null}\] --- # Field Sweep (`field.sweep`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-sweep/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-sweep/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** a job, with progress and Cancel > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. Each point is one call of the command with the point's values written into params, so its row is exactly that single solve's result; a repeated 3D solve comes from the field cache. Progress counts the points; cancel stops between points and the reply keeps the rows run so far. Changes nothing. ## Parameters - `command`: str="magnetics.fieldSolve" (the field command each point runs: magnetics.fieldSolve, magnetics.fieldCoreLoss, field.windingAc, field.thermalSolve or field.peec) - `params`: object (that command's params, the base every point starts from; apply is refused) - `parameters`: \[{"path":str (where the value goes in params: dotted keys, a number indexing a list, e.g. "elementMm" or "design.best.gapMm"; a bare gapMm, gapCentreMm, gapOuterMm, turns, secondaryTurns, stacks, shape, material or wire goes in the design (its best design for a magnetics.design reply), and gapMm there also sets a given gapCentreMm),"paths":\[str | {"path":str,"times":number=1,"plus":number=0}\]? (instead of path: 1 to 64 places the one value goes, each written as value × times + plus, e.g. both path points' z of a busbar layer at a swept spacing),"name":str? (the name its rows carry; default the path; required with paths, times or plus),"values":\[any\]? (the values to run, 1 to 256; numbers or text, e.g. core shapes) or "from":number,"to":number,"step":number? (from to to by step, both ends included, a negative step running down; not with points or scale),"points":int=5 (linear and log: 2 to 256 in all, both ends; decade and octave: 1 to 256 per decade or octave, from \`from\` up to the last not past \`to\`),"scale":"linear"|"log"|"decade"|"octave"="linear" (log, decade, octave: both ends above 0)}\] (1 to 4) - `combine`: "nested"|"synchronised"="nested" (nested: a grid of every combination, the first parameter slowest; synchronised: the parameters' values taken pairwise, each with as many; at most 256 points; not with optimize) - `design`: "latinHypercube"|"fractionalFactorial"? (instead of combine: a sampled design of experiments over each parameter's from-to range, linear, or evenly in ln with scale log (no points or step), the plans of analysis.doe; latinHypercube: "runs":int=10 per parameter (2 to 256) and "seed":int=1, each range cut into runs equal strata, each stratum used once, at a random point inside it, the same seed giving the same points; fractionalFactorial: a two-level 2^(k-p) at the range ends, "fraction":int=1 with the NIST/SEMATECH e-Handbook generators (3 or 4 parameters) or your own "generators":\[str\] e.g. \["C=AB"\]; with optimize: the design runs first and the search starts from its best point, golden-section on the bracket of that point's neighbouring design values, Nelder–Mead from that point with a step of one stratum (latinHypercube) or a quarter of each range (fractionalFactorial)) - `outputs`: {name:str (a JSON pointer into the command's reply, e.g. "/model/nodes")}? (more columns) - `optimize`: {"output":str (a column),"goal":"target"|"min"|"max"="target" with target,"target":number? (for goal target),"tolerancePct":number=0.5 (goal target: stop once the output is this close to the target, 0 to 100 %; default the field solver's mesh tolerance, metrics.json mesher\_independence),"maxEvaluations":int=40 (1 to 256; the search's own, after a design's runs, the two together at most 256)}? (instead of the grid: search the parameters, each a from-to range, for the goal; one parameter by golden-section search on its range, more by Nelder–Mead on the box, each value kept inside its range; started from the middle, or from a design's best point with design) - `surface`: {"output":str (a column),"goal":"min"|"max"="min","goals":\[{"output":str (a column),"goal":"min"|"max"|"target","low":number,"high":number (the acceptable range: min has desirability 1 at low and 0 at high, max 0 at low and 1 at high, target 0 at both and 1 at target),"target":number? (goal target, between low and high),"weight":number=1 (the shape exponent, 0.1 to 10: above 1 asks more of the output near its best),"importance":number=1 (0.1 to 10)}\]? (1 to 8, one per column; instead of output and goal: several outputs at once by the Derringer-Suich desirability, D = the importance-weighted geometric mean of the goals' desirabilities, 0 when any is outside its range),"confirm":bool=true}? (with a grid or a design over from-to ranges, linear or log: fit analysis.doe's quadratic response surface to the rows' output in coded units (-1 the low end, +1 the high end, in ln for log; squares only for parameters at 3 or more values) and find its exact least or greatest value on the box (with goals: one surface per column and the point of greatest D, a grid of about 2e5 points refined by a compass search); confirm runs the command once more at that point, as one more row; not with optimize) ## Reply - command - parameters:\[{path,values} | {name,paths:\[{path,times,plus}\],values}\] (with design: the values drawn, in run order) - combine (nested, synchronised, or the design's name) - plan?:{design,runs,coded:\[\[number\]\] (each run's levels, -1 the low end, +1 the high end),seed? (latinHypercube),generators?:\[str\] (fractionalFactorial)} (with design) - columns:\[str\] (the outputs: each number of the reply's result.values by its name, the reply's numbers at its top level, peakB (the reply's peak.b, or the largest peakB\[\].b), bP99 (the core's 99th percentile of |B| beside it: the reply's bP99, or the largest peakB\[\].bP99; a corner peak grows with the mesh, the percentile does not) and the outputs given) - rows:\[{point,values:{name:value},outputs:{column:number},error?:str (that point's refusal or failure; the sweep goes on),warnings?:\[object\] (that reply's warnings, as the command gives them alone)}\] - warnings:\[object\] (every distinct warning of the rows once, by code, as first raised, with points:\[int\] (the rows that raised it)) - optimum?:{values,outputs,objective,evaluations (the search's, after the design),method (golden|nelderMead),stop (tolerance|bracket|simplex|evaluations|cancelled),start?:{design,runs,point (the row of the design's best point, or null when no design run gave the output),objective} (with design)} - surface?:{output,goal,runs (rows fitted),model:{terms:\[{term,coefficient}\],r2},optimum:{values:{name:number},coded:\[number\],predicted,onBoundary},stationary:{values,coded,predicted,kind (minimum|maximum|saddle),inside}|null (the unconstrained stationary point of the canonical analysis; null when the model has none),confirmation:{point,measured,predicted,differencePct}|null} | {goals:\[{output,goal,low,high,target?,weight,importance,runs,model:{terms,r2},predicted,desirability} (each at the optimum)\],optimum:{values,coded,desirability (D),feasible (D above 0: every goal in its range),onBoundary},confirmation:{point,outputs:\[{output,measured,predicted,differencePct}\],desirability (D of the measured outputs)}|null} (with goals) - notes --- # Field Table Lookup (`field.tableLookup`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-tableLookup/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-tableLookup/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. Reads the tables of field.tables3d without solving: psiCurve and coupledCurve as the circuit models read them, the loss grid interpolated bilinearly in log frequency and log current (exact for a Steinmetz power law, as the linear field gives), bP99 and peak |B| linearly in the current. A frequency or current outside the loss grid is refused naming its range. Changes nothing. ## Parameters - `tables`: object (a field.tables3d reply) - `current`: A=0 (winding 1's current, or a coupled part's magnetizing current; −1e5 to 1e5, read as |current| for L) - `frequency`: Hz? (with the reply's lossTable: the loss at this frequency and current as a sine peak) ## Reply - current - inductance:{l} | {l11,m,l22,k} (H at the current: dλ/di of psiCurve, the coupledCurve row, or the linear matrix) - fluxLinkage? (psiCurve: λ at the current, Wb) - from:"psiCurve|coupledCurve|linear" - beyondTable (the current is past the table's last row: the table continues as the circuit model continues it) - loss?:{frequency,current,lossW,lossIgseW,bP99,bPeak,exact (a grid point)} - source --- # 3D Field Tables (`field.tables3d`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-tables3d/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-tables3d/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** a job, with progress and Cancel > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. Solves the 3D model of magnetics.fieldSolve {dimension:3} ONCE and returns the tables a circuit and a design loop reuse without solving again: the linear L/M matrix from one 1 A solve per winding; with currents, winding 1 swept through them by the 3D Newton solve on the core's catalogue B-H curve (warm-started, with a first point at a thousandth of the first current standing for zero current), giving the flux-linkage table psiCurve (one winding) or the incremental L/M matrix at each current as coupledCurve rows (two windings, M the mean of the two mutual terms), the tables magnetics.fieldFluxMap writes from the 2D sweep and both circuit solvers follow; with loss, the iGSE core loss of the 3D field for winding 1 driven by a sine of each peak current at each frequency (the other windings open), from the 1 A field scaled (linear at the model's μr, no further solve), each row with the core's bP99 and peak |B| so it reads as loss vs flux and frequency. field.tableLookup reads L, M and the loss from this reply at any current and frequency. A job: progress counts the solves, the swept points and the grid points; cancel stops at the next conjugate-gradient iteration. ## Parameters - `design`: object? (a magnetics.design reply, or its best design) - `sketch`: object? (instead of design: the planar drawing magnetics.fieldSolve takes, in mm; one or two circuits) - `muR`: number? (design only: a linear core at this μr) - `clearanceMm`: number=0.1 (design only) - `elementMm`: number? (as magnetics.fieldSolve) - `layers`: int? (an extrusion's element layers, 1 to 64; default 8) - `material`: str? (a sketch's catalogue core material: its B-H curve for currents and its loss data for loss; a design names its own) - `temperatureC`: number? (core temperature for the B-H curve and the loss data, -40 to 200 °C; default the design's, else 25) - `linear`: bool=false (keep the core linear even when its material has a B-H curve; currents are then refused) - `currents`: \[A\]? (the L(I) sweep: winding 1's currents, rising, 1 to 15, each above 0 and at most 1e5 A; needs a core material with a catalogue B-H curve; without it the table is the linear matrix, one row) - `loss`: {"frequencies":\[Hz\] (1 to 16, each above 0 and at most 1e8),"currents":\[A\] (winding 1's peak sine current, 1 to 16, each above 0 and at most 1e5)}? (the core-loss grid) - `component`: str? (the inductor, coupled inductor or transformer to write) - `apply`: bool=false (an inductor: l, and with currents psiCurve (and the design's core link when the part links none); a coupled inductor: l1, l2, k and coupledCurve; a transformer: n and coupledCurve; in ONE history step) - `ignoreMemoryCheck`: bool=false ## Reply - kind:"field.tables3d" - source - result:{headline,values:\[l0,lMax?,maxCurrent?\]} - windings - nonlinear - material? - temperatureC? - linear:{l:\[H per winding, 1 A solve\],m?,k?} - table:\[{current,fluxLinkage?:\[Wb\],incremental:\[\[H\]\] (the L/M matrix at this point; row 1 at zero current)}\] - psiCurve? (one winding with currents: i:λ pairs, A and Wb) - coupledCurve? (two windings: i:L11:M:L22 rows, A and H) - lossTable?:{material,temperatureC,frequencies,currents,rows:\[{frequency,current,bP99 (T),bPeak (T),lossW,lossIgseW}\],coreVolume (m³)} - model:{dimension:3,construction,family,nodes,elements,edges,elementMm,layers,iterations:\[per winding\],newtonSteps?:\[per point\],residuals?,solverVersion,inputHash} - apply:\[edits\] - applied - notes - preview - previewNote --- # Thermal Field Solve (`field.thermalSolve`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-thermalSolve/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-thermalSolve/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** a job, with progress and Cancel > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. Steady temperature of the part on the drawing magnetics.fieldSolve meshes: conduction in the named regions, convection from every outer edge of them (the clearances between core and winding count as outer edges), the regions left out not solved. Copper regions are iterated with their temperature until the largest change is below 0.05 K. With ac, the conductors' heat is the time-average |J|²/(2σ) of the time-harmonic solve (the air and every label of the drawing in it; a coil label without sigmaSm carries no current), and a copper conductor's conductivity follows its mean temperature (IEC 60028), iterated with the thermal solve; the values in ac are at the settled temperature. With core, the core's heat is magnetics.fieldCoreLoss's loss map, computed with the material's Steinmetz temperature factor at the core's mean temperature and iterated with the thermal solve (Wegstein's secant step) until the largest change is below 0.05 K; a core that heats to its Curie point is refused. With core and ac together, both losses heat one thermal solve and are iterated in one loop, each at its own temperature; a core region given sigmaSm is refused (the data-sheet core loss already holds its eddy loss). With core and copper regions given a loss (no ac), that loss follows the copper resistivity at each element's temperature in the same loop as the core loss. With dimension 3 and core, the core loss is magnetics.fieldCoreLoss {dimension:3, linear:true}'s on the same extrusion (with drive curve, magnetics.fieldCoreLoss {dimension:3}'s on the curve), iterated the same way. Planar, as deep as the drawing; an axisymmetric sketch is revolved a full turn, its axis insulated by symmetry. Along a line, the temperature is linear inside each element as solved, null where the line leaves the solids; the CSV is in SI units (m, °C). The lumped network reproduces the regions' mean temperatures for any losses (superposition; maxErrorK at this call's losses), so a sweep needs no further field solve; it gives means, not the hot spot, and copper losses follow each region's mean. No heat-transfer coefficient is built in, and conductivities only for copper, aluminium, air, ferrite, kapton hn, nomex 410 and mg 832tc (handbook, Fair-Rite, DuPont Kapton HN, DuPont Nomex 410 and MG Chemicals 832TC data sheets): give the rest from data sheets or a measurement. Changes nothing. ## Parameters - `design`: object? (a magnetics.design reply, or its best design) - `sketch`: object? (instead of design: the planar drawing magnetics.fieldSolve takes, in mm; or with axisymmetric:true and no depthMm an (r, z) section about x = 0 revolved a full turn) - `clearanceMm`: number=0.1 (design only) - `elementMm`: number? (largest element in the core and the windings, 0.01 to 50 mm) - `regions`: \[{"name":str (a label name of the drawing; every label with that name),"k":W/(m·K)? (thermal conductivity, from the data sheet),"material":str? (instead of k: a built-in conductivity, copper | aluminium | air | ferrite | kapton hn | nomex 410 | mg 832tc, each cited; a range is used at its low end),"kAxes":\[W/(m·K)\]? (instead of k or material: the conductivity along each axis of the model, from the data sheet, for a material that conducts differently by direction (a lamination stack, a winding bundle, a board in-plane and through-plane): \[kx, ky\] in 2D, \[kr, kz\] for an axisymmetric sketch, \[kx, ky, kz\] with dimension 3, z along the depth; not on a ring-core design in 3D),"kAngleDeg":deg=0 (with kAxes: the angle from the model's x axis (r when axisymmetric) to the axis kAxes' first value runs along, turning towards y (z), -180 to 180, for a sheet or stack laid at an angle; the tensor is turned about the depth axis, so kz stays),"kTable":\[\[°C,W/(m·K)\]\]? (instead of k, material or kAxes: the data sheet's conductivity against temperature, 2 to 200 points, temperatures rising; k is linear between the points and held at the end values outside them (warned), taken at each element's temperature and iterated until the largest change is below 0.05 K; planar, axisymmetric or dimension 3, not with ac, core, eddy, lumped or copper regions),"lossW":W? (heat of the region for the model's depth, or over the full revolution when axisymmetric, spread by volume),"heatWm3":W/m³? (instead of lossW: heat density),"lossMultiplier":number=1 (above 0, at most 100: scales lossW or heatWm3, a margin such as 1.2 maps 10 W as 12 W of heat; only with one of them, so not on an ac, core or eddy region; a lumped sweep's losses are taken as given),"copper":bool=false (the loss follows the copper resistivity, IEC 60028),"lossAtC":°C=20 (copper only: the temperature lossW, heatWm3 or sigmaSm was found at),"sigmaSm":S/m? (with ac: the region is a solid conductor of the AC solve with this electrical conductivity, from the data sheet; its heat is the AC loss, so no lossW or heatWm3),"bundle":{"wire":str? (a round or litz wire of the wire catalogue; gives the strands, instead of strandDiameterMm and strands),"strandDiameterMm":mm (copper diameter of one wire or litz strand, at most 10),"strands":int=1 (strands in parallel per turn: 1 for round wire, more for litz),"turns":int (turns of the winding through the region, 1 to 1e6)}? (with sigmaSm: the region is round wire or litz, solved as one homogeneous region by Meeker's model; its turns carry the winding's current, and with copper its strands follow their temperature)}\] (the solid regions; the rest are left out) - `convection`: {"hWm2K":W/(m²·K) (heat-transfer coefficient of every outer surface of the solids),"ambientC":°C,"emissivity":number? (0 to 1, from the surface's data sheet: the outer surfaces also radiate as grey surfaces to large surroundings at ambientC, ε σ (T⁴ − T∞⁴), each surface seeing only the surroundings (no view factors), iterated with the temperature until the largest change is below 0.05 K; planar, axisymmetric or dimension 3 (each outer triangle at its mean temperature), not with ac, core, eddy, lumped, kTable or copper regions)} - `surfaces`: \[{"name":str,"region":str? (the outer edges of this solved region),"boxMm":\[x0,y0,x1,y1\]|\[x0,y0,z0,x1,y1,z1\]? (the outer edges with both ends in this box, mm; with region, the edges both pick; with dimension 3 the outer faces with all three corners in it, four numbers spanning every z, six bounding z too),"hWm2K":W/(m²·K)? (convection; 0 = insulated),"ambientC":°C? (with hWm2K; default convection ambientC),"temperatureC":°C? (instead of hWm2K: the edges (faces in 3D) held at this temperature, a cold plate or heat sink taken as isothermal),"heatInWm2":W/m²? (instead of hWm2K: this heat flux into the part through the edges (faces in 3D), a heater pad or a known flux; negative takes heat out),"emissivity":number? (with hWm2K: 0 to 1, from the surface's data sheet; the surface also radiates to surroundings at its ambientC, as convection emissivity does; wins over convection emissivity, 0 does not radiate; given alone it turns radiation on for this surface)}\]? (per-surface boundaries: each outer edge (with dimension 3, each outer face of the solids, an extrusion's end faces among them unless ends is insulated) takes the first entry that picks it, the rest keep convection; each entry gives exactly one of hWm2K, temperatureC or heatInWm2; an entry that picks no edge is refused, and so is a node two held entries hold at different temperatures; with convection emissivity the convecting entries and the rest radiate (an insulated entry, hWm2K 0, only with its own emissivity), held and flux entries never; not with lumped when an ambient or held temperature differs or with heatInWm2; the reply lists every surface with its kind (convection | held | flux), areaMm2 (over the depth or the revolution), minC, maxC, meanC (area-weighted), heatW, a held surface's the heat the hold takes out, heatFluxWm2 (heatW per area) and, convecting, hEffectiveWm2K (heatW / (areaMm2 (meanC − ambientC)), convection and radiation together; null when meanC is the ambient), and with radiation its emissivity and radiatedW, the part of heatW it radiates) - `contacts`: \[{"name":str? (default a–b),"regions":\[str,str\] (two solved regions that share faces),"resistanceM2KW":m²·K/W? (the contact's resistance per unit area R″, from the pad's or grease's data sheet or a measurement; above 0, at most 1),"thicknessMm":mm?,"k":W/(m·K)? (instead of resistanceM2KW: a layer too thin to draw, R″ = t / k; thicknessMm at most 10)}\]? (planar, axisymmetric or dimension 3: thermal contact resistance, a zero-thickness interface between the two regions across which the temperature jumps by q″ R″ (Incropera §3.1.4); nodes that also touch a third solved region keep one temperature; no default value; at most 64; with emissivity the outer faces radiate while the contacts carry their jump) - `transient`: {"stepS":s (above 0, at most 3.2e7),"steps":int (1 to 10000),"heatCapacityJm3K":{"\":J/(m³·K)} (ρ·c of every solved region, from its data sheet or a handbook; none is built in),"initialC":°C? (uniform start; default convection ambientC),"fosterTerms":int? (1 to 8: fit a Foster chain to zthKW)}? (also step the warm-up after the losses switch on at t = 0: lumped heat capacity, backward Euler (first order in stepS); fixed losses only, planar, axisymmetric or dimension 3 (its tetrahedra, surfaces and contacts): not with copper or kTable regions, emissivity, ac, core, eddy or lumped) - `line`: {"from":\[x,y\] (mm),"to":\[x,y\] (mm),"points":int=101 (2 to 10000, both ends included)}? (read the temperature along this line) - `csvPath`: str? (with line: the .csv file to write, through the host's file service) - `plane`: {"axis":"x"|"y"|"z" (the axis the cut is normal to),"atMm":mm (where it cuts that axis; z = 0 is mid-depth),"points":int|\[int,int\]=51 (grid points along each side, 2 to 1001, or one count per in-plane axis)}? (dimension 3: read the temperature on this axis-aligned cut plane, on a regular grid over the solids' bounding box in the plane's two axes (y, z for x; x, z for y; x, y for z), linear inside each tetrahedron as solved; refused when no grid point is in a solved region) - `summary`: {"regions":\[str\]? (names from regions: volume entries),"surfaces":\[str\]? (instead of regions: names from surfaces, or convection for the outer edges no entry picks),"quantities":\[str\]? (default every one of the kind: regions volumeMm3, lossW, minC, maxC, meanC; surfaces areaMm2, heatW, heatFluxWm2, minC, maxC, meanC; a surface quantity asked of regions is refused, a volume offers only its temperatures, loss and volume),"rows":"each"|"together"="each" (each: one row per name, in the order given; together: one row for all, min of the minima, max of the maxima, the mean weighted by volume or area, sums of the rest, the flux the summed heat over the summed area)}? (a fields-summary table over chosen regions or surfaces, read from this reply's rows: no further solve; at most 128 names) - `lumped`: bool|{"sweep":\[\[W per region, in regions order\]\]? (at most 10000 points)}? (also reduce the solve to a thermal network, one node per region at its mean temperature, one more field solve per region, and evaluate the sweep on it) - `field`: bool=false (also return the solved temperature field, for a temperature map: field.exportImage and field.exportCsv read it in 2D; in 3D the app's 3D view and report.export draw it) - `ac`: {"frequencyHz":Hz|\[Hz\] (0 for DC, at most 1e9; a list of 1 to 64 distinct frequencies, the harmonics of the winding currents, solves each and adds their losses, as simultaneous (they are orthogonal over a period); planar or extruded (dimension 3), with or without core),"windings":\[{"name":str,"currentA":A|\[A\] (peak, at most 1e6; with a frequency list, one peak per frequency, 0 where the winding carries none),"conductors":\[{"region":str (a region given sigmaSm; every label with that name is one conductor in series),"direction":1|-1=1 (1 going, -1 returning)}\]}\]}? (heat the conductors with the winding loss of the time-harmonic solve on the whole drawing: skin, proximity and eddy loss; the planar section's loss, also on the extruded model (dimension 3); not with lumped) - `core`: {"material":str? (sketch only, required there: the catalogue material of the muR labels; a design uses its own),"waveform":{t:\[s\],i:\[\[A\] one list per circuit, in the order magnetics.fieldSolve reports the circuits\]}? (one period, as magnetics.fieldCoreLoss takes it),"signals":\[str|null\]? (instead of waveform: the current signals of the last run, one per circuit, as magnetics.fieldCoreLoss takes them),"t0":s?,"t1":s?,"fsw":Hz?,"tEnd":s?,"points":int=200 (signals only: the period's window and resampling, as magnetics.fieldCoreLoss reads them),"permeability":"fixed"|"followsTemperature"="fixed" (followsTemperature: the core takes the data sheet's permeability or B-H curve at its temperature),"drive":"linear"|"curve"="linear" (curve: the core on the catalogue B-H curve, the model solved by Newton's method at every step of the waveform as magnetics.fieldCoreLoss solves a curve core, in 2D and 3D; with fixed the curve at the ambient temperature, solved once; with followsTemperature the curve at the core's temperature, solved again at each step)}? (heat every muR label, each named in regions with k and no lossW or heatWm3, with the iGSE core loss of the waveform, recomputed at the core's mean temperature until it settles; with ac, the AC winding loss is iterated in the same loop, so winding and core warm each other; copper regions' given loss follows ρ(T) in the same loop; planar or extruded (dimension 3), not with lumped) - `dimension`: 2|3=2 (3: solve the 3D model magnetics.fieldSolve {dimension:3} builds, the planar drawing extruded through its depth on the same tetrahedra; regions, convection and copper as in 2D, lossW is the region's whole heat; core as in 2D with the 3D core loss on the same tetrahedra, at the drawing's permeability or, with followsTemperature, the data sheet's initial permeability at the core's temperature (every winding solved again at each step), or with drive curve on the B-H curve; line takes from and to as \[x,y,z\] mm, or \[x,y\] on the middle plane z = 0, and its points add zMm; lumped as in 2D, one 3D solve per region; ac as in 2D with the planar section's AC loss on every tetrahedron over its triangle, the same along the depth (no end turns), copper following each conductor's mean temperature, with core both losses iterated in one loop as in 2D, not with lumped; a ring-core design is its (r, z) section revolved a full turn as magnetics.fieldSolve {dimension:3} revolves it, its core the only solid (the windings are current sheets), every face convecting, core as above, no layers, ends or ac; naming a region A or B also draws that winding's copper as a solid frame around the core (the build its turns of the design's wire fill in the hole, carried over the faces and outside, clearanceMm from the core), each frame air to the core drive; not with an axisymmetric sketch) - `eddy`: {"frequencyHz":Hz (above 0, at most 1e9),"currentsA":\[A\] (peak, one per winding in the design's order, in phase, each at most 1e6)}? (dimension 3, a ring-core design only: heat the regions given sigmaSm (the core; with copper and lossAtC σ follows the mean temperature, IEC 60028) with the 3D time-harmonic eddy-current loss ½∫σ|E|² on the revolved ring, each winding a toroidal current sheet, iterated with the temperature; a winding's frame given sigmaSm is refused (a shorted turn); not with ac, core or lumped) - `layers`: int? (dimension 3: element layers through the depth, 1 to the extrusion's limit, default magnetics.fieldSolve's 8) - `stepDeg`: number? (dimension 3, a ring-core design: the largest angular step of its revolution, 1 to 30°, default 10, as magnetics.fieldSolve takes it) - `ends`: "convecting"|"insulated"="convecting" (dimension 3: whether the two end faces convect like the other outer faces; insulated gives the planar solve's temperature) - `ignoreMemoryCheck`: bool=false (dimension 3: run past the memory guard) ## Reply - hotSpot:{temperatureC,atMm (\[x,y\], or \[x,y,z\] in 3D),region} - regions:\[{name,areaMm2 (2D only),volumeMm3,lossW,minC,maxC,meanC,kWmK (null with kAxes or kTable),kAxesWmK (null without),kAngleDeg (null without kAxes),kTable (null without),kAtMeanWmK (kTable's k at the region's mean temperature; null without),kSource (null when k or kAxes was given),lossMultiplier (1 unless given; lossW includes it)}\] - heatGeneratedW - heatRemovedW - balance - coupling:{solves,lastChangeK,history}|null - radiation:{emissivity,surroundingsC,radiatedW,convectedW}|null (with emissivity) - contacts:\[{name,regions:\[a,b\],resistanceM2KW,thicknessMm|null,kWmK|null,faces (2D: interface edges, each a face of the depth or the revolution),areaMm2,heatW (from a to b),meanJumpK,maxJumpK,sharedNodes (interface nodes on a third region, kept at one temperature)}\]|null (with contacts) - line:{points:\[{sMm,xMm,yMm,zMm (3D only),region,temperatureC}\],minC,maxC,csv}|null - plane:{axis,atMm,uAxis,vAxis (the in-plane axes),uMm:\[mm\],vMm:\[mm\] (the grid, rising),temperatureC:\[\[°C|null, one per uMm\] one row per vMm\] (null in the air),points,inside,insideFraction,minC,maxC,meanC (the mean of the grid points inside the solids),hotSpot:{temperatureC,atMm:\[x,y,z\],region}}|null (dimension 3 with plane) - path - written - summary?:{entity (regions | surfaces),rows (each | together),names,quantities,table:\[{name (together: the names joined by a plus sign),\:number|null}\],csv (header name,\; an empty field for null)} (with summary) - lumped:{nodes,resistances:\[{between,rKW}\],toAmbient:\[{region,rKW}\],negative:\[{between|region,rKW (below 0)}\] (conductances that come out negative, a region reaching ambient only through another: kept in the network, so the sweep stays exact, but no resistor can hold them),leftOut (how many are in negative),maxErrorK,fieldSolves,sweep:\[{lossW,meanC,hottest,solves}\]}|null - transient:{stepS,steps,initialC,timesS:\[s\],hotSpotC:\[°C per time\],regions:\[{name,meanC:\[°C per time\]}\],zthKW:\[K/W per time\] (the hot spot's rise over initialC per W of the whole loss; null without loss),foster:{terms,rKW:\[K/W\],tauS:\[s\],worstKW}|null (with fosterTerms),finalHotSpotC,steadyHotSpotC (this reply's hotSpot),settledFraction (the last step's share of the rise to the steady hot spot),iterations}|null (with transient) - ac:{frequencyHz,skinDepthMm (null at DC),windings:\[{name,currentA,lossW,rdcOhm,racOhm,fr}\],conductors:\[{region,sigmaSm (settled),meanC,lossW,currentA:\[re,im\] (a bundle's: all its turns),bundle:{wire,strandDiameterMm,strands,turns,fill}|null}\],totalLossW,solver,iterations}|{frequencyHz:\[Hz\],harmonics:\[that object, one per frequency\],windings:\[{name,lossW (summed)}\],conductors:\[{region,sigmaSm,meanC,lossW (summed)}\],totalLossW (summed)} (with a frequency list)|null - core:{material,permeability,drive (linear | curve),regions,circuits,waveform:{source (call | last result | new run),signals,t0,t1,points},lossW (settled),lossAtC (the core temperature of the last loss),meanC (the core's mean temperature),lossHistoryW,muR:\[number|null per core region\],peakBT,p99BT,saturationT}|null - eddy:{frequencyHz,windings:\[{name,turns,currentA}\],conductors:\[{region,sigmaSm (settled),copper,meanC,lossW,skinDepthMm}\],totalLossW,lossHistoryW,iterations,residual,solver}|null - model:{family,form (planar | axisymmetric | extruded | revolved),depthMm (null when axisymmetric or revolved),nodes,elements (tetrahedra in 3D),minAngleDeg,iterations,residual,leftOut,solverVersion,dimension (3D only),layers (3D only),ends (3D only),memoryEstimateBytes (3D only),stepDeg (3D ring only: the revolution's largest step)} - field?:{nodes:\[\[x,y\]\] (m),triangles:\[\[a,b,c\]\],elementRegions:\[region\],regions:\[{name}\],temperatureC:\[°C per node\]} (the solids' mesh only; in 3D {dimension:3,nodes:\[\[x,y,z\]\] (m),tetrahedra:\[\[a,b,c,d\]\],elementRegions,regions:\[{name}\],temperatureC:\[°C per node, single precision\]}) - notes - warnings --- # Winding AC Loss (`field.windingAc`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-windingAc/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-windingAc/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. The time-harmonic field solve of the winding window, one-dimensional as in Dowell (Proc. IEE 1966): every layer fills the breadth (foil, a full-width planar layer, or round wire or litz homogenized as one bundle per layer), the core faces are ideal, and fringing, edge and end-turn effects are left out. The primary carries 1 A and the secondary the balancing −Np/Ns A. fr is Rac/Rdc of the winding from the solve, dowellFr Dowell's per-layer result and errorPct their difference (with wire, Dowell's equal-area-square approximation, and with trace, Dowell's porosity factor, both reported without a threshold); proximityShare is the share of the solved loss that is not the layers' own skin loss (Ferreira 1994). The leakage is seen from the primary, from the solve's reactive power; it falls with frequency as the field leaves the copper. The latest result goes into report.export's Field section: Rac/Rdc, Dowell's and the leakage per frequency (with dimension 3 the planar result beside them; on a design's wound core each winding's end-turn share, and with coreConductivitySm the core's eddy loss) and their plot against frequency. Changes nothing. ## Parameters - `design`: object? (a magnetics.design reply or its best design: an E core with one or two windings of round wire, litz or foil (one foil per turn, not in parallel; Dowell's 1D foil model, a lower estimate in the end turns) on its centre leg; with "endTurns":true and "dimension":3 the design's core is wound in 3D, the winding window keys are refused, and only design, endTurns, dimension, frequenciesHz or sweep (at most 40), temperatureC, elementMm (the largest element, mm), clearanceMm, muR and coreConductivitySm are taken; the reply is then {windings:\[{name,turns,conductor (round|litz|foil),strandDiameterMm (null for foil),strands (null for foil),foilThicknessMm (null for wire),meanTurnMm,sectionMm2,fill,rdcOhm}\],inductance (self with one winding, leakage with two),rows:\[{frequencyHz,skinDepthMm,strandOverSkinDepth (null with foil alone),foilOverSkinDepth (null without foil),withinCheckedRange,primary:{name,turns,currentA,racOhm,rdcOhm,fr,proximityLossW,skinLossW,proximityShare,endTurnLossW,endTurnShare (of the winding's loss),endTurnVolumeShare},secondary:{…}|null,inductanceNh,leakageNh (null with one winding),threeD:{fieldInductanceNh,lossFromFieldW,coreLossW,lossFromTerminalsW,tetrahedra,iterations}}\],model:{family,dimension,construction (wound),coreConductivitySm,core,gapMm,conductor,wireModel,conductivitySm,temperatureC,elementMm,estimatedBytes,solverVersion},memoryWarnings,notes,warnings}; a design with layout \\"outerLegs\\" (a two-phase coupled inductor, T53: winding A round the left outer leg, B round the right, both alike, of round wire or litz; windings of different turns or wire are refused) is solved as magnetics.fieldSolve's outer-legs eighth with both windings homogenized bundles, once for the common part (equal currents) and once for the differential part, and the reply is then {windings:\[A,B\],inductance:\\"matrix\\",rows:\[{frequencyHz,skinDepthMm,strandOverSkinDepth,withinCheckedRange,primary (winding A),secondary (B):{name,turns,racOhm (with the other winding open, its strands' proximity loss included),rdcOhm,fr,inductanceNh},mutual:{resistanceOhm (R\_M: the loss of in-phase peak currents ia, ib is ½(R\_A ia² + R\_B ib² + 2 R\_M ia ib)),inductanceNh (M, negative)},k,inductanceNh (B's),leakageNh (null),parts:{common (ia = ib = 1 A),differential (ia = −ib = 1 A):{lossFromTerminalsW,lossFromFieldW,proximityLossW,skinLossW,endTurnLossW,endTurnShare,coreLossW,iterations}},threeD:{fieldInductanceNh,fieldMutualNh,endTurnVolumeShare,tetrahedra}}\],model:{…,construction (woundOuterLegs),spacerMm,turns,gapElements},memoryWarnings,notes,warnings}) - `endTurns`: bool=false (with design: its winding wound round the centre leg with its end turns, one eighth meshed, each winding a homogenized bundle; the core does not conduct unless coreConductivitySm is given) - `elementMm`: number? (with design and endTurns: the largest element of the top view and the thickest layer, 0.01 to 50 mm; default graded from the gap and the clearances) - `gapElements`: number? (with an outerLegs design: the elements across each thin region of the top view, 0 to 3, as magnetics.fieldSolve's outer-legs model takes it; default 1, 0 a coarse mesh for a large pair past the node or memory limit, reported as model.gapElements with a note; refused on a centre-leg design) - `clearanceMm`: number=0.1 (with design and endTurns: space between drawn regions) - `muR`: number? (with design and endTurns: core relative permeability; default the catalogue's initial permeability at the design temperature) - `coreConductivitySm`: S/m=0 (with design and endTurns: every core body conducts at this conductivity, from the core material's data sheet, and its eddy loss is threeD.coreLossW; lossFromTerminalsW is then the windings' loss plus the core's; 0 to 1e8) - `arrangement`: str (the layers from the core outward, P primary and S secondary, e.g. "P/S/P" or "PPSS"; 1 to 50 layers, both windings present) - `primaryTurnsPerLayer`: int=1 - `secondaryTurnsPerLayer`: int=1 (1 to 100; each layer's turns side by side across the breadth) - `copperMm`: mm (thickness of every layer: the foil or the planar PCB copper; with \`wire\`, the band one layer of wire takes, at least the strand diameter; 0.001 to 20) - `secondaryThicknessMm`: mm? (the copper thickness of the secondary's layers when it differs from copperMm, then the primary's: a foil primary with a PCB secondary; 0.001 to 20; foil or full-width planar layers only, not with wire, trace or dimension 3) - `parallel`: \[\[int\]\]? (groups of layers joined in parallel at their terminals: each group two or more layer numbers from 1, from the core outward as layers\[\].index, of one winding with the same turns, each layer in one group at most, e.g. \[\[1,5\]\] for the outer primaries of P/S/P/S/P; a group counts its turns once, its DC resistance is its layers' in parallel, and the solve splits the current between them; dowellFr takes an even split; foil or full-width planar layers only, not with wire, trace or dimension 3) - `wire`: {"diameterMm":mm (copper diameter of the round wire, or of one litz strand, 0.001 to 20),"strands":int=1 (strands per turn: 1 round wire, more for litz),"resolved":bool=false (round wire of one strand only: every turn drawn as its own solid copper circle, centred in equal pitches of the breadth, and solved in the two-dimensional window instead of homogenized, valid at any strand d/δ; wires must not touch (a clear gap of a hundredth of the diameter); at most 500 wires and 40 frequencies; not with thermal)}? (round wire or litz instead of foil: each layer's turns side by side across the breadth, homogenized by Meeker's bundle model unless resolved) - `trace`: {"widthMm":mm (copper width of one planar trace, 0.001 to 2000; a layer's turns times it at most the breadth) or "layout":\[\[{"startMm":mm (from the window's bottom face),"widthMm":mm}\]\] (one list per layer of the arrangement, one trace per turn in order across the breadth, touching allowed, no overlap)}? (planar PCB traces instead of full-width copper: each layer's turns are traces of copperMm thickness, one centred in each pitch breadth/turns or where the layout puts it, every trace drawn and solved in the two-dimensional window; not with wire) - `insulationMm`: mm (insulation before each layer and after the last, 0.001 to 100) - `breadthMm`: mm (window breadth the layers fill, 0.1 to 2000) - `mltMm`: mm (mean turn length, 1 to 20000) - `coreDepthMm`: mm? (the core's depth along its legs, E or planar E: the core covers 2 × it of each turn and the rest of the mean turn, mltMm − 2 × coreDepthMm, is the end turns in air, solved by PEEC as two straight runs of the window's cross-section, each turn its own bar; 0.1 to 10000 and below mltMm/2; foil or full-width planar layers, not with wire, trace, current or dimension 3; with parallel each group's split is solved over the whole turn, the window over 2 × coreDepthMm plus the end turns' impedances, and the end turns and total carry it; the reply adds endTurns:{coreDepthMm,inCoreMm,lengthMm,inCoreShare} and each row endTurns:{primary:{fr,rdcOhm,racOhm},secondary:{…},leakageNh,filaments,layers:\[{currentPerPrimaryA,currentPhaseDeg}\] (with parallel: each layer's current at the whole turn's split),total:{primary:{fr,racOhm},secondary:{…},leakageNh}} (total: the window over 2 × coreDepthMm plus the end turns; the row's other fields stay the window over the whole mean turn)) - `temperatureC`: °C=20 (copper resistivity, IEC 60028) - `frequenciesHz`: \[Hz\]? (1 to 200, each above 0 and at most 1e9) or "sweep":{"fromHz","toHz","points":int=20 (2 to 200)}? (log-spaced, both ends included) or "current":{"waveform":\[\[s,A\]\] (one period of the primary current, piecewise linear: times not decreasing, two points at one time a step, the end joining the start),"harmonics":int=15 (1 to 200; the rows are harmonics 1 to this, each at most 1e9 Hz)}? (a non-sinusoidal current: the reply adds current) - `dimension`: int=2 (2 the planar window; 3 the window extruded and solved in 3D on edge elements, foil or round wire or litz or traces: wire through a length equal to its breadth, each foil layer, trace or resolved wire a solid conductor driven at the voltage that carries its turns' current; at most 40 frequencies, and with foil, traces or resolved wire at most 200 layers (traces, wires) times frequencies; with wire.resolved planar is the resolved planar window; each row then also carries planar:{primary:{fr},secondary:{fr},leakageNh,maxDifferencePct} and threeD:{lossFromFieldW,lossFromTerminalsW,fieldLeakageNh,tetrahedra,iterations}) - `thermal`: {"currentA":A (the primary's peak, the secondary balancing it; above 0, at most 1e6),"frequencyHz":Hz (above 0, at most 1e9),"insulation":{"k":W/(m·K)} or {"material":str (a built-in conductivity: kapton hn, nomex 410, …)},"layers":{"k":W/(m·K)} or {"material":str} (foil only; wire or litz needs k, its homogenized conductivity from a measurement or the maker),"convection":{"hWm2K":W/(m²·K),"ambientC":°C} (the outer side only),"copper":bool=true (each layer's σ follows its mean temperature, IEC 60028, from temperatureC)}? (dimension 3 only, not with trace: the winding heated by its own 3D loss at that current, iterated with the steady thermal solve; the outer side convects, the core face, top, bottom and ends are insulated, so the temperature varies across the layers alone) ## Reply - arrangement - primary:{turns,layers,rdcOhm} - secondary:{turns,layers,rdcOhm,currentPerPrimaryA} - layers:\[{index,winding (P|S),turns,rdcOhm,copperMm,parallelGroup (with parallel: the layer's group from 1, or null)}\] - leakageDcNh (one-dimensional window energy, seen from the primary) - rows:\[{frequencyHz,skinDepthMm,copperOverSkinDepth,strandOverSkinDepth (with wire),withinCheckedRange (false with homogenized wire past strand d/δ 10),primary:{racOhm,fr,dowellFr,errorPct,proximityShare},secondary:{…},leakageNh,layers:\[{fr,dowellFr,skinFr,currentPerPrimaryA,currentPhaseDeg (with parallel: the layer's peak current per ampere of the primary and its phase, °)}\]}\] - model:{family,dimension,conductor (foil|round|litz|trace),wireModel (homogenized|resolved; null without wire),porosity (with trace: each layer's total trace width / breadth),conductivitySm,temperatureC,solverVersion} - current:{periodS,fundamentalHz,dcA,rmsA,derivativeRmsAPerS (null with a step),hurleyK,harmonicRmsA:\[A\],capturedPct (the mean square the harmonics carry),primary:{currentRmsA,effectiveFr ((I0²+Σ fr In²)/(I0²+Σ In²)),dowellEffectiveFr,racOhm,lossW (over the harmonics taken),hurley:{layers,copperOverSkinDepth,closedFormFr,optimumCopperOverSkinDepth,optimumCopperMm}|null (foil in two blocks, no step)},secondary:{…},totalLossW}? (with current) - thermal:{currentA,frequencyHz,ambientC,hWm2K,copperFollowsTemperature,hotSpot:{temperatureC,fromCoreMm,region},outerSideC,insulationMeanC,layers:\[{index,winding,conductivitySm (settled),lossW (the whole winding),meanC,maxC}\],totalLossW,lossHistoryW,heatGeneratedW,heatRemovedW,coupling:{solves,lastChangeK,history},insulationKWmK,layerKWmK,kSources,tetrahedra}|null - notes - warnings:\[{code (oneDimensionalModel: foil or wire on Dowell's window; planarModel with data.depth = the mean turn: traces, resolved wire or dimension 3; idealCore: always; outsideCheckedRange: homogenized wire past strand d/δ 10 (on a design's wound core too, where a winding's strands sit in aligned rows; 2 where they cannot), data {fromHz,strandOverSkinDepth,checkedMax}),message,messageZh,data}\] --- # Winding Capacitance (`field.windingCapacitance`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/field-windingCapacitance/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/field-windingCapacitance/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** a job, with progress and Cancel > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. Solves −∇·(ε∇V) = 0 on an automatic mesh of the drawing with Voltecx's own 2D electrostatic solver, one solve per terminal at 1 V with the others at 0 V, and gives the Maxwell capacitance matrix two ways (from the conductor charges and from the field energy, which agree to the solver tolerance). With windings, the energy method with a linear voltage along each winding (turn k of N at (k − ½)/N of the way from start to end) reduces it to the winding ends, then to each winding's self-capacitance and the interwinding capacitance. Planar values are for the depth given (the end turns are not in a 2D section); axisymmetric ones for the full revolution. With component, each winding of more than one turn gets a parallel capacitor CW\ across its pins at its selfCapacitanceF, and each pair of windings one capacitor CIW\ between their starts (p1 and p2) at its interwindingF (the capacitance with each winding's ends joined, which one capacitor between any pin of each reproduces); the part is checked before any solve. A job: progress counts the solves, and cancel stops before the next. Without component it changes nothing. ## Parameters - `sketch`: object (a drawing in mm as magnetics.fieldSolve takes it, planar {depthMm, …} or {axisymmetric:true, …} about x = 0 (the axis is a line of symmetry, not ground), with electrostatic labels: \[{name?, at:\[x,y\], maxSizeMm?, winding:str + turn:int (turn 1 at the winding's start; a turn drawn twice, as its go and return sides, gives both labels the same winding and turn) | conductor:str (a core, screen or other conductor; labels with one name are one conductor), floating:bool=false (conductor only: left floating with no net charge instead of a terminal) | epsR:number (a dielectric, 1e-3 to 1e5) | none of these (air, εr 1)}\]; the outer boundary of the drawing is the ground, 0 V, and no conductor may touch it; openBoundary?:{radiusMm, centreMm=\[0,0\] (on the axis when axisymmetric), layers=4 (1 to 10)} instead puts the drawing in a circle of air of that radius with Meeker's graded-permittivity shells outside it, so the ground is at infinity (open space: a line, a sphere, a winding with no screen); the air between the drawing and the circle is labelled "open boundary air" unless the drawing labels it, and the shells are regions "open boundary shell 1…N"; planar, only charge-neutral excitations are exact, so the capacitance between conductors is open space's but each one's capacitance to the ground depends on radiusMm) - `elementMm`: number? (largest element in every conductor and dielectric region, 0.01 to 50 mm; default the automatic mesher's) - `component`: str? (the inductor (1 winding, p–n), coupled inductor, common-mode choke or transformer (2 windings, p1–n1 and p2–n2) the drawing models: the drawing's windings in the order their first labels appear are the part's windings, each one's start at the dot pin; the capacitors go into the circuit as a pending proposal) - `apply`: bool=false (with component: add the capacitors at once, in ONE history step, instead of a proposal) - `closedForm`: \[{winding:str (a winding of the drawing),conductorDiameterMm:number (bare wire, Dc),outerDiameterMm:number (over the enamel, Do \> Dc),coatingEpsR:number (the enamel's εr),turnLengthMm?:number (one turn, lt; default depthMm when planar, required when axisymmetric),layout:singleLayer|singleLayerOnCore|twoLayers|twoLayersOnCore|threeLayers (two and three layers from 10 and 11 turns)}\]? (the Massarini–Kazimierczuk closed form for a coil of round enamelled wire, reported beside that winding's selfCapacitanceF, not checked against it) - `ignoreMemoryCheck`: bool=false ## Reply - conductors:\[{name,kind:turn|conductor,winding?,turn?,floating}\] - matrix:{names,byChargeF:\[\[F\]\],byEnergyF:\[\[F\]\],twoWaysRelative} (the Maxwell matrix of the terminals: every turn, then each conductor that is not floating, the ground the reference) - windings:\[{name,turns,selfCapacitanceF,closedForm?:{model,layout,turnLengthMm,thetaStarRad,turnToTurnF (eq. 15),turnToTurnExactF (eq. 9),networkFactor (Cs/Ctt, eq. 16–23),selfCapacitanceF,fieldOverClosedForm}}\] (between the winding's two ends, every other end, conductor and the ground floating; 0 for one turn) - interwindingF:\[\[F\]\] (between two windings, each with its ends joined, the others floating; 0 on the diagonal) - terminals:{names ("\ start", "\ end", then the other terminals),byChargeF,byEnergyF,twoWaysRelative} (the lumped matrix on the winding ends) - model:{form:planar|axisymmetric,depthMm,elementMm,nodes,elements,minAngleDeg,solves,openBoundary:{centreMm,radiusMm,layers}|null,solverVersion} - capacitors?:\[{part,kind:parallel|interwinding,winding?|between?,component,pins?,nets,cF}\] (with component: the parts planned) - apply? - proposal?|applied? - notes - warnings:\[{code,message,messageZh,data}\] (planarModel with the depth in m for a planar sketch; none axisymmetric) - preview - previewNote --- # Add Arc (`geometry.addArc`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-addArc/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/geometry-addArc/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Adds a circular arc, as FEMM's arc segment. A full circle is two arcs (geometry.addCircle). One undo step. ## Parameters - `from`: int|\[number\] (a point index, or x, y in m) - `to`: int|\[number\] - `sweepDeg`: number (0 to 360, not inclusive: the arc turns counter-clockwise from \`from\` to \`to\`) - `snap`: number? (grid, m) ## Reply - edge - from - to - ...summary --- # Add Circle (`geometry.addCircle`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-addCircle/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/geometry-addCircle/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Adds a circle as two half-circle arcs. One undo step. ## Parameters - `centre`: \[number\] (x, y in m) - `radius`: number (m) - `snap`: number? (grid, m, for the centre) ## Reply - added:\[int\] (the edges: upper and lower half) - ...summary --- # Add Dimension (`geometry.addDimension`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-addDimension/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/geometry-addDimension/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Shows the distance from point a to point b on the drawing; geometry.setDimension edits it. One undo step. ## Parameters - `a`: int (a point index) - `b`: int (another point index) ## Reply - dimension (its index) - value (m) - ...summary --- # Add Point (`geometry.addPoint`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-addPoint/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/geometry-addPoint/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Adds a point; a point with exactly these coordinates is reused. One undo step. ## Parameters - `at`: \[number\] (x, y in m) - `snap`: number? (grid, m: round each coordinate to a multiple of it) ## Reply - point (its index) - ...summary --- # Add Rectangle (`geometry.addRectangle`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-addRectangle/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/geometry-addRectangle/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Adds the axis-aligned rectangle as four segments, reusing points and segments it shares with the drawing. One undo step. ## Parameters - `min`: \[number\] (one corner, x, y in m) - `max`: \[number\] (the opposite corner) - `snap`: number? (grid, m) ## Reply - added:\[int\] (the edges: bottom, right, top, left) - ...summary --- # Add Segment (`geometry.addSegment`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-addSegment/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/geometry-addSegment/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Adds the straight segment; points given by coordinates are added or reused, and the same segment is reused. One undo step. ## Parameters - `from`: int|\[number\] (a point index, or x, y in m) - `to`: int|\[number\] - `snap`: number? (grid, m) ## Reply - edge (its index) - from - to (point indices) - ...summary --- # Delete Drawing Items (`geometry.delete`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-delete/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/geometry-delete/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Deletes items by index. A point takes its edges and dimensions with it; the items after a deleted one move down one index each. One undo step. ## Parameters - `points`: \[int\]? - `edges`: \[int\]? - `labels`: \[int\]? - `dimensions`: \[int\]? ## Reply - deleted {points, edges, labels, dimensions} - ...summary --- # Field Drawing (`geometry.get`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-get/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/geometry-get/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does The whole drawing (m, degrees) and whether it is ready to mesh: valid with each region's label and area (m²), or the first problem, naming the point, edge, region or label. With fill, a valid drawing also gives each region as triangles (arcs in 5° pieces; not a mesh to solve on), and an unfinished one null. Read-only. ## Parameters - `fill`: bool=false (also return a coarse triangulation of the regions, for a canvas to paint) - `sketch`: bool=false (also return the drawing as the \`sketch\` param magnetics.fieldSolve and the other field commands take: mm, arcs as \[a, b, sweepRad\]) ## Reply - symmetry - depth - points:\[\[x,y\]\] - edges:\[{kind:"segment"|"arc", start, end, sweepDeg}\] - labels:\[{name, at:\[x,y\], material:"air"|"magnetic"|"coil", muR, circuit, turns, maxSize}\] - dimensions:\[{a, b, value}\] - valid - problem {en, zh-Hant} - regions:\[{label, name, area}\] - fill?:{nodes:\[\[x,y\]\], triangles:\[\[a,b,c\]\], labels:\[label index per triangle\]}|null - sketch?:{depthMm | axisymmetric:true, points, edges, labels} - history --- # Label Region (`geometry.label`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-label/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/geometry-label/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Says what the region around \`at\` is: air, a linear magnetic material, or a stranded winding. One undo step. ## Parameters - `at`: \[number\] (a point inside the region, x, y in m) - `name`: str (the region's name in messages) - `material`: "air|magnetic|coil"="air" - `muR`: number? (relative permeability, required for magnetic) - `circuit`: str? (the winding's circuit, required for coil) - `turns`: int? (turns through the region, negative for the return side; required for coil) - `maxSize`: number? (largest mesh element in the region, m) - `index`: int? (replace this label instead of adding one) - `snap`: number? (grid, m) ## Reply - label (its index) - ...summary --- # Move Drawing Items (`geometry.move`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-move/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/geometry-move/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Moves points (their edges follow; an arc keeps its sweep) and region labels. One undo step. ## Parameters - `points`: \[int\]? - `labels`: \[int\]? - `by`: \[number\] (dx, dy in m) ## Reply - moved {points, labels} - ...summary --- # New Field Drawing (`geometry.new`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-new/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/geometry-new/) **Menu:** **Design › Field Solver › New Field Drawing** · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Starts an empty drawing for the field solver. Planar: x, y in metres, depth metres deep. Axisymmetric: x is the radius r ≥ 0 and y the axial coordinate z, revolved a full turn. A drawing already open stays one undo step back. ## Parameters - `symmetry`: "planar|axisymmetric"="planar" - `depth`: number? (m, the planar section's depth along z; required for planar) ## Reply the drawing summary {points, edges, labels, dimensions, history {step, steps, canUndo, canRedo, undo, redo}} --- # Redo Drawing Edit (`geometry.redo`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-redo/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/geometry-redo/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Redoes the drawing edit undone last. ## Parameters None. ## Reply - redone (the edit's label) - ...summary --- # Set Dimension (`geometry.setDimension`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-setDimension/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/geometry-setDimension/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Sets a dimension: its point b moves along the line from point a to the new distance, and the edges at b follow. One undo step. ## Parameters - `index`: int (the dimension) - `value`: number (m) ## Reply - dimension - value - ...summary --- # Undo Drawing Edit (`geometry.undo`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/geometry-undo/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/geometry-undo/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Undoes the drawing's last edit. ## Parameters None. ## Reply - undone (the edit's label) - ...summary --- # Coupled Inductor Report (`magnetics.coupledReport`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/magnetics-coupledReport/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/magnetics-coupledReport/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** a job, with progress and Cancel > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. A two-winding coupled inductor checked in one call by the field commands: magnetics.fieldSolve for L1, L2, M, k and the common- (both windings the same current, L̄ + M) and differential-mode (opposite currents, L̄ − M) inductance, solved again on a refined mesh as the mesh check; magnetics.fieldCoreLoss at each corner for each leg's mean |B| (each element's peak over the period, averaged over the leg: the flux a reluctance model gives the leg, which the corner spikes do not move), the core's bP99, the peak and whether it sits on a drawing corner, and the iGSE core loss with the DC-bias note; both windings held at currentLimitA for the current-limit check; and the worst outer leg's mean |B| per ampere of i1 − i2 at the first corner's mean currents, with the imbalance that reaches bsatMargin × Bsat and Bsat at that slope (a linear extrapolation; a saturating core gets there sooner). Every number is the field's (source field); the corner currents are the call's, a triangle built from idc and ripplePp, or the last run's (source run). A job: each solve is one of its steps, and cancel stops at the next. ## Parameters - `design`: object? (a magnetics.design reply or its best design with two windings, e.g. layout outerLegs) - `sketch`: object? (instead: magnetics.fieldSolve's planar drawing with two circuits; its legs are named by legZones, else the leg checks read the core's bP99) - `legZones`: {"centreHalfWidthMm","windowHalfWidthMm","windowTopMm"}? (sketch: where its E set's legs lie, as magnetics.fieldCoreLoss takes them, e.g. a set drawn from a data sheet's printed dimensions) - `network`: object? (instead: the magnetic network of magnetics.fieldSolve) - `muR`: number? - `clearanceMm`: number? - `elementMm`: number? (as magnetics.fieldSolve) - `material`: str? (sketch: the core's catalogue material, required) - `temperatureC`: number? (core temperature for the B-H curve, the loss data and Bsat; default the design's, else 25) - `linear`: bool=false (keep the core linear) - `corners`: \[{"label":str (1 to 64 characters),"waveform":{t:\[s\],i:\[\[A\],\[A\]\]}?|"signals":\[str|null|\[\[str,number\]\]\]? (with t0,t1,fsw,tEnd,points as magnetics.fieldCoreLoss)|"idc":\[A,A\]? (each winding's mean current; with ripplePp:\[A,A\] (peak to peak, ≥ 0), duty (0 to 1, the rising share of the period), fsw (Hz) and phaseShift=0.5 (winding 2's delay, a fraction of the period) a triangle per winding, each rising from its valley at its phase; without ripple the currents held)}\] (1 to 8 operating corners) - `currentLimitA`: A? (both windings held at this current: the largest leg mean |B| against bsatMargin × Bsat) - `imbalanceA`: A=1 (the step i1 − i2 of the imbalance slope, taken at the first corner's mean currents) - `bsatMargin`: number=0.8 (0 to 1, magnetics.design's default) - `checkElementMm`: number? (the mesh check on a linear mesh this fine, 0.01 to 50 mm; default quadratic elements on the same mesh) - `images`: bool|{"path":str? (the .png or .svg file the three images are written beside, as name-dc, name-ripple and name-peak),"format":"png|svg"?,"widthPx":int=1200,"heightPx":int=900,"dpi":int=300,"palette":"light|dark|print"="light" (as field.exportImage)}=false (draw the worst corner's |B| at its mean currents (dc, the common mode), at the swing from the mean to the peak instant (ripple, the differential mode) and at the peak instant (peak), on one colour scale) ## Reply - kind:"magnetics.coupledReport" - source - inductance:{l1,l2,m,k,lCommon (L̄ + M),lDifferential (L̄ − M),source:"field",meshCheck:{method (elementOrder2|elementMm),elementMm?,l1,l2,m,changePct:{l1,l2,m},maxChangePct}} - corners:\[{label,currents:{source (call|triangle|held|run)},legs:\[{leg,meanBT,bP99BT,peakBT}\]|null,outerLegBT,outerLeg,centreBT,bP99T,peakBT,cornerPeak,coreLossW,coreLossIgseW,dcBiasCorrected,frequencyHz,temperatureC,material,warnings:\[code\],source:"field"}\] - currentLimit?:{currentA,legs,peakLegMeanBT,peakLeg,bsatT,limitT,bsatMargin,marginPct,pass,source:"field"} - imbalance?:{atA:\[A,A\],stepA,leg,balancedBT,imbalancedBT,sensitivityTPerA,mTPerA,toMarginA,toBsatA,method,source:"field"} - material? - images?:{corner,range:{min,max} (T: 0 to the largest of the three maps' own tops),currentsA:{mean:\[A,A\],peak:\[A,A\],swing:\[A,A\]},saturated (on a B-H curve: dc and peak drawn from the Newton solves at those currents, ripple the change between them; false: the 1 A linear fields superposed),dc,ripple,peak (each field.exportImage's reply at those currents, or null when they are all zero)} - result:{headline,values} - summary:{en,zh-Hant} - notes:\[{en,zh-Hant}\] - preview - previewNote --- # Export FEMM Model (`magnetics.femmExport`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/magnetics-femmExport/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/magnetics-femmExport/) **Menu:** **Design › Field Solver › FEMM Export** · **Runs as:** at once ## What it does Writes the design as a FEMM 4.2 model: the planar section of an E pair, a planar E set, or an ETD, EFD or RM set (post and legs at their true sections over the depth) with the gap ground into the centre leg, or the top view of a ring core, with each winding (round, litz or foil, conductors in hand, layers) in the window, the core as μr or a B-H table, and copper at 20 °C. The Lua script opens the .fem, drives 1 A in each winding in turn and writes L, M and the winding resistance at the frequency; pass that file to magnetics.femmImport. Writes the files through the host's file service when paths are given. Changes nothing. ## Parameters - `design`: object (a magnetics.design reply, or its best design; the design may add layout:"centreLeg"|"outerLegs" (outerLegs, an E set with two windings: winding A on the left outer leg and B on the right, the two-phase coupled inductor), gapOuterMm (a spacer gapping every leg, 0 to 100), gapCentreMm (the centre leg's whole gap, spacer included; default gapMm, else the spacer) and stacks (sets stacked, 1 to 64; default the core's)) - `frequency`: Hz? (of the AC solution; default the reply's fsw, 0 solves magnetostatics) - `muR`: number? (core relative permeability; default the catalogue's initial permeability at the design temperature) - `bh`: \[\[H,B\]\]? (core B-H table, A/m and T, up to 200 points) - `clearanceMm`: number=0.1 (space between drawn regions) - `femPath`: str? - `luaPath`: str? - `resultsPath`: str? (where the script writes its results; default next to the .fem) ## Reply - model:{family,problem:"planar",depthMm,gapMm,spacerMm,layout,stacks,frequency,muR,bhPoints,windings:\[{circuit,turns,parallel,conductor}\],nodes,labels} - fem - lua - femPath - resultsPath - notes - written --- # Import FEMM Results (`magnetics.femmImport`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/magnetics-femmImport/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/magnetics-femmImport/) **Menu:** **Design › Field Solver › FEMM Import** · **Runs as:** at once ## What it does Reads field-solver results back: L of each winding, M, k = M/√(L1·L2), the magnetising inductance a·M and the leakages L1 − a·M and L2 − M/a, and the winding resistance at the frequency (rac). Give exactly one of results, path or values. With apply, an inductor gets l, a coupled inductor l1, l2 and k, a transformer lm, llk1 and llk2; the source (e.g. 'FEMM, gap 1.2 mm, 100 kHz') names the history step. ## Parameters - `results`: str? (the text of the results file the magnetics.femmExport script wrote) - `path`: str? (that file, read through the host's file service) - `values`: {"source":str,"frequency":Hz,"gapMm":number?,"l1":H,"l2":H?,"m":H?,"r1":Ω?,"r2":Ω?,"turns1":int?,"turns2":int?}? (from another field solver, e.g. Ansys Maxwell or COMSOL) - `component`: str? (inductor, coupled inductor or transformer to write) - `ratio`: number? (N1/N2 for the transformer split; default the results' turns, then the part's n) - `apply`: bool=false (write ONE history step named after the source) ## Reply - source - frequency - gapMm - result:{values} - apply:\[edits\] - applied - notes --- # Field-Check Designs (`magnetics.fieldCheck`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/magnetics-fieldCheck/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/magnetics-fieldCheck/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** a job, with progress and Cancel > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. Field-checks the top candidates of a magnetics.design reply and ranks them again: each candidate is solved with Voltecx's own 2D field solver on the drawing magnetics.fieldSolve solves (linear, the core at the candidate's muRPeak, 1 A in the primary alone), giving its field L and the core's peak flux at the design's peak current ipkA (the area-weighted 99th percentile of |B| in the core, the saturation rule of the field reports, times ipkA). A candidate passes when that flux is at most its saturation flux at the hottest corner (bSatHotT; the field rule of magnetics.fieldCoreLoss, without the design's bsatMargin, which is a margin on the analytic mean flux), and, with lTolerance, when its field L is within that fraction of the design's. Ranked: the passing candidates first, then the least total loss (the design's core and copper loss), then the smallest |lError|, then the design's own order. The planar model leaves out the end turns, so lField reads low by their share (magnetics.fieldSolve dimension 3 with endTurns adds them). A job: progress counts the candidates solved, and cancel stops within one iteration. Candidates from a reply made before magnetics.design reported ipkA are refused with that said. ## Parameters - `design`: object (a magnetics.design reply, with its candidates) - `top`: int=3 (check the first 1 to 10 candidates, in the design's order) - `elementMm`: number? (largest element in the core and the windings, 0.01 to 50 mm, as magnetics.fieldSolve takes it) - `clearanceMm`: number=0.1 (space between drawn regions) - `lTolerance`: number? (0 to 1: a candidate whose field L is off the design's l by more than this fraction fails; default no L limit, the error is only reported) - `ignoreMemoryCheck`: bool=false ## Reply - checked - candidates:\[{rank,designRank,core,shape,material,turns,gapMm,wire,parallel,lDesign (H),lField (H, from the field energy),lError (lField/lDesign − 1),ipkA,bPeakDesignT,bPerAmpT (the core's area-weighted 99th-percentile |B| at 1 A),bPeakFieldT (bPerAmpT × ipkA),bSatHotT,saturation (bPeakFieldT/bSatHotT),coreLossW,copperLossW,totalLossW,temperatureC,pass,fails:\[saturation|inductance\],model:{nodes,elements,minAngleDeg,residual,inputHash,solverVersion}}\] - best (the first passing row, or null) - lTolerance - rankedBy - notes - preview - previewNote --- # Field Core Loss (`magnetics.fieldCoreLoss`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/magnetics-fieldCoreLoss/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/magnetics-fieldCoreLoss/) **Menu:** **Design › Field Solver › Core Loss from Last Run** · **Runs as:** a job, with progress and Cancel > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. Core loss from the field: the model magnetics.fieldSolve meshes, driven by one period of winding current, B(t) on every core element: when the material has a data-sheet B-H curve (N87, N97, 3C90 and 3C95) a nonlinear Newton solve at every time point on the curve at the temperature, warm-started from the point before; otherwise, or with linear, one solve per winding at 1 A scaled by the currents; then the iGSE per element with the material's Steinmetz data at the waveform's fundamental and the temperature, summed over the core's volume (the planar slice as deep as the core). The map lists every core element as \[xMm, yMm, areaMm2, W/m³\]. In 2D, model.provenance names the loss solve's solver version and a hash of its input (fnv1a64 of the model, the windings, the core regions, the depth, the waveform, the material's loss data, temperature and saturation, and with field the reference solves the loss is scaled from), so a stored result can be checked against a fresh one: the same call gives the same hash. Saturation: the core's 99th percentile of element |B| by area (bP99: per core region the |B| below which 99 % of its area lies, the largest region's; by volume in 3D) is checked against the material's saturation flux density at the temperature, the peak reported beside it; a peak on a corner of the drawing, where the linear field is singular, gets a cornerPeak warning. In 2D on a B-H curve, a bP99 at or above 0.9 of the saturation flux density gets a warning that the planar model under-represents the flux spreading through a real core's depth near saturation (8.3 % off the 3D loss for the E 25/13/7 buck at full load, 0.5 % at half load) and suggests dimension: 3. An inductor design whose winding current peaks above bsatMargin·isat (the limit magnetics.design held it to) gets a warning naming both currents, in 2D and 3D: the design was made for a smaller current, and its core saturates at this one. With field and a B-H curve, the field view's potentials are the linear solves at 1 A (the loss map is the nonlinear one). A job: cancel stops before the loss is computed. With magnets the magnets are solved once with no current and their field is added at every time point (on a B-H curve every time point is solved with the magnets in place): the core's DC bias, which the iGSE takes as DC premagnetization (dcBias, totalLossIgseW and the DC-bias warnings as for a DC current); a magnet region is not core and takes no B-H curve. In 3D a magnet is its region's body through the depth, magnetized in the drawing's plane, and the extrusion keeps its half through the depth but is never quartered; a ring design takes no magnets in 3D. B-H tables and more than two circuits are refused. An axisymmetric sketch (2D only) takes each element's loss over its ring 2π r̄ |Δ|, so the loss and coreVolume are the whole core's, and reports model.form axisymmetric (planar otherwise); with magnets their direction is \[r, z\]; field is refused. With dimension 3 the reply adds dimension:3 and provenance:{solverVersion,inputHash} (a hash of the 3D mesh, the fields, the waveform and the material), coordinates gain z (peak, hottest and dcBias give atMm:\[x,y,z\] instead of xMm,yMm; bMean and bPeak add bz; the map's columns are \[xMm,yMm,zMm,volumeMm3,lossDensity\], one row per core tetrahedron of the meshed part (with model.symmetry 2 the half z ≥ 0, whose rows sum to half the total; with 4 the quarter x ≥ 0, z ≥ 0, a quarter); coreVolume is the 3D core's; regions, p99 and bP99 are over tetrahedra, weighted by volume where 2D weighs by area, and no peak is at a sketch corner), and model is the 3D one (construction extruded|revolved|wound, layers, nodes, elements and coreElements in tetrahedra, edges, freeEdges, iterations and residual per winding, estimatedPeakMemoryBytes, provenance per winding's solve); field is magnetics.fieldSolve's 3D field (nodes, tetrahedra, elementRegions, regions, circuits, b per winding at 1 A) with lossDensity per tetrahedron, peakCurrents, peakTimeS and waveform. B(t) comes from one 3D solve per winding at 1 A, scaled by the currents, or, for a core whose material has a data-sheet B-H curve (without linear), from a 3D Newton solve on the curve at every time point with every winding at its current, warm-started from the two points before (extrapolated along the currents) or the point before, and a waveform whose every current is half-wave symmetric, i(t+T/2) = -i(t) at the points, solved on its first half period only (nonlinear:true; model adds newton:{tolerance,maxSteps,cgTolerance} and steps:\[{step,timeS,start (cold|warm|extrapolated (from the two points before, along the currents)|coldAfterWarm|ramped (the cold start failed too; the currents ramped to the point in 4 stages from the point before)|halfWave|repeated (the point's currents are an earlier point's, bit for bit: it takes that point's B and is not solved again)),warmStartError (why the warm start, and for ramped the cold one, failed),mirrorsStep (halfWave: the step half a period before whose B, sign changed, this one takes),repeatsStep (repeated: the earlier step whose B this one takes),newtonSteps,cgIterations,residual}\] (with method incremental only the two check steps), method (scaled|perStep|incremental), provenance solver names the Newton drive; with method incremental the reply adds incremental:{dcCurrents:\[A\],dcNewtonSteps,dcResidual,inductanceH:\[\[H\]\] (the incremental inductance matrix at the DC point),checkSteps,bError,swingError,lossError (fractions: the expansion against the full solve at the ripple's extremes; lossError is the loss its swing error gives by the iGSE's ΔB^β scaling),limit (0.01)} and an incrementalError warning when lossError is above limit, and with field the field view's B is the linear solve at 1 A).. The 3D model past the node or element limit, or whose memory estimate (the solve and the per-tetrahedron loss) is past 60 % of the memory available (unless ignoreMemoryCheck), is refused before it is built; progress counts the windings solved (or the time points solved on a curve) and the loss, and cancel stops the 3D solve within a second. ## Parameters - `design`: object? (a magnetics.design reply, or its best design) - `network`: {"windings":\[str\] (every winding element of a core drawn in the circuit as a magnetic network, its reluctances, leakage paths and flux probes),"core":{"shape":str,"material":str,"wire":str (catalogue names),"parallel":int=1,"core":str?,"stacks":int?,"gapOuterMm":number?,"gapCentreMm":number? (as a design takes them)}}? (instead of design or sketch, not with component or apply: the windings one flux runs through in series are one leg, their turns summed, and the two legs are the windings A and B of the outer-legs design of the core (layout outerLegs), the leg of the first winding named being A; the reply adds network:{legs:\[{circuit,windings,turns,totalTurns}\],reversed (leg B's current is turned round to match the template's sense),network:{l1,l2,m,k} (from the network's reluctances),field?:{l1,l2,m,k},difference?:{l1,l2,m,k} ((field − network)/|network|, M in the network's sense)}) - `sketch`: object? (instead of design: the planar drawing magnetics.fieldSolve takes, or an axisymmetric (r, z) section, axisymmetric: true with no depthMm, revolved a full turn about x = 0, as magnetics.fieldFluxMap takes it: each element's loss is its density times the ring it sweeps, 2π r̄ |Δ|, with no depth; 2D only, without field; its muR labels are the core) - `muR`: number? (design only, as magnetics.fieldSolve) - `clearanceMm`: number=0.1 (design only) - `elementMm`: number? (as magnetics.fieldSolve) - `legZones`: {"centreHalfWidthMm","windowHalfWidthMm","windowTopMm"}? (planar sketch only, 2D: where its E set's legs lie, the set centred on the origin as a design is drawn: the centre leg within centreHalfWidthMm of x = 0, the outer legs beyond windowHalfWidthMm, the yokes beyond ±windowTopMm; each \> 0 mm, centre below window; the reply's legs then names them as for a design) - `material`: str? (sketch only, required there: the catalogue material of the core regions; a design uses its own) - `temperatureC`: number? (core temperature, -55 to 250 °C; default the design's, else 25) - `waveform`: object? ({t:\[s\], i:\[\[A\] one list per circuit, in the order magnetics.fieldSolve reports the circuits\]}: one period, the last point starting the next one) - `signals`: \[str|null|\[\[str,number\]\]\]? (instead of waveform: one current signal per circuit from the last run, such as "i(L1)", null for a winding that carries no current, or a list of 1 to 64 \[signal, weight\] pairs summed (weights finite, at most 1e6); with network the default is each leg's windings' currents weighted by their share of its turns; a new run when the result is missing or stale) - `t0`: s? (signals: the period's start; default t1 - 1/fsw) - `t1`: s? (signals: the period's end; default the end of the run) - `fsw`: Hz? (signals: the period is 1/fsw; default the circuit's PWM frequency) - `tEnd`: s? (signals: run the circuit to tEnd first) - `points`: int=200 (signals: the period resampled to this many intervals, 4 to 10000) - `map`: bool=true (return the loss-density map) - `field`: bool=false (also return the solved field for a field view: what magnetics.fieldSolve's field holds, with lossDensity \[W/m³ per element, 0 outside the core\] peakCurrents \[A per circuit at the instant of the peak |B|\], peakTimeS and waveform {t, i} \[the period's currents, for field.exportImage {at}\]) - `dimension`: int=2 (2 or 3; 3 builds the 3D model magnetics.fieldSolve builds with dimension 3, a sketch or an E-core design extruded straight through its depth or a ring design revolved, and computes the loss per tetrahedron) - `layers`: int? (dimension 3, extruded: element layers through the depth, 1 to 64; default 8; an even count meshes only the half z ≥ 0, the middle plane being a symmetry plane no flux crosses, and doubles the totals: model.symmetry 2; when the section is also antisymmetric about x = 0 (every region mirrored by one of the same material, coils by the same circuit with opposite turns), only the quarter x ≥ 0, z ≥ 0: model.symmetry 4; with field the reply's field and lossDensity are the whole extrusion reflected from the half or quarter, the meshed part's elements first) - `endTurns`: bool=false (dimension 3, an E or planar E design with one or two round or litz windings on the centre leg: the wound model magnetics.fieldSolve builds with endTurns, each winding wound around the leg as a bobbin with its end turns, one eighth of the core meshed (x, y, z ≥ 0); the loss, coreVolume and incremental's inductance are the whole core's, eight times the eighth's, model.construction is wound and model.symmetry 8, the map lists the eighth's core tetrahedra, and field is the whole core reflected from the eighth; on the core's B-H curve unless linear:true; not with sketch, layers or magnets) - `ignoreMemoryCheck`: bool=false (dimension 3: solve even when the memory estimate is past the limit) - `lossPoints`: \[{"frequencyHz":Hz,"bPeakT":T,"loss":number (in lossUnit),"temperatureC":number? (on every point or on none)}\]? (3 to 1000: your own tabulated core-loss curves, Pv against the sine's peak B at two or more frequencies, read off the data sheet's loss curves or measured, as the loss model instead of the catalogue's Steinmetz data: with tables at several temperatures, a core between two of them takes the two tables' laws interpolated with ln Pv linear in temperature (the two tables at the same frequencies), outside their span the nearest table as it is; one Steinmetz law fitted between each two neighbouring frequencies to their points, the iGSE taking the one that holds the fundamental (the nearest outside the table); no DC-bias correction; the reply adds lossPoints:{points,given,lossUnit,temperatureC,interpolatedC:\[lo,hi\]?,weight?,frequencyHz:\[min,max\],ranges:\[{fMinHz,fMaxHz,k,alpha,beta,points,rmsLnError}\]} and a note; refused when a pair of neighbouring frequencies gives no law) - `lossUnit`: "W/m3|kW/m3|mW/cm3"="W/m3" (of lossPoints) - `linear`: bool=false (keep the core linear at its muR even when the material has a data-sheet B-H curve, in 2D and 3D) - `method`: str="perStep" (dimension 3, on a B-H curve: perStep solves the curve at every time point; incremental solves it once at the period's mean currents and adds the ripple on the incremental field there (the first-order expansion, for a ripple small against its DC level, as in a buck inductor), with full solves at the ripple's two extremes as its error estimate; refused without a curve or with linear) - `magnets`: \[{region:str (the name of a region of the drawing that is not a coil; with a design, \\"centre-leg gap\\" draws the centre leg's gap as its own region, a slot the magnet fills, refused for a ring or a gapless design),direction:\[x,y\] (the magnetization direction, any length; \[r, z\] in an axisymmetric section),temperatureC:number,grade:str (a built-in grade: Arnold N35, Arnold N42, Arnold N42H or Arnold N42UH, sintered NdFeB, each from its Arnold Magnetic Technologies data sheet) | {name:str,source:str (the data sheet the values come from: document, revision, table),recoilMuR:number (≥ 1),points:\[{temperatureC,brT (remanence),hcjAPerM (intrinsic coercivity),hkAPerM (knee field, H\_k ≤ H\_cJ)}\] (1 to 64, rising temperature)}}\]? (permanent magnets, at most 64: each region becomes a magnet on its recoil line B = μ0 μrec H + Br at the temperature, Br, H\_cJ and H\_k linear between the sheet's points and the nearest point outside them with an outsideMaterialData warning; any other grade's values are the caller's, and the grade must name its sheet; demagCurve:\[\[H,B\]\]? (field.lineProfile, field.regionTable, magnetics.fieldFluxMap, magnetics.fieldSolve {dimension: 3} and field.force {dimension: 3} only, every other command refuses it: the grade's normal demagnetization curve at temperatureC from the same data sheet, A/m and T, 2 to 200 points from \[0, Br\] with H and B both falling through the knee, its Br within 1 % of the grade's; the magnet is then solved by Newton's method on it, a reverse field along the magnetization on the curve and a forward or crosswise one on the recoil line, reversibly, with Br from the curve)) ## Reply - source - nonlinear (the core was solved on its B-H curve) - magnets? (with magnets: each magnet's data and demagnetization check, as field.lineProfile gives them, at the worst of the time points where a winding's current is largest and smallest, with atTimeS and atCurrentsA; in 3D by volume: volumeMm3 (the whole model's) for areaMm2, direction \[x,y,0\] and worstAtMm \[x,y,z\]) - magnetWarnings? (\[{code,message,messageZh,data,region}\], the magnet warnings; their sentences are in warnings too) - result:{values} - totalLossW - totalLossIgseW (the plain iGSE total; equal to totalLossW unless the material's DC-bias data corrected it: N87 and 3C90 carry Steinmetz Premagnetization Graphs fitted from the Princeton MagNet measurements, the table measured nearest the temperature; a dcBiasNotCovered warning when the material has none or the most biased element is outside the measured H\_dc, frequency, flux amplitude or temperature) - dcBias:{element,xMm,yMm,hDc \[A/m, the period mean of H\],fluxDc \[T, the period mean of B\],corrected} (the core element with the largest DC premagnetization) - coreVolume - meanLossDensity - frequency - peak:{b,timeS,element,xMm,yMm} - p99 (T: the largest core region's 99th percentile by element count, the element at index ⌊0.99 n⌋ of the ascending list; it moves with the mesh, kept for compatibility) - bP99 (T: the same percentile by area, each element's peak |B| over the period weighted by its area, the largest of the core regions: it does not lean towards the small elements the mesh crowds into corners; what the saturation check reads and the Field Core Loss window shows) - regions:\[{region,name,elements,p99BT (by count),bP99BT (by area),meanBT,peakBT,peakElement,peakAtCorner}\] (per core region, each element's peak |B| over the period) - legs:\[{leg (centre|left|right|top|bottom: the yokes),elements,areaMm2,meanBT (by area),bP99BT (by area),peakBT}\]|null (a design's E, ETD, EFD or RM set in 2D: per leg, over the core elements whose centroid lies in it, each element's peak |B| over the period; a leg's mean is the flux density a reluctance model gives it, which the corners do not move; for a planar sketch with legZones the same over the zones it gives; null for a sketch without them or a ring core; not in a 3D reply) - saturation - hottest:{element,xMm,yMm,lossDensity} - bMean:{t,bx,by} (the area-weighted mean vector over the core, which cancels where the flux returns through other legs) - bAbsMean:\[T\] (the area-weighted mean |B| over the core at each time point) - bPeak:{t,bx,by} (B(t) of the element with the peak |B|) - waveform:{source,signals,t0,t1,points} - material:{name,temperatureC} - model:{family,circuits,turns,form (planar|axisymmetric),depthMm,gapMm,muR,elementMm,nodes,elements,coreElements,solverVersion,provenance:{solverVersion,inputHash}} - map:{columns,elements}? - field? - warnings - notes - preview - previewNote --- # Field Flux Map (`magnetics.fieldFluxMap`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/magnetics-fieldFluxMap/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/magnetics-fieldFluxMap/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** a job, with progress and Cancel > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. Sweeps one winding's current through the model magnetics.fieldSolve meshes (planar, or an axisymmetric sketch's (r, z) section) and solves each point with the nonlinear Newton solve, the core on its catalogue B-H curve at the core temperature (N87, N97, 3C90 and 3C95 have data-sheet curves; another material stays linear, with a note), warm-started from the point before. Records every winding's flux linkage λ = d·Σ J/i·∫A dS (an axisymmetric sketch: λ = 2π·Σ J/i·∫ψ dr dz on the flux function ψ = r·A\_φ, with no depth), so the driven winding's λ(i) is the saturating inductor's flux-linkage table and the other windings' the mutual one. With apply, an inductor gets l (dλ/di at zero current) and psiCurve; refsolve and fastsolve then follow the table's incremental inductance. A part that links no core also gets the design's core, material, turns and gap (a sketch cannot give them: link the core first). A part with bhCurve is refused (give one curve). With two or more windings each table row also has the incremental L/M matrix ∂λ\_k/∂i\_w, from the Newton Jacobian at that point (symmetric; its coupling coefficient is M/√(L1·L2)); with exactly two windings, apply writes a coupled inductor's l1, l2, k (at zero current) and coupledCurve (winding 1 = the driven winding, M the mean of the two mutual terms), and both solvers then follow the matrix at the magnetizing current i1 + n\_e·i2 (n\_e = √(L22/L11)). Into a transformer, apply writes coupledCurve and n = √(L11/L22) at zero current: the table becomes its whole magnetic model (magnetizing inductance, saturation and leakage; llk1, llk2, rw1, rw2 and rcore still add), its winding currents read i(T1.1) and i(T1.2), and a transformer that sets lm, isat, lmsat, im0, psiCurve, bhCurve or a core is refused (remove them first). With magnets the origin is solved too (the magnets' field alone), every row's inductance is the incremental dλ/di from the Newton Jacobian at that point and apparent is measured from the bias, (λ − λ(0))/i; on its recoil line a magnet's load does not depend on the current, so their bias shifts the saturation knee (by about B\_r g/(μ0 μrec N) for a magnet in the gap, less with fringing). A biased λ(i) is not odd about zero current, so a biased sweep also runs −maxCurrent/points to −maxCurrent from the same bias (the table then runs from −maxCurrent, current rising, and the demagnetization check covers both sides), and its psiCurve is two-sided, from −maxCurrent through the bias point 0:λ(0) to maxCurrent; apply writes it and l (the incremental inductance at zero current) into an inductor, and both solvers follow its dλ/di on each side. With two windings its coupledCurve is two-sided the same way, from −maxCurrent through the bias row at 0 A to maxCurrent, and the coupled inductor or transformer that apply writes it into reads the matrix at the signed magnetizing current (so the side whose ampere-turns add to the magnets' flux saturates first). A magnet given its demagCurve is solved on that curve at every point: past its knee its load depends on the current, and each row's incremental inductance takes the curve's slope there from the Newton Jacobian. A job: progress counts the swept currents, and cancel stops before the next one. ## Parameters - `design`: object? (a magnetics.design reply, or its best design) - `network`: {"windings":\[str\] (every winding element of a core drawn in the circuit as a magnetic network, its reluctances, leakage paths and flux probes),"core":{"shape":str,"material":str,"wire":str (catalogue names),"parallel":int=1,"core":str?,"stacks":int?,"gapOuterMm":number?,"gapCentreMm":number? (as a design takes them)}}? (instead of design or sketch, not with component or apply: the windings one flux runs through in series are one leg, their turns summed, and the two legs are the windings A and B of the outer-legs design of the core (layout outerLegs), the leg of the first winding named being A; the reply adds network:{legs:\[{circuit,windings,turns,totalTurns}\],reversed (leg B's current is turned round to match the template's sense),network:{l1,l2,m,k} (from the network's reluctances),field?:{l1,l2,m,k},difference?:{l1,l2,m,k} ((field − network)/|network|, M in the network's sense)}) - `sketch`: object? (instead of design: the planar drawing magnetics.fieldSolve takes, or an axisymmetric (r, z) section, axisymmetric: true with no depthMm, revolved a full turn about x = 0, its magnets' direction \[r, z\] in the section; its cores stay linear at their muR) - `maxCurrent`: A (the largest swept current, above zero) - `points`: int=12 (swept currents, 2 to 40, evenly spaced from maxCurrent/points to maxCurrent; the origin is added) - `winding`: str? (the circuit to drive; default the first) - `along`: {circuit:number}? (the other windings carry this multiple of the swept current, -1000 to 1000, a winding left out none: {B:1} sweeps a coupled inductor's two legs together as their DC flows, so each row's incremental matrix is L and M at that bias; not with component, apply or magnets) - `temperatureC`: number? (design only: core temperature for its B-H curve, -40 to 200; default the design's, else 25) - `laminations`: object? (#3069, as magnetics.fieldSolve takes it: magnetic region name to {stackingFactor:number (above 0, at most 1),normal:"x"|"y"}, up to 64: the region is a stack of sheets, linear at μ along the sheets F·μr + (1 − F) and across them 1/(F/μr + 1 − F) in every Newton solve of the sweep, or, when the core is on a B-H curve (a design whose material has one), each sheet on that curve and the stack on its own curve along the sheets (H shared) and across them (B shared), so it saturates (laminations.md §8); model.laminations gives \[{region,stackingFactor,normal,sheetMuR,muAlong,muAcross,bhCurve (the sheet's curve, or null for a linear stack)}\]) - `clearanceMm`: number=0.1 (design only) - `elementMm`: number? (as magnetics.fieldSolve) - `component`: str? (the inductor, coupled inductor or transformer to write) - `apply`: bool=false (an inductor: write l and psiCurve, and core, material, turns and gap when the part links no core; a coupled inductor: write l1, l2, k and coupledCurve; a transformer: write n and coupledCurve; in ONE history step) - `magnets`: \[{region:str (the name of a region of the drawing that is not a coil; with a design, \\"centre-leg gap\\" draws the centre leg's gap as its own region, a slot the magnet fills, refused for a ring or a gapless design),direction:\[x,y\] (the magnetization direction, any length; \[r, z\] in an axisymmetric section),temperatureC:number,grade:str (a built-in grade: Arnold N35, Arnold N42, Arnold N42H or Arnold N42UH, sintered NdFeB, each from its Arnold Magnetic Technologies data sheet) | {name:str,source:str (the data sheet the values come from: document, revision, table),recoilMuR:number (≥ 1),points:\[{temperatureC,brT (remanence),hcjAPerM (intrinsic coercivity),hkAPerM (knee field, H\_k ≤ H\_cJ)}\] (1 to 64, rising temperature)}}\]? (permanent magnets, at most 64: each region becomes a magnet on its recoil line B = μ0 μrec H + Br at the temperature, Br, H\_cJ and H\_k linear between the sheet's points and the nearest point outside them with an outsideMaterialData warning; any other grade's values are the caller's, and the grade must name its sheet; demagCurve:\[\[H,B\]\]? (field.lineProfile, field.regionTable, magnetics.fieldFluxMap, magnetics.fieldSolve {dimension: 3} and field.force {dimension: 3} only, every other command refuses it: the grade's normal demagnetization curve at temperatureC from the same data sheet, A/m and T, 2 to 200 points from \[0, Br\] with H and B both falling through the knee, its Br within 1 % of the grade's; the magnet is then solved by Newton's method on it, a reverse field along the magnetization on the curve and a forward or crosswise one on the recoil line, reversibly, with Br from the curve)) ## Reply - source - result:{headline,values:\[l0,lMax,maxCurrent\]} - table:\[{current,fluxLinkage:\[Wb per winding\],inductance (dλ/di of the driven winding, H),apparent:\[λ\_k/i, H\],incremental? (two or more windings: the incremental L/M matrix \[k\]\[w\] = ∂λ\_k/∂i\_w at this point, H)}\] - reciprocity? (two or more windings: the largest |M\_jk − M\_kj|/|M| over the table) - coupledCurve? (exactly two windings: i:L11:M:L22 rows, A and H, winding 1 the driven one; two-sided from −maxCurrent for a biased sweep) - psiCurve (i:λ pairs of the driven winding, A and Wb; two-sided from −maxCurrent for a biased sweep) - bias? (with magnets: λ(0) of every winding, Wb, the magnets' flux linkage at zero current) - biased? (with magnets: whether λ(0) ≠ 0) - magnets? (with magnets: each magnet's data and demagnetization check at the swept point with the most area past the knee, else the largest reverse field, as field.lineProfile gives them, plus atCurrentA) - warnings? (\[{code,message,messageZh,data,region}\], the magnet warnings) - windings - driven - along (each winding's multiple of the swept current) - nonlinear - material? - temperatureC? - model:{family,form (planar or axisymmetric),nodes,elements,elementMm,newtonSteps:\[per point\],residuals:\[per point\],solverVersion} - apply:\[edits\] - applied - notes - preview - previewNote --- # Field Solve (`magnetics.fieldSolve`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/magnetics-fieldSolve/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/magnetics-fieldSolve/) **Menu:** **Design › Field Solver › Field Solve** · **Runs as:** a job, with progress and Cancel > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. Solves the magnetic field with Voltecx's own 2D solver, without FEMM: the planar model magnetics.femmExport writes for a design (the front section of an E pair with the gap ground into the centre leg, or the top view of a ring core), or the sketch; meshed automatically, magnetostatic with linear materials, 1 A in each winding in turn. Returns what magnetics.femmImport returns for these values: L of each winding from the field energy, M, k, and when the turns ratio allows, the magnetising inductance and the leakages (a split that falls below zero is left out with a note); no rac (mode harmonic gives the AC impedance with the eddy loss of solid conductors; the windings' own copper loss is field.windingAc's, or magnetics.femmExport's). With apply, an inductor gets l, a coupled inductor l1, l2 and k, a transformer lm, llk1 and llk2. A job: progress counts the windings solved, and cancel stops the solve within one iteration. Memory: before the job starts, the fewest nodes the element sizes need give an estimate of the memory the solve takes, and once meshed (before the matrix is built) the mesh gives it exactly; past 60 % of the memory available now the solve is refused with what to change (the same refusal and Run Anyway as simulation.run), unless ignoreMemoryCheck. model.provenance names, per winding's solve, the solver (its form and method) and a hash of its input (fnv1a64 of the mesh, materials, sources and stopping rule, as field.exportDiagnostics records it), so a stored result can be checked against a fresh solve: the same call gives the same hashes. Other core families, B-H tables, axisymmetric sketches and more than two circuits (without connections or mode harmonic) are refused. With dimension 3 the reply adds dimension:3, inductance:{fromEnergy:{l:\[H\],m,k},fromFluxLinkage:{l:\[H\],m12,m21,k},maxRelativeDifference} (L from the field energy and from the flux linkage, M from the mutual energy and from each winding's linkage; the values and apply use L from the energy and M from the flux linkage, as in 2D), peakB:\[{circuit,b (T at 1 A in that winding),atMm:\[x,y,z\],region,element,bP99 (T at 1 A: the core's 99th percentile of |B| by volume, per core region the |B| below which 99 % of its volume lies, the largest region's; the saturation rule, which small elements crowded into an edge do not move; null without a core),atCorner (the peak's tetrahedron has a node on an edge where its region's surface bends: a field singularity that grows with the mesh; read bP99)}\], warnings:\[{code,message,messageZh,…}\] (planarModel for an extrusion, linearMaterial per core; with adaptive, notConverged when it stopped at maxPasses or maxElements and meshTooCoarse when the last pass's estimate puts the L error above 0.5 %) and model:{dimension:3,construction:extruded|revolved|imported|wound,symmetry (the whole model is this many times the meshed part: 8 for wound, 4 for an extrusion meshed as its quarter or a ring revolved through a quarter turn (without field or adaptive: the ring is the same at every angle, so the cut planes are left free), 2 for an extrusion meshed as its half through the depth, else 1),family,circuits,turns,depthMm,gapMm,muR,elementMm,layers,revolveStepDeg,nodes,elements (tetrahedra),edges,freeEdges,minDihedralDeg,maxDihedralDeg,iterations:\[per winding\],residual:\[per winding\],reciprocity (|M12 − M21|/|M| of the flux linkages, 0 with one winding),amgLevels,tolerance,estimatedPeakMemoryBytes,solverVersion,provenance:\[{circuit,solver,solverVersion,inputHash}\]}, fieldCache:{enabled,mesh (the model came from the cache),solution (the solves came from the cache),entries,bytes (what the cache holds now)}, and with field, field:{dimension:3,nodes:\[\[x,y,z\]\] (m),tetrahedra:\[\[a,b,c,d\]\],elementRegions:\[region\],regions:\[{name,muR}\],circuits,b:\[\[\[Bx,By,Bz\] per tetrahedron, T at 1 A in that circuit, single precision\]\]} (the materials are linear, so the field at any winding currents is the sum of each list times its current). With import (Preview, T49) the model is the bodies meshed on a graded lattice, with a plane through each vertex coordinate along an axis when there are at most 64 (flat-faced bodies then lie on lattice planes) and three cells or more across each interval; model.construction and model.family are imported, and a freeFormPreview warning says faces off the lattice planes are less accurate. A 3D model past the node or element limit, or whose memory estimate is past 60 % of the memory available (unless ignoreMemoryCheck), is refused before it is built; cancel stops the 3D solve within a second. Cache: the 3D model is kept by the parameters that build it (design, sketch, muR, clearanceMm, elementMm, layers, stepDeg, endTurns; not for import, whose file may change) and the solves by model.provenance's inputHash (a nonlinear sweep with its currents), at most 256 MiB for the process, the least recently used dropped first; a repeated call skips the meshing and the solve, gives the same reply but fieldCache, and checks the memory again; magnetics.fieldCacheClear empties it. Nonlinear 3D: a design whose core material has a catalogue B-H curve (N87, N97, 3C90, 3C95), without linear or muR, is solved on that curve at the core temperature by damped Newton iteration, each winding driven alone at every current of currents (warm-started from the one before); a sketch, muR, linear:true or a material with no curve takes the linear solve; endTurns is solved on the curve the same way, its eighth's ψ and L scaled to the whole core (a note says which). The reply then has nonlinear:true, material:{name,temperatureC}, inductance:{incremental:{l:\[H\],m,k},atCurrent} (L\_jj and M = the mean of the two mutual terms of the incremental matrix f̂ᵀJ⁻¹f̂ at the first current, which the values and apply use), lOfI:\[{circuit,points:\[{current,fluxLinkage:\[Wb per winding\],secant (ψ/I, H),incremental (dψ/dI, H),incrementalMatrix,newtonSteps,halvings,converged,residual,step,cgIterations,peakB}\]}\], peakB at the largest current, warnings (planarModel for an extrusion; outsideMaterialData for the material data at the temperature and for a region whose peak |B| is past its curve's last point; aboveSaturation when the core's 99th percentile of |B| by volume passes the material's saturation flux density at the temperature at any current, data {bP99,b (the core's peak),element,region,saturation,temperature}; noSaturationData when the material gives none) and model.newton:{tolerance,maxSteps,cgTolerance}; progress counts windings × currents, the memory check adds what Newton holds, field is refused (it is the linear superposition), and a Newton solve that does not converge is an error naming the saturating region, its curve and its peak |B|. Harmonic 3D (mode harmonic, #3824): the 3D model as above with the conductivities given, solved time-harmonically (complex A\* of the A,V–A formulation with V = 0 in the conductors, Bíró and Preis 1989; Whitney edge elements; AMS-preconditioned COCG; 3d.md §15), each winding driven alone at 1 A peak; the reply is {source,dimension:3,mode:"harmonic",frequency,result:{headline,values:\[r1 (Ω),l1 (H),r2?,l2?,f\]},windings:\[{circuit,resistance (Re Z, Ω: twice the loss at 1 A),reactance (Ω),inductance (H, Im Z/ω),lossW (the whole model's),regions:\[{region,lossW}\] (each conducting region),fluxLinkage:\[{re,im} (Wb, per winding)\],drives:\[{region,re,im}\] (an extrusion: the field along the depth, V/m, that holds each conducting region at zero net current),iterations,residual}\],impedance:\[\[{re,im}\]\] (row i, column j: winding i's voltage per ampere in winding j, Ω; the windings' own copper is not in it, field.windingAc gives that),conductors:\[{region,conductivity,muR,skinDepthMm,elementMm (the median of the region's tetrahedra's shortest edges)}\],warnings (planarModel, linearMaterial, freeFormPreview; skinDepthUnresolved per conductor whose skin depth is below its element size, data {region,skinDepthMm,elementMm}),notes,model:{dimension:3,construction,family,circuits,turns,depthMm,elementMm,layers,revolveStepDeg,symmetry,nodes,elements,edges,freeEdges,minDihedralDeg,maxDihedralDeg,iterations,residual,amgLevels,tolerance,estimatedPeakMemoryBytes,solver,solverVersion},field?,fieldCache}; with field:true, field is the 3D field as for the magnetostatic solve (nodes, tetrahedra, elementRegions, regions, circuits, the whole extrusion unfolded from its half; b per winding at 1 A peak is the real part of the B phasor) with bIm (its imaginary part), lossDensity (\[\[W/m³ per tetrahedron\] per winding at 1 A peak: the time-averaged ½σ|E|², the drives included; it integrates to lossW\]) and currentDensity (\[\[A/m² per tetrahedron\] per winding: √(2σ·lossDensity), the RMS over the tetrahedron of the peak |J|; 0 where nothing conducts\]); with terminals the reply adds terminals:\[{region,between:\[str,str\] (its two terminals, the first at 1 V),resistance,reactance,inductance,impedance:{re,im} (Ω, U/I between its end faces),current:{re,im} (A at 1 V peak),lossW (at 1 V peak, every conducting region's; ½ Re(U Ī)),regions:\[{region,lossW}\],mutual:\[{circuit,re,im}\] (winding i's voltage per ampere in the conductor, Ω; equal to the conductor's drive in that winding's row times the depth),iterations,residual}\] and values rt1,lt1,…; adaptive refines the mesh as for the linear magnetostatic solve, on the recovery error of the complex B (its real and imaginary parts, each winding counted alike), and stops when every winding's resistance and reactance (or only the one stopOn names) change by less than stopChangePct (or at maxPasses or maxElements; an extrusion with field is meshed whole), the reply adding adaptive:{stop,maxElements,maxPasses,stopChangePct,minPasses,minConvergedPasses,refinePct,stopOn,passes:\[{pass,nodes,elements,resistance:\[Ω per winding\],inductance:\[H per winding\],energy:\[J per winding, ½∫ν(|Re B|²+|Im B|²) of the whole model\],changePct,estimatedErrorPct,minDihedralDeg,maxDihedralDeg,terminalResistance?:\[Ω per terminal\],terminalInductance?:\[H per terminal\]}\]} with the warnings notConverged and meshTooCoarse as there, and model describing the last mesh; the memory check counts the complex solve (of a mesh at maxElements with adaptive) (two more matrices, the complex iteration's vectors, copies of the mesh and each held region's solve, and with field the reply's lists) once the model's size is known, and the solve uses at most the cores less one, as every 3D solve. Harmonic 2D (mode harmonic without dimension 3, #3069 N1): the planar drawing of the design or sketch, meshed as the magnetostatic solve meshes it, solved time-harmonically (plan.md T12: A–V on linear triangles, sparse LU or COCG), each circuit driven alone at 1 A peak through its stranded coils and each region given a conductivity a solid body held at zero net current (a shield, a plate, a conducting core); the reply is {source,dimension:2,mode:"harmonic",frequency,result:{headline,values:\[r1 (Ω),l1 (H),r2?,l2?,f\]},windings:\[{circuit,resistance (Re Z, Ω: twice the loss at 1 A),reactance (Ω),inductance (H, Im Z/ω),lossW,regions:\[{region,lossW}\] (each conducting name),fluxLinkage:\[{re,im} (Wb, per circuit)\]}\],impedance:\[\[{re,im}\]\] (row i, column j: circuit i's voltage per ampere in circuit j, Ω; the off-diagonal real part is the mutual resistance; the windings' own copper is not in it),reciprocity (the largest |Z\_ij − Z\_ji|/|Z\_ij|),conductors:\[{region,conductivity,muR,skinDepthMm,elementMm (the median of the region's triangles' shortest edges),skinLayers:{layers,depthMm,firstMm}|null}\],lossyMagnetic:\[{region,muR,muRLoss,lossTangent (μ″/μ′)}\] (the regions muRLoss gives a loss; windings\[\].regions lists their loss too),current:{circuit (null for a port),port (with connections),trace:{signal,window:\[t0,t1\],samples}|null,periodS,fundamentalHz,dcA,rmsA,capturedPct (the share of the mean square the DC part and the harmonics taken carry),harmonics:\[{n,frequencyHz,rmsA,resistance (Re Z, Ω),lossW,regions:\[{region,lossW}\]|null}\],dcLossW (0),totalLossW,regions:\[{region,lossW}\]|null (summed; null for a port, whose windings' fields mix),fundamentalOnlyLossW (the AC part's mean square at the fundamental's Re Z)}? (with current),warnings (planarModel, linearMaterial; skinDepthUnresolved per conductor whose skin depth is below its element size: give the region a maxSizeMm below it),notes,model:{dimension:2,family,circuits,turns,depthMm,gapMm,muR,elementMm,nodes,elements,minAngleDeg,iterations,direct,estimatedPeakMemoryBytes,openBoundary,solver,solverVersion}}; adaptive (#3069 N6) refines the drawing's mesh from the one without it, pass after pass: the worst refinePct of the triangles by the Zienkiewicz–Zhu recovery error of the complex B (real and imaginary parts, each circuit counted alike, the conducting and muRLoss regions counted a second time against their own field energy, so their loss is resolved and not only the core's energy) split at their edge midpoints, the mesher then restoring the angles; it stops as the 3D loop does, on each circuit's own resistance and reactance (or the one stopOn names), at maxPasses, when the next mesh would pass maxElements (default ten times the first mesh's triangles) or at the node limit; with current it refines at the highest harmonic and the others are solved on the last mesh; not with dcBias; the reply adds adaptive:{stop (converged, passes, elements or refinement),frequency,maxElements,maxPasses,stopChangePct,minPasses,minConvergedPasses,refinePct,stopOn,passes:\[{pass,nodes,elements,resistance:\[Ω per circuit\],inductance:\[H per circuit\],changePct,estimatedErrorPct,minAngleDeg}\]}, notConverged when it did not converge, and model describes the last mesh; the memory check counts the complex solve and its sparse factor once meshed (with adaptive, of a mesh at maxElements); progress counts the circuits, and cancel stops between them. ## Parameters - `design`: object? (a magnetics.design reply, or its best design, or one written by hand with no circuit open and no magnetic part placed: {shape:"E 25/13/7",material:"N87",wire:"Round 0.5 - Grade 1" (catalogue names, magnetics.library lists them),turns:34,gapMm:1.0}; layout, gapOuterMm, gapCentreMm and stacks in it as magnetics.femmExport takes them) - `network`: {"windings":\[str\] (every winding element of a core drawn in the circuit as a magnetic network, its reluctances, leakage paths and flux probes),"core":{"shape":str,"material":str,"wire":str (catalogue names),"parallel":int=1,"core":str?,"stacks":int?,"gapOuterMm":number?,"gapCentreMm":number? (as a design takes them)}}? (instead of design or sketch, not with component or apply: the windings one flux runs through in series are one leg, their turns summed, and the two legs are the windings A and B of the outer-legs design of the core (layout outerLegs), the leg of the first winding named being A; the reply adds network:{legs:\[{circuit,windings,turns,totalTurns}\],reversed (leg B's current is turned round to match the template's sense),network:{l1,l2,m,k} (from the network's reluctances),field?:{l1,l2,m,k},difference?:{l1,l2,m,k} ((field − network)/|network|, M in the network's sense)}) - `sketch`: object? (instead of design: a planar drawing in mm, {depthMm, points:\[\[x,y\]\], edges:\[\[a,b\] | \[a,b,sweepRad\]\], labels:\[{name?, at:\[x,y\], muR? | circuit+turns?, maxSizeMm?}\]}; a label with muR is a linear core, with circuit and turns a coil of that circuit (negative turns for the return side), with neither air; one or two circuits (up to 32 joined by connections); openBoundary?:{radiusMm, centreMm=\[0,0\], layers=4 (1 to 10; each layer matches one more harmonic of the field outside, and meshes into many more nodes)} puts the drawing in a circle of air of that radius with Meeker's graded-permeability shells outside it (an open boundary, for air-core parts, busbars and lines) instead of A = 0 on the drawing's outer edge; the air between the drawing and the circle is labelled "open boundary air" unless the drawing labels it, and the shells are regions "open boundary shell 1…N") - `muR`: number? (design only: core relative permeability; default the catalogue's initial permeability at the design temperature) - `clearanceMm`: number=0.1 (design only: space between drawn regions) - `openBoundary`: object? (design only, 2D: {radiusMm, centreMm (default the middle of the design's drawing), layers=4} puts the design's drawing, its A = 0 box then an inner edge, inside an open boundary as sketch.openBoundary does; the stray field then spreads as in open space instead of stopping at the box; a closed core keeps its L) - `connections`: \[{"name":str (the port's name, 1 to 64 characters),"join":"series"|"parallel","windings":\[str|{"circuit":str,"reversed":bool=false}\] (the drawn circuits it joins, each in at most one port; reversed swaps a winding's start and finish)}\]? (2D: join the drawn windings into one or two ports before reporting, for paralleled planar layers and split primaries; the drawing may then hold up to 32 circuits, each solved alone, and the values, the split and apply are the ports', in this order: in series one current, L = Σ s\_j s\_k L\_jk, turns Σ s N; in parallel one voltage, the current dividing to keep one flux linkage, turns those its windings share (none when they differ); a winding in no port is left open; the reply adds connection:{ports:\[{name,join,turns,windings:\[{circuit,reversed,currentPerA}\]}\],l:\[\[H\]\] (port matrix),currents:\[\[A per winding in model.circuits order\] per ampere into each port\],open:\[circuit\]}; model keeps every drawn circuit; with mode harmonic the ports join the impedance matrix instead (#3069 N8: one current phasor in series, one voltage phasor in parallel, so a parallel port's current divides by the windings' impedances, their eddy loss included): result.values and the headline are the ports', windings and impedance stay the drawn circuits', and connection is {ports:\[{name,join,turns,resistance (Re Z, Ω),inductance (Im Z/ω, H),windings:\[{circuit,reversed,currentPerA:{re,im}}\]}\],impedance:\[\[{re,im}\]\] (the port matrix, Ω),currents:\[\[{re,im}\]\],open}) - `symmetryPlanes`: \[{"axis":"x"|"y","atMm":number=0,"kind":"fluxTangential"|"fluxNormal"}\]? (sketch only, 2D, magnetostatic or mode harmonic, #3069 N16: the sketch is a half (one plane) or a quarter (one plane per axis) of the device, cut along x = atMm or y = atMm, which must be a straight outer edge with the whole drawing on one side; fluxTangential: the field odd about the plane (go and return sides mirrored), A = 0 on it; fluxNormal: the field even about it (a winding or core cut through its middle), its nodes free (dA/dn = 0); L and M (with mode harmonic Z, R, L and every loss) are multiplied by 2 per plane, the turns stay the drawn ones; with mode harmonic a conductor may not reach a fluxTangential plane (its eddy current is odd about it), and adaptive (each refined mesh cut the same way, the passes the whole device's) and dcBias (solved on the cut drawing) take the planes too, and forceCurrents is refused; model.symmetry gives the multiplier and model.symmetryPlanes the planes) - `periodicSector`: {"angleDeg":number (360/n for n from 2 to 360 sectors),"startDeg":number=0,"centreMm":\[x,y\]=\[0,0\],"kind":"periodic"|"antiPeriodic"}? (sketch only, 2D magnetostatic, linear triangles, #3069 N16: the sketch is one of n sectors of a device that repeats around the centre, between two straight outer edges on the rays at startDeg and startDeg + angleDeg, the rest of its outer edge (an arc) held at A = 0; periodic: every sector's currents alike, A on one side equals A at the same radius on the other; antiPeriodic: alternate sectors' currents reversed (a winding's poles), A is minus it, and a centre on both sides is held at 0; the sides are meshed with nodes at the same radii (points added to the drawing until they match) and tied; L and M are n times the drawn sector's, the turns the drawn ones (a winding is its drawn coils once in each sector, in series); model.symmetry gives n and model.periodicSector the sector; not with symmetryPlanes, mode harmonic, elementOrder 2 or laminations) - `elementOrder`: int=1 (2D magnetostatic only, #3069: 1 linear triangles, 2 quadratic six-node triangles on the same mesh, a node added at every edge's middle: the inductance converges as h⁴ against h² for a smooth field, so the same accuracy takes about a quarter of the nodes or fewer (the window transformer: 0.04 % off on a mesh where linear is 0.45 % off); the solve has about four times the unknowns; model.elementOrder says which; the field view shows the vertex values; magnets are refused) - `laminations`: object? (2D only, magnetostatic or mode harmonic, #3069: magnetic region name to {stackingFactor:number (the sheets' share of the stack, above 0, at most 1),normal:"x"|"y" (the drawing's axis the sheets are normal to; r or z in an axisymmetric drawing)}, up to 64, e.g. {"core":{"stackingFactor":0.95,"normal":"y"}}: the region (every label of that name, one muR, the sheet's) is a stack of steel sheets with non-magnetic coats, solved as one homogeneous region with μ along the sheets F·μr + (1 − F) and across them 1/(F/μr + 1 − F) (layers in parallel and in series, laminations.md §1), the stack's limit as its sheets thin; a coil, air or an unknown region is refused; not with elementOrder 2; no eddy currents inside the sheets (the 3D mode harmonic takes conductivityStack); in mode harmonic the stack is each of its triangles' reluctivity tensor, so a laminated region takes no conductivity or muRLoss, and laminations take no dcBias or adaptive; model.laminations gives \[{region,stackingFactor,normal,sheetMuR,muAlong,muAcross}\] and the field's regions muAxes:\[μx, μy\]) - `elementMm`: number? (largest element in the core and the windings, 0.01 to 50 mm; default the automatic mesher's: 3 elements across every gap, graded out from there) - `component`: str? (inductor, coupled inductor or transformer to write) - `ratio`: number? (N1/N2 for the transformer split; default the windings' turns) - `apply`: bool=false (write ONE history step named after the source) - `field`: bool=false (also return the solved field, for a field view: in 2D the mesh and each winding's potential, in 3D the tetrahedral mesh and each winding's B) - `ignoreMemoryCheck`: bool=false (solve even when the memory estimate is past the limit) - `cache`: bool=true (dimension 3: take the 3D model and its solution from the cache of identical solves, and keep them for the next call; false meshes and solves afresh and keeps nothing) - `dimension`: int=2 (2 or 3; 3 builds the model in 3D and solves it with the 3D field solver: a sketch or an E-core design is its planar section extruded straight through the depth with no flux leaving the end faces (its section meshed with one element across each gap and arcs in 30° pieces, so the layers stay short), so L matches the 2D solve and checks it; a ring-core design is its section revolved about the axis with each winding an ideal current sheet around the core) - `layers`: int? (dimension 3, extruded: element layers through the depth, 1 to 64; default 8; an even count without adaptive meshes only the half z ≥ 0, the middle plane being a symmetry plane no flux crosses, and doubles the totals: model.symmetry 2; when the section is also antisymmetric about x = 0 (every region mirrored by one of the same material, coils by the same circuit with opposite turns), only the quarter x ≥ 0, z ≥ 0: model.symmetry 4; with field the reply's field is the whole extrusion reflected from the half or quarter, in the drawing's regions) - `stepDeg`: number? (dimension 3, a ring-core design: the largest angular step of its revolution about the axis, 1 to 30°; default 10; halving it doubles the tetrahedra and quarters the faceting error of L and of a terminal's Re Z (second order in the step); not for an extrusion, endTurns or import) - `endTurns`: bool=false (dimension 3, an E or planar E design with one or two round or litz windings on the centre leg: each winding wound around the leg as a bobbin with its end turns, the second over the first, the core and winding solved in 3D in the air box of the 2D drawing (twice the core's largest half-size, grown to hold the winding through the depth); one eighth is meshed and L is eight times its value; on the core's B-H curve unless linear:true, as an extrusion; elementMm is the largest element of the top view and the thickest layer (default: the top view graded from the gap and the winding's clearances, coarser inside the core, and no layer thicker than its largest element); no layers; with field (linear only) the reply's field is the whole core, the eighth reflected across its three symmetry planes; an E design with layout outerLegs: each winding wound round its outer leg with its end turns, one eighth solved twice, for equal and opposed ampere-turns, model.construction woundOuterLegs and inductance.eighth {common,differential}; with field the reply's field is the whole pair, both circuits each alone at 1 A (the two parts unfolded and superposed); with adaptive (linear:true or muR) the eighth is refined with both parts solved on each mesh, each pass's energy \[common, differential\] the model's at 1 A in winding B, and with field the cap is at most an eighth of the view's limit; on the core's B-H curve (no linear or muR) the full-width quarter holding both windings is meshed (the eighth mirrored across x = 0, the whole model 4 times it) and each winding swept through currents in turn, the reply the nonlinear one above (lOfI, inductance.incremental, field refused), with adaptive the quarter refined by the nonlinear loop below, or with operatingPoint both windings solved at once (with adaptive each pass that one solve, the loop stopping when both flux linkages and every entry of the incremental matrix settle, each pass adding fluxLinkage:\[Wb\] and incrementalMatrix:\[\[H\]\], the whole model's)) - `gapElements`: number? (dimension 3, the outer-legs model only, 0 to 3; default 1: elements across each thin region of the top view (the winding's clearance from its leg and the strips beside it), each graded out from there; 0 refines across none of them, only the mesher's 25° angle bound, a mesh several times smaller (the thesis pair of 2 × E 65/32/27: about 8 times fewer nodes), for a core too large for the default; model.gapElements says which) - `adaptive`: bool|object=false (dimension 3, linear or on the B-H curve, or the 2D mode harmonic: refine the 3D mesh where the element error estimate is largest and solve again, pass after pass (Zienkiewicz–Zhu recovery of B per region; the worst 30 % of elements bisected at their longest edge, the mesh kept conforming; a winding drawn in a sketch is carried onto the new edges exactly, so L rises pass to pass); the built mesh is the first pass, so a large elementMm starts it coarse; with even layers and no field that is the extrusion's half or quarter, as without adaptive, and nodes and elements count it; {maxElements:int? (the largest mesh solved, 1 to the element limit; default ten times the first),maxPasses:int=8 (1 to 20),stopChangePct:number=0.1 (stop when every winding's energy changes by less than this, 0.01 to 10 %),minPasses:int=1 (1 to maxPasses: no converged stop before this many solves),minConvergedPasses:int=1 (1 to 19, below maxPasses when above 1: that many passes in a row must each change by less than stopChangePct, so one that settles by chance does not stop the loop),refinePct:number=30 (1 to 100: the share of elements marked each pass, the worst first; closing the mesh bisects more),stopOn:str? (mode harmonic only: "impedance" (default: each winding's resistance and reactance), "resistance" (the loss at a given current) or "inductance"; the magnetostatic loop always watches the energy, the inductance at 1 A),estimate:str? (operatingPoint on the B-H curve only: "chord" (default: the DC field in the chord reluctivity H/B, aimed at the flux linkages), "incremental" (each winding's incremental field in the Jacobian's differential reluctivity, whose norm is that winding's incremental L: aimed at the L and M reported) or "both"; the reply's adaptive.estimate names it)}; the memory check is of a mesh at maxElements; the reply adds adaptive:{stop (converged, passes or elements),maxElements,maxPasses,stopChangePct,minPasses,minConvergedPasses,refinePct,passes:\[{pass,nodes,elements,energy:\[J per winding, the whole model's\],changePct,estimatedErrorPct,minDihedralDeg,maxDihedralDeg}\]} and model describes the last mesh; on the B-H curve (#3069 N6) each pass sweeps every winding through currents by Newton iteration, the estimate takes each element's chord reluctivity H/B at the largest current, the loop stops when every flux linkage of every point changes by less than stopChangePct, each pass adds secant:\[H per winding, ψ/I at the largest current, the whole model's\] and its energy is the stored energy ∫w(|B|)dV there, the memory check is of the Newton solve, the cache is not used, and lOfI, the values and model are the last mesh's) - `linear`: bool=false (dimension 3: keep every material linear even when the design's core material has a B-H curve; 2D is always linear) - `currents`: \[A\]? (dimension 3, nonlinear only: the winding currents to solve at, rising, 1 to 16, each above 0 and at most 1e5 A; default \[1\]) - `operatingPoint`: object? (dimension 3, the outer-legs model on the B-H curve only, not with currents; adaptive refines its mesh, one solve a pass: each winding's current at one instant by circuit name, A, signed in the drawing's polarity, each at most 1e5 in size, not all 0, e.g. {"A":21.7,"B":12.5}: one Newton solve with both windings driven at once (a saturating core does not superpose the windings' sweeps), then the incremental matrix there; L and M (what apply writes) are the incremental ones at the point; the reply adds inductance.atCurrents and operatingPoint:{currents,fluxLinkage:\[Wb per winding, the whole model's\],incrementalMatrix:\[\[H\]\],peakB:{b,atMm,region,element,atCorner},bP99,legs:{A,centre,B: {peakB,atCorner,bP99,meanBz (T: the leg's flux over its section averaged along its height, signed)}},newtonSteps,halvings,residual,step,cgIterations,converged}) - `temperatureC`: number? (dimension 3, nonlinear only, or the 2D mode harmonic with dcBias: core temperature for the B-H curve, -40 to 200 °C; default the design's, else 25) - `import`: object? (dimension 3, instead of design or sketch: closed bodies from an STL file or the solids of a STEP file (ISO 10303-21) with plane, cylinder, cone, sphere and torus faces and line and circle edges (circles cut into 5° pieces, so a round leg or bore comes in as its inscribed 72-gon, a chamfer or taper as the frustum on those polygons, and a sphere or a ring torus bounded by parallels and meridians (a rounded end, a fillet) as flat pieces of at most 5° by 5° with their corners on it; a cone's semi-angle is read in the file's plane angle unit; B-spline curves and faces, rational or not, as flat pieces that bend no more than a 5° piece of a circle, their corners on the surface; a solid with voids (BREP\_WITH\_VOIDS) as the material between its outer shell and its voids; the parts of an assembly come in at their places, one body per placed solid), {path:str (read through the host's file service; a file starting with ISO-10303-21; is STEP; a fixed-format IGES 5.3 file (S in column 73 of its first record) is IGES, read for its manifold solid B-rep objects (type 186) with plane faces (types 108, 190), right circular cylinder, cone, sphere and ring torus faces (types 192, 194, 196, 198; cut as STEP cylinders, cones, spheres and tori), rational B-spline surface faces (type 128; cut as STEP B-spline faces) and line, circular arc and rational B-spline curve edges (types 110, 100, 126; arcs cut into 5° pieces as STEP circles, B-spline curves as STEP B-spline curves), or with no solid its trimmed surfaces (type 144: bounded by curves on the surface, N1 = 1, or a rational B-spline surface's domain, N1 = 0: its whole knots' range or the part its parameter range U(0), U(1), V(0), V(1) names) and bounded surfaces (type 143: bounded by boundary entities, type 141, of model-space curves) welded into closed bodies, any other IGES surface or edge curve refused by name),unitMm:number? (mm per file unit: default 1 for STL; a STEP or IGES file states its own (IGES: the Global units flag), and unitMm is taken only when it names none, refused when it disagrees),bodies:\[{muR:number (1e-3 to 1e7, linear),name:str?}\] (one per solid of the file, in its order; a binary STL's one solid is named after the file, a STEP solid after its name or #n, an IGES solid after its directory entry label or D\; in a STEP assembly one per placed solid, top assembly first, a solid placed more than once named after it and its occurrences, as 'half in lower'),windings:\[{circuit:str,turns:number (nonzero; negative winds the other way),bobbin:{centerMm:\[x,y\],halfSizeMm:\[a,b\],cornerRadiusMm:number=0,thicknessMm:number,zMm:\[z0,z1\]} (around an axis parallel to z) | straight:{yMm:\[y0,y1\],goMm:\[x0,x1\],backMm:\[x0,x1\]} (conductors along z through the whole box, go and return) | toroid:{rMm:\[r0,r1\],zMm:\[z0,z1\]} (an ideal sheet around a ring core about the z axis; only mesh edges with both ends in the section carry it, so the section grows to wrap the meshed bodies it overlaps (a faceted ring's bore reaches in to r·cos 2.5° for a STEP file's 5° pieces), and a note says to what) | spiral:{centerMm:\[x,y\],halfSizeMm:\[a,b\] (the outermost turn's outer edge),cornerRadiusMm:number=0,widthMm:number,pitchMm:number (at least widthMm),zMm:\[z0,z1\] (the copper),startAngleDeg:number=0,pitched:bool=true} (a planar spiral around an axis parallel to z with turns:int whole turns, each where it is: pitched steps in once a turn from startAngleDeg and returns by a radial lead across the turns in the same layer; pitched:false gives closed concentric turns; needs a hole: (turns, one fewer unpitched)·pitch + width below the smaller half size) | helix:{centerMm:\[x,y\],halfSizeMm:\[a,b\],cornerRadiusMm:number=0,thicknessMm:number,heightMm:number,pitchMm:number (at least heightMm),bottomMm:number,startAngleDeg:number=0,pitched:bool=false} (turns:int whole turns stacked along z from bottomMm, each a closed ring heightMm tall, the helix's one-turn axial current and leads left out; pitched:true makes it a true helix rising counter-clockwise about +z one pitch a turn from bottomMm at startAngleDeg, with its axial current and a straight return lead from the top back down through the turns' shell at startAngleDeg, as for a coil with both terminals at the bottom; needs cornerRadiusMm at least thicknessMm)}\] (one or two),boxMm:{lo:\[x,y,z\],hi:\[x,y,z\]}? (the box of air, whose sides let no flux out and may cut a body: a symmetry plane; default the bounds of the bodies and windings grown by half their largest extent)}; elementMm is then the largest lattice cell, default a twentieth of the box's largest side) - `mode`: str="magnetostatic" ("harmonic" solves the eddy currents of solid conductors at frequency instead, linear, each winding driven alone at 1 A peak; not with apply or currents; in 2D not with field, and every drawn circuit (up to 32) is solved, then joined into ports by connections when given; dimension 3: not with temperatureC; with endTurns the wound E core's eighth, its loss and Z eight times the eighth's, only the core conducting; an extrusion is meshed whole or as its half through the depth, never its quarter, and each of its conducting regions is held at zero net current along the depth as in the 2D AC solve, one more solve per region) - `frequency`: number? (Hz, above 0 and at most 1e9; mode harmonic only, and required there) - `conductivity`: object? (mode harmonic only, and required there unless muRLoss gives a loss: region name to S/m, 0 to 1e9, at least one above 0, e.g. {"plate":3.77e7}; a sketch label's name (every label of that name), an imported body's name or a design region, and core for every magnetic region when none is named core (the wound model's core bodies); a winding's region is refused (with endTurns every region but the core's), its turns being stranded, and so is an open boundary's shell) - `terminals`: \[str\]? (dimension 3, mode harmonic, an extrusion (then meshed whole), import, or a ring design (its quarter turn; not with field or adaptive, which mesh the whole ring): conducting regions by name, each a solid conductor driven between the extrusion's two end faces, an imported body between the one pair of opposite box sides that cut it (boxMm; a body cut by no pair or by more than one is refused), or a ring region as one turn around the axis cut once at φ = 0 (the quarter turn solved between its cut planes, the four quarters in series), at 1 V peak in one more solve, every winding at 0 A and the other conducting regions held at zero net current; up to 16; with adaptive each pass drives them too and the loop watches their resistance and reactance as well; with field, field.terminals holds each one's b, bIm, lossDensity and currentDensity at 1 V peak) - `muRLoss`: object? (mode harmonic, 2D only, #3069 N3: magnetic region name to μ″, 0 to 1e7, the loss part of its complex relative permeability μ′ − jμ″ with μ′ its muR (a ferrite's or powder core's data-sheet μ″ at the frequency, IEC 60401-3), e.g. {"core":30}; every label of that name; air, windings and an open boundary's shells are refused; the region's magnetic loss (ω/2)·Im(1/μ)·|B|² is in Re Z, lossW and regions, and conductivity may then be left out) - `skinLayers`: object? (mode harmonic, 2D only, #3069 N5: conducting region name to n, 1 to 20, e.g. {"plate":3}: n mesh layers under the region's surface, together 2 skin depths deep at the frequency (its own conductivity and muR), each twice as thick as the one outside it (the first 2δ/(2ⁿ − 1)); every label of that name; a region conductivity does not give a conductivity above 0 is refused; conductors\[\].skinLayers gives {layers,depthMm,firstMm}, and a region whose first layer is thinner than its skin depth gets no skinDepthUnresolved) - `surfaceImpedance`: \[str\]? (mode harmonic, 2D only, #3069 N10: conducting regions by name solved by their surface impedance, for a shield, wall or busbar many skin depths thick: the region's inside is left out of the field and its boundary carries the Leontovich condition (Jackson §8.1), so its mesh needs no element finer than its shape and no skinLayers; its loss is the Poynting flux ½R\_s∮|H\_t|², R\_s = 1/(σδ); valid where δ is small against its thickness and radius of curvature (a round bar of radius a loses a/(2δ) of its DC loss by it, against a/(2δ) + 1/4 exactly); every label of that name; a region conductivity gives no conductivity above 0, one in skinLayers, and two that touch are refused; with adaptive each pass solves it by its surface impedance and the estimate weights the elements beside it instead of its inside; conductors\[\].surfaceImpedance is true for it, with thicknessOverSkinDepth (2·area/perimeter over δ), and a surfaceImpedanceThin warning when that is below 5, where the condition is more than about 1 % off) - `current`: object? (mode harmonic, 2D only, #3069 N2: one period of a converter current, as field.peec takes it (waveform, or signal with periodS and t1 from the last run), with "circuit":str? (the drawn circuit it flows in, or a port of connections; default the only one) in place of port and harmonics 1 to 50 (default 15); leave out frequency: the drawing is solved at each harmonic n/T, the other circuits open, and harmonic n of rms In loses In² Re Z(n/T), summed by Parseval (Hurley, Gath and Breslin 2000); the DC part loses nothing, the windings being stranded and the solids at zero net current; skinLayers are meshed for the highest harmonic, the skin warnings checked there, and the rest of the reply is the fundamental's) - `dcBias`: object? (mode harmonic, 2D only, #3069 N4: drawn circuit name to its DC current, A, -1e5 to 1e5, at least one not 0, e.g. {"P":3}: the drawing is first solved magnetostatically at those currents with every core region (magnetic, not an open boundary's shell) on the catalogue B-H curve of its material at the core temperature (Newton, 2d.md §3.2; N87, N97, 3C90, 3C95; a material with no curve is refused), and the AC solve takes each core triangle's incremental reluctivity tensor there (dH/dB along the bias field, H/B across it), so Z is the small-signal impedance on the bias: inductance is the incremental L, the ripple's, and the losses are the ripple's; conductivity may then be left out; not with muRLoss on a core; with current, its harmonics are solved on the bias; the reply adds dcBias:{currents:\[{circuit,a}\],material:{name,temperatureC},newton:{steps,residual},peakB (T, the cores' largest |B| at the bias),incrementalMuR:{mean (the cores' area mean of the incremental μr along the field),min}}) - `forceCurrents`: object? (mode harmonic, 2D only: drawn circuit name to its peak current, A, as a number (negative for the opposite phase) or {"peakA":A,"phaseDeg":°=0}, -1e5 to 1e5 A and -360 to 360°, at least one not 0, a circuit left out at 0 A, e.g. {"P":1000,"S":-2000}: the Lorentz force J × B through the depth on every winding side (its stranded current) and every conducting region (its eddy current) at those currents, the time-averaged AC winding force and the short-circuit forces; with i = I cos ωt it is a mean part and a part at twice the frequency, F(t) = mean + Re(F₂ e^{j2ωt}) (mean ½ Re ∫ J\* ∇A, F₂ = ½ ∫ J ∇A); a magnetic core's own force (its magnetisation) is not in it; not with current, dcBias, surfaceImpedance or symmetryPlanes; the reply adds forces:{frequency,doubleFrequency (Hz),currents:\[{circuit,peakA,phaseDeg}\],regions:\[{region,circuit (null for a conductor),meanN:\[x,y\],doubleFrequencyN:\[x,y\] (the amplitudes of the 2f part),peakN:\[x,y\] (each component's largest |F| over the cycle, |mean| + amplitude),peakMagnitudeN (the largest |F| over the cycle)}\] (labels of one name summed),windings:\[{circuit,meanN,doubleFrequencyN,peakN,peakMagnitudeN}\] (each circuit's coil regions summed),method}) - `material`: str? (with dcBias on a sketch, and required there: the catalogue material of its core regions, e.g. "N87"; a design names its own) - `conductivityStack`: object? (dimension 3, mode harmonic: region name to {normal:"x|y|z"|\[x,y,z\] (the sheets' normal, any direction),across:S/m=0 (σ across the sheets, 0 to the region's conductivity; 0 for insulated coats)}, up to 64, each region also in conductivity with σ above 0, which is then σ along the sheets: a lamination stack whose tensor is σ\_along I + (σ\_across − σ\_along) n nᵀ (laminations.md (9)); a tilted normal meshes an extrusion whole and is refused on a model solved as a part (endTurns' eighth; a ring's quarter turn, which takes only normal z); conductors\[\].stack gives {normal,conductivityAcross}) - `magnets`: \[object\]? (as magnetics.fieldFluxMap takes them; dimension 3 only, an extruded design or sketch with a coil, linear (a design on its B-H curve asks for linear: true); each magnet is its region through the depth, magnetized in the drawing's plane; the extrusion keeps its half through the depth (even layers) or the whole (odd), never the quarter; L is each winding's alone at 1 A; a magnet's demagCurve (#3069) puts it on its curve: the magnets' field is then the 3D Newton solve at no current, a reverse field along the magnetization on the curve and any other on the recoil line, its check reads that field, model.magnets is "demagCurve" with model.newtonSteps, and incrementalInductanceH:\[\[H\]\] is the incremental inductance matrix f̂ᵀJ⁻¹f̂ there (the curve's slope past the knee), while the values and apply keep L at the recoil permeability; not with field, adaptive, mode harmonic, endTurns, import or a ring design) ## Reply - source - frequency - gapMm - magnets? (each magnet's data and demagnetization check at no current, as magnetics.fieldCoreLoss {dimension: 3} gives them, with demagCurve:{points,brT}|null) - incrementalInductanceH? (with a demagCurve) - magnetWarnings? (also in warnings) - result:{values} - apply:\[edits\] - applied - notes - model:{family,circuits,turns,depthMm,gapMm,muR,elementMm,nodes,elements,minAngleDeg,iterations,residual,reciprocity,openBoundary:{centreMm,radiusMm,layers}|null,solverVersion,provenance:\[{circuit,solverVersion,inputHash}\]} - warnings:\[{code,message,messageZh,data}\] (planarModel with the depth in m; linearMaterial for each magnetic region but an open boundary's shells, since the 2D solve has no B-H curve) - field?:{nodes:\[\[x,y\]\] (m),triangles:\[\[a,b,c\]\],elementRegions:\[region\],regions:\[{name,muR}\],fixed:\[node held at A = 0\],circuits,potentials:\[\[A\_z per node, Wb/m, 1 A in that circuit\]\]} - preview - previewNote --- # Field Torque (`magnetics.fieldTorque`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/magnetics-fieldTorque/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/magnetics-fieldTorque/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** a job, with progress and Cancel > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. Builds a permanent-magnet machine (surface magnets magnetized parallel to their centre line, north and south in turn, or interior magnets magnetized across their centre line; open sector slots), meshes the smallest sector the slot and pole numbers allow with its sides tied periodic or anti-periodic, and turns the rotor through an air-gap sliding band. At each angle: the torque on the rotor of the whole machine by Arkkio's stress-tensor average over the stator's ring of the air gap (N·m, anticlockwise positive), and each phase's flux linkage λ = L·turns·Σ±(∫A dS/S) over its coil sides. With speedRpm, the back-EMF e = ω dλ/dθ by central differences (wrapping around when the sweep is one whole period). Linear iron unless ironBh, magnets on their recoil line unless magnetDemagCurve; slot and magnet edges fall on the nearest mesh cell. A job: progress counts the angles, and cancel stops before the next one. Changes nothing. ## Parameters - `slots`: int (a multiple of 3, 3 to 360) - `poles`: int (even, 2 to 360) - `rotor`: "surface|interior|vShape"="surface" (surface: magnets on a solid iron rotor, magnetized radially, north and south in turn; interior: the flux-concentrating rotor of design.motor's rotor "interior", one magnet buried at each pole boundary between iron pole pieces on a non-magnetic hub, magnetized azimuthally so that each pair drives its pole piece north or south; vShape: two bar magnets per pole buried in the rotor iron in a V opening towards the air gap, magnetized across the bar into the pole between them, with iron ribs at the centre post and under the gap; its ribs short the magnets until they saturate, so give ironBh) - `rotorRadiusMm`: number (surface: outer radius of the rotor iron, under the magnets; interior: outer radius of the rotor, the pole pieces; vShape: outer radius of the rotor iron) - `magnetThicknessMm`: number (surface: radial thickness; interior: thickness along the magnetization at the rotor's outer radius, a wedge of the angle magnetThicknessMm/rotorRadiusMm, below the pole pitch there; vShape: a bar's width, along its magnetization) - `magnetArc`: number (surface: share of the pole pitch a magnet spans, above 0 to 1; vShape, required: share of the pole pitch between a pole's two bar centre lines at their outer ends, above 0 and below 1; not taken by interior) - `magnetDepthMm`: number (interior and vShape, required: the magnets' radial depth from the rotor's outer radius, below rotorRadiusMm; interior: the hub inside is non-magnetic; vShape: the V's bars run from that depth, at the d axis, out to ribMm under the gap) - `ribMm`: number (vShape only, required: the iron of the centre post between a pole's two bars and of the bridge between each bar and the air gap; each bar must stay ribMm/2 clear of the q axis) - `barrierMm`: number=0 (vShape only: an air pocket this long at the outer end of each bar, along the bar, between the magnet and the bridge, so only the bridge still carries the magnet's flux round its end; it takes that much of the bar's length from the magnet, and must leave some) - `airGapMm`: number (magnet surface to stator bore) - `slotDepthMm`: number - `slotWidth`: number (share of the slot pitch a slot spans, above 0 and below 1; slots are open sectors) - `outerRadiusMm`: number (stator outer radius, held at A = 0) - `stackLengthMm`: number - `ironMuR`: number (relative permeability of the rotor and stator iron, linear; not used by the solve when ironBh is given) - `ironBh`: \[\[H,B\]\]? (the rotor and stator iron's B-H table from its data sheet, A/m and T, from \[0,0\] with H and B both rising, 2 to 200 points; past the last point the slope is μ0. With it the iron saturates: each angle is solved by Newton's method on the tied sector) - `magnetBrT`: number (remanence, 0 to 3 T, from the magnet's data sheet) - `magnetMuR`: number (recoil permeability, from the data sheet) - `magnetDemagCurve`: \[\[H,B\]\]? (the magnet grade's normal demagnetization curve at its working temperature from the same data sheet, A/m and T, 2 to 200 points from \[0, Br\] with H and B both falling through the knee, its Br within 1 % of magnetBrT; the magnets then take the curve's Br and follow it for a reverse field along their magnetization, a forward or crosswise one staying on the recoil line at magnetMuR, and each angle is solved by Newton's method on the tied sector; reversible unless magnetIrreversible) - `magnetIrreversible`: bool=false (with magnetDemagCurve only: keep the irreversible loss, the angles solved in order and each magnet cell of the rotor recoiling at every later angle along a line of slope μ0·magnetMuR from the lowest point it has reached on the curve, with the reduced remanence Br' = B − μ0·magnetMuR·H there; the cell's two triangles take the lower point) - `turns`: number=1 (series turns of one coil side) - `winding`: "auto|distributed|concentrated"="auto" (distributed: a 60° phase belt per slot, single layer; concentrated: a coil around each tooth, double layer; auto: distributed when the slots per pole and phase are a whole number, else concentrated) - `divisionsPerSlot`: int=12 (cells per slot pitch on the stator, 2 to 200, even for a concentrated winding) - `divisionsPerPole`: int=24 (cells per pole pitch on the rotor, 2 to 200) - `symmetry`: "smallest|full"="smallest" (solve the smallest periodic or anti-periodic sector, or the whole cross-section) - `startDeg`: number=0 (first rotor angle, mechanical degrees, anticlockwise) - `stopDeg`: number? (default one cogging period, 360/lcm(slots, poles), at zero current, else one electrical period, 720/poles) - `steps`: int=24 (angles from startDeg in equal steps up to, not including, stopDeg; 1 to 720) - `currents`: {"A":A,"B":A,"C":A}? (constant phase currents; default none, the cogging torque) - `speedRpm`: number? (for the back-EMF; default none) ## Reply - machine:{slots,poles,rotor:"surface"|"interior"|"vShape",winding,sector:{angleDeg,copies,antiPeriodic},coggingPeriodDeg,layout:\[{slot,left,right}\] (the coil side in each half slot, A+ to C−)} - points:\[{angleDeg,torqueNm,fluxLinkageWb:{A,B,C},emfV?:{A,B,C},magnetReverseHAm? (with magnetDemagCurve: the largest reverse field along the magnetization in the magnets, A/m),magnetPastKneePct? (with magnetDemagCurve when it holds a knee: the share of the magnet area past it, %),magnetBrLossPct? (with magnetIrreversible: the area-weighted mean remanence the magnets have lost after this angle, % of Br),magnetMaxBrLossPct? (the most any magnet element has lost, %)}\] - torque:{meanNm,minNm,maxNm,peakToPeakNm} - emfPeakV?:{A,B,C} - model:{nodes,elements,solverVersion,iron:"linear"|"bh",bhPoints?,magnets:"recoil"|"demagCurve",irreversible?:true (with magnetIrreversible),demagPoints?,magnetBrT (the remanence solved with: magnetBrT, or the curve's Br),iterations:\[per angle\] (conjugate-gradient iterations, over every Newton step with ironBh or magnetDemagCurve)} - warnings:\[{code,message,messageZh,data}\] (planarModel with the stack length as the depth in m; linearMaterial for the rotor and the stator iron at ironMuR, left out with ironBh; the magnets are on their recoil line or magnetDemagCurve and are not listed) - demagnetization?:{kneeHAm (where the curve's intrinsic J = B − μ0H falls to 0.9 Br, the data sheets' H\_k; null when the curve ends before it),worstReverseHAm,worstAngleDeg,maxPastKneePct,anglesPastKnee,irreversible:bool,finalBrLossPct?,maxBrLossPct?,areaWithLossPct? (with magnetIrreversible: after the last angle, the mean and largest remanence lost, % of Br, and the share of the magnet area with any loss, %)} (with magnetDemagCurve; a demagnetization warning when any angle is past the knee) - notes:\[{en,zh}\] - preview - previewNote --- # Field Transient (`magnetics.fieldTransient`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/magnetics-fieldTransient/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/magnetics-fieldTransient/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** a job, with progress and Cancel > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. Solves σ ∂A/∂t − ∇·(ν∇A) = σu + J\_s on the planar mesh from A = 0 at t = 0: eddy currents in the conducting regions, each a solid conductor whose net current is its winding's (or zero), and the windings driven by current or by voltage. A design's core whose material has a catalogue B-H curve (N87, N97, 3C90, 3C95), or a sketch's cores given material, sit on that curve at the core temperature: every step is a Newton solve warm-started from the step before, so a drive past the knee gives the saturating i(t) and λ(t) (with no conductivity each step's λ(i) is the static magnetics.fieldFluxMap's); muR, linear:true or a material with no curve keeps the cores linear (a note says which), and a step whose Newton iteration does not converge is an error naming the core, its curve and the time. A jilesAtherton region starts demagnetized at t = 0 and follows its loop (one scalar model along x and one along y, or with rotational one vector model; the parameters are the scalar fit's either way, and the vector model is isotropic); it takes no B-H curve, and a coil side, a magnet or an open boundary's shell cannot take one. A voltage is the winding's terminal voltage over the model's depth (a planar model has no end turns). A job: cancel stops at the next step. Changes nothing. ## Parameters - `sketch`: object? (a planar drawing in mm, the form magnetics.fieldSolve reads) or "design":object? (a magnetics.design reply or its best design, with "muR":number? and "clearanceMm":number=0.1 as in magnetics.fieldSolve) - `elementMm`: number? (largest element in cores and coils, mm) - `conductivity`: {region: S/m}? (regions with eddy currents, by label name; each is a solid conductor carrying no net current unless a solid winding drives it; take σ from the material's data sheet) - `windings`: {circuit: {"drive":"current|voltage|solid"="current","waveform":{"step":value}|{"sine":{"amplitude","frequencyHz","phaseDeg"=0}}|{"table":\[\[t,value\]\],"stepMean":bool=false} (A, or V for a voltage drive; a step starts at t = 0; stepMean drives each step with the table's exact mean over it, its volt-seconds over Δt, so a switched PWM table keeps its edges and backward Euler integrates it exactly, where the default point sample at each step's end moves every edge by up to a step; the rows then show those means),"resistanceOhm":number? (voltage only: the whole winding's)}} (current: thin wire carrying the waveform; voltage: thin wire driven through v = R i + dλ/dt; solid: the circuit's coil regions are conductors in series, each needing a conductivity and ±1 turn, so skin and proximity effect follow; a circuit left out carries no current) - `stepS`: number (Δt, s) - `steps`: int (1 to 20000) - `scheme`: "bdf2|euler"="bdf2" (BDF2 after a first backward-Euler step, or backward Euler throughout) - `rows`: int=200 (output rows, evenly spaced over the run, 1 to 2000) - `snapshots`: int=0 (field snapshots, 0 to 50: peak and mean element |B| at evenly spaced times) - `snapshotTimes`: \[s\]? (#3069 N14: 1 to 50 times, each above 0 and at most steps·stepS, for snapshots at those instants besides the evenly spaced ones; each is taken at the nearest step, round(t/stepS), and two times on one step give one snapshot) - `snapshotField`: bool=false (also return each snapshot's whole field, potentialWbPerM (nodal A\_z, Wb/m) and bT (\[Bx, By\] per element, T), with snapshotMesh once; refused past 5e6 numbers in all) - `temperatureC`: number? (core temperature for the B-H curve, -40 to 200 °C; default the design's, else 25) - `material`: str? (sketch only: the catalogue material of its core regions, which then saturate on its B-H curve) - `linear`: bool=false (keep every core at its muR even when its material has a B-H curve) - `jilesAtherton`: {region: {"ms","a","k" (A/m),"c" (0 ≤ c \< 1),"alpha" (≥ 0),"source":str,"rotational":bool=false}}? (magnetic regions, by label name, on the Jiles–Atherton hysteresis model instead of muR or a B-H curve: Ms, a, k, c and α fitted to a published loop, with source naming the paper or data sheet and its table; never guess them, ask; rotational: one isotropic vector model per element driven by B, so a flux that turns, as at a ring's corners or a T-joint, follows rotational hysteresis, instead of one scalar model along x and one along y) - `laminations`: object? (#3069, as magnetics.fieldSolve takes it: magnetic region name to {stackingFactor:number (above 0, at most 1),normal:"x"|"y"}, up to 64: the region is a stack of sheets, linear at μ along the sheets F·μr + (1 − F) and across them 1/(F/μr + 1 − F) in every step, or, when the cores sit on a B-H curve (a design's material or a sketch's material), each sheet on that curve and the stack on its own curve along the sheets (H shared, B = F·B\_sheet(H) + (1 − F)·μ0·H) and across them (B shared, H = F·H\_sheet(B) + (1 − F)·B/μ0), so it saturates (laminations.md §8); refused on a region given a conductivity (eddy currents inside the sheets: draw the sheets, or use the 3D transient's conductivityStack) or a jilesAtherton loop; model.laminations gives \[{region,stackingFactor,normal,sheetMuR,muAlong,muAcross,bhCurve (the sheet's curve, or null for a linear stack)}\], else null) - `magnets`: \[{region,direction,temperatureC,grade,demagCurve?}\]? (#3069: permanent magnets in the drawing, each region a magnet as field.regionTable reads them: grade from its data sheet, on its recoil line B = μ0 μrec H + Br at temperatureC; with demagCurve (\[\[H, B\]\] A/m and T from the same sheet at that temperature, 2 to 200 points from \[0, Br\] through the knee, its Br within 1 % of the grade's) every time step is a Newton solve on the curve, a reverse field along the magnetization following it through the knee and a forward or crosswise one the recoil line, reversibly (no recoil from the lowest point reached); a magnet takes no core curve, jilesAtherton loop or lamination, may take a conductivity (eddy currents in the magnet), and is not a core for the core loss) - `skinLayers`: {region: n}? (#3069 N5: conducting region name to n, 1 to 20, e.g. {"plate":3}: n mesh layers under the region's surface, together 2 skin depths deep at skinFrequencyHz (its own conductivity and muR), each twice as thick as the one outside it (the first 2δ/(2ⁿ − 1)), so a conductor many skin depths thick is resolved without refining its whole inside; every label of that name that conductivity gives a conductivity above 0, others refused) - `skinFrequencyHz`: number? (with skinLayers only: the frequency, Hz, above 0 and at most 1e9, whose skin depth sizes the layers; default the highest frequency of the sine drives, and required without one: for a switched drive, the highest harmonic that matters) - `periodS`: number? (#3069 N9: the drive's period, s, at least 4 steps, for steadyState; default 1/f when every sine drive has the same frequency f and no winding has a step or table drive; give it for a periodic table such as a PWM's switching period) - `steadyTolerance`: number=1e-3 (above 0, below 1: the relative residual under which a period repeats the one before it) - `dimension`: int=2 (#3069: 3 steps the 3D model magnetics.fieldSolve {dimension: 3, mode: "harmonic"} builds instead: an import, a design with endTurns (the wound E core's eighth), a ring-core design revolved, or an extrusion with layers and stepDeg; eddy currents in conductivity's regions, with conductivityStack's laminations, each winding a stranded coil carrying its current waveform (drive current only), steps 1 to 2000; a conductivity in an extrusion is refused (its conductors run to the end faces, which the 3D transient cannot yet hold at zero net current), and the 2D-only keys (material, linear, temperatureC, jilesAtherton, laminations, skinLayers, skinFrequencyHz, periodS, steadyTolerance) are refused, while snapshots, snapshotTimes and snapshotField are read as in 2D; the reply is then {rows:\[{timeS,currentA:{circuit},fluxLinkageWb:{circuit},voltageV:{circuit} (dλ/dt, no copper drop),eddyLossW,regionLossW:{region},energyJ,iterations}\],final,meanEddyLossW,snapshots:\[{timeS,step,peakBT,meanBT,bT?}\] (peak and mean element |B| of the meshed part, in time order; with snapshotField bT, \[Bx, By, Bz\] per tetrahedron, T, refused past 5e6 numbers in all),snapshotMesh:{nodes (m),tets,elementRegions,regions:\[{name,muR,conductivitySPerM}\],symmetry (the images that make the meshed part the whole model)}? (snapshotField only),conductors:\[{region,conductivity}\],model:{family,construction,nodes,elements,freeEdges,symmetry,stepS,steps,scheme,maxIterations,memoryEstimateBytes,solverVersion},warnings,memory,notes,fieldCache}, every value the whole model's) ## Reply - nonlinear - material - temperatureC - rows:\[{timeS,currentA:{circuit},voltageV:{circuit},fluxLinkageWb:{circuit},apparentInductanceH:{circuit: λ/i | null},incrementalInductanceH:{circuit: Δλ/Δi over the time step ending at the row | null (the first step)},eddyLossW,copperLossW}\] (an inductance is null where its current, or the current's change, is at most 1e-6 of the winding's peak; with several windings driven, λ includes their mutual flux, so λ/i is not the self-inductance alone) - steadyState:{periodS,tolerance,cycles (whole periods run),reached (the last whole period repeats the one before within tolerance),residual (the last one's),settledPeriod (the first period, from 2, that repeats the one before)|null,periodicFromS (where that one before starts)|null,residuals:\[{period,startS,residual}\] (max over the period's steps of |x(t) − x(t − T)| over max |x|, for every winding's current and flux linkage),lastPeriod:{eddyLossW,copperLossW (averaged over the last period: the losses the circuit loop takes once reached is true),rmsCurrentA:{circuit},coreLoss:{totalLossW,totalLossIgseW,fromS,toS,coreVolumeM3,bP99T,peakBT,saturationT,warnings:\[{message,messageZh}\],provenance:{solverVersion,inputHash}}|null (#3069 N9: a core on its catalogue B-H curve, or kept linear at its muR (a material with no B-H curve, or a design with linear or muR, which takes the design's material), not jilesAtherton: the iGSE of the material's Steinmetz data, with its DC-bias correction where the data exist, on each core element's own B(t) over the last period, eddy currents and saturation (on a curve) included, over the model's depth; null, with a note, when periodS is not a whole number of stepS, the run is not longer than one period, the material has no Steinmetz data, or a sketch names no material)}}|null (no period: a step drive, a table without periodS, or sines of several frequencies) - snapshots:\[{timeS,step (the step it ends, from 1),peakBT,meanBT,potentialWbPerM?,bT?}\] (in time order) - snapshotMesh:{nodes (m),triangles,elementRegions,regions:\[{name,muR,conductivitySPerM}\],fixed (nodes held at A = 0)}? (snapshotField only) - final:{currentA,voltageV,fluxLinkageWb,eddyLossW} - meanEddyLossW (over the last fifth of the run) - model:{family,nodes,elements,elementMm,stepS,steps,scheme,maxNewtonSteps,solverVersion,skinLayers:{frequencyHz,regions:\[{region,layers,depthMm,firstMm}\]}|null,laminations} - hysteresis:{cores:\[{region,source,ms,a,k,c,alpha,rotational}\],rows:\[{timeS,cores:{region:{hAPerM:\[x,y\],bT:\[x,y\],workJ}}}\] (the rows' times),final:{region:{hAPerM,bT,workJ}}}? (with jilesAtherton only: each core's area-weighted mean H and B per axis (over the whole region, so a ring's opposite legs cancel: label each leg as its own region to read its flux), and the work ∫H·dB dV done on it since t = 0, over the model's depth; over a closed cycle of the drive the work is the core's hysteresis loss per cycle) - magnets:\[{region,name,grade,source,temperatureC,brT,hcjAPerM,hkAPerM,recoilMuR,direction,demagCurve:{points,brT}|null,areaMm2,pastKnee,sharePastKneePct,elementsPastKnee,worstReverseAPerM,worstElement,worstAtMm}\] (each magnet's demagnetization check on the last step's field: its worst reverse field along the magnetization against the sheet's knee H\_k; empty without magnets) - warnings:\[{code,message,messageZh,data}\] (planarModel with the depth in m; linearMaterial for each magnetic region kept at its muR, but an open boundary's shells; outsideMaterialData for a core whose peak |B|, at the end or at a snapshot, is past the last point of its B-H curve) - notes - preview - previewNote --- # Machine Sketch (`magnetics.machineSketch`) URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/commands/magnetics-machineSketch/ [Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/commands/magnetics-machineSketch/) **Menu:** none (Quick Open, the CLI, Python and MCP) · **Runs as:** at once > Preview: turn on Preview features in Edit › Preferences › Simulation, or run `preview.set {"enabled":true}`. Its replies carry `preview: true` and a note. ## What it does Preview. Draws the whole cross-section of the machine magnetics.fieldTorque builds, at the rotor angle. Surface rotor: the rotor iron disc and one arc magnet per pole, "magnet k (N|S)" (north and south in turn, magnetized parallel to its centre line). Interior rotor: the non-magnetic "rotor hub", then in the ring out to rotorRadiusMm one wedge magnet "magnet k (ccw|cw)" on each pole boundary (magnetized across its centre line, anticlockwise and clockwise in turn) and an iron "pole piece k (N|S)" between each two. V-shape rotor: the rotor iron disc holding two bar polygons per pole, "magnet ka (N|S)" (the clockwise bar) and "magnet kb (N|S)", each magnetized across the bar into its pole; the solver's mesh staircases them. A drawing holds no magnetization, so magnets gives each one's direction. Then the air gap, each open slot split into a left and a right half slot that is a coil of its phase (circuits A, B and C, negative turns for a return side) and the stator iron out to outerRadiusMm, the drawing's edge (held at A = 0). Magnet and slot edges sit at their true angles. Changes nothing unless open. ## Parameters - `slots` - `poles` - `rotor` - `rotorRadiusMm` - `magnetThicknessMm` - `magnetArc` - `magnetDepthMm` - `ribMm` - `barrierMm` - `airGapMm` - `slotDepthMm` - `slotWidth` - `outerRadiusMm` - `stackLengthMm` - `ironMuR` - `magnetMuR` - `winding`: (each as magnetics.fieldTorque) - `turns`: int=1 (turns of one coil side, a whole number) - `angleDeg`: number=0 (rotor angle, mechanical degrees, anticlockwise) - `magnetGrade`: str|{grade object}? (as a magnet's grade in the magnets param of field.lineProfile; with it each magnets entry carries grade and temperatureC, ready to pass on) - `temperatureC`: number? (required with magnetGrade) - `open`: bool=false (also open the drawing on the field drawing canvas, one undo step after the drawing open now) ## Reply - sketch:{depthMm,points,edges,labels} (the sketch param of magnetics.fieldSolve, field.lineProfile and the other field commands, mm) - magnets:\[{region,direction:\[x,y\],grade?,temperatureC?}\] (the magnets param) - coils:\[{region,phase (A+ to C−)}\] - machine:{slots,poles,rotor:"surface"|"interior"|"vShape",winding} - regions - drawing? (with open: the drawing summary as geometry.new gives it) - notes:\[{en,zh}\] - preview - previewNote --- # Getting started: your first buck converter in 10 minutes URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/01-first-buck/ You open a 48 V to 12 V buck converter, simulate it, read the output on the scope, change the inductor and compare the two runs. You need Voltecx installed ([manual, chapter 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/01-install/)). Nothing else. How to read the pictures: a red box with a number marks what you click, in that order. A grey chip such as `[▶ Run]` is a button, `File › Open Example` is a menu path, and `F5` is a key. ## 1. Open the buck example Choose `File › Open Example › DC-DC › Buck converter, textbook`. ![The File menu open at Open Example, DC-DC, Buck converter, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/first-buck/01-open-example.png) 1. `File`. 2. `Open Example`. 3. `DC-DC`. 4. `Buck converter, textbook`: the buck with an ideal switch and diode, whose numbers match the hand formulas (the `Buck converter` example carries the losses of real parts). **Result:** a new tab named `buckIdeal` opens with the circuit. ## 2. Read the circuit The power stage is drawn at the bottom and the control at the top. ![The buck schematic with its six main parts, marked 1 to 6](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/first-buck/02-schematic.png) 1. `Vin`: the 48 V input. 2. `S1`: the switch. 3. `L1`: the 100 µH inductor. 4. `C1`: the 100 µF output capacitor. 5. `R1`: the 2.4 Ω load, which draws 5 A at 12 V. 6. `PWM`: turns the switch on and off at 100 kHz. Its duty (`D` = 0.25) comes from the `Duty` block. This is the whole window. The library is on the left, the schematic in the middle, Properties on the right and the scope at the bottom. The switch at the top of the library shows **Symbols**, the generic parts this lesson uses, or **Parts**, the real parts with their data-sheet ratings in tables. ![The whole Voltecx window with the buck example open, marked 1 to 6](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/first-buck/02-schematic-full.png) 1. `Vin`. 2. `S1`. 3. `L1`. 4. `C1`. 5. `R1`. 6. `PWM`. ## 3. Run the simulation Click `[▶ Run]` in the toolbar, or press `F5`. ![The Run button in the toolbar, marked 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/first-buck/03-run.png) 1. `[▶ Run]`. ## 4. Read the result The scope opens in the panel under the schematic when the run ends. ![The scope in the panel with v(VOUT) and i(L1) after the first run, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/first-buck/04-result.png) 1. `v(VOUT)` is ticked in the signal list. The output starts at 12 V, because the example pre-charges C1 to 12 V, dips to about 8.6 V while the inductor current builds up, rings and settles at 12 V. 2. `[Keep as reference]` keeps this run on the plot for the next step. **Result:** the Measurements table shows `v(VOUT)` near 12 V and the inductor current `i(L1)` near 5 A. After the start-up (from 3 ms on), the output averages 12.0 V and the inductor current swings about 0.9 A peak to peak. ## 5. Keep this run Click `[Keep as reference]`. The run stays on the plot as Ref 1 while you change the circuit and run it again. ![Keep as reference in the scope's toolbar, marked 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/first-buck/05-dock.png) 1. `[Keep as reference]`. ## 6. Select the inductor Click `L1` on the schematic. ![L1 selected on the schematic and its Inductance field in Properties, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/first-buck/06-select-inductor.png) 1. `L1` is selected. 2. Properties shows its `Inductance`: `100u` (100 µH). ## 7. Double the inductance Click the field, type `200u` and press `Enter`. ![The Inductance field set to 200u, marked 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/first-buck/07-change-value.png) 1. The `Inductance` field, now `200u`. **Result:** `L1` now shows 200 µH. Every edit is one undo step (`⌘Z`). ## 8. Run again and compare Press `F5`. The scope shows both runs. ![The second run over the reference: the inductor current ripple is half as large, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/first-buck/08-compare.png) 1. `i(L1) · Ref 1`: the first run, kept as reference Ref 1 and drawn dashed in a colour of its own. 2. `i(L1)`: the new run. Its band is about half as wide: the ripple fell from 0.9 A to about 0.45 A. **Result:** twice the inductance gives half the ripple, as `ΔI = (Vin − Vout)·D / (L·fsw)` says. The output still averages 12 V, but it rings more slowly at start-up. **Runs** shows one card per run, titled with what changed (`L1 100 µH → 200 µH`). ## The same steps from a script ```sh powercraft-cli run \ --cmd file.openExample --params '{"name":"buckIdeal"}' \ --cmd simulation.run --params '{}' \ --cmd circuit.setParam --params '{"component":"L1","key":"l","value":"200u"}' \ --cmd simulation.run --params '{}' \ --cmd scope.measure --params '{"signals":["v(out)","i(L1)"],"t0":"3m"}' ``` Next: [close the loop with a compensator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/02-closed-loop-buck/). --- # Closed-loop buck: design the compensator URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/02-closed-loop-buck/ The buck of the [first tutorial](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/01-first-buck/) runs at a fixed duty, so its output follows the input. Here a feedback loop holds the output at 12 V. You let the Design panel size a PI controller, read why it fails its check on this circuit, and then take the Type III compensator it suggests. About 15 minutes. Pictures: a numbered red box is what you click or read, `[Run]` is a button, `Design › Design Steps › Voltage Loop` a menu path, `F5` a key. ## 1. Open the closed-loop example Choose `File › Open Example › DC-DC › Buck converter, closed loop`. The power stage is the one you know; the control loop is drawn above it. ![The closed-loop buck with its loop parts, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/closed-loop-buck/01-loop.png) 1. `VM` measures the output voltage. 2. `Ref` is the set point, `Vref` = 12 V. 3. `Err` subtracts the measurement from the set point. 4. `PI` turns the error into a duty. 5. `PWM` drives the switch with that duty. ## 2. Open the voltage-loop design Choose `Design › Design Steps › Voltage Loop`. ![The Design menu with Voltage Loop, marked 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/closed-loop-buck/02-design-menu.png) 1. `Voltage Loop`. ## 3. Look at the Design panel The Design page opens in the editor area, as a tab beside the circuit's. The fields start filled from the circuit, and a first design is shown at once. ![The Design panel on the Voltage Loop task, the Controller field, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/closed-loop-buck/03-panel.png) 1. `Voltage Loop` is the task. 2. `Controller` is `Auto`, and the note under it says `Auto picked Type III.`: the panel picked a Type III network, because a PI cannot reach the default crossover (a tenth of the 100 kHz switching frequency) on this circuit. ## 4. Ask for a PI In the `Controller` row click `PI`. ![The Controller row with PI, marked 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/closed-loop-buck/04-pick-pi.png) 1. `PI`. ## 5. Design the PI Click `[Run]` (it reads `[Design again]` until you change a field), then collapse the bottom panel (`↓` at its top right) to see more of the result. ![The PI design: Kp, Ki and the Bode plot of the loop, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/closed-loop-buck/05-pi-result.png) 1. `[Design again]`: the design is computed; changing a field turns the button back into `[Run]`. 2. `[Apply]` writes the design into the circuit. **Result:** `Proportional gain` 0.003017 and `Integral gain` 73.69 1/s. The crossover field shows 685.4 Hz: with 60° of phase margin, this is as high as a PI can cross, well below the LC resonance at 1.59 kHz. ## 6. Apply it and read the check Click `[Apply]`. The panel writes `kp` and `ki` into the `PI` block as one undo step, then checks the loop on a copy of the circuit. Fold `Corner check` and `Changes made` and scroll down the `Verification` list. ![Check failed: the recovery overshoot after a load step is too large, marked 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/closed-loop-buck/06-pi-check.png) 1. `Recovery overshoot` fails: 73 % against a 40 % limit. The output rings after a 50 % load step, because a loop that crosses below the resonance cannot damp it. **Result:** the PI regulates (the output error after the step is near zero), but the response is poorly damped. The note under the plot says what to do: a Type III network reaches 5.78 kHz here. ## 7. Take the Type III compensator Click `Type III` in the `Controller` row, click `[Run]`, then `[Apply]`. ![The Type III design applied and verified, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/closed-loop-buck/07-type-iii.png) 1. `Controller` is `Type III`. The crossover is 5.78 kHz with 60° of margin. 2. `✔ Verified`: the loop passes its checks. On the schematic, the `PI` block is now a transfer-function block `B(s)/A(s)` with the same name and wires. `⌘Z` brings the PI back. ## 8. Simulate the closed loop Close the Design page with the `×` on its tab and open the bottom panel again. Click `[▶ Run]` in the toolbar or press `F5`, then `Maximize` at the panel's top right for a larger plot. ![The scope in the panel: v(out) settles on vref, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/closed-loop-buck/08-run.png) 1. `v(out)`: the output sits on the set point. The plot shows the last cycles; `Whole run` above it shows the output rising from the start. 2. `vref`: the 12 V set point. **Result:** from 8 ms on, the output averages 12.00 V. ## The same steps from a script ```sh powercraft-cli run \ --cmd file.openExample --params '{"name":"buckClosedLoop"}' \ --cmd design.voltageLoop --params '{"controller":"pi"}' \ --cmd design.voltageLoop --params '{"controller":"typeIII","apply":true}' \ --cmd simulation.run --params '{}' \ --cmd scope.measure --params '{"signals":["v(out)"],"t0":"8m"}' ``` Next: [design the transformer of a flyback](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/03-flyback-magnetics/). --- # Flyback: design the transformer URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/03-flyback-magnetics/ A flyback stores energy in its coupled inductor while the switch is on and passes it to the output while it is off. Here you simulate the flyback example, let `magnetics.design` pick a core, the turns, the wire and the air gap from the simulated currents, write the result into the circuit and check it. About 10 minutes. Pictures: a numbered red box is what you click or read, `[Run]` is a button, `Design › Automate` a menu path, `F5` a key. ## 1. Open the flyback example Choose `File › Open Example › Isolated › Flyback converter`. ![The File menu open at Open Example, Isolated, Flyback converter, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/flyback-magnetics/01-open-example.png) 1. `File`. 2. `Open Example`. 3. `Isolated`. 4. `Flyback converter`. ## 2. Read the circuit ![The flyback schematic with T1, S1, D1 and C1, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/flyback-magnetics/02-schematic.png) 1. `T1`: the coupled inductor, 50 µH on each side (1:1), coupling 0.995. 2. `S1`: the switch, at 100 kHz and a duty of 0.4. 3. `D1`: the output diode. 4. `C1`: the 47 µF output capacitor, with a 20 Ω load. The 12 V source `Vin` and an RC snubber (`Csn`, `Rsn`) complete the circuit. ## 3. Simulate it first Press `F5` (or `[▶ Run]`). The magnetics design reads the winding currents from this run. ![The scope in the panel after the first run, v(out), marked 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/flyback-magnetics/03-run.png) 1. `v(out)` settles near 7.9 V. ## 4. Open Design Magnetics Choose `Design › Automate › Design Magnetics`. ![The Design menu open at Automate, Design Magnetics, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/flyback-magnetics/04-menu.png) 1. `Design`. 2. `Automate`. 3. `Design Magnetics`. ## 5. Check the spec The Design page opens at `Magnetics`. Every field may stay empty: the part is the only magnetic part, `T1`, and the currents come from the last run. ![The Magnetics task of the Design page, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/flyback-magnetics/05-form.png) 1. `Magnetics`, the task. 2. `Part kind`: `Auto` designs `T1` as the coupled inductor it is. 3. Click `[Run]`. ## 6. Read the design and apply it The result shows beside the spec. Collapse the bottom panel (`↓` at its top right) to see all of it, then click `[Apply]`: the design is written into `T1` as one undo step, and the circuit is simulated again with the new part to check it. The best fit is picked in the `Core` table; pick another row's round button first to apply that core instead. A greyed `[Apply]` says why when you point at it. ![The result: loss, temperature, peak flux, Verified, and the chosen core, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/flyback-magnetics/06-result.png) 1. The total loss of the best candidate: 37.4 mW. 2. Its temperature: 42.06 °C at 40 °C ambient. 3. Its peak flux density: 132.7 mT, well below the 503 mT where the ferrite saturates. 4. The check: `✔ Verified`. 5. The core it chose. **Result:** the best candidate is an EFD 20/10/7 core in Ferroxcube 3C95 ferrite with 14 turns on each side of 10 × 0.1 mm litz (three strands in parallel on the primary, four on the secondary), wound on its CSH-EFD20-1S-8P coil former, and a 0.163 mm gap, for 49.5 µH. It loses 37 mW, runs at 42 °C at 40 °C ambient and peaks at 133 mT, well below saturation. The check says `✔ Verified`. Scroll down for the changes it made, each check, every number and the other candidates. The candidates are ranked by the size of the core, the smallest first, then by loss. To see the larger core with the least loss, set `Rank cores by` to `Least loss`, or type a shape from the catalogue into `Shape` under `Advanced` (besides the E pairs and rings, ETD, PQ, RM, EFD and planar sets such as `ETD 34/17/11`, `PQ 26/25` or `E 32/6/20`, read from the Ferroxcube and TDK data sheets), and run again. The notes at the bottom are worth reading: the catalogue is a starter set, so check the core, gap and wire against the maker's data sheet. The page also draws the winding as a cross-section: the core side on the left, each layer coloured by its winding, and a line for the magnetomotive force across the window. Hover a layer to see its turns, its Dowell factor and its loss; the table under it lists every layer. For a transformer, `Winding order` picks `P/S`, or `P/S/P` to split the primary around the secondary: the result then names the other arrangement beside the chosen one with its winding loss and leakage, so you can see what interleaving would save. ## 7. Simulate with the designed part Close the Design page with the `×` on its tab, open the bottom panel again and press `F5`. ![The scope in the panel after the second run, v(out), marked 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/flyback-magnetics/07-rerun.png) 1. `v(out)` settles near 7.9 V with the designed `T1` (its inductances and coupling now come from the core and the winding). ## The same steps from a script ```sh powercraft-cli run \ --cmd file.openExample --params '{"name":"flyback"}' \ --cmd simulation.run --params '{}' \ --cmd magnetics.design --params '{"apply":true,"verify":true}' \ --cmd simulation.run --params '{}' \ --cmd scope.measure --params '{"signals":["v(out)"],"t0":"2m"}' ``` ## Your own cores and materials If your core, material or wire is not in the catalogue, import its OpenMagnetics MAS records (a vendor's MAS file, or records you write from the data sheet) with `magnetics.importMas`. Every record is checked first, and a bad value is refused with its field named. `magnetics.design` then searches your records beside the built-in ones and marks a design that uses one as user data (`userData`). The desktop app keeps them in `library/magnetics.json` in its settings folder. On the command line, `--root .` lets the chain read the file from the current folder: ```sh powercraft-cli run --root . \ --cmd magnetics.importMas --params '{"path":"my-ferrite.ndjson"}' \ --cmd magnetics.library --params '{"source":"user"}' ``` If the data sheet plots the material's loss but gives no Steinmetz coefficients, read a few sine-loss points off its curves, at two or more frequencies and two or more flux densities, and fit them with `magnetics.steinmetzFit`. It returns `k`, `alpha` and `beta` (W/m³, Hz, T peak) with the error of the fit at every point (`errorPct`, `maxErrorPct`) and the range the fit holds over. Fit each frequency range on its own points, because a ferrite's α and β change with frequency: ```sh powercraft-cli run --cmd magnetics.steinmetzFit --params '{"lossUnit":"kW/m3","points":[ {"frequencyHz":50e3,"bPeakT":0.1,"loss":20},{"frequencyHz":100e3,"bPeakT":0.1,"loss":50}, {"frequencyHz":100e3,"bPeakT":0.2,"loss":300},{"frequencyHz":200e3,"bPeakT":0.1,"loss":130}]}' ``` The points above only show the format. Read yours from your data sheet. Next: [boost and buck-boost](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/04-boost-buck-boost/). --- # Boost and buck-boost: step up, and turn the output negative URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/04-boost-buck-boost/ A boost makes a higher voltage from a lower one; a buck-boost makes a negative one. You simulate the boost example, let the Design panel size its inductor and capacitor, and then build an inverting buck-boost from a template. About 15 minutes. Pictures: a numbered red box is what you click or read, `[Run]` is a button, `Design › Design Steps › Converter` a menu path, `F5` a key (`⌘` is Cmd on a Mac, Ctrl elsewhere). ## 1. Open the boost example Choose `File › Open Example › DC-DC › Boost converter`. ![The File menu open at Open Example, DC-DC, Boost converter, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/boost-buck-boost/01-open-example.png) 1. `File`. 2. `Open Example`. 3. `DC-DC`. 4. `Boost converter`. ## 2. Read the circuit The parts are those of the buck, in another order: the inductor now sits at the input and the switch shorts its far end to ground. ![The boost schematic with its six power parts, marked 1 to 6](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/boost-buck-boost/02-schematic.png) 1. `Vin`: the 12 V input. 2. `L1`: 200 µH. It stores energy while the switch is on. 3. `S1`: the switch, driven by `PWM` at 50 kHz with a duty of 0.5. 4. `D1`: passes the stored energy to the output while the switch is off. 5. `C1`: 220 µF output capacitor. 6. `R1`: the 24 Ω load. ## 3. Run it Click `[▶ Run]` in the toolbar or press `F5`. ![The scope: v(out) rings round 24 V, i(L1) round 2 A, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/boost-buck-boost/03-run.png) 1. `v(out)`: the output averages 24 V, as `Vout = Vin / (1 − D)` says. 2. `i(L1)`: the inductor current averages 2 A, twice the 1 A load, because the input power equals the output power. **Result:** both traces ring at about 380 Hz and the ringing dies away slowly. Nothing controls this circuit (it is open loop), so the LC filter rings after every disturbance; the [closed-loop tutorial](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/02-closed-loop-buck/) shows how a compensator damps it. Over the last 0.1 ms the inductor ripple is 0.62 A peak to peak, close to the textbook `ΔI = Vin·D / (L·fsw)` = 0.6 A. ## 4. Open the converter design Open the `Design` menu. ![The Design menu with Converter, marked 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/boost-buck-boost/04-design-menu.png) 1. `Converter`. ## 5. Check the fields Choose `Converter`. The Design tab opens with its fields filled in. ![The Design panel on the Converter task, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/boost-buck-boost/05-converter.png) 1. `Converter` is the task. It sizes L and C for a buck, a boost or an inverting buck-boost. 2. `from circuit`: the output voltage, the load current and the switching frequency were read from the circuit. The ripple targets are defaults: 20 % of the inductor current and 1 % of the output voltage. 3. `[Design again]`: the panel has already designed L and C from these fields, and this runs the design again. It reads `[Run]` once you change a field. ## 6. Design L and C Click `[Design again]`. ![The design: inductor, output and input capacitor, and the changes it proposes, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/boost-buck-boost/06-converter-result.png) 1. `Inductor` 300 µH, `Output capacitor` 41.67 µF, `Input capacitor` 8.333 µF. The plot shows how L and C shrink as the switching frequency rises. 2. `Changes to apply`: `L1` from 200 µH to 300 µH and `C1` from 220 µF to 41.67 µF. The duty stays 0.5. 3. `[Apply]` writes them into the circuit. ## 7. Apply and read the check Click `[Apply]`. The changes are one undo step (`⌘Z`). The panel then simulates the new circuit. Collapse the bottom panel (`↓` at its top right) to see the whole check. ![Verified: the measured ripples are within their targets, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/boost-buck-boost/07-verified.png) 1. `✔ Verified`: every check passed. 2. `Verification` lists the checks. 3. The inductor ripple is 0.400 A against a 0.46 A limit, the output ripple 0.243 V against 0.276 V, and the mean output is 23.99 V. ## 8. Make a buck-boost from a template Close the Design page with the `×` on its tab, so the schematic is back. Then press `⌘K` to open Quick Open and type `template`. ![Quick Open with Circuit From Template, marked 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/boost-buck-boost/08-palette.png) 1. `Circuit From Template`. ## 9. Ask for a buck-boost Choose `Circuit From Template`. In the form, set `Topology` to `buck boost`. ![The template form with the buck-boost topology chosen, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/boost-buck-boost/09-template.png) 1. The topology. Fields left empty use the template's defaults: 12 V in, −24 V out, 1 A, 100 kHz. 2. `[Create Circuit]` builds the circuit. ## 10. Read the new circuit Click `[Create Circuit]`. A new tab opens with a laid-out buck-boost. Its values are circuit variables (`Vin`, `D`, `Lf`, `Cf`, `Rload`), sized by the template's equations. ![The buck-boost: switch on top, inductor to ground, diode reversed, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/boost-buck-boost/10-schematic.png) 1. `S1`: the switch, now in series with the input. 2. `L1`: 133.3 µH, from the switch node to ground. 3. `D1`: points away from the output, so the output charges negative. 4. `C1`: 27.78 µF. 5. `R1`: the 24 Ω load. ## 11. Run the buck-boost Press `F5`, then click the `Scope` tab of the panel (the Design tab stays in front while it is open) and `Maximize` at the panel's top right for a larger plot. ![The buck-boost output settles at −23.72 V, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/boost-buck-boost/11-run.png) 1. `v(out)` settles at −23.72 V. The duty is 0.667, so `Vout = −Vin·D / (1 − D)` = −24 V; the input source resistance and the switch take the last 0.28 V. 2. `i(L1)` averages 2.96 A: the input current plus the load current. ## The same steps from a script ```sh powercraft-cli run \ --cmd file.openExample --params '{"name":"boost"}' \ --cmd simulation.run --params '{}' \ --cmd scope.measure --params '{"signals":["v(out)","i(L1)"],"t0":"9.9m"}' \ --cmd design.converter --params '{"apply":true}' \ --cmd circuit.template --params '{"topology":"buckBoost"}' \ --cmd simulation.run --params '{}' \ --cmd scope.measure --params '{"signals":["v(out)","i(L1)"],"t0":"2.67m"}' ``` Next: [the full-bridge inverter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/05-full-bridge-inverter/). --- # Full-bridge inverter: a 50 Hz sine from a DC link URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/05-full-bridge-inverter/ A full bridge turns a DC voltage into AC. You open a single-phase inverter with sine PWM and an LC filter, read how its gates are made, simulate it, check the spectrum of the output, and let the Problems list lengthen a run that is too short. About 15 minutes. Pictures: a numbered red box is what you click or read, `[FFT]` is a button, `File › Open Example` a menu path, `F5` a key. ## 1. Open the inverter example Choose `File › Open Example › Inverters › Single-phase full-bridge inverter`. ![The File menu open at Open Example, Inverters, Single-phase full-bridge inverter, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/full-bridge-inverter/01-open-example.png) 1. `File`. 2. `Open Example`. 3. `Inverters`. 4. `Single-phase full-bridge inverter`. ## 2. Read the power stage Four MOSFETs make two legs across the 400 V link. The output is taken between the legs, through the filter. ![The power stage: two legs of two MOSFETs, the LC filter and the load, marked 1 to 7](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/full-bridge-inverter/02-power.png) 1. `Qah`: high side of leg a. 2. `Qal`: low side of leg a. 3. `Qbh`: high side of leg b. 4. `Qbl`: low side of leg b. 5. `L1`: 1 mH, one half of the filter inductance (`L2` is the other half, in the return path). 6. `C1`: 10 µF. With 2 mH it filters at 1.1 kHz, well below the switching ripple. 7. `R1`: the 50 Ω load. The voltmeter `VM` beside it gives the signal `vo`. ## 3. Read the control Each leg has its own sine reference and PWM. The gate signals reach the switches through net labels (`gah`, `gal`…), so no wire crosses the page. ![The control: sine references, PWM, inverters and dead-time blocks, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/full-bridge-inverter/03-control.png) 1. `Refa`: `0.5 + 0.4·sin(2π·50 t)`, the duty of leg a. The modulation index `Mi` = 0.8 sets the 0.4. 2. `PWMa`: compares the duty with a 10 kHz carrier and switches leg a. 3. `DTah`: delays the turn-on of `Qah` by 500 ns. Its partner `DTal`, behind the inverter `Na`, does the same for `Qal`, so the two switches of a leg are never on together. 4. `Refb`: the same sine shifted by 180°, for leg b. The voltage between the legs then switches at twice the carrier frequency (unipolar PWM), which halves the filter's work. ## 4. Run it Click `[▶ Run]` or press `F5`. The scope shows in the panel under the schematic; click `Maximize` at the panel's top right for a larger plot. ![The scope: vo is a 50 Hz sine, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/full-bridge-inverter/04-run.png) 1. `vo`: a 50 Hz sine of 316.6 V peak, 222.7 V rms. The ideal value is `Mi·Vdc` = 320 V peak; the dead time takes about 2 V from each leg (`Vdc·td·fsw`). 2. `FFT` at the end of the `vo` row of the measurements shows the spectrum of this signal over the visible window. ## 5. Read the spectrum A spectrum needs a whole number of cycles: the visible window (about 4 ms to 56 ms) is not, and its spectrum smears the 50 Hz line. So take two whole cycles after the start-up. Click `Cursors` and put the two lines at 20 ms and 60 ms. Click `Measurements` in the scope toolbar to hide the table, so the plot takes the panel's width, then the spectrum button at the left of the plot's header. ![The plot as a spectrum between the cursors: fundamental 50 Hz, 315 V, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/full-bridge-inverter/05-fft.png) 1. The spectrum button: the plot shows the spectrum of its signals instead of the waveform. 2. The time range: pick `Between cursors` (it starts at `Visible window`). 3. The fundamental and the distortion: `vo: fundamental 50Hz, 315V, THD 0.70%`. **Result:** the fundamental is 315 V at 50 Hz and the total harmonic distortion is 0.69 % over the visible window (24.5 µs to 60 ms, shown above the measurements). Another window gives a slightly different THD: the script below takes 20 ms to 60 ms and reads 0.68 %. The small odd harmonics (3rd, 5th, 7th) come from the dead time. ## 6. Read the note in Problems Click the spectrum button again to go back to the waveform, `Measurements` to bring the table back and `Restore` at the panel's top right, then click the `Problems` tab. ![Problems: Run too short, with a Run until 200 ms button, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/full-bridge-inverter/06-problems.png) 1. `Problems 1`: one note. 2. `Run too short`: 60 ms holds only three cycles of 50 Hz, too few to trust the averages. 3. `[Run until 200 ms]` sets a longer end time. ## 7. Fix it and run again Click `[Run until 200 ms]`, then press `F5`. When the run ends, click `[Show results]` on its notice and `Maximize`. ![Ten cycles of vo; Run History shows the end time change, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/full-bridge-inverter/07-fixed.png) 1. `vo` now shows ten cycles (the end time is 200 ms). From 40 ms on it holds 222.7 V rms with 0.70 % THD. 2. The `Runs` tab lists both runs and what changed between them: `tEnd 60 ms to 200 ms`. ## The same steps from a script ```sh powercraft-cli run \ --cmd file.openExample --params '{"name":"fullBridgeSpwm"}' \ --cmd simulation.run --params '{}' \ --cmd analysis.fft --params '{"signal":"vo","t0":"20m","t1":"60m"}' \ --cmd simulation.settings --params '{"tEnd":"200m"}' \ --cmd simulation.run --params '{}' \ --cmd scope.measure --params '{"signals":["vo"],"t0":"40m","thd":{"fundamental":50}}' ``` Next: [the three-phase motor drive](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/06-motor-drive/). --- # Three-phase motor drive: field-oriented control of a PM motor URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/06-motor-drive/ A permanent-magnet synchronous motor (PMSM) on a three-phase inverter, under field-oriented control (FOC): a speed loop sets the torque current, and two current loops in the rotor's d-q frame set the voltages. You read the drive, simulate a speed step, and let the Design panel size the current and speed controllers. About 20 minutes. Pictures: a numbered red box is what you click or read, `[Run]` is a button, `Design › Design Steps › Current Loop` a menu path, `F5` a key. ## 1. Open the FOC example Choose `File › Open Example › Motor drives › PM synchronous motor, field-oriented control`. ![The File menu open at Open Example, Motor drives, PM synchronous motor, field-oriented control, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/motor-drive/01-open-example.png) 1. `File`. 2. `Open Example`. 3. `Motor drives`. 4. `PM synchronous motor, field-oriented control`. ## 2. Read the power stage For these two pictures the side panels are hidden (`View` menu) so the schematic has the whole window. ![The power stage: DC link, three-phase bridge, current sensors, motor and load, marked 1 to 6](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/motor-drive/02-power.png) 1. `Vdc`: the 300 V DC link. 2. `Sah`: the high side of phase a; the bridge has three legs, `Sa`, `Sb` and `Sc`. 3. `Ama`: measures the phase-a current (`Amb` and `Amc` the others) for the current loops. 4. `M1`: the PMSM, 8 poles, 0.5 Ω, 4 mH, 0.12 Wb of magnet flux. 5. `Fan`: a fan load, whose torque rises with the square of the speed. 6. `PS`: the position sensor, which gives the rotor angle to the Park transforms. ## 3. Read the control ![The control: speed loop, Park transform, d and q current loops, inverse Park, SVM and PWM, marked 1 to 9](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/motor-drive/03-control.png) 1. `SpeedRef`: steps the speed command from 0 to 200 rad/s at 20 ms. 2. `SpdPI`: the speed controller. Its output is the q-axis (torque) current command, limited to ±8 A. 3. `Park`: turns the three phase currents into `id` and `iq`, in the frame that turns with the rotor. 4. `PIq`: the q-axis current controller. 5. `PId`: the d-axis current controller. Its command is 0 (`IdRef`), so all the current makes torque. 6. `InvPark`: turns the d-q voltages back into three phase voltages. 7. `SVM`: space-vector modulation turns them into three duties. 8. `PWM`: one 10 kHz carrier for the three legs. 9. `DTh`: the 1 µs dead time of the three high sides, on the PWM's gate bus; `N` and `DTl` give the three low sides the complement, and two bus demuxes hand the six gate signals (`gah` to `gcl`) to the bridge by label. ## 4. Run the speed step Click `[▶ Run]` or press `F5`. The run is 350 ms and takes about a second. In the scope click `Maximize` at the panel's top right, then `Fit` in the scope's toolbar: the plot first shows only the last few switching cycles. ![The scope: wm(M1) ramps to 200 rad/s and stops there without overshoot, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/motor-drive/04-run.png) 1. `wm(M1)`: the rotor speed. 2. `wref`: the command. **Result:** the speed rises as a straight ramp and stops at 200 rad/s without overshoot. During the ramp `SpdPI` sits at its 8 A limit, but the current loop trails that command by about 0.35 A while the back-EMF climbs with the speed: `iqm` is about 7.65 A, so the motor accelerates at `Kt·iqm / J` = 0.72 × 7.65 / 0.004 ≈ 1380 rad/s² (the full 8 A would give 1440 rad/s²), slowed near the top by the fan. The Problems tab shows no warnings: each gate goes through its dead-time block, which costs each leg about `Vdc·td·fsw` = 300 × 1 µs × 10 kHz = 3 V of the voltage the current loops ask for ([tutorial 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/05-full-bridge-inverter/) shows the effect of dead time on a full bridge). ## 5. Design the current loop Click `Restore` at the panel's top right, choose `Design › Design Steps › Current Loop`, then click `[Design again]`. ![The Current Loop task: Kp and Ki of the d axis, and the Bode plot, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/motor-drive/05-current-loop.png) 1. `Current Loop` is the task. It reads R and L from the motor and finds the two PIs from the wiring. 2. `Proportional gain (d axis)` = 25.13 and `Integral gain (d axis)` = 3.142k 1/s: `Kp = L·ωc` and `Ki = R·ωc` cancel the motor's R-L pole. The crossover is 1 kHz (a tenth of the switching frequency) with 72° of margin: 90° less 18° for the half-sample PWM delay. 3. `[Apply]` writes `Kpi` and `Kii`, the circuit variables both current PIs use. ## 6. Design the speed loop Click `[Apply]`, then the `Speed Loop` task, then `[Design again]`. ![The Speed Loop task: Kp and Ki by the symmetrical optimum, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/motor-drive/06-speed-loop.png) 1. `Speed Loop` is the task. It models the current loop you just applied as a first-order lag of 1 kHz. 2. `Proportional gain` = 3.386 and `Integral gain` = 531.9 1/s, by the symmetrical optimum with a symmetry factor of 4. The loop crosses at 99.5 Hz (the speed bandwidth, a tenth of the current loop's) with 70° of margin. 3. `[Apply]` writes `Kpw` and `Kiw`. ## 7. Run again Click `[Apply]`, close the Design page with the `×` on its tab and press `F5`. When the run ends, click `Maximize` and `Fit` as in step 4. ![The same ramp; Run History lists the four gains that changed, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/motor-drive/07-rerun.png) 1. `wm(M1)`: the same ramp to 200 rad/s. A large step drives the speed PI into its current limit, so the ramp depends on the 8 A limit and the inertia, not on the gains. The new gains act on small steps and load changes, where the loop stays linear. 2. The `Runs` tab: the second run and the four variables `Apply` changed. ## The same steps from a script ```sh powercraft-cli run \ --cmd file.openExample --params '{"name":"pmsmFoc"}' \ --cmd simulation.run --params '{}' \ --cmd design.currentLoop --params '{"apply":true}' \ --cmd design.speedLoop --params '{"apply":true}' \ --cmd simulation.run --params '{}' \ --cmd scope.measure --params '{"signals":["wm(M1)"],"t0":"0.3"}' ``` Next: [digital control and code generation](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/07-digital-control/). --- # Digital control: sampling, PWM resolution and C code URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/07-digital-control/ A compensator that runs on a microcontroller samples, computes and updates the PWM a little late, and it stores its coefficients and the duty in a finite number of bits. You let Digitalize Compensator show what that costs on the closed-loop buck, fix the two problems it finds, and generate the C code of the control. About 20 minutes. Pictures: a numbered red box is what you click or read, `[Run]` is a button, `Design › Automate` a menu path. ## 1. Open the closed-loop buck Choose `File › Open Example › DC-DC › Buck converter, closed loop`. It is the circuit of [tutorial 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/02-closed-loop-buck/). ![The File menu open at Open Example, DC-DC, Buck converter, closed loop, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/digital-control/01-open-example.png) 1. `File`. 2. `Open Example`. 3. `DC-DC`. 4. `Buck converter, closed loop`. ## 2. Open Digitalize Compensator Choose `Design › Automate › Digitalize Compensator`. ![The Design menu open at Automate, Digitalize Compensator, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/digital-control/02-menu.png) 1. `Design`. 2. `Automate`. 3. `Digitalize Compensator`. ## 3. Start from the voltage-loop design ![The form: Run design first set to voltage loop, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/digital-control/03-form.png) 1. Set `Run design first` to `voltage loop`. The tool runs the voltage-loop design of tutorial 2 (a Type III network crossing at 5.78 kHz with 60° of margin) and digitalizes it. It never changes the circuit. 2. Click `More options`. ## 4. Describe the firmware Scroll to the lower fields and fill in the ADC and the PWM timer. ![The lower fields: number format, compute delay, ADC and PWM timer, marked 1 to 6](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/digital-control/04-fields.png) 1. `Number format`: `q31`, 32-bit fixed point (the default). 2. `Compute delay`: 1 sample, the usual timing: sample, compute, write the duty at the next period. 3. `ADC bits`: `12`. 4. `ADC full scale`: `4` V at the ADC's top code. 5. `PWM timer counts`: `1000`, a 100 MHz timer at 100 kHz, so the duty moves in steps of 0.1 %. 6. `[Run]`. ## 5. Read the verdict ![Check failed: phase margin lost and DPWM coarser than the ADC, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/digital-control/05-result.png) 1. `✖ Check failed`. 2. `Phase margin lost`: 20.8° against a limit of 10°. The design planned for half a sample of PWM delay; with one sample of computation on top, the loop has 1.5 samples, and that extra sample costs `360° · fc · Ts` = 20.8° at 5.78 kHz. The margin falls from 60° to 39.2°. 3. `DPWM finer than the ADC`: one duty step moves the output by 48 mV (48 V × 0.1 %), more than one ADC step (977 µV). The loop then cannot settle between two duty steps and hunts round the set point (a limit cycle). The note under the table says the PWM resolves 10 bits and needs 16. Below the table are the coefficients as a C header, in float32, q15 and q31. ## 6. Shorten the delay and refine the PWM Close the window and open `Design › Automate › Digitalize Compensator` again. The form opens with the values you ran last, so `Run design first`, `ADC bits` and `ADC full scale` are already set. Clear `PWM timer counts`, because the high-resolution step replaces it, then fill in these fields: ![ISR cycles, CPU clock, Duty update end and the high-resolution PWM step, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/digital-control/06-hrpwm.png) 1. `ISR cycles`: `500`, the length of the control interrupt. 2. `CPU clock`: `170e6`. The interrupt then takes 2.94 µs, under a third of the 10 µs period. 3. `Duty update`: `end`. The new duty is written as soon as the interrupt ends, not at the next period. 4. `High-resolution PWM step`: `184e-12`, the 184 ps edge step of the STM32G474 high-resolution timer. 5. `[Run]`. ## 7. Read the new verdict ![Verified: the ISR fits, 6.1° of margin lost, the DPWM finer than the ADC, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/digital-control/07-passed.png) 1. `✔ Verified`. 2. `Phase margin lost`: 6.12°. The loop keeps 53.9° at the same 5.78 kHz crossover. 3. `ISR fits in the period`: the interrupt uses 29 % of the period. The last row now passes too: one duty step moves the output by 883 µV, less than one ADC step. ## 8. Generate the C code Close the window and choose `Tools › Code Generation`. ![The generated C: pc_control.h and pc_control.c, marked 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/digital-control/08-codegen.png) 1. `[Save Files…]` writes the files. The code holds the control blocks of the circuit (`Ref`, `Err` and `PI`), with the PI turned into a difference equation by Tustin's rule at the 10 µs sample time. Call `pc_control_step()` once per sample from the timer interrupt. Click `[Save Files…]` to write the files. The circuit still holds the PI: to generate the Type III network, apply it first as in tutorial 2. ## 9. Give the model the same PWM resolution Click the `PWM` block and open `Advanced (2)` in Properties. ![The PWM block's Advanced parameters: timer counts and high-resolution step, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/digital-control/09-pwm.png) 1. `PWM`. 2. `Timer counts in one PWM period`: with `1000` here, the simulation rounds every duty to 0.1 %. 3. `High-resolution PWM edge step`: `184e-12` (or `stm32g474`) rounds it to 184 ps steps instead. ## The same steps from a script `codegen.verify` compiles the generated C with your computer's compiler, replays the simulated inputs through it and compares the outputs with the model's; here they agree within 2e-7. ```sh powercraft-cli run \ --cmd file.openExample --params '{"name":"buckClosedLoop"}' \ --cmd design.digitalize --params '{"run":"voltageLoop","format":"q31","adcBits":12,"vFullScale":4,"dpwmCounts":1000}' \ --cmd design.digitalize --params '{"run":"voltageLoop","format":"q31","adcBits":12,"vFullScale":4,"hrpwm":184e-12,"cycles":500,"fclk":170e6,"update":"end"}' \ --cmd tools.codeGeneration --params '{}' \ --cmd codegen.verify --params '{"maxSamples":500}' ``` Back to the [learning path](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/). --- # Thermal and losses: where the watts go and how hot the junction gets URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/08-thermal-losses/ A switch that loses 14 W needs somewhere to put the heat. You simulate a buck whose MOSFET heats its own junction, read the losses split into conduction and switching, read the junction temperature, then let Design Thermal compute the steady-state junction temperature and the largest heatsink you may use. About 15 minutes. Pictures: a numbered red box is what you click or read, `[Run]` is a button, `Analysis › Losses` a menu path. ## 1. Open the buck with a thermal model Choose `File › Open Example › DC-DC › Buck converter with thermal model`. ![The File menu open at Open Example, DC-DC, Buck converter with thermal model, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/thermal-losses/01-open-example.png) 1. `File`. 2. `Open Example`. 3. `DC-DC`. 4. `Buck converter with thermal model`. ## 2. Read the thermal network The red parts above the power stage are a thermal circuit. Temperature plays the part of a voltage and watts the part of a current. ![The schematic: Q1, and the thermal parts Cth, Rth and Amb, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/thermal-losses/02-schematic.png) 1. `Q1`: its `thermal` parameter is `tj`, so its losses flow into the thermal node `tj`. Its on-resistance also rises 0.4 % per kelvin as that node heats. 2. `Cth`: 5 mJ/K, the heat the junction and case store. 3. `Rth`: 1.5 K/W from the junction to the heatsink. 4. `Amb`: holds the heatsink at 40 °C. ## 3. Run Click `[▶ Run]` in the toolbar (or press `F5`). The scope shows the junction temperature. Click `Maximize` at the panel's top right and `Fit` in the scope's toolbar, then, on the `Signals` tab, click the name `T(tj)` in the table: its row opens with the values at the window's ends, the change between them, min and max. ![The scope: T(tj) rises from 40 °C towards 59 °C, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/thermal-losses/03-run.png) 1. `T(tj)` starts at 40 °C and rises with the time constant Rth · Cth = 7.5 ms. 2. `@t2`: about 58.9 °C at the right edge of the plot, 19 ms; the run ends at 59.08 °C at 20 ms (the fitted view leaves a little of each end out, #2677). The run lasts 2.7 time constants, so the junction has not quite settled. Step 8 gives the settled value. After the run the thermal overlay is on: Q1 is tinted on the temperature scale with its temperature beside it. The run card's thermal chip names the hottest part, its temperature and its margin to `tjMax`; click it to bring the overlay back after you turn it off. ## 4. Open the analyses Click `Restore` at the panel's top right, then open the `Analysis` menu. ![The Analysis menu with Losses and Thermal, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/thermal-losses/04-analysis-menu.png) 1. `Analysis`. 2. `Losses`. 3. `Thermal` (step 6). ## 5. Read the losses Click `Losses`. ![The Losses window: 15.6 W in total, Q1 13.5 W of switching, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/thermal-losses/05-losses.png) 1. `Total losses`: 15.6 W, averaged over the whole run (0 to 20 ms). 2. `Conduction`: Q1 loses 147 mW in its 20 mΩ, and D1 1.95 W in its 0.5 V drop. 3. `Switching`: Q1 loses 13.5 W. Its data gives 50 µJ at turn-on and 80 µJ at turn-off at 48 V and 5 A, and 130 µJ × 100 kHz = 13 W. Switching, not conduction, sets the heat here: halving the switching frequency would nearly halve it. `Copy` puts the table on the clipboard. ## 6. Read the temperatures Close the window and choose `Analysis › Thermal`. ![The Thermal window: T(tj) ends at 59.1 °C, T(hs) stays at 40 °C, marked 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/thermal-losses/06-thermal.png) 1. `Final`: one row per thermal node, with its final, maximum and minimum temperature in °C. `T(tj)` ends at 59.1 °C, and `T(hs)` stays at 40 °C because `Amb` holds it there. ## 7. Open Design Thermal Close the window and open the `Design` menu. ![The Design menu with Thermal, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/thermal-losses/07-design-menu.png) 1. `Design`. 2. `Thermal`. ## 8. Compute the steady state The Design page opens at `Thermal`. Click `[Run]`, collapse the bottom panel (`↓` at its top right) and open `Advanced` under the conditions. ![Design Thermal: the hottest junction at 60.46 °C, verified, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/thermal-losses/08-design-thermal.png) 1. `Heatsink`: 0 K/W, `from circuit`. The heatsink is ideal, since `Amb` holds it at 40 °C. 2. The hottest junction: 60.46 °C = 40 °C + 13.65 W × 1.5 K/W. It is the value the simulation was heading for in step 3. The plot shows how it would rise with a heatsink of 0 to 6 K/W; it reaches the 125 °C limit at 4.14 K/W. 3. `✔ Verified`: both junctions are under 125 °C, and this static result is within 1.4 K of the simulated `T(tj)`. The notes under the devices say what was assumed: D1 has no thermal data, so 1 K/W junction to case is used, and neither part has a package, so no heatsink part is picked. Give them vendor devices with `Design › Design Steps › Parts` to get one. ## 9. Try a heatsink Type `3` in `Heatsink` and click `[Run]`. ![A 3 K/W heatsink: 107.3 °C, and the static model row is skipped, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/thermal-losses/09-heatsink.png) 1. `Heatsink`: `3` K/W, both devices on it. 2. `[Run]`, which reads `[Design again]` once the design is done. 3. The hottest junction: 107.3 °C = 40 + 15.6 W × 3 + 13.65 W × 1.5. It is still under 125 °C, with 17.7 K to spare. 4. `✔ Verified`: every junction passes. 5. The row that is skipped: the static model against the simulated `T(tj)`. The 3 K/W you typed is not in the circuit's thermal network, so the simulation cannot check it (it would show 59.1 °C against 107.3 °C). The junction rows are the answer to "will a 3 K/W heatsink do?". To have the simulation check the heatsink too, draw it into the circuit: an `Rth` of 3 K/W between `hs` and `Amb`. ## Temperatures without a thermal model Most circuits have no thermal network, and every Real run still shows temperatures. Open `File › Open Example › DC-DC › Buck converter`, set the switch `S1`'s `device` to a library MOSFET whose data sheet gives an RthJA (for example `infineon/bsc070n10ns5`), and run. The run card says *No thermal model on N parts. Temperatures use ambient + Rth from the data sheet.*, the chip shows the MOSFET at about ambient + loss × RthJA, and the overlay marks it `≈`. The diode and `C1` show `—` and **needs Rth**: their data sheets' Rth is not in the catalogue, so no temperature is guessed. **Add heatsinks** opens Design Thermal (step 8), which picks a catalogue heatsink for each device. `thermal.summary` gives the same numbers to a script. ## The same steps from a script ```sh powercraft-cli run \ --cmd file.openExample --params '{"name":"buckThermal"}' \ --cmd simulation.run --params '{}' \ --cmd analysis.losses --params '{}' \ --cmd analysis.thermal --params '{}' \ --cmd design.thermal --params '{}' \ --cmd design.thermal --params '{"rthHeatsink":3}' \ --cmd thermal.summary --params '{}' ``` Back to the [learning path](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/). --- # Conducted EMI: a pre-compliance estimate and an input filter URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/09-conducted-emi/ A converter's pulsed input current comes back out of its supply leads as noise, and CISPR 32 limits how much. You estimate the conducted emission of the plain buck, see why it is 89 dB over the limit, add an input capacitor, and let Voltecx size and insert a damped LC filter. About 15 minutes. The estimate puts a LISN (50 µH, 0.1 µF and 50 Ω, as the standard says) on a copy of the circuit and reads peak, quasi-peak and average from the spectrum. It is a pre-compliance screen, not a test house's report. Pictures: a numbered red box is what you click or read, `[Run]` is a button, `Design › Automate` a menu path. ## 1. Open the buck Choose `File › Open Example › DC-DC › Buck converter, textbook`. ![The File menu open at Open Example, DC-DC, Buck converter, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/conducted-emi/01-open-example.png) 1. `File`. 2. `Open Example`. 3. `DC-DC`. 4. `Buck converter, textbook`. ## 2. Look at the input current Click `[▶ Run]`, then `Maximize` at the panel's top right. In the scope's signal list open `Currents` and tick `i(Vin)`. ![The scope: i(Vin) jumps between 0 and about -5 A every switching period, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/conducted-emi/02-input-current.png) 1. `i(Vin)`, the current in the source (negative because it leaves the source's + terminal). 2. Its row: it jumps from 0 to the inductor current, about 5 A, and back, 100 000 times a second. In steady state it swings 5.45 A peak to peak around a mean of 1.25 A. The buck has no input capacitor, so the supply carries all of it. ## 3. Open Conducted EMI Click `Restore` at the panel's top right, then choose `Design › Automate › Conducted EMI`. ![The Design menu open at Automate, Conducted EMI, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/conducted-emi/03-menu.png) 1. `Design`. 2. `Automate`. 3. `Conducted EMI`. ## 4. Set up the estimate Click `More options` to see every field. ![The Conducted EMI Estimate form, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/conducted-emi/04-form.png) 1. `Limit`: `CISPR 32 class B`, the residential limit. Class A is for industrial equipment. 2. `Filter`: `auto` sizes a damped LC input filter if the margin is short, inserts it on a copy and measures again. 3. `Target margin`: `6` dB below the limit. 4. `Apply result`: leave it off for now, so nothing changes in the circuit. 5. `[Run]`. ## 5. Read the estimate The window opens at the verdict. Scroll for the notes at the bottom. ![The result window: verdict, margin, required attenuation, the filter and the spectrum, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/conducted-emi/05-result.png) 1. `As drawn`, `Fail`: the worst margin is −89.4 dB at 200 kHz, measured as an average. That is the second harmonic of 100 kHz, the first one inside the 150 kHz to 30 MHz band: 143 dBµV against a 53.6 dBµV limit. 2. `Required attenuation`: 95.4 dB, how much the circuit would have to drop to pass. 3. `With the input filter`, `Pass`: the copy with the filter `auto` sized has 22.3 dB of margin. The filter has two stages, 660 µH and 504 nF each, listed under `Input filter` with its damping parts. 4. `[Apply Filter]` inserts those parts into the circuit as one undo step. Leave it for now. 5. The spectrum: peak, quasi-peak and average against the CISPR 32 quasi-peak and average limits, on a log frequency axis, first as drawn and below it with the filter. The average trace sits far above its dashed limit; with the filter it falls under it. `Copy` still puts the whole reply on the clipboard as JSON (`before.total.marginDb`, `filter`, `after.total.pass` and the rest), which is what a script reads. Two 660 µH chokes for a 60 W converter is a sign that something more basic is missing: there is no input capacitor. ## 6. Add an input capacitor Close the window and press `⌘⇧Y` to open the console. Type these two lines, each followed by `Enter`: ```text circuit.apply {"label":"Add input capacitor","ops":[{"op":"add","name":"Cin","kind":"capacitor","params":{"c":"47u","esr":"10m","v0":48},"ports":{"p":"in","n":"0"},"at":[-5,0]}]} circuit.rotate {"component":"Cin","turns":1} ``` ![The console with the two commands, and Cin next to Vin, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/conducted-emi/06-console.png) 1. `Console`: every menu item is a command, and the console runs any of them. 2. `Cin`: 47 µF with 10 mΩ of ESR, across the input. It now carries the pulses, and the supply sees the average. (You can also drag a capacitor from the parts bar and wire it.) ## 7. Estimate again, and apply the filter Choose `Design › Automate › Conducted EMI` again. The more options stay open. ![The form with Apply result ticked, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/conducted-emi/07-apply.png) 1. Tick `Apply result`: the filter is inserted into the circuit as one undo step. 2. `[Run]`. With `Cin` the emission falls to 86.8 dBµV, 33.2 dB over the limit. That is 56 dB better without a filter. A single damped stage of 220 µH and 515 nF is now enough, and the copy with it passes with 11.7 dB of margin. ## 8. Read the filter Close the window. Press `⌘0` to fit the schematic, then open the `Problems` tab. ![The inserted filter between Vin and the power stage, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/conducted-emi/08-filter.png) 1. `EMI_C1`: 515 nF across the supply side. 2. `EMI_L1`: 220 µH in series with the supply. 3. `EMI_Rd1`: 6.98 Ω, which damps the filter's resonance together with 4. `EMI_Cd1`: 18 µF. Without damping, the filter's output impedance would peak at resonance and could make the converter oscillate (Middlebrook's criterion; the reply checks it). The filter is drawn in line, between `Vin` and the power stage, with its damping branch below it. `Problems` shows no warning: `Vin` and `EMI_C1` form a loop with no resistance, but `EMI_C1` starts charged to 48 V, so no current rushes into it at t = 0. ## 9. Check the converter still works Click `[▶ Run]`. When the run ends, click `[Show results]` on its notice. ![The scope after the filter: i(Vin) is smooth, v(out) still 12 V, marked 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/conducted-emi/09-rerun.png) 1. `i(Vin)` now swings 48 mA peak to peak instead of 5.45 A, and `v(out)` still settles at 12 V. The ringing in the first 2 ms is the output LC of this open-loop buck, as it was in step 2. ## The same steps from a script ```sh powercraft-cli run \ --cmd file.openExample --params '{"name":"buckIdeal"}' \ --cmd emi.conducted --params '{}' \ --cmd circuit.apply --params '{"ops":[{"op":"add","name":"Cin","kind":"capacitor","params":{"c":"47u","esr":"10m","v0":48},"ports":{"p":"in","n":"0"},"at":[-5,0]}]}' \ --cmd emi.conducted --params '{"apply":true}' \ --cmd simulation.run --params '{}' \ --cmd emi.radiated --params '{}' ``` `emi.radiated` estimates the radiated emission from the switching loop, with the loop current of the last run; see [chapter 16 of the manual](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/16-automatic-design/). Back to the [learning path](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/). --- # Automatic design: from a spec to a checked converter URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/10-auto-design/ You type a spec, and `Design › Auto Design` picks a topology, draws it, sizes the parts, closes the loop, checks every corner by simulation and writes a report. Here the first run passes. You read what it did to get there, start it from another frequency and compare. About 15 minutes. Pictures: a numbered red box is what you click or read, `[Run]` is a button, `Design › Automate` a menu path. ## 1. Open Auto Design Start with no circuit open (a run replaces the open circuit, so save your work first). Choose `Design › Auto Design`. ![The Design menu open at Automate, Auto Design, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/auto-design/01-menu.png) 1. `Design`. 2. `Automate`. 3. `Auto Design`. ## 2. Type the spec A 12 V to 3.3 V point-of-load converter for up to 5 A, which must reach 95 % efficiency at full load. ![The Auto Design form with the spec filled in, marked 1 to 6](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/auto-design/02-spec.png) 1. `Input voltage`: minimum `10.8`, nominal `12`, maximum `13.2` V. 2. `Output voltage`: `3.3` V, with an `Output tolerance` of `3` %. 3. `Load current`: minimum `1`, maximum `5` A. 4. `Ripple, peak to peak`: `0.05` V. 5. `Efficiency point`: at least `95` % at a load of `5` A. 6. `[Design converter]`. A field you leave empty is not checked, and the report says so. `Save spec` keeps the spec in a JSON file, and `Load spec` reads it back; with no circuit open the form starts empty. The nominal input, the output voltage and the maximum load current are under **Required**, the other rows under **Targets**, and the temperature and loop-margin rows under **Limits** (closed until you open it). The run's own counts (tuning rounds, simulations, solver steps) are under **Run limits**. With a converter open, the form starts with its input voltage, output voltage and load current filled in, each marked *from circuit*; type over one to change it. A greyed number in an empty field is only a typical value, never sent. ## 3. Read the verdict The run takes a few seconds. These are its stages, each a command you can also run alone (manual, [chapter 16](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/16-automatic-design/)): `topology.suggest` → `circuit.template` → `design.converter` → `magnetics.design` (a catalogue inductor) → voltage loop → **verify** → tune → parts from the catalogue → **verify** → efficiency, thermal, stress, worst case → gate drive, sense network, protection, firmware → conducted EMI → layout checklist → bill of materials. A stage that fails stops the run there, and the window says which one. Here none does. ![The result: PASS, efficiency 97.6 % against 95 %, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/auto-design/03-result.png) 1. The headline names the converter and says all checks pass. All 14 gates ran, from verify to the bill of materials. The run started at 100 kHz, but its voltage-loop step moved the switch to 315 kHz (`PWM` in the report's values). 2. `Checks`: `Efficiency at 5 A and 12 V` is 97.64 % against the 95 % limit, `PASS`. Regulation (0.10 %), ripple (655 µV) and the dip after the load step and its release (5.78 % and 5.77 % against 10 %) pass too; the spec gives no load step, so the run assumes one from 2.5 A to 5 A. The recovery time (133 µs) is only shown, `INFO`, because the spec sets no limit for it. Above the checks, the cards give the efficiency, the ripple, the loop's phase margin and the hottest part, and `Parts` lists the parts the run picked. 3. `Design report`: `Open report` shows the full report in your browser (below); `Export report` saves it. `Not checked` lists what nobody checked, such as start-up and EMI here: a pass is only as wide as the spec. ## 4. Read the report `Design report › Open report` opens it in your browser, outside the app, so it has no picture here. It starts with the reason and the changes to try, then the spec, the topology ranking, the gates, the schematic, the values with their formulas, the stages and the open items. To get the files too (`.json`, `.md`, `.html`, `.svg`), give `Report path` under `More options`. The report's loss table shows where the power goes: of 0.40 W simulated, Q1 takes 0.20 W and Q2 0.16 W, and L1 only 0.03 W (0.018 W of copper and 0.008 W of core). Two remedies explain that. The voltage loop was redesigned over every tolerance corner, which raised the switching frequency from 100 kHz to 315 kHz and set C1 to 270 µF. And no catalogue inductor meets its ratings at 24 µH, so L1 is a custom design on an ETD 39/20/13 3C95 core, rewound for 24 µH: fewer turns on the same core give a lower winding resistance and a higher saturation current. Its numbers are in the circuit. One open item remains: the output mean had not settled at 4 of the worst case's 8 corners. Those corners are left out of the output mean's minimum and maximum; lengthen the end time in Simulation Settings to read them. ## 5. Look at the design Close the window and press `⌘0`. ![The designed synchronous buck: power stage, voltage loop and dead-time blocks, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/auto-design/04-schematic.png) 1. `Q1`, the high-side MOSFET, a real part (Infineon BSC0906NS); `Q2` below it is an Infineon BSC0902NS. 2. `L1`: 24 µH, the custom ETD 39/20/13 3C95 inductor. Its DCR, 0.72 mΩ, and its 10.5 A saturation current are in the circuit: 0.72 mΩ × (5 A)² is the 0.018 W of copper loss. 3. `PI`: the voltage loop, joined to the power stage by the net labels `vfb`, `g1` and `g2`. 4. `DT1` (and `DT2`): 18 ns of dead time for each gate, sized from what the gate driver and the switches' turn-off edge need (14.2 ns) plus 25 %, rounded up. ## 6. Start from another frequency The starting frequency is only a first guess: the loop step moves it. Open `Design › Auto Design` again. The form remembers the spec of the last run, so it is already filled in. Click `More options` and set the frequency. ![More options: Switching frequency 200e3, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/auto-design/05-fsw.png) 1. `Switching frequency`: `200e3` (200 kHz). 2. `[Design converter]`. ## 7. Compare the second run ![The result: PASS, efficiency 96.6 %, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/auto-design/06-pass.png) 1. The headline: all checks pass again, and every gate after verify ran. 2. `Efficiency at 5 A and 12 V`: 96.58 %, 1.58 % to spare. This start ends elsewhere: the switch at 500 kHz, L1 a custom 12 µH winding on the same core, C1 180 µF, a recovery of 82 µs instead of 133 µs, and the same open item, here at all 8 corners. The efficiency is lower than the first run's 97.64 %, because the switches lose more at the higher frequency. So the design that passes is not unique: read the values and the losses of each run, and pick on what your board needs. A pass is a starting point: read the open items before you order parts. ## 8. Choose analog control The design above ends in firmware. To build the loop from parts instead, add a `control` object to the spec in the form and `[Design converter]` again: ```json "control": { "implementation": "analogOpAmp" } ``` 1. `analogOpAmp`: the compensator becomes a network around an LM358B op-amp, here a Type III, with E96 resistors and E12 capacitors. `controllerIc` uses the error amplifier of a controller IC instead (the LM5145 for this buck). On a boost or a flyback `controllerIc` puts the UCx843 itself in the circuit in peak-current mode: it drives the switch, reads the sense resistor `Rcs` through a small RC filter, and above 50 % duty adds slope compensation (`Cramp`, `Rramp`) from its oscillator ramp. The report's Control section then lists the sense parts, the pulse-by-pulse current limit and each corner's margins. 2. The gates list `analogControl` in place of `digitalize` and `codegen`. Its row gives the network's gain and phase change at the crossover and the op-amp's gain-bandwidth, slew and swing checks. 3. On the schematic the PI is gone: the subsystem `XCOMP` takes the output and drives the PWM. Double-click it to see the divider, the op-amp and the network inside. ![Inside XCOMP, marked 1 to 6](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/auto-design/07-analog.png) 1. `Rtop`: the divider from the output (`Rbot` below it). 2. `Rz` and `Cz`, with `Cp` above them: the integrator and first zero of the Type III network. Its second zero is `Rff` and `Cff`, in series across `Rtop`. 3. `UEA`: the LM358B op-amp. 4. `Vea`: the reference. 5. `Vaux`: the 5 V supply of the op-amp. 6. The PWM modulator: the comparison with the `Valley` ramp, the ramp gain `Kramp` and the duty limit `Dlim`. The last verify row runs after `analogControl`, so the pass is the analog loop's. Its corners run on the switching circuit: the averaged model's step is too coarse for the op-amp. This spec passes at all six corners. When you ask the AI assistant for a design without saying how the loop is built, it asks you which of the three you want. ## 9. Export the BOM and the KiCad project A passing design goes to the board. Choose `File › Export › Bill of materials`: the form shows the price source and the preferences, and `[Run]` writes the list, one catalogue part per component with its data sheet. Then choose `File › Export › KiCad project` and give a folder: it writes a KiCad 8 schematic with those parts, net classes sized for each net's voltage and current, and a design-rules file. Open it in KiCad and draw the board. Both are also in `Design › Manufacturing`; once the board is routed, `Manufacturing Outputs` there makes the Gerbers and the assembly files. The lesson in `Help › Tutorials` ends with the same two steps. ## The same steps from a script ```sh SPEC='{"vin":{"min":10.8,"nom":12,"max":13.2},"vout":{"nom":3.3,"tolPct":3},"iout":{"min":1,"max":5},"ripple":{"maxPp":0.05},"efficiency":[{"iout":5,"minPct":95}]}' mkdir -p work powercraft-cli run --new '{}' --root work --cmd design.auto --params "{\"spec\":$SPEC,\"reportPath\":\"first\"}" powercraft-cli run --new '{}' --root work --cmd design.auto --params "{\"spec\":$SPEC,\"fsw\":200000,\"reportPath\":\"second\"}" --out work/pol.voltecx ``` The reply's `pass`, `verify.rows` and `finalValues` say the same as the window. `powercraft-cli run` exits 0 even when the design fails, so a script reads `pass`. Back to the [learning path](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/). --- # The Test Bench: run one case and see it against its limits URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/11-test-bench/ `spec.verify` checks every corner of a spec at once and answers with a table. The Test Bench runs the same checks one case at a time and keeps each run's waveforms, with the limits drawn on them. You run a load-step case on the closed-loop buck, watch it fail, fix the loop, run it again and lay the two runs over each other. About 15 minutes. Pictures: a numbered red box is what you click or read, `[Run]` is a button, `Simulation › Test Bench` a menu path. ## 1. Open the Test Bench Choose `File › Open Example › DC-DC › Buck converter, closed loop` (the circuit of [tutorial 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/02-closed-loop-buck/)), then open the `Simulation` menu. ![The Simulation menu with Test Bench marked, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/test-bench/01-menu.png) 1. `Simulation`. 2. `Test Bench`, then `Open Test Bench`. ## 2. List the cases Fill in the spec in the `Spec` section at the top, the same rows as the Auto Design form. `Use spec from Auto Design` fills it with the spec Auto Design would open with (here the circuit's 48 V, 12 V and 5 A). For this tutorial, paste the whole spec instead: `Paste JSON` (in the top row), paste the text below, `Apply`, then click `List Cases`: ```json {"vin":{"min":44,"nom":48,"max":52},"vout":{"nom":12,"tolPct":2},"iout":{"min":2.5,"max":5},"loadStep":{"from":2.5,"to":5,"maxDroopPct":5,"maxSettle":"2m"}} ``` 48 V (44 to 52 V) in, 12 V ±2 % out, 2.5 to 5 A, and a load step from 2.5 to 5 A that may pull the output down by at most 5 % and must recover within 2 ms. ![The cases: six corners and three load steps, none run yet, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/test-bench/02-cases.png) 1. The `Spec` section, filled from the pasted JSON (the same spec `spec.verify` and `design.auto` take). It closes once the cases are listed; click it to open it again. 2. `List Cases`. Listing simulates nothing. 3. A corner case: one input and one load, run until the output settles, checked against the regulation band. 4. A load-step case at 48 V: the load steps from 2.5 to 5 A after the first run and back to 2.5 A after the second, checked for the largest swing after each edge and the recovery time. The list also has `preBias`, a start-up into an output already charged to half its voltage. ## 3. Run the load step Click `Load step 2.5 A to 5 A, Vin 48 V`. It runs at once. ![The load-step case failed: the dip crosses the dashed limit, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/test-bench/03-fail.png) 1. `Fail`, `Test run tb1`. The plots show `v(out)` and `i(L1)`. The dashed horizontal line is the dip limit (11.4 V, 5 % under 12 V); the two dashed vertical lines are the recovery window, 2 ms from the step at 10 ms. 2. `Undershoot or overshoot after the load step`: 16.03 % against 5 %. The output falls to about 10 V and rings past 12 V; the note gives both in millivolts. The next row, `Overshoot or undershoot after the load release`, reads the load going back to 2.5 A. 3. `Recovery after the load step`: 5.588 ms against 2 ms, the slower of the two edges. The PI loop is too slow, as tutorial 2 found. ## 4. Fix the loop Close the window and choose `Design › Design Steps › Voltage Loop`. ![The Design page: Voltage Loop with Type III, Design again and Apply, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/test-bench/04-type3.png) 1. `Controller`: `Auto picked Type III.`, a Type III network crossing at 5.78 kHz with 60° of margin. 2. `[Design again]`. 3. `[Apply]` writes the network into the circuit. 4. `✔ Verified`. On the schematic, `PI` is now a transfer function block, `B(s)/A(s)`. ## 5. Open the stale case Choose `Simulation › Test Bench › Open Test Bench` again. The spec and the cases are still there. ![The case marked out of date: the circuit changed after its run, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/test-bench/05-stale.png) 1. `⟳` after the case title: the circuit changed after this run, so the result is out of date. 2. `[Run Case]` runs the selected case again. ## 6. Run again and compare Click `[Run Case]`, then pick `tb1 · loadStep-48V` in `Compare with:`. ![Run tb2 passes; tb1 drawn dashed on the same plots, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/test-bench/06-overlay.png) 1. `Pass`, `Test run tb2`. 2. `Compare with:`: `tb1`, the first run. 3. The overlay is drawn dashed: `v(out) (tb1)` rings and dips; the new `v(out)` barely moves at the step. 4. The table adds the overlay's values and the difference: the dip falls from 16.03 % to 4.62 %, and the recovery from 5.588 ms to 122 µs. `Difference` is in the limit's unit: −11.4 % for the dip and −5.47 ms for the recovery. The plots' y axes name their signal and unit, `v(out)` in V and `i(L1)` in A. `Run All Cases` runs every case in parallel, `Re-run Failed` only those that failed, `Export CSV` writes one row per limit of every case, and `Copy JSON` copies the cases and runs. ## The same steps from a script ```sh SPEC='{"vin":{"min":44,"nom":48,"max":52},"vout":{"nom":12,"tolPct":2},"iout":{"min":2.5,"max":5},"loadStep":{"from":2.5,"to":5,"maxDroopPct":5,"maxSettle":"2m"}}' powercraft-cli run \ --cmd file.openExample --params '{"name":"buckClosedLoop"}' \ --cmd testbench.run --params "{\"case\":\"loadStep-48V\",\"spec\":$SPEC}" \ --cmd design.voltageLoop --params '{"controller":"typeIII","apply":true}' \ --cmd testbench.run --params "{\"case\":\"loadStep-48V\",\"spec\":$SPEC}" \ --cmd testbench.compare --params '{"a":"tb1","b":"tb2"}' ``` Back to the [learning path](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/). --- # The AI assistant: proposals you accept or reject URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/12-assistant-mcp/ The assistant lives in the chat on the right of the schematic. It reads your circuit, runs simulations and proposes changes, and nothing changes until you accept. You meet the chat, let it tune a part to a target and accept the proposal, then talk to the same assistant from a terminal. About 15 minutes. **About the pictures.** They are taken offscreen, where no model is connected, so the chat says "The agent needs the desktop app". On your desktop with no API key it says "Add your API key in Preferences › Assistant" instead. Steps 2 to 4 need no key at all: Tune runs inside Voltecx and comes back as the same kind of proposal card the assistant makes. Pictures: a numbered red box is what you click or read, `[Send]` is a button, `Edit › Preferences` a menu path. ## 1. Find the chat Open `File › Open Example › DC-DC › Buck converter with thermal model` (the circuit of [tutorial 8](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/08-thermal-losses/)). The chat is the second tab of the right side bar, next to `PROPERTIES`. ![The chat: the hint, the model picker and Tune, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/assistant-mcp/01-panel.png) 1. The `ASSISTANT` tab. Each circuit keeps its own chat; `+` at the right starts a new one, and `⌘L` opens the tab with the keyboard in the input. 2. The status line. With a key it shows suggestions such as "Design a 48 V to 12 V, 10 A buck". 3. The model picker (Claude Opus 5.5, `claude-opus-5-5`, by default) and the effort picker (Auto effort). 4. `Tune`, which needs no key. To use the assistant itself, open `Edit › Preferences › Assistant`, paste an Anthropic API key and press `Save`. The key goes to your system's credential store, never into a file. Your messages and the circuit data the assistant asks for go to Anthropic's API, and only when you press `Send`. ## 2. Ask for a target Click `Tune` and fill in the form: make the mean of `v(out)` equal 10 V by changing the duty cycle. ![The Tune to spec form filled in, marked 1 to 6](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/assistant-mcp/02-tune.png) 1. Target signal: `v(out)`, statistic `mean`. 2. Comparison: `=`. 3. Value: `10`. 4. Vary: part `Duty`, parameter `value`, 5. between `0.1` and `0.5`. 6. `[Run]`. ## 3. Read the proposal ![The proposal card: met in 9 iterations, Duty 0.26 → 0.2175, and the ghost on the schematic, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/assistant-mcp/03-card.png) 1. `Tune to spec` (badge MET): after 9 iterations the card names each target with its signal, statistic and unit: `v(out) mean: 12.06 V → 10.02 V (= 10 V)`, with `Duty.value` from 0.26 to 0.2175. 2. The ghost: `Duty` gets an outline and a note on a plate, `Duty.value: 0.26 → 0.2175`, placed clear of the part names. A part the proposal would add is drawn at 40 % opacity where it would go. 3. `[Accept]` applies the whole proposal as one undo step. 4. `[Reject]` throws it away. The circuit has not changed yet. A message to the assistant ("make the output 10 V") ends the same way: tool rows for what it ran, then a card like this one. ## 4. Accept, and take it back if you like Click `[Accept]`. ![The card reads Applied; Duty is now 217.5m, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/assistant-mcp/04-accepted.png) 1. `APPLIED`: the card's badge says how the proposal ended. 2. `Undo` (`⌘Z`) takes the whole proposal back in one step. `Restore` under your message puts the circuit back as it was before that turn. 3. `Duty` now holds 0.2175 (shown as `217.5m`). **Answers you can see.** With a key, ask "Show me the inductor current ripple and point at the parts that set it." The reply carries a small plot of `i(L1)` over the window it measured, with its peak-to-peak in figures, and a crop of the schematic around `L1` and `C1`, which are outlined on the canvas. Point at a part name in the reply to mark it; click the plot to open the scope on that window. "Is the loop stable?" comes back with a Bode plot, "Where do the losses go?" with one bar per device, and "How does this buck work?" starts the animation with its operating modes. Chapter 12 of the manual lists them all. ## 5. The same assistant in a terminal The command-line tool has the same assistant, for a terminal or a script. It needs the same Anthropic API key, read from the environment: ```sh export ANTHROPIC_API_KEY=sk-ant-... mkdir -p work powercraft-cli chat --automation-read-root work --automation-write-root work powercraft-cli chat -p "Open the buck example, run it and tell me the output ripple." --automation-write-root work ``` The first line opens a chat; `/save buck.voltecx` keeps the circuit in `work`. The second answers one message and exits. `powercraft-cli doctor` checks the program, the folders and the key. Voltecx's assistant is this built-in chat: outside AI tools cannot drive Voltecx. The [manual, chapter 11](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/11-chat-and-mcp/) covers the terminal chat, and [chapter 12](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/12-agent-panel/) the panel. Back to the [learning path](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/). --- # Python scripting: the same sweep in the app and from Python URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/13-python/ The `powercraft` Python package drives the same engine as the window. Every command you can run from a menu you can run from Python, and waveforms come back as numpy arrays with every sample. You sweep the buck's switching frequency in the app first, then write the same sweep in a dozen lines of Python and plot it with matplotlib against the textbook formula. About 15 minutes. Pictures: a numbered red box is what you click or read, `[Run]` is a button, `Analysis › Parameter Sweep` a menu path. ## 1. Open the Parameter Sweep Choose `File › Open Example › DC-DC › Buck converter, textbook`, then open the `Analysis` menu. ![The Analysis menu with Parameter Sweep, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/python/01-sweep-menu.png) 1. `Analysis`. 2. `Parameter Sweep`. ## 2. Sweep the switching frequency The buck's circuit variables are `Vin`, `D` and `fsw`. Sweep `fsw` and measure the inductor's ripple. ![The Parameter Sweep form filled in, marked 1 to 6](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/python/02-sweep-form.png) 1. `Variable`: `fsw`. 2. `Values`: `25e3, 50e3, 100e3, 200e3`. They replace `Start`, `End` and `Points`. 3. `Signal`: `i(L1)`. 4. `Statistic`: `pp`, peak to peak. 5. `Window start`: `3m`, after the start-up. 6. `[Run]`. ## 3. Read the sweep ![The sweep: i(L1) ripple falls from 3.6 A at 25 kHz to 0.46 A at 200 kHz, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/python/03-sweep-result.png) 1. `4 runs, 0 failed`. The runs go in parallel. The plot names its axes: `fsw` with ticks such as `50kHz`, and `i(L1) pp` in A. 2. `Copy CSV` puts the rows on the clipboard. 3. `Show data` lists them: | fsw | i(L1) peak to peak | Vout (1 − D) / (L fsw) | |---|---|---| | 25 kHz | 3.62 A | 3.60 A | | 50 kHz | 1.81 A | 1.80 A | | 100 kHz | 0.91 A | 0.90 A | | 200 kHz | 0.46 A | 0.45 A | The ripple halves each time the frequency doubles, as the textbook says. ## 4. Install the Python package The package is a wheel for your platform, for Python 3.9 and later: ```sh pip install powercraft-*-cp39-abi3-macosx_11_0_arm64.whl # the file you were given pip install matplotlib # for the plot ``` From the source tree, `cargo xtask python --wheel --release` builds the wheel (it needs [maturin](https://www.maturin.rs)). ## 5. The same sweep in Python `docs/tutorials/python/ripple_sweep.py` opens the example, sets `fsw`, runs, and reads `i(L1)` as a numpy array after 3 ms: ```python import powercraft s = powercraft.Session() s.execute("file.openExample", {"name": "buckIdeal"}) for f in [25e3, 50e3, 100e3, 200e3]: s.execute("circuit.variables", {"set": {"fsw": f}}) s.run() i_l = s.waveforms(["i(L1)"], t0=3e-3)["i(L1)"] print(f"{f / 1e3:6.0f} kHz {i_l.max() - i_l.min():.3f} A") ``` - `Session.execute(command, params)` runs any engine command by its id (the manual names them), and returns its reply as dicts and lists. - `Session.run()` is `simulation.run`. - `Session.waveforms(signals, t0, t1)` returns `"time"` and one array per signal, every sample. Run the whole script; it prints the table and writes the plot: ```sh python docs/tutorials/python/ripple_sweep.py ripple-sweep.png ``` ```text 25 kHz 3.617 A (textbook 3.600 A) 50 kHz 1.811 A (textbook 1.800 A) 100 kHz 0.911 A (textbook 0.900 A) 200 kHz 0.462 A (textbook 0.450 A) ``` ## 6. The plot The script writes two matplotlib plots to `ripple-sweep.png`, outside the app, so this page shows no picture of them. Left, the inductor current at 25 kHz over the last 0.2 ms: a triangle 3.6 A high around the 5 A load. Right, on log axes, the four simulated points on the textbook line Vout (1 − D) / (L fsw). The same numbers as the app's sweep in step 3, because it is the same engine. `Session.sweep(part, key, values, measure)` does the loop for a part's parameter and undoes its changes afterwards, `Session.dataframe()` gives a pandas DataFrame, and `apps/powercraft-python/examples/design_simulate_plot.ipynb` is a Jupyter notebook. See the [manual, chapter 17](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/17-python/). Back to the [learning path](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/). --- # Power factor correction: a boost PFC from the mains URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/14-pfc/ A diode bridge with a capacitor behind it draws current only at the voltage peaks, so its power factor is poor. A power factor corrector puts a boost converter between the bridge and the capacitor and makes the line current follow the line voltage. You open a boost PFC, read its two control loops, compare the line current with the line voltage, measure the power factor and the distortion of the current, load it with a step, and let Auto Design size the same converter and its loops. About 20 minutes. Pictures: a numbered red box is what you click or read, `[▶ Run]` is a button, `File › Open Example` a menu path, `⌘⇧Y` a key (`⌘` is Cmd on a Mac, Ctrl elsewhere). ## 1. Open the example Choose `File › Open Example › Power quality › Boost PFC`. ![The File menu open at Open Example, Power quality, Boost PFC, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/pfc/01-open-example.png) 1. `File`. 2. `Open Example`. 3. `Power quality`. 4. `Boost PFC`. ## 2. Read the power stage The 230 V, 50 Hz mains feeds a diode bridge. Behind it a boost converter charges a 470 µF capacitor to 400 V, and a 160 Ω load takes 1 kW. ![The power stage: mains source, diode bridge, boost inductor, switch, boost diode, capacitor and load, marked 1 to 7](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/pfc/02-power.png) 1. `Vs`: the mains, 325 V peak (230 V rms) at 50 Hz. It floats: the DC negative rail is the ground. 2. `D1`: one of the four bridge diodes `D1` to `D4`, which turn the sine into a rectified sine. 3. `L1`: the 3 mH boost inductor. It carries the rectified current and a 20 kHz ripple. 4. `S1`: the MOSFET. Its duty decides how much current the inductor draws. 5. `D5`: the boost diode, which passes the inductor current to the capacitor when `S1` is off. 6. `C1`: 470 µF at 400 V. It holds a ripple of twice the line frequency (100 Hz), because the power from a sine is not constant. 7. `R1`: the 160 Ω load, 1 kW at 400 V. The voltmeter beside it gives the signal `vdc`. Two meters in the bridge give the signals this tutorial uses: the ammeter `AmAc` gives the line current `iac`, and the voltmeter `VMac` gives the line voltage `vac`. ## 3. Read the two loops The control sits above the power stage and meets it only through net labels (`vac`, `il`, `vdc`, `g`). ![The control: voltage loop, multiplier, current loop, feed-forward duty and PWM, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/pfc/03-control.png) 1. `PIv`: the slow voltage loop. It compares `vdc` with 400 V and gives `ipk`, the peak of the line current the converter must draw. Its output is limited to 0 to 15 A. 2. `Mul`: multiplies `ipk` by the shape of the rectified line voltage, `|vac|/Vpk`. The result `iref` is a rectified sine, so the current has the shape of the voltage. 3. `PIi`: the fast current loop. It compares `iref` with the inductor current `il`. 4. `Dff`: the feed-forward duty `1 − |vac|/Vref`. It is the duty a boost needs for its input voltage, so the current loop only corrects it. 5. `PWM`: turns the duty into the gate signal `g` at 20 kHz. The voltage loop crosses over near 10 Hz, well below the 100 Hz ripple on `vdc`, so the ripple hardly moves `ipk` and the current stays a clean sine. The gains in this example (`PIv`: 0.07 A/V and 1.5 A/(V·s); `PIi`: 0.06 and 120) are illustrative; step 9 shows designed ones. ## 4. Run it and compare the current with the voltage Click `[▶ Run]`, then `Open in Separate Window` at the top right of the scope, so the scope has a window of its own (the next steps use it). The window folds its signal list to a strip on the left edge: click `Show signals` there, then open `Voltages` and tick `vac`. A meter's signal is drawn by what it measures, so `vac` (volts) and `iac` (amperes) each get an axis of their own: on one shared axis, 7 A would be a flat line under 325 V. ![The scope: vac on top, iac below, both sine waves in phase, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/pfc/04-run.png) 1. `vac`: the line voltage, 325 V peak, 230 V rms. 2. `iac`: the line current. It is a sine in phase with `vac`, 6.8 A at its peak, with the 20 kHz ripple of the inductor on top. A plain bridge and capacitor would give narrow pulses at the voltage peaks instead. The first 0.1 s or so is the start-up: the DC link rises to 400 V (`vdc` has its own trace; tick it to see it) and the current follows the voltage loop's demand. Judge the current only after that. ## 5. Choose a window of whole cycles The table measures what the plot shows, start-up included. The scope folds the table away while the plots would get less than half its width, so click `Measurements` in the toolbar to show it. Click `Cursors` (`Shift+C`) and drag the two lines to 160 ms and 240 ms: four whole line cycles after the start-up. ![The scope with two cursors; the table heading now says cursors 160 ms to 240 ms, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/pfc/05-window.png) 1. `Cursors`: shows two vertical lines and the values of every signal at each. 2. The table's heading now reads `cursors 160ms – 240ms`. Every figure below, including the power rows, is taken over that window. ## 6. Read the distortion of the line current Click `Measurements to show` and tick `THD`. ![The measurement picker with THD ticked, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/pfc/06-thd.png) 1. `Measurements to show`: the columns of the table, in groups (basic, AC, transient, power). 2. `THD`: the total harmonic distortion of each signal, from its spectrum up to the 50th harmonic, as a share of the fundamental. ## 7. Read the power factor Press `Esc` to close the picker. On the scope panel's `Power` tab, choose `vac` in the first list and `i(AmAc)` in the second (the ammeter's own current, the same as `iac`), then click `[Add power]` (the line reads `Power from [vac] × [i(AmAc)] [Add power]`). ![The Power tab with a power row for vac and i(AmAc), marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/pfc/07-power.png) 1. The power row of `vac` and `i(AmAc)`. The `THD` column is on the `Summary` and `Signals` tabs: 6.13 % for `iac`, so the harmonics add up to 6 % of the 50 Hz current, and 0.00 % for `vac`, as the source is a pure sine. 2. `PF` of the pair: 0.994, from `P` = 1.007 kW and `S` = 1.013 kVA. A plain bridge with a capacitor typically gives 0.5 to 0.7. The distortion alone would cost 0.2 % (1/√(1 + 0.0613²) = 0.998); the rest is a phase shift of about 5° between the current and the voltage. The lists offer `vac` because it is the output of a voltmeter: a signal that is not named `v(…)` is offered after the ones that are. ## 8. Load it with a step Press `⌘⇧Y` to open the console (first click `Dock Back` on the scope). Type these two lines, each followed by `Enter`: ```text simulation.tune {"component":"R1","key":"r","value":80} simulation.continue {"duration":0.25} ``` ![The console with the two commands, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/pfc/08-tune.png) 1. `Console`: every menu item is a command, and the console runs any of them. 2. `simulation.tune` halves the load resistor from 160 Ω to 80 Ω at the end of the run, 0.25 s, with every capacitor voltage and inductor current kept. 3. `simulation.continue` runs another 0.25 s from there. Click the `Scope` tab and `Open in Separate Window`. ![The scope after the step: vdc falls and recovers, iac doubles, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/pfc/09-load-step.png) 1. `vdc`: the load doubles from 1 kW to 2 kW at 0.25 s and the DC link falls from 400 V to 343 V, 57 V lower, within 22 ms. The 10 Hz voltage loop is slow, so the capacitor supplies the difference until `ipk` has grown. The link is back near 396 V at 0.5 s. 2. `iac`: the peak line current rises from 6.8 A to 12.9 A. Over 0.4 s to 0.5 s the converter takes 1.98 kW at a power factor of 0.996 and a THD of 6.2 %: the correction holds at twice the load. A faster voltage loop would shrink the dip, but it would also let the 100 Hz ripple into `ipk` and distort the current. That trade-off is why the voltage loop is slow. ## 9. Design the two loops, then let Auto Design size the converter `Design › Design Steps › Current Loop` and `Design › Design Steps › Voltage Loop` recognise this circuit as a boost PFC and design its two PI blocks in place. Design the current loop first: the voltage loop sits on top of it. 1. `Design › Design Steps › Current Loop`: the plant is `Vout/(s·L)` (400 V across the 3 mH `L1`) behind half a switching period of delay. The crossover is a tenth of the 20 kHz switching frequency, 2 kHz, with the PI zero at a quarter of it. `PIi` gets `Kp` 0.0914 and `Ki` 287 (the example has 0.06 and 120), with 58° of phase margin. The feed-forward duty `Dff` stays as it is. 2. `Design › Design Steps › Voltage Loop`: the plant runs from the peak current `ipk` to the DC link, from the power balance. The crossover is a tenth of the 100 Hz ripple, 10 Hz, again with the zero at a quarter of it. `PIv` gets `Kp` 0.0765 A/V and `Ki` 1.20 (the example has 0.07 and 1.5), with 99° of phase margin at full load and 79° at a tenth of it. The reply also gives `h3`, the third harmonic the 100 Hz ripple puts into the line current through the loop: 5.3 %. In each panel press `Run` to see the design, then `Apply`: it writes the gains in one undo step and verifies them by simulating the circuit over whole line cycles. With both loops applied the check reads a power factor of 0.997, a THD of 5.8 %, the DC link within 0.05 % of 400 V with 16.9 V of 100 Hz ripple, and, after a 50 % load step, a dip of 5.6 % that settles with no overshoot. The panels tune the loops of the circuit you have; they do not choose `L1` or `C1`. For that, Auto Design takes a mains spec. Its form has only DC input rows, so give the spec on the console (`⌘⇧Y`). A run replaces the open circuit, so save your work first. ```text design.auto {"spec":{"vinAc":{"min":184,"nom":230,"max":264},"fline":50,"vout":400,"pout":1000,"pf":0.98,"thd":10},"fsw":"20k"} ``` ![The Auto Design result for the mains spec: PASS, power factor 0.999, THD 3.606 %, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/pfc/10-auto.png) 1. `Verdict`: PASS. All five checked rows pass. 2. `Power factor`: 0.999 against at least 0.98, and `Input current THD`: 3.606 % against at most 10 %. Below it the DC link holds 400 V within 0.109 %, its 100 Hz ripple is 14.6 V against 20 V, and it stays above 300 V for 18 ms after the mains is cut (10 ms asked). The reply holds the design: `L1` 2.81 mH and `C1` 560 µF (the ripple needs 398 µF and the hold-up 322 µF; the larger, divided by 0.8 for a 20 % tolerance, is rounded up to the E12 value 560 µF). The current loop, `Kp` 0.0429 and `Ki` 67.3, crosses at 1 kHz (a twentieth of the switching frequency, so the delay of a firmware loop leaves 46° of phase margin). The voltage loop, `Kp` 15.3 W/V and `Ki` 240, crosses at 10 Hz with 77° of margin. Every value comes with its formula in the report. Compare with step 3: the example's hand-set loops give 0.994 and 6.1 %, the designed ones 0.999 and 3.6 %. Two more things the same call can do. Add `"harmonics":"classA"` to the spec and the verification also checks each harmonic of the line current against its IEC 61000-3-2 limit (a `harmonics` row in percent of the limit). Add `"topology":"totemPolePfc"` beside `spec` and the run draws the bridgeless totem-pole instead of the diode bridge, with the same inductor, capacitor and loops (chapter 16 of the manual explains both). Either way the circuit comes back grouped: the power stage and the controller as blocks joined by labels. ```text design.auto {"spec":{"vinAc":{"min":184,"nom":230,"max":264},"fline":50,"vout":400,"pout":1000,"pf":0.98,"thd":10,"harmonics":"classA"},"fsw":"20k","topology":"totemPolePfc"} ``` ## The same steps from a script ```sh powercraft-cli run \ --cmd file.openExample --params '{"name":"pfcBoost"}' \ --cmd simulation.run --params '{}' \ --cmd scope.measure --params '{"signals":["iac"],"t0":"0.16","t1":"0.24","thd":{"fundamental":50},"power":{"v":"vac","i":"iac"}}' \ --cmd simulation.tune --params '{"component":"R1","key":"r","value":80}' \ --cmd simulation.continue --params '{"duration":0.25}' \ --cmd scope.measure --params '{"signals":["vdc","iac"],"t0":"0.25","t1":"0.5"}' ``` The first `scope.measure` gives `power.powerFactor` 0.994 and `thd.iac.thdPercent` about 6.1; the second gives the 343 V minimum of `vdc` and the 12.9 A peak of `iac`. Back to the [learning path](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/). --- # LLC resonant converter: design the tank and check the gain URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/15-llc/ An LLC converter drives a resonant tank (a capacitor and an inductor in series, with the transformer's magnetising inductance in parallel) from a half bridge. Near the tank's resonant frequency the gain hardly depends on the load, and the switches turn on at zero voltage. You open an LLC half bridge, read its resonant current and output, let `Design › Design Steps › LLC Tank` size the tank for an input range, read its gain curve, check the zero-voltage switching, and then step the input voltage and the load. About 25 minutes. Pictures: a numbered red box is what you click or read, `[▶ Run]` is a button, `File › Open Example` a menu path, `⌘⇧Y` a key (`⌘` is Cmd on a Mac, Ctrl elsewhere). ## 1. Open the example Choose `File › Open Example › Isolated › LLC resonant half bridge`. ![The File menu open at Open Example, Isolated, LLC resonant half bridge, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/llc/01-open-example.png) 1. `File`. 2. `Open Example`. 3. `Isolated`. 4. `LLC resonant half bridge`. ## 2. Read the power stage A 400 V source feeds a half bridge. Its switch node drives a resonant capacitor, a resonant inductor and a 4:1 transformer. A diode bridge and a capacitor turn the transformer's output into DC for a 5 Ω load. ![The power stage: source, two switches, ammeter, resonant capacitor and inductor, transformer, diode bridge, output capacitor and load, marked 1 to 9](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/llc/02-power.png) 1. `Vin`: 400 V DC. 2. `Q1`: the upper switch of the half bridge; `Q2` below it is the lower one. They conduct in turn, so the switch node is a square wave between 0 V and 400 V. 3. `AmR`: an ammeter in the resonant branch. Its output is the signal `ir`, the resonant current. 4. `Cr`: the resonant capacitor, 63.3 nF. 5. `Lr`: the resonant inductor, 40 µH. With `Cr` it resonates at 1/(2π√(`Lr`·`Cr`)) = 100 kHz, and √(`Lr`/`Cr`) = 25 Ω is the tank's characteristic impedance. 6. `T1`: the transformer. Its turns ratio is 4:1 and its magnetising inductance `Lm` is 200 µH, five times `Lr`. That is the second inductor of the name LLC. 7. `D1`: one of the four rectifier diodes `D1` to `D4`. 8. `Co`: the output capacitor, 100 µF. 9. `R1`: the 5 Ω load, about 470 W. ## 3. Read the gate drive The gate signals are made above the power stage and reach it through the net labels `g1` and `g2`. ![The gate drive: constant duty, PWM, inverter and two dead-time blocks, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/llc/03-control.png) 1. `PWM`: a carrier at 100 kHz (the circuit variable `fr`) against a constant duty of 0.5. It is the only place the switching frequency is set. 2. `Inv`: the complement of the PWM signal, for the lower switch. 3. `DT2`: delays the rising edge of the lower switch's signal by 200 ns. 4. `DT1`: the same for the upper switch. While both are off, the resonant current moves the switch node from one rail to the other. ## 4. Run it Click `[▶ Run]`, then `Open in Separate Window` at the top right of the scope, so the scope has a window of its own (the next steps use it). The window folds its signal list to a strip on the left edge: click `Show signals` there, then open `Voltages` and tick `v(out)`. A meter's signal is drawn by what it measures, so `v(out)` (volts) and `ir` (amperes) each get an axis of their own. ![The scope: v(out) above, ir below, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/llc/04-run.png) 1. `v(out)`: the output voltage. It rings for most of the first millisecond as the circuit settles and then holds near 48 V. 2. `ir`: the resonant current. It is close to a sine at 100 kHz, which is why the first-harmonic model of the tank works. ## 5. Measure whole cycles Click `Cursors` (`Shift+C`) and place the two lines at 1.5 ms and 1.9 ms, after the ringing. ![The scope with two cursors; the table heading now says cursors 1.5ms to 1.9ms, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/llc/05-window.png) 1. `Cursors`: shows two vertical lines and the values at each. 2. The table's heading now reads `cursors 1.5ms – 1.9ms`. `v(out)` has a mean of 48.25 V with 114 mV peak to peak, and `ir` peaks at 4.52 A with an RMS of 3.19 A (a sine has an RMS of its peak divided by √2). At the resonant frequency the gain is one, so the output is `Vin`/(2·4) = 50 V less two diode drops, 48.6 V; the run gives 48.25 V. ## 6. Open Design › LLC Tank The example's tank was chosen by hand. The task `Design › Design Steps › LLC Tank` designs it from a spec. First click `Dock Back` on the scope to put it back in the dock. ![The Design menu with LLC Tank, marked 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/llc/06-design-menu.png) 1. `LLC Tank`: opens the Design panel on this task. ## 7. Give the spec Fill in the five fields. An empty field uses the circuit's value or a default; `you` at the right of a field says you typed it. The nominal input, where the gain is one, is the 400 V of the circuit's source. ![The LLC Tank form: lowest input 360 V, highest input 420 V, output 48 V, 480 W, resonant frequency 100 kHz, marked 1 to 6](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/llc/07-panel.png) 1. `Lowest input`: 360 V. The gain has to rise to 400/360 = 1.11 there. 2. `Highest input`: 420 V. The gain has to fall to 400/420 = 0.95 there. 3. `Output voltage`: 48 V. 4. `Output power`: 480 W. 5. `Resonant frequency`: 100k, that is 100 kHz. 6. `Run`: computes the design and changes nothing. `Apply` writes it into the circuit. `Advanced` holds the rest: the ratio `Lm`/`Lr` (5 by default), the quality factor (by default the largest whose peak gain is 10 % above what the low input needs), the lightest load (10 %), the rectifier drop, the switch capacitance and the dead time. ## 8. Read the tank and its gain curve Click `[Run]`, then collapse the bottom panel (`↓` at its top right) to give the page the window. ![The result: the four tank values and the gain against frequency at full and lightest load, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/llc/08-result.png) 1. Turns ratio `Np/Ns`: 4.032. For a gain of one at 400 V, half of 400 V (the half bridge's square wave) divided by the 48 V output plus 1.6 V of diode drops. 2. `Resonant inductor`: 50.51 µH. 3. `Resonant capacitor`: 50.15 nF. 4. `Magnetising inductance`: 252.5 µH, five times `Lr`. 5. `full load`: the gain against switching frequency at 480 W. It peaks at 1.22 near 55 kHz and is 1 at 100 kHz. `Mmax` (1.11) and `Mmin` (0.95) are the gains the input range asks for. The `lightest load` curve (10 % of the power) peaks much higher; the plot cuts it off at twice the full-load peak so the working range stays readable. It falls to `Mmin` at 115 kHz. ## 9. Read the numbers Click `Changes to apply` to fold it, then `Numbers`. ![The numbers: peak frequency 54.88 kHz, fmin 76.99 kHz, fmax 115.4 kHz, magnetising current 1.715 A, swing time 97.95 ns, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/llc/09-numbers.png) 1. `fPeak`: 54.88 kHz, the frequency of the full-load peak. Below it the tank is capacitive and the switches lose zero-voltage switching, so this is the lowest the converter may run. 2. `fmin`: 76.99 kHz, where the full-load curve reaches `Mmax`. It is the lowest frequency the 360 V input needs. 3. `fmax`: 115.4 kHz, where the lightest-load curve falls to `Mmin`. The converter works between `fmin` and `fmax`. 4. `imPeak`: 1.715 A, the peak magnetising current at the switch's turn-off. It is the current that moves the switch node. 5. `tSwing`: 97.95 ns. The node has to move 2·`Coss`·`Vin,max` = 2 · 200 pF · 420 V = 168 nC, and 168 nC at 1.715 A takes 97.95 ns. The dead time is 200 ns, so the node arrives before the switch turns on. `Rac` is the load seen from the tank (65.37 Ω), `Q` the quality factor 0.485 and `Cf` the output capacitor (47.74 µF, sized for the ripple at `fmin`, where the output pulses are longest). The list under `Changes to apply` is what `Apply` will write: the turns ratio `Nt` 4 → 4.032, `T1.lm` 200 µH → 252.5 µH, `Lres` 40 µH → 50.51 µH, `Cres` 63.3 nF → 50.15 nF, the load `R1.r` 5 Ω → 4.8 Ω (480 W at 48 V), `Co.c` 100 µF → 47.74 µF. ## 10. Apply and read the verification Click `Apply`, then fold `Numbers` and `Changes made`. ![The verification: peak gain 1.222, swing time 97.95 ns, simulated output 47.899 V, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/llc/10-apply.png) 1. `Apply`: writes every change in one step, so `⌘Z` takes the design back out. It also sets the run's end time to 1.83 ms. 2. `All targets met`: all three checks pass. 3. `Full-load peak gain`: 1.222, against 1.111 asked for at the lowest input. 4. `Leg swing time at turn-off`: 97.95 ns, against the 200 ns dead time. 5. The third check runs the circuit with the new tank at the nominal input: the mean output is 47.899 V, 0.21 % from 48 V (3 % is allowed). The badge `out of date` over the panel says the scope still shows the run of the old circuit. ## 11. Run it again and look at one cycle Close the Design page with the `×` on its tab, open the bottom panel again, then click `[▶ Run]`. When the run ends, click `Open in Separate Window` on the scope. Tick `v(sw)` in the scope, `ir` keeps its own axis; choose `Scope > Zoom Axis > Time Only` and then click `Zoom In` six times. ![Three cycles: v(sw) is a square wave from 0 to 400 V, ir a sine wave of 4.4 A peak, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/llc/11-resonant-current.png) 1. The `Scope` menu, where `Zoom X Only` is: the zoom changes the time axis and leaves the voltage and current axes alone. 2. `Zoom In`: halves the time window about its middle. Six clicks leave about 30 µs, three cycles of 10 µs. 3. `v(sw)`: the switch node, 0 V while `Q2` conducts and 400 V while `Q1` does, with the 200 ns dead time between. 4. `ir`: the resonant current, a sine with a peak of 4.36 A. Its two parts: the load current's part peaks at π·`Io`/(2·`n`) = π · 10 A/(2 · 4.032) = 3.9 A, and the magnetising current at 1.7 A, a quarter of a period apart. They add as √(3.9² + 1.7²) = 4.3 A. Over 1.4 ms to the end, `v(out)` has a mean of 47.9 V, as the design asked. ## 12. Ask for the zero-voltage check over a frequency range Click `Dock Back` on the scope, then `Analysis › Soft Switching`. Type `fr` as the sweep's variable and the values in the `Values` field. ![The Soft Switching form with the sweep over fr, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/llc/12-zvs-form.png) 1. `Variable`: the circuit variable to sweep. Here it is `fr`, the PWM's frequency. 2. `Values`: the values to try, 40k, 50k, 55k, 60k, 77k, 100k and 115k. 3. `Run`: runs a copy of the circuit once per value and classifies every turn-on of every switch. ## 13. Read the result ![The sweep: zero-voltage switching is lost at 55 kHz and below, and kept from 60 kHz up, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/llc/13-zvs-sweep.png) 1. `All zero voltage`: whether every switch turned on at zero voltage. It does not at 40, 50 and 55 kHz and does from 60 kHz up. 2. `60k`: the first row with `Yes`. The result line says the same: both switches gain zero-voltage switching between 55 and 60 kHz. The tank design said 54.88 kHz for the peak (`fPeak`), so the first-harmonic model and the simulation agree within the 5 kHz of this scan. Everything in the working range, 77 to 115 kHz, is zero-voltage. The switches in this circuit have no output capacitance, so the check reads the voltage across the switch at its turn-on edge: about −0.07 V, the body diode conducting, which happens when the current has reversed during the dead time. Whether the dead time is long enough for a real switch is the swing time of step 9. ## 14. Step the input voltage Close the result window and press `⌘⇧Y` to open the console. Type these two lines, each followed by `Enter`: ```text simulation.tune {"component":"Vin","key":"v","value":360} simulation.continue {"duration":0.002} ``` ![The console with the two commands, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/llc/14-input-step.png) 1. `Console`: every menu item is a command, and the console runs any of them. 2. `simulation.tune` changes the source to its lowest input, 360 V, at the end of the run, with every capacitor voltage and inductor current kept. 3. `simulation.continue` runs another 2 ms from there. Click the `Scope` tab and `Open in Separate Window`. ![The scope after the step: v(out) falls from 47.9 V to 43.0 V, ir falls from 4.35 A to 3.9 A, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/llc/15-step-scope.png) 1. `v(out)`: the output follows the input down by the same 10 %, from 47.9 V to 43.0 V. The switching frequency is still 100 kHz, where the gain is one for any load, so nothing opposes the change. The 48 V has to be brought back by a lower frequency. 2. `ir`: the resonant current falls from 4.35 A to 3.9 A because the load current falls with the output. ## 15. Lower the frequency to hold the output Click `Dock Back` on the scope, press `⌘⇧Y` and type: ```text circuit.variables {"set":{"Vin":"360","fr":"83k"}} ``` ![The console with the command, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/llc/16-lower-frequency.png) 1. `Console`: the same console. 2. `circuit.variables`: sets the circuit variables `Vin` (the source) and `fr` (the PWM frequency). This edits the circuit; undo it to get the 400 V and 100 kHz back. Then type `simulation.run`. When the run ends, click `[Show results]` on its notice and `Open in Separate Window` on the scope, tick `v(out)` under `Voltages`, click `Zoom to Fit` and `Zoom In` three times (only the time axis zooms, as in step 11), so that about twenty cycles fill the plots. ![The output at 360 V and 83 kHz: v(out) at 47.9 V, ir peaking at 5 A, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/llc/17-regulated.png) 1. `v(out)`: 47.94 V from 360 V in, the 48 V the design asked for. The first-harmonic model of step 9 asked for 77 kHz (`fmin`); the simulated circuit reaches 48 V at 83 kHz. 2. `ir`: the peak is 5.0 A, against 4.35 A at 400 V and 100 kHz. Below resonance the magnetising current grows, and the tank carries more current for the same power. ## 16. Take the load down to a tenth Type these two lines, or run them as the picture's script does: ```text simulation.tune {"component":"R1","key":"r","value":48} simulation.continue {"duration":0.0015} ``` ![The scope after the load drops to a tenth: v(out) jumps and settles at 48.7 V, ir falls from 5 A to 2.3 A, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/llc/18-light-load.png) 1. `v(out)`: the output jumps to 52.9 V, falls back within 0.2 ms and settles at 48.74 V, 0.8 V (1.7 %) above its full-load value. At a tenth of the load, the frequency stays where it was and the output hardly moves: this is the property the LLC is chosen for. The lightest-load curve of step 8 shows how far the frequency would have to rise to bring it back to exactly 48 V. 2. `ir`: the peak falls from 5.0 A to 2.3 A and no further. The rest is the magnetising current, which does not depend on the load. It is why the light-load efficiency of an LLC is limited. ## The same steps from a script ```sh powercraft-cli run \ --cmd file.openExample --params '{"name":"llcHalfBridge"}' \ --cmd design.llc --params '{"vin":400,"vinMin":360,"vinMax":420,"vout":48,"pout":480,"fr":"100k","apply":true}' \ --cmd simulation.run --params '{}' \ --cmd scope.measure --params '{"signals":["v(out)","ir"],"t0":"1.4m"}' \ --cmd analysis.softSwitching --params '{"sweep":{"variable":"fr","values":[40000,50000,55000,60000,77000,100000,115000]}}' ``` `scope.measure` gives a mean of 47.9 V for `v(out)` and a peak of 4.35 A for `ir`. The sweep's `boundary` says where zero-voltage switching starts: between 55 000 and 60 000 Hz. Back to the [learning path](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/). --- # Grid-tie inverter: lock to the grid and control the current URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/16-grid-tie/ A grid-tie inverter feeds power into the mains. It must follow the grid's phase, push a current that is a clean sine in step with the voltage, and keep doing so when the power asked for changes or the grid voltage sags. You open the single-phase `gridTieInverter` example, read its phase-locked loop (PLL) and current controller, and measure the current against the voltage. Then Auto Design draws a three-phase grid-tie inverter with a dq current loop, and you read its loop, jump the grid's phase, step the active and the reactive power, and sag the grid. About 30 minutes. Pictures: a numbered red box is what you click or read, `[▶ Run]` is a button, `File › Open Example` a menu path, `⌘⇧Y` a key (`⌘` is Cmd on a Mac, Ctrl elsewhere). ## 1. Open the example Choose `File › Open Example › Grid › Grid-tie inverter`. ![The File menu open at Open Example, Grid, Grid-tie inverter, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/grid-tie/01-open-example.png) 1. `File`. 2. `Open Example`. 3. `Grid`. 4. `Grid-tie inverter`. ## 2. Read the power stage A 400 V DC source feeds a full bridge. An LCL filter (an inductor, a capacitor with a damping resistor, and a second inductor) joins the bridge to a 230 V, 50 Hz grid. The nets `oa` and `ob` (the bridge outputs) and the gate signals are drawn as labels, so the picture shows the stage without long wires. ![The power stage: DC source, two legs of two MOSFETs, LCL filter, ammeter, grid source and voltmeter, marked 1 to 7](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/grid-tie/02-power.png) 1. `Vdc`: the 400 V link. 2. `Qah`: the upper switch of the first leg; `Qal` below it, and `Qbh` and `Qbl` in the second leg. Both legs share one carrier and take mirrored duties, so the output has three levels and the ripple is at 40 kHz. 3. `L1`: 2 mH on the bridge side. 4. `Rd`: a 4 Ω damping resistor in series with the filter capacitor. 5. `Cf`: 5 µF. With `L1` and `L2` it resonates at 2.8 kHz; `Rd` damps that peak. 6. `L2`: 1 mH on the grid side. It keeps the 20 kHz and 40 kHz ripple out of the grid current. 7. `Vg`: the grid, 325 V peak (230 V rms) at 50 Hz. The ammeter `AmG` beside `L2` gives the grid current `ig`, and the voltmeter `VMg` gives the grid voltage `vg`. ## 3. Read the control The control sits below the power stage and meets it through the labels `vg`, `ig` and the gate signals. ![The control: PLL, current reference, proportional-resonant controller, grid feed-forward and the two duty calculations, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/grid-tie/03-control.png) 1. `PLL`: measures the angle of the grid from `vg` and gives `th`. 2. `Ref`: turns `th` and the two constants `Id` (0) and `Iq` (−10 A) into the reference `iref` = 10 A · sin θ, a sine that is in phase with the grid because it uses the grid's own angle. 3. `PR`: the current controller. A plain PI cannot follow a sine without error, so this is a proportional-resonant controller: `Kp` 10 V/A, plus a resonance at 50 Hz with a gain of 1000 V/A. At 50 Hz the loop gain is so high that the current ends on the reference with almost no error in amplitude or phase. 4. `Vff`: adds the measured grid voltage to the controller output, so the controller only supplies the drop across the filter. 5. `Da`: the duty of the first leg, `0.5 + v/(2·Vdc)`; `Db` makes the mirror image for the second leg. Each goes to a PWM block at 20 kHz and, through dead-time blocks, to the gates. ## 4. Run it and compare the current with the voltage Click `[▶ Run]`, then `Open in Separate Window` at the top right of the scope, so the scope has a window of its own (the next steps use it). The scope shows the grid voltage `vg` on the top axis and the grid current `ig` below it, each on its own axis. ![The scope: vg on top, ig below, both sine waves in phase, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/grid-tie/04-run.png) 1. `vg`: the grid voltage, 325 V peak. 2. `ig`: the grid current. It reaches its 10 A peak within the first cycle (the table says 10.17 A over the whole run, a little more than 10 A during the start) and is a sine in phase with `vg`. ## 5. Choose a window of whole cycles The scope folds the table away while the plots would get less than half its width, so click `Measurements` in the toolbar to show it. Click `Cursors` (`Shift+C`) and place the two lines at 80 ms and 120 ms: two whole line cycles, after the start. ![The scope with two cursors; the line over the table now says cursors 80ms to 120ms, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/grid-tie/05-window.png) 1. `Cursors`: shows two vertical lines and the values at each. 2. The line over the table now ends with `cursors 80ms – 120ms`. Every figure below is taken over that window. ## 6. Read the distortion of the grid current Click `Measurements to show` and tick `THD`. ![The measurement picker with THD ticked, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/grid-tie/06-thd.png) 1. `Measurements to show`: the columns of the table. 2. `THD`: the total harmonic distortion up to the 50th harmonic, as a share of the fundamental. ## 7. Read the power factor Press `Esc` to close the picker. On the scope panel's `Power` tab, choose `vg` in the first list and `i(AmG)` in the second (the ammeter's own current, the same as `ig`), then click `[Add power]`. ![The Power tab with a power row for vg and i(AmG), marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/grid-tie/07-power.png) 1. The power row of `vg` and `i(AmG)`. The `THD` column is on the `Summary` and `Signals` tabs: 3.72 % for `ig` (`scope.measure` with the fundamental given as 50 Hz reads 3.60 %), 0.00 % for `vg`, as the grid source is a pure sine. 2. `PF` of the pair: 0.999, from `P` = 1.626 kW and `S` = 1.628 kVA. The distortion alone gives 1/√(1 + 0.0372²) = 0.9993, so the fundamental of the current is in phase with the voltage within a degree (about 0.6°, the current slightly leading). `Q`, the reactive power √(S² − P²) (tick it in the picker's Power group), is 62 var: nearly all of it is the distortion, and the figure has no sign. The expected power is 325 V · 10 A / 2 = 1.63 kW. ## 8. Let Auto Design draw a three-phase grid-tie inverter The example is single phase. For three phases, Auto Design takes an inverter spec: a 700 V DC link, a 400 V line-to-line grid, 10 kW, and the current distortion limit of IEEE Std 1547. Its form has only DC converter rows, so give the spec on the console (`⌘⇧Y`; first close the scope window with `Dock Back`). A run replaces the open circuit, so save your work first. ```text design.auto {"spec":{"vdc":700,"grid":{"vll":400},"pout":10000,"thd":"ieee1547"}} ``` ![The Auto Design result: PASS, current distortion 0.63 % against 5 %, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/grid-tie/08-auto.png) 1. The headline: `Three-phase two-level inverter, 10 kHz: all 2 checks pass`. 2. `Total rated-current distortion`: 0.63 % against at most 5 %. Below it: power factor 0.997 at the light 10 % load, DC-link ripple 2.65 V (14 V allowed), efficiency 98.8 %. The reply holds the design. The bridge inductor `L1` is 2.86 mH (20 % current ripple at 10 kHz), the grid-side inductor `L2` 154 µH, the filter capacitor 9.95 µF with a 1.28 Ω damper, resonating at 4.17 kHz, and the DC link 82 µF. The grid-side current loop is a dq PI: `Kp` 12.4 V/A and `Ki` 5118 V/(A·s). It crosses over at 677 Hz with 72° of phase margin and 6.5 dB of gain margin. The PLL has a natural frequency of 15 Hz and a damping of 0.71 (`Kp` 133, `Ki` 8883). `Design › Design Steps › Current Loop` designs the current loops of a motor from its R and L, and of a grid-tie inverter from its LCL filter. On this design it sees L1 + L2 = 3.02 mH and proposes `Kp` 12.45 V/A and `Ki` 5131 V/(A·s), crossing over at 656 Hz with 72.7° of phase margin and 6.5 dB of gain margin: gains within 1 % of Auto Design's. ## 9. Read the three-phase circuit Press `Esc` to close the result. The controller is one module, `Ctrl`; entering it (`circuit.enterSubsystem`) shows its blocks. ![The circuit: DC source and link, three legs, an LCL filter per phase, the grid and the controller module, marked 1 to 7](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/grid-tie/09-circuit.png) 1. `Vdc`: the 700 V source, behind a small model of its impedance and the DC-link capacitor. 2. `Qah`: the upper switch of the first of three legs. 3. `L1a`: the bridge-side inductor of phase a; phases b and c repeat the filter below it. 4. `Cfa`: the filter capacitor, with its damping resistor above it. 5. `L2a`: the grid-side inductor. The ammeter `Ama` and the voltmeter `VMa` after it give `ia` and `va`. 6. `Grid`: the three-phase grid, 400 V line to line. It has the parameters `sagDepth`, `sagStart` and `sagEnd` for a voltage sag. 7. `Ctrl`: the controller. Its pins on the left are the measured phase currents, the phase voltages and the DC voltage; on the right the six gate signals. Inside `Ctrl`, the PLL gives the angle `th`; Park transforms turn the grid voltage into `vd` and `vq` and the current into `idm` and `iqm`; the references are `Idref = Pref/(1.5·Vpk)` and `Iqref = −Qref/(1.5·Vpk)`, so `P = 1.5·vd·id` and `Q = −1.5·vd·iq`. Two PIs add the filter's drop to the measured grid voltage, and space-vector modulation drives the bridge. Two math signals, `P` and `Q`, are added to the scope for the next steps. They take `P = 1.5(vd·id + vq·iq)` and `Q = 1.5(vq·id − vd·iq)`. ## 10. Run it and read the phase current Click `[▶ Run]`. When the run ends, click `[Show results]` on its notice, then `Open in Separate Window` on the scope, and place the cursors at 80 ms and 120 ms again. ![The scope: phase voltage va and phase current ia, with a table for 80 ms to 120 ms, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/grid-tie/10-run.png) 1. `va`: the phase voltage, 326.6 V peak. 2. `ia`: the phase current, a sine in phase with `va`, 20.5 A peak (14.4 A rms), with a distortion of 0.63 %. The power row for `va` and `ia` reads 3.333 kW and a power factor of 1.000: three phases give 10 kW. ## 11. Jump the grid's phase and watch the PLL lock Press `⌘⇧Y` to open the console (first click `Dock Back` on the scope). Type these two lines, each followed by `Enter`: ```text simulation.tune {"component":"Grid","key":"phase","value":120} simulation.continue {"duration":0.12} ``` ![The console with the two commands, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/grid-tie/11-pll-console.png) 1. `Console`: every menu item is a command, and the console runs any of them. 2. `simulation.tune` moves the grid's phase from 90° to 120° at the end of the run, 0.12 s. The inverter's state is kept. 3. `simulation.continue` runs another 0.12 s from there. Click the `Scope` tab and `Open in Separate Window`. ![The scope after the jump: Ctrl.vq spikes and settles, ia hardly moves, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/grid-tie/12-pll-scope.png) 1. `Ctrl.vq`: the q-axis grid voltage, which is the PLL's error: zero when the PLL is locked. The 30° jump puts it at 327 V · sin 30° = 163 V. It swings to −35 V and is within 2 V of zero 60 ms later, three line cycles, as a PLL with a 15 Hz natural frequency and 0.71 damping settles. A faster PLL would lock sooner and pass more of a distorted grid into the current. 2. `ia`: the phase current. It has a spike of 46 A that lasts a few milliseconds, then goes on with the same 20.5 A peak: the current loop does not wait for the PLL, it follows the angle the PLL has at each moment. ## 12. Step the active power Type these two lines on the console: ```text simulation.tune {"component":"Ctrl.IdRef","key":"value","value":10.2} simulation.continue {"duration":0.08} ``` ![The scope after the step: P falls from 10 kW to 5 kW, Ctrl.idm from 20.4 A to 10.2 A, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/grid-tie/13-p-step.png) 1. `P`: between the cursors, 280 ms to 320 ms, it is 4.997 kW. The step took the power from 10 kW down within about 5 ms: the d-axis current is controlled directly, so the active power follows at the speed of the current loop (677 Hz). 2. `Ctrl.idm`: the measured d-axis current, 10.2 A. This is the new reference: `Idref = P/(1.5·Vpk)` = 5000 W / (1.5 · 326.6 V). `IdRef` is a constant block that held the expression `Idref`, and the tune replaces it with 10.2 A. ## 13. Step the reactive power ```text simulation.tune {"component":"Ctrl.IqRef","key":"value","value":-10.2} simulation.continue {"duration":0.08} ``` ![The scope after the step: P stays at 5 kW, Q rises from 0 to 5 kvar, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/grid-tie/14-q-step.png) 1. `P`: unchanged at 4.997 kW through the step. 2. `Q`: from 0 to 4.997 kvar, a share of the apparent power of 7.07 kVA (a power factor of 0.71), within about 10 ms. A negative `Iqref` gives a positive `Q` in `Q = 1.5(vq·id − vd·iq)`. The phase current grows from 10.2 A to 14.4 A peak, the vector sum of the two axes. The two axes do not disturb each other: `Q` moves, `P` does not. ## 14. Sag the grid A grid that drops to half its voltage for 40 ms, starting at 440 ms: ```text simulation.tune {"component":"Grid","key":"sagEnd","value":0.48} simulation.tune {"component":"Grid","key":"sagStart","value":0.44} simulation.tune {"component":"Grid","key":"sagDepth","value":0.5} simulation.continue {"duration":0.12} ``` (The end is set first because a sag must end after it starts, and both start at 0.) ![The scope through the sag: va halves for 40 ms, ia spikes, P drops to half, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/grid-tie/15-sag.png) 1. `va`: the phase voltage falls from 326.6 V to 163.3 V peak at 440 ms and comes back at 480 ms. 2. `ia`: the grid is an ideal source, so the voltage step reaches the filter capacitors at once, and the phase current spikes to 111 A for a millisecond, five times the rated peak of 20.4 A. The d-axis current is back within 10 ms. Between the cursors, 450 ms to 470 ms, the current is still 14.4 A peak (10.2 A rms). 3. `P`: with the same current and half the voltage, the power is half, 2.499 kW (and `Q` 2.498 kvar). The controller keeps the current, not the power, and it has no current limit. The DC link holds above 695 V throughout. Auto Design checks the same thing when the spec has `"rideThrough":{"residualPu":0.5,"duration":0.15,"maxCurrentPu":1.5}`: this design passes it, with a bridge-side current of 1.24 per unit against the 1.5 allowed. When a design fails the row, the report says what to try: a current limit in the controller, a higher switching frequency, or a grid impedance. ## The same steps from a script ```sh powercraft-cli run \ --cmd file.openExample --params '{"name":"gridTieInverter"}' \ --cmd simulation.run --params '{}' \ --cmd scope.measure --params '{"signals":["ig"],"t0":"0.08","t1":"0.12","thd":{"fundamental":50},"power":{"v":"vg","i":"ig"}}' ``` The reply gives `power.powerFactor` 0.9993, `power.real` 1626 and `thd.ig.thdPercent` about 3.6. The three-phase part needs Voltecx Cloud, because `design.auto` runs there: ```sh powercraft-cli run --new '{}' \ --cmd design.auto --params '{"spec":{"vdc":700,"grid":{"vll":400},"pout":10000,"thd":"ieee1547"}}' \ --cmd scope.addMath --params '{"expr":"1.5*(Ctrl.vd*Ctrl.idm+Ctrl.vq*Ctrl.iqm)","name":"P"}' \ --cmd simulation.run --params '{}' \ --cmd simulation.tune --params '{"component":"Ctrl.IdRef","key":"value","value":10.2}' \ --cmd simulation.continue --params '{"duration":0.08}' \ --cmd scope.measure --params '{"signals":["P"],"t0":"0.14","t1":"0.2"}' ``` The last `scope.measure` gives a `P` of about 5 kW. Add the math signal before the run: a later `scope.addMath` changes the circuit, and `simulation.tune` refuses a circuit that changed since the run. Back to the [learning path](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/). --- # Modular multilevel converter: submodules, balancing and the circulating current URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/17-mmc/ A modular multilevel converter (MMC) builds its output from many small steps instead of two big ones. Each phase leg has two arms, and each arm is a stack of identical submodules, a capacitor with two switches, that are inserted or bypassed one by one. The output has many levels and a low distortion with a slow switching rate. The price is control: the capacitors must stay at the same voltage, and the two arms exchange a current of their own, the circulating current. You open the `mmcInverter` example, read its arms and its controller, then follow the arm currents, the circulating current, the four submodule capacitor voltages, the output levels and the distortion. Last, you switch the circulating-current controller off and see what it was doing. About 30 minutes. Pictures: a numbered red box is what you click or read, `[▶ Run]` is a button, `File › Open Example` a menu path, `⌘⇧Y` a key (`⌘` is Cmd on a Mac, Ctrl elsewhere). ## 1. Open the example Choose `File › Open Example › Inverters › MMC inverter leg`. ![The File menu open at Open Example, Inverters, MMC inverter leg, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/mmc/01-open-example.png) 1. `File`. 2. `Open Example`. 3. `Inverters`. 4. `MMC inverter leg`. ## 2. Read the power stage One phase leg stands between two 200 V sources, a 400 V bus with its middle at ground. The upper arm hangs from the positive rail, the lower arm from the negative rail, and the load takes the middle point `ac` of the leg back to ground. The rails and the signals `iu`, `il`, `mu` and `ml` are drawn as labels, so the leg is one short column. ![The power stage: the two DC sources, the upper arm with its inductor, the middle point, the lower arm, and the load, marked 1 to 8](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/mmc/02-power.png) 1. `Vp`: the upper 200 V source; `Vn` below it is the lower one. Together they are the 400 V bus. 2. `AmU`: an ammeter in the upper arm. Its output is the arm current `iu`; `AmL` gives `il` in the lower arm. 3. `AU`: the upper arm, four submodules in series. `AL` is the lower arm. The label `mu` brings the arm its insertion index: 0 bypasses every submodule, 1 inserts all four. 4. `LU`: a 5 mH arm inductor. `LL` is the lower one. The arms must have them: they limit the current between two stacks of capacitors that are never at exactly the same voltage. 5. `AmLoad`: the load current `iload`, taken at the middle point `ac`. 6. `RL`: a 10 Ω load resistor, with `LO`, 10 mH, in series to ground. 7. `AmL`: the lower arm's current `il`. 8. `AL`: the lower arm, a copy of `AU`. The upper arm inserts a share `mu = (1 − 0.8·sin ωt)/2` of its submodules and the lower arm `ml = (1 + 0.8·sin ωt)/2`: while one arm inserts more, the other inserts fewer, so the two always insert four between them. The leg puts 0.8 · 400 V / 2 = 160 V peak at 50 Hz across the load. ## 3. Read one arm Click `AU` on the schematic. Its parameters are in Properties. ![The properties of the arm AU: submodules, capacitance, starting voltage and carrier frequency, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/mmc/03-arm.png) 1. `Submodules in series in the arm`: `n` is 4. 2. `Capacitance of each submodule`: `c` is 2 mF. 3. `Voltage of each submodule capacitor`: `v0` is 100 V, the bus divided by `n`, so the capacitors start at their working voltage. 4. `Carrier frequency`: `fc` is 1 kHz. The four submodules switch with carriers shifted by a quarter of a period each, so the arm steps at an apparent 4 kHz. With `level` switched, the arm is built from its parts when you run: for every submodule an upper switch to the capacitor and a lower switch that bypasses it. An `mmcBalance` block (the library part `MMC Submodule Selection`) sits inside the arm. It reads the insertion index, the arm current and the four capacitor voltages, and it decides how many submodules are inserted and which ones. Step 9 shows its output. ## 4. Read the control The control sits below the power stage. The two arms get the same sine references, and one small loop adds a correction to both. ![The control: the circulating current from the two arm currents, a band-pass, a gain, the two references and their mixers, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/mmc/04-control.png) 1. `Sum`: adds the two arm currents `iu` and `il`; `Half` halves the sum. The result `icirc = (iu + il)/2` is the circulating current: the part of the current that goes through both arms and not through the load. 2. `Bp`: a band-pass at 100 Hz, twice the output frequency. It keeps the second harmonic of the circulating current and drops its DC part. 3. `Kc`: a gain `kc` of 0.025. The result `dm` is added to both arm references. For the circulating current this is a resistance of `kc` · 400 V = 10 Ω, and it acts at 100 Hz only. The DC part and the output are not touched. 4. `RefU`: the upper arm's sine reference, `0.5 + 0.4·sin(ωt + 180°)`; `RefL` is the lower one. 5. `MixU`: adds `dm` to the reference and gives `mu`; `MixL` gives `ml`. ## 5. Run it and read the output Click `[▶ Run]`. The scope shows the voltage `v(ac)` at the middle point on the top axis and the load current `iload` below it. ![The scope: v(ac) on top, iload below, both at 50 Hz, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/mmc/05-run.png) 1. `v(ac)`: the voltage at the middle point, a 50 Hz sine of about 117 V rms with a ripple on it. Step 11 looks at that ripple. 2. `iload`: the load current, a sine of 15.4 A peak. The table says 10.7 A rms; the load takes 10 Ω · (10.7 A)² = 1.15 kW. ## 6. Read the arm currents and the circulating current In the signal list tick `iu`, `il` and `icirc`, then give `icirc` its own axis: click the plot button at the end of its row (its tooltip names the plot it is on), and `icirc` moves to the next plot, stacked under the others. ![The scope: iu and il on top, icirc below, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/mmc/06-arms.png) 1. `iu`: the upper arm current. 2. `il`: the lower arm current. Its load part is the opposite of `iu`'s: when one arm carries more, the other carries less. 3. `icirc`: the circulating current. It starts at 0, because the capacitors start charged and the bus has not yet pushed current through the leg. It overshoots to 5.1 A and settles near 3 A with a small ripple at 100 Hz. ## 7. Choose a window of whole cycles The scope folds the table away while the plots would get less than half its width, so click `Measurements` in the toolbar to show it. Click `Cursors` (`Shift+C`) and place the two lines at 100 ms and 200 ms: five whole cycles after the start. ![The scope with two cursors; the table says between the cursors 100ms to 200ms, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/mmc/07-window.png) 1. `Cursors`: shows two vertical lines and the values at each. 2. The table's heading reads `between the cursors 100ms – 200ms`. Every figure below is taken over that window. In the table, `iu` has a mean of 2.88 A, `il` 2.90 A, and `icirc` 2.89 A. The mean of an arm current is the DC part of the circulating current, the current that brings the power in from the bus: 400 V · 2.89 A = 1.16 kW, and the load takes 1.15 kW. On top of it each arm carries half of the load current: `iu` swings from −5.1 A to 10.85 A, which is 2.89 A plus or minus 7.6 A (half of the 15.1 A load current), plus the ripple. The circulating current itself moves between 2.04 A and 3.82 A, a second harmonic of 1.78 A peak to peak. ## 8. Read the capacitor voltages Untick the currents and tick `AU:v1`, `AU:v2`, `AU:v3` and `AU:v4` on one axis, and `AU:vsum` on its own. ![The scope: the four capacitor voltages of the upper arm on top, their sum below, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/mmc/08-caps.png) 1. `AU:v1`: the capacitor voltage of the first submodule of the upper arm. The traces of `AU:v2` and `AU:v3` lie on top of it. 2. `AU:v4`: the fourth. The four means are 99.31, 99.31, 99.31 and 99.30 V, within 0.01 V of each other, and each swings 10.3 V peak to peak, from 94.8 V to 105.1 V. 3. `AU:vsum`: the sum of the four, the voltage the arm can make: 397.2 V on average, 41 V peak to peak at 50 Hz. The arm gives and takes energy as the output swings, and the voltage rides up and down by 10 %. The four traces are indistinguishable at this scale. The submodules are identical, and one that is inserted more often than the others charges and discharges more, so only the control keeps them together. The next two steps show how. ## 9. See which submodules are inserted Untick the voltages and tick `AU:g1` to `AU:g4`, each with its own axis. Choose `Scope > Zoom Axis > Time Only`, then click `Zoom In` six times. ![The scope zoomed to 3 ms: the four selection signals g1 to g4, each a train of pulses, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/mmc/09-gates.png) 1. `AU:g1`: the output of `mmcBalance` for submodule 1: 1 while it is inserted, 0 while it is bypassed. 2. `AU:g4`: the same for submodule 4. No submodule stays on or off. Over the 100 ms of the window, `AU:g1` to `AU:g4` average 0.497, 0.495, 0.503 and 0.505: each submodule is inserted half of the time, and a submodule that has been inserted a little more than the others is bypassed next. That is the sorting: the block ranks the four capacitor voltages, and while the arm current charges the capacitors it inserts the lowest ones; while it discharges them, the highest. A submodule changes state only when the number of inserted submodules changes, not each time two voltages cross, so the switching is as slow as the modulation needs it to be. ## 10. See the sorting at work on the voltages Untick the selection signals, tick `AU:v1` to `AU:v4` on one axis and click `Autoscale Y`. ![The four capacitor voltages over 3 ms: staircases that rise one after the other and stay within half a volt, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/mmc/10-zoomed-caps.png) 1. `Autoscale Y`: fits the voltage axis to the zoomed window, so the 10 V swing of step 8 becomes a 1 V window. 2. `AU:v1`: each voltage is a staircase. A slope is the submodule inserted, charging or discharging with the arm current; a flat part is the submodule bypassed. The four climb in turn and cross, and at no point are two of them more than about 0.5 V apart. ## 11. Count the output levels Click `Show signals` on the left edge of the scope window to unfold its signal list, then `+` (`Add Math Signal`) at the top of the list; type `AU:g1+AU:g2+AU:g3+AU:g4` in `Expression` and click `Add`. The sum is the number of submodules inserted in the upper arm; the scope calls it `math1`. Put `v(ac)` and `math1` on their own axes and zoom in four times on the time axis. ![The scope over 14 ms: v(ac) rising in steps, and math1, the number of inserted submodules, falling from 4 to 1, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/mmc/11-levels.png) 1. `v(ac)`: the output rises in steps of about 100 V, the bus divided by the four submodules, with a 4 kHz ripple around each step. Every PWM period it switches between two adjacent levels. 2. `math1`: the number of inserted submodules of the upper arm, 0 to 4. Its mean over whole cycles is 2.0; the table shows a minimum of 0 and a maximum of 4. The lower arm inserts the rest, so the leg has five levels, `N + 1` for `N` submodules. ## 12. Read the distortion Zoom back to the whole run (`Zoom to Fit`), keep `v(ac)` and `iload`, click `Measurements to show` and tick `THD`. ![The measurement picker with THD ticked, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/mmc/12-thd-picker.png) 1. `Measurements to show`: the columns of the table. 2. `THD`: the total harmonic distortion up to the 50th harmonic, as a share of the fundamental. ## 13. Compare the voltage and the current Press `Esc` to close the picker. ![The table with the THD column: v(ac) 0.578 %, iload 0.423 %, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/mmc/13-thd-table.png) 1. `THD` of `v(ac)`: 0.578 % (`scope.measure` with the fundamental given as 50 Hz reads 0.57 %). The fundamental is 158.7 V peak, a little under the 160 V the modulation asks for. 2. `THD` of `iload`: 0.423 %. The 10 mH load filters the output voltage further, and the 15.1 A fundamental is clean. Four submodules, a carrier of 1 kHz each and a small arm inductor are enough. ## 14. Keep this run and turn the circulating-current controller off In the signal list put `icirc`, `AU:v1` and `iload` on one axis each, click `Keep as reference`, then `Dock Back` on the scope. Press `⌘⇧Y` to open the console and type: ```text circuit.variables {"set":{"kc":"0"}} ``` ![The console with the command; the reply shows kc as 0, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/mmc/14-off-console.png) 1. `circuit.variables` sets the circuit variable `kc` to 0. `Kc` has a gain of `kc`, so `dm` is now 0 and the arm references are the plain sines. This edits the circuit; undo it to get 0.025 back. 2. The reply lists the variable as 0. This step turns off the balance between the two arms of the leg. The sorting inside each arm is a separate balance with its own switch, the arm's `sorting` parameter: set to 0, the submodules go in by index and their capacitor voltages drift apart. It stays on here. ## 15. Run again and compare Type `simulation.run`, put the cursors at 100 ms and 200 ms again, and keep the same three signals on the scope. ![The scope: the reference run light, the new run dark; icirc, AU:v1 and iload each on their own axis, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/mmc/15-off-run.png) 1. `icirc · Ref 1`: the first run, kept as a reference and drawn lighter, with the controller on. 2. `icirc`: the new run. The second harmonic is now 9.6 A peak to peak, against 1.78 A: its rms value is 2.41 A against 0.43 A, 5.6 times as much. The mean is the same 2.90 A, so the power from the bus does not change. Scroll the measurements down: `Runs` lists the two runs and what changed between them (`kc 25m→0`). The rest follows from the larger circulating current: - The capacitor voltage `AU:v1` swings 17.3 V peak to peak, from 91.3 V to 108.6 V, against 10.3 V: the second harmonic of the arm current charges and discharges the capacitors at 100 Hz on top of the 50 Hz swing. - The arm current has an rms value of 6.83 A against 6.10 A. That is 12 % more, so the conduction loss in the arm's switches is about 25 % higher, and the arm needs bigger capacitors and bigger switches for the same load. - The load current has a THD of 1.35 % against 0.42 %. The arm voltages move more, and some of it reaches the output. So an MMC has two balances. The sorting inside an arm keeps the four capacitors together (steps 8 to 10). The circulating-current controller keeps the two arms from swinging energy against each other, and it is the one you switched off here. ## The same steps from a script ```sh powercraft-cli run \ --cmd file.openExample --params '{"name":"mmcInverter"}' \ --cmd simulation.run --params '{}' \ --cmd scope.measure --params '{"signals":["icirc","AU:v1","AU:g1","iload","v(ac)"],"t0":"0.1","t1":"0.2","thd":{"fundamental":50}}' \ --cmd circuit.variables --params '{"set":{"kc":"0"}}' \ --cmd simulation.run --params '{}' \ --cmd scope.measure --params '{"signals":["icirc","AU:v1","iload"],"t0":"0.1","t1":"0.2","thd":{"fundamental":50}}' ``` The first `scope.measure` gives an `icirc` of 1.78 A peak to peak, an `AU:v1` of 10.3 V peak to peak and a `thd.iload.thdPercent` of 0.42. The second gives 9.6 A, 17.3 V and 1.34 (the table's 1.35 % is the same figure with the fundamental found by the scope). Back to the [learning path](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/). --- # Fast isolation: a SiC half bridge on fiber URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/18-fast-isolation/ SiC and GaN switch nodes move at 50 to 200 V/ns. Every part that carries a gate signal across a barrier has a common-mode transient immunity (CMTI): the slope it survives without a false edge. Here you open an 800 V SiC half bridge whose gate signals travel on fiber, read its link budget, run it, and let `design.gateDrive` choose the isolation by the switch node's slope. About 15 minutes. Pictures: a numbered red box is what you click or read, `[▶ Run]` is a button, `File › Open Example` a menu path. ## 1. Open the example Choose `File › Open Example › Isolated › SiC half bridge with fiber-optic gate drive`. ![The File menu open at Open Example, Isolated, SiC half bridge with fiber-optic gate drive, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/fast-isolation/01-open-example.png) 1. `File`. 2. `Open Example`. 3. `Isolated`. 4. `SiC half bridge with fiber-optic gate drive`. ## 2. Read the circuit ![The schematic: the control on the left, the dashed barrier, the receivers and the half bridge on the right, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/fast-isolation/02-schematic.png) 1. `U1`: the fiber transmitter of the high-side gate signal, on the control ground with the PWM module `XPWM` (50 kHz, half duty, 200 ns dead time). 2. `U3`: its receiver, on the source of `Q1` with its own 15 V supply `Vgh`. The green wire between them is the fiber: it crosses the dashed barrier, and nothing else does. 3. `Q1`: a Wolfspeed C3M0016120K at the dynamic switching level, so the switch node moves with the device's gate charge and capacitances. `Q2` is the low side, with `U2` and `U4`. 4. `Rtie`: the documented 10 kΩ tie that gives the solver a path between the two grounds. It carries no current. The fiber parts keep their defaults, labelled "typical, user must set": no transmitter or receiver data sheet is in Voltecx yet. Set your parts' values (`ic.describe {name: "fiberRx"}` lists them) before you trust a delay or a budget. The link budget is checked without a run. `fiber.linkBudget {}` gives, for each link, −8 dBm launched − 0.4 dB of fiber (2 m at 0.2 dB/m) − 2 dB of connectors = −10.4 dBm received, 14.6 dB over the −25 dBm sensitivity. To try a longer fiber, set the receiver's length: `circuit.setParam {component: "U3", key: "length", value: 70}` rebuilds `U3` with 70 m of fiber, in one undo step. `fiber.linkBudget {}` then gives −24 dBm into `U3`, and its 1 dB of margin is less than the 3 dB asked for, so the link fails and `circuit.problems` lists the `fiber.linkBudget` warning. `fiber.linkBudget {pTx: -8, length: 70, alpha: 0.2, lossConn: 2, pSens: -25}` checks the same numbers without changing the circuit. ## 3. Run it Click `[▶ Run]`. ![The scope: v(sw) switching between 0 and 800 V, i(Lload) a triangle of ±8 A, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/fast-isolation/03-run.png) 1. `v(sw)`: the switch node, from 0 to 800 V at 50 kHz. 2. `i(Lload)`: the load current, a triangle of ±8 A around zero. Zoom on an edge: each gate command reaches its MOSFET 55 ns after it left the PWM module (15 ns in the transmitter, 10 ns of flight in 2 m of fiber, 30 ns in the receiver), Each MOSFET is driven as in its data sheet's switching tests (−4 V / +15 V through 2.5 Ω), so the outgoing one is off well inside the 200 ns dead time, and the load current swings the switch node across before the incoming one turns on: a zero-voltage turn-on, with no shoot-through. Here the edge is about 12 V/ns, set by the load current charging the two MOSFETs' output capacitances. ## 4. Choose the isolation by the slope Run `design.gateDrive` with the spec and a 5 ns switching edge: ```sh powercraft-cli run --cmd file.openExample --params '{"name":"sicHalfBridgeFiber"}' \ --cmd design.gateDrive --params '{"spec":{"vin":800,"vout":400,"iout":8},"fsw":50e3,"tEdge":5e-9}' ``` `isolation.why` reads: the switch node swings 800 V at 160 V/ns, so the choice is the fiber-optic link (no galvanic path, so no CMTI limit). The UCC21750 isolated gate driver is passed over (its CMTI of 150 V/ns is below 160 V/ns), and so are the ISO7710 digital isolator (100 V/ns) and the high-speed logic optocoupler. With `"tEdge": 8e-9` the slope is 100 V/ns and the isolated driver qualifies; at the 12 V/ns of this run it would too. `design.auto` quotes the same choice in its gateDrive gate. ## 5. See a CMTI failure An on-board isolator that sees a slope above its rating glitches. Place a digital isolator (`ic.place {name: "digitalIsolator"}`) with its output side on a node that moves faster than 100 V/ns and run: `circuit.problems` lists `CMTI exceeded: 120 V/ns > 100 V/ns rating on `U5`` and the output shows a 20 ns spurious pulse. A part with `cmti` 0 (its rating is not in Voltecx) is measured but never trips: enter the value from its data sheet. Next: the [manual](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/10-models/) describes `highSpeedOpto`, `fiberTx`, `fiberRx` and `pvDriver`. --- # Tolerance and Monte Carlo: which part limits the flyback URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/19-flyback-tolerance/ Every part on a board differs from its nominal value. Here you take the flyback whose output is regulated by a TL431 and an optocoupler, let its divider resistors, its inductance and its output capacitor vary within their tolerances in a Monte Carlo analysis, read the output-voltage and peak-current distributions, and rank the parts by how much of the spread each one causes. Then you tighten the part that limits the output and check the yield again. About 20 minutes. Pictures: a numbered red box is what you click or read, `[Run]` is a button, `Analysis › Monte Carlo` a menu path. Every number on this page comes from a run of these steps, and a test runs them again and fails when a number here differs from the run (`crates/engine/tests/tutorial_flyback_tolerance.rs`). ## 1. Open the flyback with the TL431 loop Choose `File › Open Example › Isolated › Flyback with TL431 and optocoupler`. ![The File menu open at Open Example, Isolated, Flyback with TL431 and optocoupler, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/flyback-tolerance/01-open-example.png) 1. `File`. 2. `Open Example`. 3. `Isolated`. 4. `Flyback with TL431 and optocoupler`. The circuit runs from 12 V to 12 V at 6 W. The TL431 compares the output, divided by `Rup` and `Rlow`, with its reference, and the optocoupler carries the error to the primary-side PWM. ## 2. Prepare the parts that vary Make three changes before the analysis: - **Keep the full load.** The example halves its load at 4 ms. Select the block `load_on` and set its `after` to `1` in the Properties panel, so the load stays and the whole run is one operating point. - **One inductance for both windings.** Choose `Circuit › Variables`, add `Lm` = `20u`, then select `T1` and set both `l1` and `l2` to `Lm`. A core's inductance tolerance moves both windings together, and the analysis can now vary them as one value. - **Measure after the loop has settled.** Every measurement below reads 5 ms to 6 ms of the 6 ms run. With `C1` at the top of its tolerance the output is still recovering at 3 ms; by 5 ms it has settled. ![The flyback schematic with Rup, Rlow, T1 and C1, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/flyback-tolerance/02-parts.png) 1. `Rup` (9.53 kΩ): the upper divider resistor, ±1 %. 2. `Rlow` (2.49 kΩ): the lower divider resistor, ±1 %. 3. `T1`: the coupled inductor, both windings `Lm` = 20 µH, ±10 %. 4. `C1`: the 100 µF output capacitor, ±20 %. The tolerances are the ones an engineer picks for this exercise: the grades IEC 60062 codes F (±1 %), K (±10 %) and M (±20 %). Each part is drawn uniformly within its tolerance. ## 3. Monte Carlo of the output voltage Choose `Analysis › Monte Carlo` and fill in the form. ![The Monte Carlo form with the variables, runs, seed, measurement and lower limit, marked 1 to 5](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/flyback-tolerance/03-form.png) 1. `Variables`: `[{"name":"Rup.r","tol":0.01},{"name":"Rlow.r","tol":0.01},{"name":"Lm","tol":0.1},{"name":"C1.c","tol":0.2}]`. 2. `Number of runs`: `50`. 3. `Seed`: `1`. The same seed draws the same 50 sets of parts every time, so the next steps vary exactly the same circuits. 4. `Measure`: signal `v(out)`, statistic `mean`, window start `5m`, window end `6m`. 5. Under `More options`, `Lower limit` `11.88` and `Upper limit` `12.12`: the output must stay within 12 V ± 1 %. Press `[Run]`. The 50 simulations take a few seconds. ## 4. Read the histogram ![The Monte Carlo result: statistics, yield and the histogram of v(out) between the two limits, marked 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/flyback-tolerance/04-histogram.png) 1. The result: the statistics, the yield against the limits and the histogram, with the limits as red lines. The mean output is 12.065 V with a standard deviation of 86.2 mV; the 50 runs lie between 11.916 V and 12.234 V. Only 39 of the 50 runs stay within 12 V ± 1 %: a yield of 78 %. The window also gives the 95 % confidence interval of the yield, since 50 runs only estimate it. ## 5. The peak current Open `Analysis › Monte Carlo` again. Keep the variables, runs and seed, set `Measure` to signal `i(S1)` with statistic `max` (same window), clear both limits and press `[Run]`. ![The Monte Carlo result for the peak switch current i(S1), marked 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/flyback-tolerance/05-peak-current.png) 1. The peak current of the switch over the same 50 circuits. The peak current averages 2.51 A with a standard deviation of 71 mA, from 2.36 A to 2.64 A. Size the switch, the current sense and the core for the top of that range, not for the mean. ## 6. Which part drives the spread The histogram says how wide the spread is, not where it comes from. Press `⌘K` to open the command palette, type `sensitivity` and choose `Sensitivity`. Fill in `Variables` `Rup.r, Rlow.r, Lm, C1.c`, and `Metrics` `{"vout":{"signal":"v(out)","stat":"mean","t0":"5m","t1":"6m"},"ipk":{"signal":"i(S1)","stat":"max","t0":"5m","t1":"6m"}}`. Press `[Run]`. ![The Sensitivity result: each part's normalized and absolute sensitivity for vout and ipk, marked 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/flyback-tolerance/06-sensitivity.png) 1. The table, largest first. `Normalized` is the relative change of the metric per relative change of the part: 0.8 means a 1 % larger part moves the metric by 0.8 %. At the nominal parts the output is 12.067 V and the peak current 2.50 A. A sensitivity alone does not rank the parts: a sensitive part with a tight tolerance can matter less than a dull part with a loose one. Multiply each sensitivity by the part's own spread (a part drawn uniformly within ±tol has a standard deviation of tol/√3) and you get the spread it adds to the metric. The last column checks the ranking against the Monte Carlo itself: the correlation between each part's value and the metric over the 50 runs of steps 4 and 5 (`[Copy CSV]` in their windows gives the samples). The output voltage: | Part | Tolerance | Sensitivity | Spread it adds (1σ) | Correlation in the 50 runs | |---|---|---|---|---| | `Rup` | ±1 % | +0.79 | 0.46 % | +0.70 | | `Rlow` | ±1 % | −0.79 | 0.46 % | −0.74 | | `C1` | ±20 % | 0.00 | 0.00 % | +0.09 | | `Lm` | ±10 % | 0.00 | 0.00 % | −0.02 | The peak current: | Part | Tolerance | Sensitivity | Spread it adds (1σ) | Correlation in the 50 runs | |---|---|---|---|---| | `Lm` | ±10 % | −0.50 | 2.89 % | −0.97 | | `Rup` | ±1 % | +0.79 | 0.46 % | +0.27 | | `Rlow` | ±1 % | −0.79 | 0.45 % | −0.11 | | `C1` | ±20 % | 0.00 | 0.00 % | +0.34 | Both methods agree. The two divider resistors set the output's spread; the inductance and the output capacitor add nothing to it, because the loop corrects whatever they change. The peak current follows the inductance: in discontinuous conduction the core stores the same energy each period, so a smaller `Lm` needs a higher current (`Ipk = √(2P/(Lm·f))`, a sensitivity of −0.5). A correlation of a few tenths for a part whose sensitivity is zero is chance: 50 runs cannot tell it from nothing. ## 7. Tighten the part that limits the output The divider limits the output, so buy better resistors. Open `Analysis › Monte Carlo` once more, set the measurement back to `v(out)` `mean` with the limits `11.88` and `12.12`, change the tolerance of `Rup.r` and `Rlow.r` to `0.001` (±0.1 %) and press `[Run]`. ![The Monte Carlo result of v(out) with 0.1 % divider resistors, marked 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/flyback-tolerance/07-tighter.png) 1. The narrower histogram, well inside the limits. The standard deviation falls from 86.2 mV to 8.6 mV; the runs lie between 12.051 V and 12.083 V, and 50 of 50 pass: a yield of 100 %. What is left is the offset of the mean, 12.066 V: the divider was chosen for 12.06 V, including the TL431's REF current through `Rup`. From now on the nominal values, not the tolerances, are the largest error of the output. ## What you learned - A Monte Carlo analysis varies every part at once within its tolerance and gives the distribution, the yield against limits and the worst run. - The same seed draws the same parts, so several measurements can be read from the same set of circuits. - To find the part that limits a specification, weigh each part's sensitivity by its own tolerance, and check the ranking against the correlation in the Monte Carlo samples. - In a regulated converter the feedback divider sets the output's accuracy; the power parts set the stresses, such as the peak current. Next: [Python scripting](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/13-python/) runs the same analyses from a script, or go back to the [tutorial list](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/). --- # Operating modes: T1, T2… of one switching period URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/20-operating-modes/ Converter papers explain a switching period as intervals: T1 [t0, t1] with the switch on, T2 [t1, t2] with the diode on, and so on, each with a figure of the path that conducts. Voltecx finds those intervals in a finished run, shades them on the animation's timeline and on the scope, dims what carries no current in each, and exports the table and one figure per mode for your paper. About 10 minutes. `[▶ Run]` is a button, `View › Overlays › Animate` a menu path and `Shift+F8` a key. The numbers on this page are checked by the tests of `simulation.modes` (`crates/engine-core/src/flow/modes/tests.rs`). ## 1. Run the buck Choose `File › Open Example › DC-DC › Buck converter, textbook` and press `F5`. The buck steps 48 V down to 12 V at a fixed duty cycle D = 0.25 and 100 kHz, so one period is T = 10 µs. ![The Run button in the toolbar, marked 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/operating-modes/01-run.png) 1. `[▶ Run]` (`F5`) simulates the buck. ## 2. Show the modes Press `Shift+F8` (`View › Overlays › Animate`; `F8` in the Classic keymap). Under the time slider, the modes row shows the last whole switching period: ![The modes row under the time slider with the bands T1 and T2, marked 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/operating-modes/02-modes.png) 1. The modes row: T1 is the left quarter, T2 the rest. | Mode | Interval | Duration | Conducting | |---|---|---|---| | T1 | [t0, t1] | 2.5 µs (25 %) | S1 | | T2 | [t1, t2] | 7.5 µs (75 %) | D1 | These are the analytic times: T1 = D·T and T2 = (1 − D)·T. The period starts at a turn-on of S1, so T1 is its on time, as papers number the modes. - **Hover** a band to read its interval, duration, share and the switches and diodes that conduct. - **Click** a band to jump the animation to the start of that mode. - The canvas follows: while the playback time is in T2, `S1`, `Vin` and the input net are drawn faint and `D1` is lit, the freewheeling loop of the equivalent circuit. In T1 it is `D1` that is faint. - The layers icon at the left of the row turns the modes off and on. ## 3. Limit playback to one mode or a span In the timeline's `Loop` list: - **One operating mode** loops the mode the playback time is in, and the scope zooms to it. - **Dragged span**: drag across the modes row to play only that span (for example the end of T1 and the start of T2 around the turn-off); the scope zooms to it too. - **One switching period** loops the whole period. Zoom the scope to a few periods (`Scope › Zoom to 5 Cycles`) to see T1 and T2 shaded over the waveforms, the current mode a little darker. ## 4. Export for the paper Click the save icon at the right of the modes row and pick `buck-modes.csv`. Voltecx writes the table and one schematic per mode beside it, `buck-modes-T1.png` and `buck-modes-T2.png`: the parts and nets that carry no current faint, and a caption such as `T2 [t1, t2] 7.5 µs (75.0 %) on: D1` over the drawing. For a LaTeX table, export from the command line or an agent: `simulation.exportModes {"path": "modes.tex"}` writes a `tabular` with `$T_{1}$`, `$[t_{0}, t_{1}]$` and the durations in `\SI{}{}`; `.md` writes a Markdown table. ## 5. The flyback Open `File › Open Example › Isolated › Flyback converter` and run it. At D = 0.4 and 100 kHz it stays in continuous conduction (2L/(R·T) = 0.5 is above (1 − D)² = 0.36), so there are again two modes: T1 = 4 µs with S1 on, the secondary and the snubber faint; T2 = 6 µs with D1 on and the primary faint. A converter in discontinuous conduction shows a third mode in which nothing conducts. ## From an agent or a script ```text simulation.modes {} → T1…Tn: start, end, duration, share, conducting, path, idle simulation.modes {"period": "10u", "t0": "3.5m"} → another window simulation.exportModes {"path": "modes.csv"} → csv, md or tex by the extension file.exportSchematic {"path": "fig.png", "mode": "all"} → fig-T1.png, fig-T2.png… ui.set {"animate": {"on": true, "modes": true, "range": "mode"}} ``` Intervals shorter than 1 % of the window (the commutation of a switch and a diode, a step or two long) are folded into the next one; pass `min` to keep or fold more. --- # Dual active bridge: power set by a phase shift URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/21-dual-active-bridge/ A dual active bridge (DAB) is two full bridges on either side of a transformer, with an inductance between them. Both bridges switch at half duty; the secondary's lag behind the primary sets how much power moves and in which direction. That makes it the usual stage between a DC bus and a battery, which must charge and discharge. Here you open the `dab` example, compare its power with the textbook formula, see what a larger shift costs in current, send the power back, and let Design › Automate size one from a spec. About 15 minutes. `[▶ Run]` is a button, `File › Open Example` a menu path and `F5` a key. The numbers on this page are checked by the tests of `crates/engine/tests/tutorial_dab.rs`, which run the same example. ## 1. Open the example Choose `File › Open Example › Isolated › Dual active bridge`. ![The File menu open at Open Example, Isolated, Dual active bridge, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/dual-active-bridge/01-open-example.png) The left bridge (legs `a` and `b`) sits on the 400 V bus `V1`, the right bridge (legs `c` and `d`) on the 200 V bus `V2`. Between them are the ammeter `AmL` (its output is the signal `iL`), the series inductance `Lk` and the 2:1 transformer `T1`. Above each bridge is its modulator: a 50 kHz carrier, an inverter for the second leg and a 100 ns dead time on each gate. The gate signals reach the switches by net label. The example's variables (`Circuit › Variables`) hold its whole design: | Variable | Value | What it is | |---|---|---| | `V1`, `V2` | 400 V, 200 V | the two buses | | `Nt` | 2 | the transformer ratio n | | `fsw` | 50 kHz | the switching frequency of both bridges | | `Lk` | 50 µH | the series inductance, referred to the primary | | `Phs` | 30 | the phase shift, in degrees, of the secondary's carrier behind the primary's | | `td` | 100 ns | the dead time | Both buses are sources, so the run measures the power a given shift moves; nothing regulates it yet. With n·V2 = V1 the inductor current is flat-topped and each switch turns on at zero voltage. ## 2. Run it Press `F5`. The run is 2 ms; the currents start at zero, so read everything after 1 ms (`scope.measure {"signals":["iL","i(V1)","i(V2)"],"t0":1e-3}`). - `iL` is a trapezoid of ±13.8 A peak, 12.6 A rms. - `i(V2)` averages to 4.43 kW into the 200 V bus, while the 400 V bus gives 4.46 kW. The 32 W between them heat the eight 20 mΩ switches. ![The scope after the run at 30 degrees, zoomed to 5 cycles: the inductor current i(Lk) is flat-topped, with its flat tops near +14 A and −14 A, just outside the ±10 A gridlines, marked 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/dual-active-bridge/02-run.png) The textbook power (De Doncker, Divan and Kheraluwala, 1991) is P = V1 · n·V2 · φ · (π − φ) / (2π² · fsw · Lk) with φ the shift in radians. At 30 degrees it gives 4.44 kW: the run and the formula agree within the dead time's and the switches' share. The power depends only on the shift, both voltages, the frequency and `Lk`, so `Lk` is chosen for the full power at a moderate shift. ## 3. A larger shift: more power, much more current Set `Phs` to 60, run, then 90, and read the same numbers: | `Phs` | Power out | Formula | `iL` peak | `iL` rms | Lost in the switches | |---|---|---|---|---|---| | 30 | 4.43 kW | 4.44 kW | 13.8 A | 12.6 A | 32 W | | 60 | 7.05 kW | 7.11 kW | 27.5 A | 23.5 A | 112 W | | 90 | 7.89 kW | 8.00 kW | 41.1 A | 32.7 A | 215 W | The power peaks at 90 degrees, where φ·(π − φ) is largest, but its last 30 degrees add little while the rms current, and with it the conduction loss, keeps climbing: most of that current only circulates between the two bridges. This is why a DAB is designed for its full power at a shift well below 90 degrees, and why a shift above 90 degrees moves less power, not more. ## 4. Send the power back Set `Phs` to −30 and run. Now the secondary leads: the 200 V bus gives 4.46 kW and the 400 V bus takes 4.43 kW, the formula's 4.44 kW in the other direction. The circuit did not change: only the sign of the shift. A battery on the 200 V side discharges into the bus this way. ![The scope after the run at −30 degrees, zoomed to 5 cycles, compared with Run 1: i(Lk) (solid) has the same flat tops near ±14 A as the 30 degree run (dashed), but its edges fall at other times: the current's phase has moved with the shift, marked 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/dual-active-bridge/03-reverse.png) ## 5. Design one from a spec `design.auto` draws a DAB when you name it, sizes `Lk` for the full power at 30 degrees from the lowest input, and closes a PI on the output that moves the shift (chapter 16 of the manual, "A dual active bridge"). Like the rest of Design › Automate, it runs on Voltecx Cloud. ```sh powercraft-cli run --cmd design.auto --params \ '{"spec":{"vin":[360,440],"vout":200,"iout":20,"ripple":2},"topology":"dab","fsw":"50k"}' ``` After the forward checks, the `reverse` stage runs copies of the finished circuit backwards at the lowest and the highest input: the load becomes a current source that feeds the full-load current into the output. The reply's `reverse.corners` gives, for each input, the output it held, the phase shift (negative: the power flows back) and the power that reached the input. A corner that misses the output tolerance is an open item, not a failed gate, since the spec asks for no reverse power. ## Try next - Set `V2` to 160 and run at 30 degrees: n·V2 is no longer V1, the current is no longer flat-topped: its peak rises while the power falls, so each kilowatt costs more rms current. - `threePortDab` adds a third bridge on the same core (`File › Open Example › Isolated`), and `threePortDabClosedLoop` closes a loop on each of its two shifts. Next: the [manual](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/15-examples/) lists the isolated examples, and [chapter 16](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/16-automatic-design/) the DAB template. --- # Long battery runs: a real pack charged in seconds URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/22-long-battery-run/ A real charge takes hours, and a switching run needs steps of a few µs: 1.5 hours of this charger would be about 2.7e9 steps. Here you open a charger with a real pack, charge it for 1.5 hours with `Simulation › Long Battery Run` in seconds of compute, then open a few milliseconds of switching at 30 minutes with `Simulation › Battery Run Switching Window` to see the ripple. About 10 minutes. Pictures: a numbered red box is what you click or read, `[Run]` is a button, `File › Open Example` a menu path. ## 1. Open the example Choose `File › Open Example › DC-DC › Battery charger: a 4.5 Ah pack over a 1.5 h run`. ![The File menu open at Open Example, DC-DC, Battery charger: a 4.5 Ah pack over a 1.5 h run, marked 1 to 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/long-battery-run/01-open-example.png) 1. `File`. 2. `Open Example`. 3. `DC-DC`. 4. `Battery charger: a 4.5 Ah pack over a 1.5 h run`. The pack `B1` is four Molicel INR-21700-P45B cells in series, with the values of the cell's data sheet (E-One Moli Energy, "Product Data Sheet, Model INR-21700-P45B", version 1.2): 4.5 Ah, charged at 4.5 A to 4.2 V a cell (16.8 V), over its standard charge time of 1.5 hours, 15 mΩ a cell. The sheet gives no rest voltage against charge, so the pack keeps the battery part's default table, which is illustrative. The synchronous buck and its two loops (a voltage PI that sets the current reference, a current PI) charge at constant current, then at constant voltage. The pack starts at 20 %. The circuit's own run is a 50 ms switching window. `Problems` notes `battery.longRun`: the pack is too large for anything to happen in 50 ms, and it suggests the long run. ## 2. The two menu items Open the `Simulation` menu. ![The Simulation menu with Long Battery Run and Battery Run Switching Window, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/long-battery-run/02-menu.png) 1. `Simulation`. 2. `Long Battery Run` (`simulation.batteryRun`): the whole charge, on the converter's averaged model. 3. `Battery Run Switching Window` (`simulation.batteryZoom`): a few milliseconds of the switching circuit, from where the long run left it. ## 3. Run the whole charge Choose `Simulation › Long Battery Run` and type the end time. ![The Long Battery Run form with End time 5.4k and the Run button, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/long-battery-run/03-run-form.png) 1. `Stop time`: `5400` (1.5 hours; the field shows `5.4k`). 2. `[Run]`. The other fields can stay empty. `Stop current` ends the run once the current falls to a charger's termination current, `Stop state of charge` at a state of charge, and `Largest charge step` is how far one jump may move the charge (1 %). How it works: the converter runs on its averaged model in short bursts until the battery's current settles. Between bursts time jumps ahead by seconds to a minute, and only the battery's charge moves, at the settled current. The controller's constant-current and constant-voltage logic is what each burst settles to. ## 4. Read the charge ![The scope after the long run: vbat rising to 16.8 V and holding, ibat at 4.5 A then falling, marked 1 to 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/long-battery-run/04-charge.png) 1. `vbat`: the pack voltage rises from 14.2 V to 16.8 V, then holds there. 2. `ibat`: 4.5 A of constant current, until about 2670 s (44 minutes), where the voltage reaches 16.8 V. Then the current falls, to 0.45 A (C/10) at about 3180 s with the charge at 99.4 %, and to under 1 mA at 1.5 hours. `soc`, under the two, rises from 20 % to full. The status bar reads `simulated 39674 steps, … ; battery B1 at 100.0 % charge after 5.4 ks`: 1.5 hours of charge in about 40 000 steps, which takes a fraction of a second. Each signal has samples only where the solver ran, so it is a straight line across each jump, and it never shows the switching ripple. ## 5. Open a switching window Choose `Simulation › Battery Run Switching Window`. ![The Battery Run Switching Window form with Start time 1.8k, Window length 0.005 and Run, marked 1 to 3](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/long-battery-run/05-zoom-form.png) 1. `Start time`: `1800` (30 minutes into the charge). 2. `Window length`: `0.005` (5 ms). 3. `[Run]`. The long run goes to 1800 s first. Then the switching circuit itself runs from the state it reached: the capacitor voltages, the inductor current, the pack's charge and the controllers' states carry over by name. ## 6. Read the ripple ![The scope of the switching window: vbat with its 10 kHz ripple near 15.9 V, ibat near 4.5 A, marked 1](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/img/en/long-battery-run/06-zoom.png) 1. `ibat`: the charge current, 4.5 A on average, with the 10 kHz switching ripple. `vbat` shows the ripple on the pack, about 20 mV near 15.9 V. The status bar reads `simulated 2752 steps, … ; battery B1 at 70.0 % charge after 1.8 ks; switching window from 1.8 ks`. The window's time axis starts at 1800 s. Its first samples hold a short current spike while the switching circuit takes over from the averaged state, so read the ripple after it. To run the same from a script or the console: ```text simulation.batteryRun {"tEnd": 5400} simulation.batteryZoom {"at": 1800, "span": 0.005} ``` Next: the [manual](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/04-simulation-settings/) describes every field of both commands, the accuracy checks and the limits. --- # LED drivers: constant current with PWM and analog dimming URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/23-led-drivers/ An LED wants a current, not a voltage, so an LED driver is a converter that holds a current and lets the string's voltage fall where it will. Here you open two drivers, size the first one with `Design › Design Steps › LED Driver`, see why 1 kHz PWM dimming is a flicker problem and 2 kHz is not, and then dim the second one two ways: the current itself (analog) and the share of time it flows (PWM). About 15 minutes. `File › Open Example` is a menu path and `F5` a key. The numbers on this page are checked by the tests of `crates/engine/tests/tutorial_led.rs`, which run the same examples. All LED values in the examples are illustrative: each LED is a 3 V threshold and 1 Ω straight line, not a part. ## 1. Open the buck driver Choose `File › Open Example › DC-DC › LED driver, buck with PWM dimming`. 48 V feeds a buck whose comparator `Hys` holds the LED current `iled` inside a band of ±50 mA around 0.7 A; no oscillator and no compensator are needed, the band sets the switching frequency. The string `LED1` is eight LEDs, so it sits near 29.6 V. A 1 kHz PWM `Dim` at half duty switches the reference to zero for half of each period, so the current flows in pulses. ## 2. Size it Choose `Design › Design Steps › LED Driver` and press `[▶ Run]` with every field empty: each input is read from the circuit (the list says which ones came from the circuit and which are defaults). The command is `design.ledDriver {"verify": true}`. - The switching frequency in regulation is 243 kHz: the inductor's volt-second balance over the band (Erickson and Maksimović, *Fundamentals of Power Electronics*, 3rd ed., §2.2). - The mean LED current with half-duty dimming is 0.349 A, and the verify run simulates the circuit and finds 0.349 A, with a peak of 0.75 A, the top of the band. - A pulse needs time to rise from zero, so a very short pulse never reaches regulation: the shortest dimming duty that does at 1 kHz is 1.7 %. ## 3. Flicker The same reply shows the flicker: 100 %, because the light goes fully off between pulses. IEEE Std 1789-2015 (Recommended Practices 1 and 2) allows a low-risk flicker of 0.08 times the frequency in percent, which at 1 kHz is 80 %, so the verify check `flicker` fails and the notes say so. Set `dimFreq` to `2k` and the reply reads low risk: above 1250 Hz the standard sets no limit, so the same pulses now pass. Dimming above 1250 Hz is the rule; the other way out is analog dimming, below. `apply` writes the design into the circuit in one history step, which `Edit › Undo` takes back. ## 4. Open the boost driver Choose `File › Open Example › DC-DC › LED driver, boost with analog and PWM dimming`. 12 V feeds a boost onto a string of ten LEDs near 33 V, so this one has to step up. A PI loop sets the switch's duty so `iled` follows the reference `Ifull·Adim` (`Ifull` 0.5 A, `Adim` 0.6). A series switch `Sdim` cuts the string off between dimming pulses; while it is open the loop's integrator is held and the output capacitor keeps the string's voltage, so each pulse starts at the regulated current. Press `F5`: the run is 20 ms, four periods of the 200 Hz dimming. ## 5. Two ways to dim Read `iled` in the middle of the last pulse, and its mean over the whole last period (`scope.measure`). | `Adim` | Held current in a pulse | Mean over a period (PWM at 0.5) | |---|---|---| | 0.6 | 0.307 A | 0.150 A | | 0.3 | 0.152 A | 0.075 A | Change `Adim` under `Circuit › Variables` and the current inside each pulse follows it: that is analog dimming, with no flicker added. Change `Ddim` and the share of time the current flows follows it instead: that is PWM dimming, and the mean is the duty times the held current. Both work together, as the table shows (half the duty on half the current is a quarter of the full current). The flicker of the PWM part is again 100 %, and at 200 Hz the low-risk limit is 16 %, so for a 200 Hz dimming the current should be dimmed with `Adim` and PWM kept above 1250 Hz. `design.ledDriver {"topology": "boost"}` reads this circuit, sizes `L1`, `Cout` and the loop gains (with the loop's phase margin against the right-half-plane zero) and, with `apply`, writes them and checks the mean current by simulation. Next: the [manual](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/) lists every field of `design.ledDriver`. --- # Wireless power transfer: a series-series link URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/24-wireless-power/ Two coils a few centimetres apart pass power through the air. Each coil alone is a poor transformer (the coupling factor `k` is far below 1), so each is tuned by a series capacitor to the switching frequency, and the pair behaves as a current source. Here you open the 85 kHz link, read the schematic, run it, then change the coupling (a misalignment of the pads), and detune one capacitor to see why resonance matters. About 15 minutes. `File › Open Example` is a menu path and `F5` a key. The numbers on this page are checked by the tests of `crates/engine/tests/tutorial_wpt_charger_mppt.rs`, which run the same example. All values are illustrative: the coils are 120 µH each with a quality factor of 300, not a product's pads. ## 1. Open the link Choose `File › Open Example › Isolated › Wireless power transfer, series-series`. A full bridge turns 50 V into a ±50 V square wave at 85 kHz (the nominal frequency of SAE J2954). The primary coil `L1` and the secondary coil `L2` are one coupled inductor `T1` with `k` = 0.2; each has its tuning capacitor (`C1`, `C2`) and its winding resistance (`Rc1`, `Rc2`). A diode bridge, 10 µF and a 10 Ω load make the output, on a secondary ground `sgnd` that is joined to the primary only by a 10 kΩ tie: the air gap is the barrier between the two halves of the drawing. Each capacitor is `1/((2π·f0)²·L)`, so each coil resonates at `f0`. Then the two self-inductances cancel and what is left between the sides is the transfer impedance `ω·M`, with `M = k·√(L1·L2)` (Wang, Covic and Stielau, *IEEE Trans. Industrial Electronics* 51(1), 2004): the secondary current is `V1/(ω·M)` whatever the load, so the link is an output current source. ## 2. Run it Press `F5`. Read `vout`, `i1` and `i2` over the last 34 periods (`scope.measure`, after the start-up): | `k` | Output `vout` | Primary peak `i1` | Secondary peak `i2` | Power out | Link efficiency | |---|---|---|---|---|---| | 0.2 | 31.1 V | 3.4 A | 4.9 A | 101 W | 96.4 % | The power out is the mean of `v2·i2` (the rectifier's input) and the efficiency is that over the mean of `vab·i1`, the power the bridge puts in: the coils' own resistance is the loss. ## 3. Misalign the pads Under `Circuit › Variables` change `k` and run again. A pad that is off centre couples less; a closer one couples more: | `k` | Output `vout` | Primary peak `i1` | Secondary peak `i2` | Power out | Link efficiency | |---|---|---|---|---|---| | 0.1 | 59.3 V | 12.6 A | 9.6 A | 361 W | 93.4 % | | 0.3 | 21.0 V | 1.5 A | 3.2 A | 47 W | 97.1 % | Halving `k` halves `ω·M`, so the secondary current doubles and the output voltage with it, because the link is a current source into a fixed load; the primary current rises faster still, since it is the output voltage over `ω·M`. That is why the efficiency falls with the coupling: the primary coil's resistance carries more current for each ampere delivered (Zhang and Mi, *IEEE Trans. Vehicular Technology* 65(6), 2016). A real system would regulate against it; this example has no loop. To sweep `k` in one call, use `analysis.paramSweep` with the variable `k`. ## 4. Detune a coil Set `Cs` under `Circuit › Variables` to `1.1/((2*pi*f0)^2*L2)`, a secondary capacitor 10 % too large, and run at `k` = 0.2. The output hardly moves, 102 W against 101 W, because the link is still a current source and the primary current adjusts. What changes is what the bridge sees: the secondary's reactance is reflected into the primary, so the primary current rises to 4.3 A peak (from 3.4 A) and lags the bridge voltage. The bridge's power factor, the power it puts in over the product of its rms voltage and rms current, falls from 0.90 to 0.74. A tuned link holds the 0.90 of a square wave (only its fundamental carries power) and lets the switches turn on at zero current; a detuned one needs more current for the same power and loses that. Real chargers keep the tuning by adjusting the frequency or a tuning stage. Next: [tutorial 25](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/25-battery-charger/) charges a battery from a converter, in constant current and then constant voltage. The [manual](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/) lists every command used here. --- # Battery charger: constant current, then constant voltage URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/25-battery-charger/ A lithium-ion pack is charged in two stages. While the pack is low the charger pushes a fixed current (CC); when the pack voltage reaches its limit the charger holds that voltage (CV) and the current tapers away. Here you open a buck charger with two nested loops, read the hand-over on the scope, and change the current limit to see when it moves. About 10 minutes. `File › Open Example` is a menu path and `F5` a key. The numbers on this page are checked by the tests of `crates/engine/tests/tutorial_wpt_charger_mppt.rs`, which run the same example. The pack is four cells with a capacity of 1 mAh, far smaller than any real pack: that makes the charge move in a fraction of a second instead of hours. For a real 4.5 Ah pack see [tutorial 22](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/22-long-battery-run/). All parameters are illustrative. ## 1. Open the charger Choose `File › Open Example › DC-DC › Battery charger, constant current then constant voltage`. A synchronous buck from 24 V charges four cells in series (`B1`, 15.3 V at 70 % charge). The inner loop makes the inductor current `il` follow a reference `iref`; the outer loop compares the filtered pack voltage with the target `Vcv` (16.6 V, 4.15 V a cell) and its PI gives `iref`, limited between 0 and `Icc` (5 A). While the pack is below the target the error is large and `iref` sits on its 5 A limit: constant current. Near the target the PI leaves the limit and the current falls: constant voltage. ## 2. Run it Press `F5` (0.6 s). Read `ibat` and `vbat` on the scope: - In the first 0.1 s the current is held at 5.00 A, the limit `Icc`. - The current reference `iref` leaves the limit at 150 ms: that is the hand-over from CC to CV. - In the last 50 ms the pack voltage is 16.61 V, held at the target, the current has tapered to 0.01 A, and the charge `soc` has reached 95.6 %. The current falls in CV because the pack's rest voltage keeps rising towards the target, so less and less current is needed to hold the terminal voltage. ## 3. Change the current limit Under `Circuit › Variables` set `Icc` to 2.5 and run again. The held current is now 2.50 A, and since the pack climbs to the target at half the rate, the hand-over moves from 150 ms to 330 ms. The end of the run shows 16.60 V and 0.01 A, with the charge at 95.5 %: a lower limit charges more gently but takes longer to reach the same state. Next: [tutorial 26](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/26-solar-mppt/) charges a battery from a solar array, with the converter finding the array's best operating point. The [manual](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/) lists every command used here. --- # Solar charger: perturb and observe URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/26-solar-mppt/ A solar array gives its most power at one voltage, and that voltage moves with the sunlight. A tracker (MPPT) finds it by trying: step the duty, see whether the power rose, and keep going the same way if it did. Here you open a boost charger with a perturb-and-observe tracker, watch it climb to the peak, and then cut the sunlight in half. About 15 minutes. `File › Open Example` is a menu path and `F5` a key. The numbers on this page are checked by the tests of `crates/engine/tests/tutorial_wpt_charger_mppt.rs`, which run the same example. All parameters are illustrative. ## 1. Open the charger Choose `File › Open Example › Renewable energy › Solar charger with MPPT`. Two 60-cell modules in series (each 38 V open circuit, 9.5 A short circuit, maximum power at 31 V and 9 A) feed a boost converter that charges a 104 V battery. The battery holds the output, so the duty sets the array voltage: `Vpv = Vbat·(1 − D)`. At standard test conditions the array's most power is `62 V · 9 A` = 558 W, which needs a duty near 0.40. ## 2. Read the tracker Every 5 ms the blocks `ZV` and `ZI` sample the array voltage and current and `Pw` multiplies them. `DV` and `DP` keep the previous samples, and the sign of `ΔP·ΔV` says which side of the peak the array is on: positive on the rising side, where the voltage must go up. A comparator turns that into 1 or 0 and a sampled integrator moves the duty by 0.01 in the right direction. The 5 ms period leaves the array's input filter time to settle between steps. ## 3. Run it Press `F5` (0.15 s). The duty starts at 0.29 and the sampled power `ps` first reaches 98 % of its final value at 55 ms. In the last 30 ms the array gives 557 W at 62.0 V, with a duty of 0.41, close to the 558 W and 0.40 expected from the ratings. The duty does not stop: it steps between three neighbouring values around the peak, which is the cost of tracking by trying. ## 4. Cut the sunlight Select `PV1` and set `irr` to 500 W/m², then run. The array now peaks lower, and the tracker settles at 279 W with a duty of 0.41; the array voltage is 61.8 V, close to the 62.0 V at full sun: the voltage of a cell depends on the light only by its logarithm, while the current is proportional to it. For a step, as a cloud would make, add a `Step` block (`circuit.addComponent`, kind `step`, `t0` = 0.06, `before` = 1000, `after` = 500), join its output to the `g` pin of `PV1` and run. The tracker follows the new peak within the run: in the last 30 ms the array gives 279 W, against 279 W for the run that started at 500 W/m². The [manual](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/) lists every command used here. --- # Tutorials URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/ Step-by-step lessons, each one a real run of Voltecx. Every picture is a screenshot of the current build, taken by a script that clicks through the same steps, and a test runs that script and checks its numbers, so a tutorial cannot drift from the program. How to read them: a red box with a number marks what you click, in that order. `[▶ Run]` is a button, `File › Open Example` a menu path and `F5` a key (`⌘` is Cmd on a Mac, Ctrl elsewhere). ## First result in 5 minutes New to power electronics or to Voltecx? Start in the app. The Start page shows a card, **First result in 5 minutes**. Click `[Start the guide]` and the Lessons view opens beside it with five steps. Each step names the command it waits for and moves on when that command runs, whether you click the step's own button, the toolbar or Properties: 1. Open the buck example (`file.openExample`): 48 V in, 12 V out at 5 A. 2. Run it (`simulation.run`): the scope shows the output voltage `v(VOUT)` and the inductor current `i(L1)`. 3. Read the waveform (`scope.measure`): `v(VOUT)` settles near 12 V, and `i(L1)` ripples by about 0.9 A peak to peak. 4. Halve the inductor (`circuit.setParam`): set `L1` to 50 µH. 5. Run again (`simulation.run`): the ripple of `i(L1)` about doubles, to about 1.8 A, while `v(VOUT)` stays near 12 V. `Skip this step` goes on without the command. `[Not now]` hides the card for good; the guide stays under `Lessons` in the activity bar. Tutorial 1 below walks the same circuit with pictures. ## Learning path | # | Tutorial | You learn | Time | |---|---|---|---| | 1 | [Getting started: your first buck converter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/01-first-buck/) | Open an example, simulate, read the scope, change a part, compare runs | 10 min | | 2 | [Closed-loop buck: design the compensator](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/02-closed-loop-buck/) | The Design panel, a PI and its limit, a Type III compensator, the verification | 15 min | | 3 | [Flyback: design the transformer](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/03-flyback-magnetics/) | Design Magnetics: core, turns, wire and gap from simulated currents | 10 min | | 4 | [Boost and buck-boost](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/04-boost-buck-boost/) | The boost example, the Converter design task, a circuit from a template | 15 min | | 5 | [Full-bridge inverter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/05-full-bridge-inverter/) | Sine PWM and dead time, the spectrum of the output, a fix from the Problems list | 15 min | | 6 | [Three-phase motor drive](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/06-motor-drive/) | Field-oriented control of a PM motor, the current and speed loop designs | 20 min | | 7 | [Digital control and C code](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/07-digital-control/) | Sampling delay, PWM resolution and limit cycles, fixed-point coefficients, code generation | 20 min | | 8 | [Thermal and losses](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/08-thermal-losses/) | Conduction and switching losses, the junction temperature, Design Thermal and a heatsink | 15 min | | 9 | [Conducted EMI](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/09-conducted-emi/) | A CISPR 32 pre-compliance estimate, an input capacitor, a damped input filter inserted for you | 15 min | | 10 | [Automatic design](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/10-auto-design/) | Design › Automate: a spec, the stages, the verdict and report, what to do when a gate fails | 15 min | | 11 | [The Test Bench](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/11-test-bench/) | One test case at a time, waveforms against their limits, a fix and two runs compared | 15 min | | 12 | [The AI assistant](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/12-assistant-mcp/) | The chat, a proposal you accept or reject, the same assistant in a terminal | 15 min | | 13 | [Python scripting](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/13-python/) | A parameter sweep in the app, the same sweep from Python, and a matplotlib plot | 15 min | | 14 | [Power factor correction](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/14-pfc/) | A boost PFC: its two loops, line current against line voltage, power factor and THD, a load step, a design from the mains spec | 20 min | | 15 | [LLC resonant converter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/15-llc/) | Design › LLC Tank from a spec, the gain curve, the zero-voltage check over frequency, an input step and a light load | 25 min | | 16 | [Grid-tie inverter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/16-grid-tie/) | PLL and current controller, line current against line voltage, THD and power factor; a three-phase dq loop from Auto Design, a PLL phase jump, active and reactive power steps, a grid sag | 30 min | | 17 | [Modular multilevel converter](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/17-mmc/) | The two arms of an MMC leg, the arm currents and the circulating current, the submodule capacitor voltages and their sorting, the output levels and THD, the circulating-current controller off against on | 30 min | | 18 | [Fast isolation: a SiC half bridge on fiber](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/18-fast-isolation/) | Gate signals on fiber across the barrier, the link budget, the delay of each edge, the isolation chosen by the switch node's dv/dt against each part's CMTI, a CMTI failure in Problems | 15 min | | 19 | [Tolerance and Monte Carlo](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/19-flyback-tolerance/) | A Monte Carlo of a flyback's output and peak current, the yield against limits, which part drives the spread, and a tighter part | 20 min | | 20 | [Operating modes](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/20-operating-modes/) | The intervals T1, T2… of one switching period on the timeline and the scope, the conducting path of each, playback limited to one mode, the table and one figure per mode for a paper | 10 min | | 21 | [Dual active bridge](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/21-dual-active-bridge/) | Power set by a phase shift: the run against the textbook formula, what a larger shift costs in circulating current, the power sent back with a negative shift, a DAB designed from a spec | 15 min | | 22 | [Long battery runs](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/22-long-battery-run/) | A real 4.5 Ah pack charged CC then CV over 1.5 hours in seconds with Simulation › Long Battery Run, then a 5 ms switching window at 30 minutes for the ripple | 10 min | | 23 | [LED drivers](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/23-led-drivers/) | Design › LED Driver on a hysteretic buck, the flicker of PWM dimming against IEEE Std 1789-2015, a boost driver dimmed by its current (analog) and by its duty (PWM) | 15 min | | 24 | [Wireless power transfer](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/24-wireless-power/) | A series-series link at 85 kHz: the tuned coils as a current source, the output and efficiency against the coupling, a detuned secondary and the bridge's power factor | 15 min | | 25 | [Battery charger](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/25-battery-charger/) | A buck charger's two loops: constant current held at its limit, the hand-over to constant voltage, the current taper, and a lower current limit | 10 min | | 26 | [Solar charger with MPPT](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/26-solar-mppt/) | Perturb and observe on a boost charger: the climb to the array's peak power, the duty that dithers around it, half the sunlight and a step in the sunlight | 15 min | ## Worked examples - Choosing the switching frequency with a sweep: a 48 V to 12 V, 10 A synchronous buck run at ten frequencies from 100 kHz to 1 MHz, with a data-sheet loss model and the inductor resized at each, to find the knee of the loss against inductor size. A script runs the sweep from the command line and pastes every number. Questions: see the [FAQ](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/faq/). The full reference is the [manual](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/). --- # FAQ URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/faq/ ## The scope is empty after I open a circuit. Nothing has run yet. Press `F5` or `[▶ Run]`. If the run finished and the plot is still empty, tick a signal in the scope's **Signals** list, or press `Shift+P` (Probe) and click a wire. ## Where did the scope go after a run? By default it opens in a window of its own, as PSIM opens SIMVIEW: each run you start opens the scope's window or brings it to the front. To keep it in the bottom panel instead, pick **Keep in the dock** under `Edit › Preferences › Simulation › After each run` (**Each plot in its own window** gives every plot a window). The dock icon at the window's top right puts the scope back in the bottom panel. ## A red message appeared in the status bar. The run was stopped by a problem in the circuit: a pin not wired, no ground, two ideal sources fighting. Click the message (or the **Problems** tab) for the list, what each one means and, often, a one-click **Fix**. [Manual, chapter 8](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/08-problems-and-fixes/) lists the common ones. ## The run is slow. Shorten the end time (`tEnd`) or raise the largest step (`maxStep`) in **Properties › Simulation** when nothing is selected, or choose variable step ([manual, chapter 4](https://voltecx-web.nguyenvanqui291.workers.dev/docs/manual/04-simulation-settings/)). Properties shows the step count before you run. ## How do I undo a design the Design panel applied? Press `⌘Z`. Every **Apply** is one undo step, so one undo restores all the values it changed. ## What does a "✖ Check failed" badge mean? The design was written, but the simulation that checks it missed a target. Open **Verification** to see which check failed and by how much; the line under it says what to change. [Tutorial 2](https://voltecx-web.nguyenvanqui291.workers.dev/docs/tutorials/02-closed-loop-buck/) walks through one. ## Can I run the same steps without the window? Yes. Every button runs an engine command, and `powercraft-cli run` runs a list of them; each tutorial ends with its script. The same commands are open to Python and to the built-in assistant. ## In which file format is my circuit saved? A `.voltecx` file, which is plain JSON text. `⌘S` saves it. If Voltecx closes before you save, it offers to restore your work at the next start. --- # Voltecx End-User Licence Agreement URL: https://voltecx-web.nguyenvanqui291.workers.dev/terms/ > **Draft — to be reviewed by a lawyer before public release.** > The licensor's legal entity name ("Tecxmate") is a placeholder until it is confirmed. Text in square > brackets is still to be confirmed. Sections 2 and 6 describe the paid tiers and the cloud service, which > are being built; they apply once those are released. Traditional Chinese version: [EULA.zh-Hant.md](https://voltecx-web.nguyenvanqui291.workers.dev/zh/terms/). If the two versions differ, the version stated in section 14 governs. Last updated: 2026-10-26. This agreement is between **Tecxmate** ("we", "us") and you, the person or organisation that installs or uses Voltecx ("you"). By installing, copying or using Voltecx you accept this agreement. If you do not accept it, do not install or use Voltecx. ## 1. What this agreement covers "Voltecx" means the Voltecx desktop application, the `powercraft-cli` command-line tool, the browser version, the documentation and examples that come with them, and every update we provide. It does not include third-party software, which is covered by section 9. ## 2. Licence grant We grant you a worldwide, non-exclusive, non-transferable, revocable licence to install Voltecx on devices you own or control and to run it, in object-code form only, for your own personal, educational or commercial purposes, including to design, simulate and analyse circuits for your work or your employer's work. ### Tiers, accounts and activation - **Free tier.** The Free tier needs no account, login or licence key, and it works offline. A Free installation makes no connection to us unless you turn on something that does (section 6). - **Pro.** Some features ("Pro features", listed in Voltecx under Help › Licence…) need a Pro licence that we issue to you under a separate order or subscription. Pro needs a Tecxmate account, a sign-in and an online activation. A licence is a signed file that Voltecx checks on your device. It names the licensee, is valid for a short period only, and is bound to your devices as described below. - **Daily refresh and offline grace.** While Voltecx can reach us, it renews the licence online about once a day. If it cannot reach us, Pro features that run on your device keep working for up to 30 days after the last successful renewal. Features that run on our servers (section 6) need a connection. - **Devices.** One seat may be active on up to 2 devices at the same time, and only on devices you own or control. To use a seat on another device, deactivate one of the two first, in your account or in Voltecx. - **Enterprise and air-gapped sites.** For customers who agree on it in a separate order, we can issue offline licence files that Voltecx verifies without contacting us, so that a site with no internet connection can use Voltecx. The order sets the term, the number of seats and any limits. - **When a licence ends.** When a licence ends, or the offline grace has passed, its Pro features stop and Voltecx continues to work as the Free tier. Circuits and other files you saved stay yours and still open in the Free tier, even when you made them with Pro features. ## 3. Restrictions Unless we agree in writing, you must not, and must not let anyone else: 1. reverse engineer, decompile, disassemble or otherwise try to obtain the source code, algorithms, models or file-format internals of Voltecx, except to the extent that applicable law expressly permits this despite this limit; 2. copy Voltecx, except for one backup copy and the copies needed to install it on your own devices; 3. redistribute, publish, lend, lease, rent, sell, resell, sublicense or otherwise make Voltecx available to others, whether free or for payment, alone or inside another product or service; 4. modify Voltecx or create derivative works from it; 5. remove, hide or change any copyright, trademark, licence or attribution notice; 6. circumvent any technical measure that protects Voltecx, or use Voltecx in breach of applicable law; 7. use Voltecx, its cloud services or their outputs to develop, train, improve or benchmark a product or service that competes with Voltecx, including any machine-learning model, or let anyone else do so; 8. access the cloud services by automated means to collect outputs in bulk, for example with scripts that send large numbers of systematically varied requests, or get around the limits that apply to your licence; 9. publish benchmark results or other comparisons of Voltecx with other products or services without our prior written consent. You may share circuits, results and documents that you create with Voltecx (see section 5) without restriction from us. Using outputs in your own engineering work is allowed (section 5). Items 7 and 8 are about copying the service, not about using its results, and item 9 limits only publishing comparisons, not the benchmarks you run for your own engineering work. ## 4. Ownership Voltecx is licensed, not sold. We and our licensors own all rights, title and interest in Voltecx, including all copyright, trademarks (including the names Voltecx and Tecxmate and the logos) and other intellectual property. This agreement gives you no right to our trademarks. All rights not expressly granted are reserved. If you send us feedback or suggestions, you allow us to use them without payment or restriction. ## 5. Your files Circuits, models, waveforms, exports and other files you create or open with Voltecx belong to you (or to whoever owned them before). We do not claim any right in them. Voltecx stores them on your device, and we do not receive them, except as described in section 6. ## 6. Cloud features and your data Voltecx is local software. This section lists everything that leaves your device, when, and where it goes. Our privacy notice ([PRIVACY.md](https://voltecx-web.nguyenvanqui291.workers.dev/privacy/)) gives the details and your rights. **6.1 What stays on your device.** Circuits, models, waveforms, exports and other files stay on your device. We receive a circuit, a file or a value only in the cases below, and only when you use that feature. **6.2 Cloud features (Pro).** The AI assistant and automatic design (Design › Automate) run on servers that we operate. They need a Pro licence and a connection, and they use credits that are metered per account. When you use them: - *To Tecxmate:* your sign-in, your licence and device activation data (the licence identifier, a device identifier that is a hash, and the app version), and what we need to meter and bill use (credits, token counts, timings, tool names and error codes). - *AI assistant:* your conversation and the circuit data needed to answer (for example the parts, parameters, simulation results and the files you let it read) are sent from your device to Tecxmate, and from Tecxmate to Anthropic, which provides the AI model. Our servers keep a conversation in memory only while it runs and do not write its content to a database or a log. - *Automatic design:* the specification you enter is sent. Your open circuit is not. The result comes back and opens in a new tab. - *Anthropic:* we send Anthropic only what it needs to answer. Anthropic works for us as a service provider and processes the data under its terms with us. We do not allow Anthropic to use it to train models [to be confirmed against our agreement with Anthropic before release]. Inference may run outside Taiwan, for example in the United States. - *Your choice to send more:* if you choose "send this conversation to support", we keep it encrypted for up to 30 days to help you, and then delete it. *Fair use and limits.* Each licence has rate limits and daily or monthly limits on the cloud services, which depend on your plan. When a limit is reached, Voltecx tells you which limit it is and when it resets. To protect the services from bulk extraction, we record for each request: when it was made, which service it used, and a one-way hash of the request. We do not record the request itself. Our systems look for patterns of automated bulk use and alert our staff, who review them. No automatic decision is taken against your licence because of these patterns. If we have concerns, we contact you first, except where the use clearly breaks section 3. *Output identifiers.* Each output of a cloud service carries an identifier linked to your licence, so that we can recognise our outputs if they are copied. It contains no personal data. **6.3 Your own Anthropic account (Enterprise only).** Only Enterprise customers can use their own Anthropic key, or Claude through their own cloud provider contract, with an on-premises Voltecx server. In that case your data goes to your provider under your agreement with them, bills come from them, and nothing reaches Tecxmate. Free and Pro cannot use their own key. **6.4 Anonymous statistics and crash reports (opt in).** They are off until you agree in the question that Voltecx asks the first time you start it. You can change your answer at any time in Preferences, under Privacy, where you can also see everything that is waiting to be sent. If you agree, Voltecx sends the app version, your operating system, the names of the commands you use, whether a simulation worked and roughly how long it took, and, after a crash, where in the program it happened. It never sends circuits, file names, parameter values, specifications or conversations with the AI assistant. The browser version of Voltecx and the Voltecx website may use website analytics, as the website says. **6.5 Problem reports.** Help › Report a Problem… shows you the report before anything is sent, and sends it only after you confirm. It leaves out file paths and user names. **6.6 Offline sites.** Voltecx with an offline licence file (section 2) and a Free installation without statistics make no connection to us. **6.7 AI output.** Output from an AI model may be wrong. Check any design, value or advice before you rely on it. ## 7. Updates We may provide updates, which are covered by this agreement unless they come with their own terms. We do not have to provide updates, support or new features. ## 8. Warranty disclaimer Voltecx is provided "as is" and "as available". To the fullest extent permitted by law, we give no warranty of any kind, express or implied, including any warranty of merchantability, fitness for a particular purpose, accuracy, non-infringement or uninterrupted or error-free operation. Simulation results are estimates from mathematical models. They can differ from real hardware. Voltecx is a design aid and not a substitute for engineering judgement, testing and certification. You are responsible for checking results before you build, sell or operate anything. Do not use Voltecx as the only safeguard in any system where a failure could cause injury, death or serious damage to property or the environment. ## 9. Third-party software Voltecx includes third-party software and assets. They are licensed under their own terms, which are listed in ATTRIBUTION.md and NOTICE and are not changed by this agreement. Nothing in this agreement limits your rights under those terms. ## 10. Limitation of liability To the fullest extent permitted by law, we and our licensors are not liable for any indirect, incidental, special, consequential or punitive damages, or for loss of profit, revenue, data, goodwill or business, arising from or related to Voltecx or this agreement, even if we were told of the possibility. Our total liability for all claims is limited to the amount you paid us for Voltecx in the twelve months before the claim. Nothing in this agreement excludes or limits liability that cannot be excluded or limited by law, including liability for intentional misconduct or gross negligence, and your rights under mandatory consumer-protection law. ## 11. Termination This agreement lasts until it ends. It ends automatically if you breach it. You may end it at any time by uninstalling Voltecx and deleting all copies. When it ends, you must stop using Voltecx and delete all copies. Sections 3, 4, 8, 10, 11, 13, 14 and 15 continue after it ends. We may suspend cloud access for a licence that breaks section 3, items 7 or 8, while we review the case with you. ## 12. Changes to this agreement We may change this agreement for future versions of Voltecx. A change applies to a version only when you install or update to that version. The version that came with your copy keeps applying to that copy until then. ## 13. Governing law This agreement is governed by the laws of Taiwan (Republic of China), without regard to its conflict of law rules. ## 14. Courts and language The Taipei District Court of Taiwan is the court of first instance with exclusive jurisdiction over any dispute arising from this agreement, to the extent the law allows this choice. If you are a consumer, this does not remove any right you have under mandatory law to bring a claim in another court. If the English and Traditional Chinese versions differ, the Traditional Chinese version governs for users in Taiwan and the English version governs for everyone else. ## 15. Confidentiality "Confidential information" means the Voltecx software (its object code and anything in it that is not published), documentation we have not made public, its file-format internals, how the cloud services work and behave, and any pre-release, beta or evaluation build, together with anything else we tell you is confidential. It does not include information that is or becomes public without a breach of this agreement, that you already lawfully had without a duty of confidence, or that you develop on your own without using our confidential information. Your circuits, files and results (section 5) are not our confidential information. They stay yours, and this section does not limit what you do with them. You must: 1. keep our confidential information confidential, and protect it with at least the care you use for your own confidential information and never less than reasonable care; 2. use it only to use Voltecx under this agreement; 3. give access to it only to people who need it for that use and who are bound by this agreement, or by written duties of confidentiality at least as strict, such as your employees and contractors; you are responsible for what they do with it; 4. tell us without delay if you learn of any use or disclosure of it that this agreement does not allow. You may disclose confidential information when a law, court or authority requires it, only as much as is required, and after telling us first where the law allows. These duties continue after this agreement ends. When it ends, you must delete or return our confidential information, except copies that the law requires you to keep, which stay confidential. *Remedies.* A breach of section 3 or of this section may cause us harm that money alone cannot put right. In addition to damages and any other remedy, we may therefore ask a court for an injunction or other interim relief to stop or prevent the breach. ## 16. General If a part of this agreement is held unenforceable, the rest stays in force. Not enforcing a right now does not waive it later. You may not assign this agreement without our written consent. This agreement, together with LICENSE and NOTICE, is the whole agreement between you and us about Voltecx. ## 17. Contact Legal questions: write to Tecxmate at the contact address published on the Voltecx website (contact address to be added before public release). --- # Voltecx Privacy Notice URL: https://voltecx-web.nguyenvanqui291.workers.dev/privacy/ > **Draft — to be reviewed by a lawyer before public release.** > The name of the party responsible for your data ("Tecxmate") is a placeholder until the legal entity is > confirmed. Text in square brackets is still to be confirmed. The paid tiers and the cloud service > described here are being built; the notice applies to each part once it is released. Traditional Chinese version: [PRIVACY.zh-Hant.md](https://voltecx-web.nguyenvanqui291.workers.dev/zh/privacy/). If the two versions differ, the version stated in section 14 of the [EULA](https://voltecx-web.nguyenvanqui291.workers.dev/terms/) governs. Last updated: 2026-10-30. This notice explains what personal data **Tecxmate** ("we", "us") collects when you use Voltecx, why, how long we keep it and what you can ask us to do. It follows Taiwan's Personal Data Protection Act (個人資料保護法, "PDPA"), including the notice that Article 8 of the Act requires. Section 6 of the [EULA](https://voltecx-web.nguyenvanqui291.workers.dev/terms/) says what leaves your device and when; this notice gives the detail. ## 1. In short - The **Free tier** needs no account. It collects **nothing** unless you choose to send something. - **Anonymous statistics and crash reports** are **off** until you agree. You can see exactly what they contain and turn them off at any time. - Your **circuits, file names, parameter values, specifications and conversations** are never part of statistics. A local crash report has paths, user names, quoted text and tokens taken out, but it keeps a shortened copy of the program's own error message, so you read it before deciding to send it. - **Pro** needs an account. The cloud features (AI assistant, automatic design) send the content they need to our servers while you use them. We do not store that content. - **Validation data** (a comparison of a simulation with your lab measurement) is sent only if you tick the consent box in the share dialog, and the circuit only if you tick a second box (section 6). - We do not sell your data and we do not use it for advertising. ## 2. Who is responsible, and how to reach us Tecxmate (a placeholder name) is the party that collects and uses the data described here. Write to us at [contact address and email to be added before public release] for any question about this notice and for the requests in section 10. ## 3. What we collect, why and on what basis | Data | When | Why (purpose) | Basis | |---|---|---|---| | Account: email address, name, organisation, seat and role | You create a Pro or Enterprise account | Run your account, licence and seats | Contract | | Licence and devices: licence identifier, a device identifier (a hash, not the machine's name), app version (build id), the operating system (macOS, Windows or Linux), the result of the app's integrity self-check (or that it was not checked), times of activation and renewal | You activate or renew a Pro licence | Check that you hold a licence, enforce the limit of 2 devices per seat, support | Contract | | Licence abuse checks: the country and network (autonomous system number) your network address belongs to, the device identifier, the kind of event (sign-in, renewal, cloud call), app build id and times. The address itself is used only to look up the country and network and is then dropped; it is never stored or logged [owner review, #350] | You sign in, renew a licence or use a cloud feature | Detect a licence shared or resold beyond its seats (for example sign-ins from two countries too close in time); a licence can be held for review or its renewal refused, and you can ask us to look again (section 2) | Contract and our legitimate interest | | Billing: plan, invoices, credits bought and used. The payment provider handles your card; we do not see the card number | You buy a plan or credits | Charge, issue invoices, meet tax and accounting law | Contract and legal duty | | Usage records: credits used, token counts, timings, names of tools, error codes — never the content | You use a cloud feature | Meter and bill the feature, find faults, keep the service safe | Contract and our legitimate interest | | Content you send to a cloud feature: your conversation with the AI assistant and the circuit data it needs, or the specification for automatic design | You use that feature | Produce the answer | Contract | | Support conversation (only if you choose "send this conversation to support") | You choose it | Help you | Your consent | | Problem report (only if you press Send after reading it) | You choose it | Fix the problem | Your consent | | Anonymous statistics and crash reports (section 4) | Only after you agree | Learn which features are used and where the program crashes | Your consent | | Validation data you choose to share (section 6) | You tick the consent box and press Send | Publish how closely each model matches real benches | Your consent | | Website analytics on our website and the browser version [only if enabled; the website says so and asks first] | You visit | Understand how the site is used | Your consent | We do not ask for more than we need. If you do not give us the data a feature needs, that feature cannot work; the Free tier still does. ## 4. Anonymous statistics and crash reports **They are off until you agree.** The first time you start Voltecx it asks, with two buttons and no box ticked in advance. Until you answer, and whenever your answer is no, Voltecx records nothing, saves nothing and sends nothing. You can change your answer in Preferences, under Privacy. When we add a new kind of statistics, Voltecx asks again: on 2026-10-22 the first steps below were added, so a "yes" given before then is asked again and nothing is recorded until you answer. **What they contain.** Only these items, and each is limited to a fixed list: - the day (not the time), the app version and your operating system (macOS, Windows, Linux or other); - the names of the Voltecx commands you used, from Voltecx's own command list, and how many times; - whether a simulation worked or failed, and how long it took in a coarse step (under 1 second, under 10 seconds, under 1 minute, under 10 minutes, longer); - after a crash: the place in the program's own source code where it happened (a file name such as `crates/engine/src/lib.rs` with a line number), and the names of Voltecx's own functions that were running; - the first steps of a new user, each once per installation: the first start with statistics on, the first part placed, the first simulation that finished, the first answer from the AI assistant and the first report. Only the name of the step is sent, never what was placed, simulated, asked or reported. To count each step once, Voltecx notes the steps already sent in its settings file (`telemetry.json`); turning statistics off deletes that note. **What they never contain.** Circuits, file names, folder names, user names, paths under your home folder, parameter values, specifications, the text of any error or crash message, conversations with the AI assistant, or any account or licence identifier. There is no install identifier: events from one installation cannot be linked to each other or to you. Voltecx builds them from fixed lists of ids, so free text cannot be added by mistake. **Every field an event can have.** Each event is one line of data with only the fields below. Voltecx is tested against this list: a field that is not on it cannot be sent. | Field | In events | What it holds | |---|---|---| | `type` | `start` `command` `simulation` `crash` `milestone` | The kind of event: `start`, `command`, `simulation`, `crash` or `milestone` | | `day` | `start` `command` `simulation` `crash` `milestone` | The day, as year-month-day | | `version` | `start` `command` `simulation` `crash` `milestone` | The app version, such as 1.2.0 | | `os` | `start` `command` `simulation` `crash` `milestone` | The operating system: `macos`, `windows`, `linux` or `other` | | `count` | `start` `command` `simulation` | How many times it happened that day | | `id` | `command` | The name of a command from Voltecx's own command list | | `ok` | `simulation` | Whether the simulation worked (true or false) | | `duration` | `simulation` | How long it took: `lt1s`, `lt10s`, `lt1m`, `lt10m` or `gte10m` (under 1 second, 10 seconds, 1 minute, 10 minutes, or longer) | | `location` | `crash` | A file and line in Voltecx's own source code, or "external" when it is outside it | | `frames` | `crash` | Up to 40 names of Voltecx's own functions | | `step` | `milestone` | The first step reached: `firstLaunch`, `firstPart`, `firstSimulation`, `firstAiTurn` or `firstReport` | **Local crash reports (desktop app).** Separately, when you turn on "Keep a crash report when the app crashes" in Preferences, a crash leaves a report on your computer only. It holds the app version, your operating system, the program's error message cut to 200 characters with quoted text, values in brackets, licence or update tokens and long codes taken out, the place in the source code, the names of Voltecx's functions that were running, and the names (never the parameters) of the last commands, with paths and user names removed. Voltecx cannot promise that the shortened message never holds a fragment of what you were working on, so on the next start it opens the report in Help › Report a Problem… for you to read, and nothing is sent unless you send it. The circuit is not included unless you tick "Include the circuit file". Our relay files each kind of crash once, as an issue in our private issue tracker, and counts later reports of the same crash (the same place in the source code and the same Voltecx functions) in that issue instead of filing them again. **Problem reports and feedback.** Help › Report a Problem… and Help › Send Feedback… send only what you read and confirmed, when you press Send. Our relay (a Cloudflare Worker that we run) takes out paths, user names, email addresses and credentials a second time, files the text as an issue in our private issue tracker on GitHub, and keeps neither your network address nor a copy of the text. If you tick "Attach a screenshot of the Voltecx window", the picture shows whatever that window shows, your circuit included: the relay keeps it for 90 days for the Voltecx team only and then deletes it. An email address you give for a reply is kept by the relay for 90 days, only to reply to you, and is never put in the issue. **You can see all of it.** Events wait in a file in Voltecx's settings folder (`telemetry-queue.json`) before they are sent. Preferences › Privacy › "Show what is sent" lists exactly what is waiting, and a button deletes it. Turning statistics off deletes the file. **How they are sent.** In batches of at most 100 events, over an encrypted connection, to an address [to be added] that this build of Voltecx was made with. A build with no address never sends anything. If the server cannot be reached, events wait in the file; the oldest are dropped after 500, and no error is shown. Our relay sees your network address when a batch arrives, as every server does. It does not store it or log it: it uses a hash of it, mixed with a random value that is never stored, only in memory to limit how often one sender can send. It keeps only daily counts (how many times each command ran, each simulation outcome, each crash place, each first step), never the events themselves. The desktop app does not use website analytics. ## 5. What leaves your device in the cloud features Only when you use them, and only what they need: - *AI assistant:* your conversation and the circuit data needed to answer go to our servers and from there to Anthropic, the provider of the AI model. Our servers keep the conversation in memory while it runs (and drop it after it has been idle for about two hours); they do not write it to a database or a log. - *Automatic design:* the specification you enter goes to our servers. Your open circuit does not. - *Partner device models:* when Automatic design picks a part whose model a device maker gave us under an agreement, we add one to a count for that part, month and country. The count holds no account, organisation, specification or circuit, and we show a device maker only counts of 5 or more. - *Enterprise with your own provider:* your content goes to your provider under your agreement with them and not to us. Our logs hold identifiers, sizes, token counts, timings, tool names and error codes. They never hold the content of a conversation, a circuit or a specification. ## 6. Validation data you choose to share > **Draft — the consent wording is pending the owner's review (#350).** After you compare a simulation with a lab measurement (File › Import Measurement), the window offers **Share this validation with Voltecx…**. It helps us publish how closely each model matches real benches, not only ours. **Nothing is sent unless you tick the consent box in its dialog**, which starts unticked; Send stays grey until you do. The dialog shows the exact text that will be sent before you send it. The command behind it is `validation.share`. **What is sent.** Only these items: - the Voltecx version and the solver (fast or reference), which together name the device models used; - the kinds of components in the circuit and how many of each (for example 2 MOSFETs, 1 inductor), not their names or values; - a fingerprint of the circuit (a SHA-256 hash of the circuit file). It tells repeated uploads of one circuit apart; the circuit cannot be rebuilt from it. The dialog shows it; - the topology you pick (buck, boost, flyback, … or other); - if you fill them in, the operating point (input and output voltage and current, power, switching frequency, duty, ambient temperature, load) and the instrument (scope model, file format, and per probe its model, bandwidth, attenuation and accuracy); - per compared signal, its name (such as `v(out)`), the number of samples and summary numbers: the errors (relative RMS, RMS and largest), the mean, peak-to-peak and ripple of both traces, gain, offset, correlation and the match rating (good, fair or poor); - the length of the compared time window; - the circuit file itself, **only if you also tick the separate "Also send the circuit" box**, which starts unticked. **What is never sent.** Your network address, account, licence identifier, a device or install identifier, file or folder names, the circuit (unless you tick the second box), and the waveforms themselves: only the summary numbers above leave your device, never the measured or simulated samples. The upload is made without signing in. **Where it goes.** The upload waits in a folder in Voltecx's settings folder (`validation-queue/`) until it is sent, over an encrypted connection, to our server. If you are offline, it waits and Voltecx tries again every hour; at most 50 wait at once. Our server sees your network address when an upload arrives, as every server does; it does not store it (the rate limiter keeps only a salted hash in memory). The server stores the upload with the day it arrived (not the time) in our database [hosting as in section 7]. **Who sees it.** Our staff review each upload and accept or reject it. Only accepted uploads count, and only in aggregate: for each Voltecx version, solver, topology and kind of signal (voltage, current, power), the number of uploads and the median and 90th percentile of the relative RMS error. A group with fewer than 3 accepted uploads is not published, so one bench's numbers are never shown alone. The circuit, when you sent it, is seen only by our staff and is never published. **Withdrawing it.** Before it is sent, delete the files in `validation-queue/`. After it is sent, write to us at the address in section 2 with the circuit fingerprint (`sha256:…`) shown in the dialog, and we will delete the uploads with that fingerprint. Since an upload carries no identifier of you, the fingerprint is how we find it. ## 7. Who receives data - **Anthropic** (the AI model), for the AI assistant. It acts for us as a service provider. We do not allow it to train models on your content [to be confirmed against our agreement with Anthropic]. - **Hosting.** Our servers and database run in Google Cloud in Taiwan (asia-east1) [to be confirmed]. - **Payment provider** [name to be added], for payments. - **Authorities,** when the law requires it. To find the country and network of an address we use the DB-IP Lite databases, which run on our own server; no data is sent to DB-IP. IP Geolocation by [DB-IP](https://db-ip.com), licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). We do not sell personal data and do not share it for advertising. ## 8. Transfers outside Taiwan AI inference by Anthropic may run outside Taiwan, for example in the United States. Only the content of your AI assistant conversation goes there, only while you use it. We take the steps the PDPA requires for such transfers. Your payment provider may also process data outside Taiwan. ## 9. How long we keep data | Data | Kept | |---|---| | Account, licence and device data | While your account exists, then deleted on request or [after a period to be set] | | Usage records (no content) and invoices | [7 years], because accounting and tax law require invoicing records; then deleted | | Conversations and specifications for cloud features | Not stored; in memory while the session runs | | "Send this conversation to support" copies | Encrypted, up to 30 days, then deleted | | Screenshots you attached to feedback, and an email address you gave for a reply | 90 days on our relay, then deleted | | Licence abuse check events (country, network, device identifier, kind, time) | 30 days, then deleted; per-day counts, the signals that fired and the licence's score are kept while the licence exists [owner review, #350] | | Statistics and crash reports | Daily counts for up to 400 days, with no identifier in them | | Statistics waiting on your device | Until sent, deleted, or dropped after 500 events | | Validation data you shared | [Period to be set], or until you ask us to delete it (section 6) | | Validation data waiting on your device | Until sent or deleted; at most 50 uploads wait | ## 10. Your rights Under Article 3 of the PDPA you can ask us to: - tell you whether we hold data about you, and let you read it; - give you a copy; - add to it or correct it; - stop collecting, processing or using it; - **delete it.** Write to us at the address in section 2. We may ask you to show who you are. We answer within the periods the Act sets; where the Act allows a fee for copies, we will tell you before we charge it. When we delete an account, we keep only what the law requires us to keep, such as invoices, and delete the rest. Anonymous statistics carry no identifier, so we cannot find your events in them; to stop them, turn them off in Preferences. Shared validation data is found by its circuit fingerprint (section 6). If you think we handled your data wrongly, you can also complain to the competent authority. ## 11. Security Connections to our servers use TLS. Signing keys and service keys are held in a secret manager. Your settings folder holds the statistics files and your licence with file permissions that only your user account can read. Please keep your own device secure as well. ## 12. Children Voltecx is made for engineers and students. Please do not create a Pro account if you are under 18 without a parent or guardian. ## 13. Changes If we change this notice in a way that matters to you, we will say so in Voltecx and on our website before the change applies, and the date above will change. We ask for your consent again if a change needs it, as for any new kind of statistics. ## 14. Contact [Contact address and email to be added before public release.] --- # Getting started URL: https://voltecx-web.nguyenvanqui291.workers.dev/docs/getting-started/ Then follow the tutorials, or keep the manual open beside the app.