# 5. The 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(<part>.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.
