๐ŸŽš

Slider

Sources
Run the live example Free ยท no sign-up ยท runs in your browser

The Slider block provides an interactive on-canvas graphical fader control that allows users to adjust signals or project variables live during a simulation run. Dragging the slider knob updates the output value in real time, automatically pacing the simulation to real-time wall-clock execution so the system responds immediately to user manipulation. The block can operate as a standard physical signal source or can directly drive global project variables (such as PID controller gains or physical plant mass) without requiring explicit signal wiring across the diagram.

Mathematical Model

The continuous output signal y(t)y(t) corresponds to the user-selected slider position v(t)v(t), clamped within the defined range [vminโก,vmaxโก][v_{\min}, v_{\max}] and quantized to the resolution step ฮ”v\Delta v:

y(t)=clampโก(vminโก+roundโก(v(t)โˆ’vminโกฮ”v)โ‹…ฮ”v,โ€…โ€Švminโก,โ€…โ€Švmaxโก)y(t) = \operatorname{clamp}\left( v_{\min} + \operatorname{round}\left(\frac{v(t) - v_{\min}}{\Delta v}\right) \cdot \Delta v, \; v_{\min}, \; v_{\max} \right)

where vminโก=minValuev_{\min} = \text{minValue}, vmaxโก=maxValuev_{\max} = \text{maxValue}, ฮ”v=step\Delta v = \text{step}, and:

clampโก(x,a,b)=minโก(maxโก(x,a),b)\operatorname{clamp}(x, a, b) = \min(\max(x, a), b)

When variable is non-empty (Vnameโ‰ ""V_{\text{name}} \ne \text{""}), the block simultaneously updates the shared global project parameter:

V[Vname]โ†y(t)\mathcal{V}[V_{\text{name}}] \leftarrow y(t)

allowing all blocks referencing {{V_name}} to dynamically inherit the updated numerical value on the subsequent simulation step.

Inputs & Outputs

Direction ID Label Type Status
← Out out Value number Output

Parameters

Parameters Label Type Default Description
value Value number 0 Current slider value โ€” drag the on-canvas slider or edit here
minValue Min number -1
maxValue Max number 1
step Step number 0.01
label Label string
variable Drives Variable string Variable this slider sets live; parameters that use it follow. Empty: signal only.

Usage Examples

Example 1: Real-Time Human Setpoint Steering for Speed Control

Using a Slider to provide interactive target speed commands to a servomotor. Configuring minValue = 0.0, maxValue = 3000.0, step = 10.0, and label = "Speed (RPM)". Dragging the slider handle live while observing the response on a uPlotDisplay allows dynamic evaluation of motor tracking delay and overshoot.

Example 2: Wireless Interactive Tuning of Controller Gain

Tuning a PID controller gain live in an embedded interactive showcase without cluttering the canvas with wires. Setting minValue = 0.1, maxValue = 20.0, step = 0.1, label = "Proportional Gain", and variable = "Kp". Inside the PIDController block, setting parameter kp to {{Kp}} binds the gain directly to the slider position.

Remarks & Best Practices

  • Automatic Real-Time Pacing: Inserting an interactive Slider block automatically synchronizes the simulation engine to real-time wall-clock pacing (1 second of simulation time equals 1 second of wall-clock time), ensuring smooth interactive user control.
  • Undo Integration: Releasing the mouse handle after a drag gesture automatically registers a single consolidated undo state in the platform history stack.
  • Boundary Clamping: Output values are strictly clamped to [vminโก,vmaxโก][v_{\min}, v_{\max}] even if an out-of-range value is entered manually in the inspector.
  • Embedded Showcase Ready: Fully responsive inside zero-knowledge shared links and embedded interactive iframe demonstrations.

Related Components

  • Joystick2D: Two-axis interactive joystick for simultaneous 2D XY steering.
  • KeyboardInput: Steers simulation signals live via arrow or WASD keyboard keys.
  • Constant: Fixed, non-interactive scalar value source.
  • PIDController: Closed-loop controller frequently tuned interactively via sliders.