Scope
SinksThe uPlotDisplay block (Scope) provides a hardware-accelerated real-time multi-channel digital oscilloscope directly on the simulation canvas. Built on the lightweight, high-performance uPlot rendering engine, it visualizes continuous and discrete time-series waveforms as well as parametric XY trajectories with negligible CPU overhead. The block supports multiple simultaneous signal inputs, flexible time windows (rolling live tail, expanding span, or full simulation), configurable frame refresh throttling, level/edge triggering, and automated statistics computation (minimum, maximum, mean).
Mathematical Model
The block acts as an observation sink probe. At simulation time , incoming scalar or vector signals are appended to high-speed circular SharedArrayBuffer time-stamped records:
The visible time interval depends on viewportMode:
where is windowDuration.
When downsampling is required to display within maxPoints (), the renderer partitions the buffer into uniform temporal buckets and extracts min-max envelope pairs, ensuring that transient oscillatory spikes and zero-crossings are never lost:
When triggerEnabled = true, the display synchronizes its horizontal window origin to level crossings:
Inputs & Outputs
| Direction | ID | Label | Type | Status |
|---|---|---|---|---|
| → In | signal |
Signal | number | Required |
Parameters
| Parameters | Label | Type | Default | Description |
|---|---|---|---|---|
title |
Title | text | Signal Plot |
|
viewportMode |
Time window | select | expanding |
|
windowDuration |
Window duration (s) | number | 10 |
|
renderMode |
Update mode | select | timebased |
|
updateFrequencyHz |
Refresh rate (Hz) | number | 10 |
How often the plot updates visually when in Time-based mode. |
maxPoints |
Max display points | number | 500000 |
Limit the number of points drawn to prevent performance drops. |
useAutoY |
Auto-scale Y-axis | boolean | true |
Automatically adjust the Y-axis to fit all visible data. |
yMin |
Y-axis minimum | number | -1 |
|
yMax |
Y-axis maximum | number | 1 |
|
lineWidth |
Line width | number | 2.5 |
|
showGrid |
Show grid | boolean | true |
|
showLegend |
Show legend | boolean | false |
|
showPoints |
Show points | boolean | false |
|
showStatistics |
Show statistics | boolean | false |
Display min, max, and mean values. |
triggerEnabled |
Trigger | boolean | false |
Stabilise periodic waves by aligning the window to a level crossing (time-domain, rolling only). |
triggerSource |
Trigger source (signal index) | number | 0 |
Which input signal triggers (0 = first). |
triggerLevel |
Trigger level | number | 0 |
Amplitude threshold for the trigger crossing. |
triggerEdge |
Trigger edge | select | rising |
Detect crossings on the rising or falling edge. |
xyXChannel |
XY: X signal index | number | 0 |
In XY mode, which input signal is the X axis (0 = first). |
xyYChannel |
XY: Y signal index | number | 1 |
In XY mode, which input signal is the Y axis. |
Usage Examples
Example 1: Multi-Channel Control Setpoint Tracking and Actuator Saturation
Monitoring closed-loop motor velocity control. Connecting the reference setpoint, actual velocity feedback, and control effort to the multi-input signal port. Setting viewportMode = "rolling" with windowDuration = 5.0 s and showLegend = true provides a real-time sliding trace showing transient settling and control saturation.
Example 2: Lissajous Phase Trajectory in XY Mode
Visualizing the phase relationship between two quadrature signals (, ). Setting renderMode = "xy", xyXChannel = 0, and xyYChannel = 1 transforms the time-series scope into a phase-plane display showing a circular trajectory.
Remarks & Best Practices
- Zero-Copy SharedArrayBuffer (SAB): In supported browsers, data retrieval bypasses JavaScript heap serialization, streaming samples directly from the WebAssembly worker memory to WebGL canvas context.
- Envelope-Preserving Downsampling: Even under aggressive buffer decimation, min-max bucket extraction ensures that high-frequency noise spikes and limit cycles remain visible.
- Multiple Signal Multiplexing & Navigation: Accepts multiple wire connections as independent colored traces. Double-clicking resets axis zoom, and dragging across a region magnifies that time window.
Related Components
- XYPlot: Dedicated animated phase-plane trajectory plotter with fading trail memory.
- NumericDisplay: Real-time digital LCD scalar readout.
- ScatterPlot: Point-cloud accumulator for bivariate statistical distributions.
- SignalGenerator: Periodic waveform generator for scope testing.