ƒ

Scope

Sinks
Run the live example Free · no sign-up · runs in your browser

The 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 tkt_k, incoming scalar or vector signals u(tk)=[u0(tk),u1(tk),…,uM−1(tk)]T\mathbf{u}(t_k) = [u_0(t_k), u_1(t_k), \dots, u_{M-1}(t_k)]^T are appended to high-speed circular SharedArrayBuffer time-stamped records:

Dk={(ti,u(ti))  |  i=max⁡(0,k−Nbuf+1),…,k}\mathcal{D}_k = \left\{ \left(t_i, \mathbf{u}(t_i)\right) \;\middle|\; i = \max(0, k - N_{\text{buf}} + 1), \dots, k \right\}

The visible time interval [tstart,tend][t_{\text{start}}, t_{\text{end}}] depends on viewportMode:

[tstart,tend]={[max⁡(0,tk−Tw),tk],viewportMode=rolling[0,min⁡(tk,Tmax⁡)],viewportMode=expanding[0,Tsim],viewportMode=full[t_{\text{start}}, t_{\text{end}}] = \begin{cases} [\max(0, t_k - T_w), t_k], & \text{viewportMode} = \text{rolling} \\ [0, \min(t_k, T_{\max})], & \text{viewportMode} = \text{expanding} \\ [0, T_{\text{sim}}], & \text{viewportMode} = \text{full} \end{cases}

where TwT_w is windowDuration.

When downsampling is required to display within maxPoints (Pmax⁡P_{\max}), 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:

ybucket,j=[min⁡ti∈Δtjum(ti),  max⁡ti∈Δtjum(ti)]y_{\text{bucket}, j} = \left[ \min_{t_i \in \Delta t_j} u_m(t_i), \; \max_{t_i \in \Delta t_j} u_m(t_i) \right]

When triggerEnabled = true, the display synchronizes its horizontal window origin to level crossings:

utrig(t∗)=Ltrigwithdutrigdt(t∗)≷0u_{\text{trig}}(t^*) = L_{\text{trig}} \quad \text{with} \quad \frac{du_{\text{trig}}}{dt}(t^*) \gtrless 0

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 (u1=sin⁡ωtu_1 = \sin \omega t, u2=cos⁡ωtu_2 = \cos \omega t). 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.