K

Gain

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

Multiplies the input signal by a constant scalar gain factor KK. Serves as the fundamental scaling element in linear dynamical systems, signal processing pipelines, and feedback control architectures. Forms the proportional action in PID controllers, enables conversion between physical engineering units (such as RPM to radians per second), sets open-loop gain margins in Bode stability analysis, and calibrates sensor transducer sensitivity.

Mathematical Model

In continuous and discrete time domains, the gain block performs an instantaneous linear scaling:

y(t)=K⋅u(t)y(t) = K \cdot u(t)

In the Laplace domain (ss) and frequency domain (ω\omega), the transfer function exhibits a constant magnitude and zero frequency-dependent phase lag:

G(s)=K,∣G(jω)∣dB=20log⁡10∣K∣,∠G(jω)={0∘,if K>0−180∘,if K<0G(s) = K, \quad |G(j\omega)|_{\text{dB}} = 20 \log_{10} |K|, \quad \angle G(j\omega) = \begin{cases} 0^\circ, & \text{if } K > 0 \\ -180^\circ, & \text{if } K < 0 \end{cases}

Inputs & Outputs

Direction ID Label Type Status
→ In in Input number Required
← Out out Output number Output

Parameters

Parameters Label Type Default Description
gain Gain (K) number 1 Multiplication factor for the input signal

Usage Examples

Example 1: Proportional Feedback Control Loop

In a position servomechanism, the tracking error e(t)=r(t)−y(t)e(t) = r(t) - y(t) from a Subtraction block is fed into a Gain block configured with gain = 25.0 (Kp=25 V/radK_p = 25\text{ V/rad}). The amplified error signal drives the motor actuator, increasing closed-loop stiffness, reducing steady-state tracking offset, and shifting closed-loop system poles toward faster response times.

Example 2: Transducer Unit Conversion (RPM to rad/s)

Rotational speed encoders on turbine shafts report velocity in revolutions per minute (RPM). Wiring the sensor output into a Gain block with gain = 0.104719755 (2π60 rad/s per RPM\frac{2\pi}{60}\text{ rad/s per RPM}) converts the rotational measurement into SI units of angular velocity (rad/s\text{rad/s}), providing properly scaled telemetry for downstream kinetic energy and torque calculations.

Remarks & Best Practices

  • Memoryless Linear Operation: Evaluated as an instantaneous algebraic operator with zero internal state memory, introducing no parasitic phase delay or high-frequency distortion.
  • Algebraic Loop Caution: In pure algebraic feedback loops where an actuator instantaneously feeds into a controller without dynamic lag (such as direct feedback through a Gain and Sum block), an algebraic loop occurs unless broken with an Integrator or UnitDelay.
  • Decibel Gain Scaling: In Bode frequency analysis, a gain of K=1K = 1 represents 0 dB0\text{ dB}, K=10K = 10 represents +20 dB+20\text{ dB}, and K=0.1K = 0.1 represents −20 dB-20\text{ dB} attenuation.
  • High-Performance WASM Execution: Implemented in the Rust WASM core as a single floating-point multiplication instruction with zero heap allocations, ensuring high computational throughput.

Frequently Asked Questions (FAQ)

Q: How does open-loop gain tuning trade off disturbance rejection against noise amplification?

In negative feedback L(s)=C(s)P(s)L(s) = C(s)P(s), output tracking error obeys e(s)=S(s)r(s)−S(s)d(s)+T(s)n(s)e(s) = S(s)r(s) - S(s)d(s) + T(s)n(s), where Sensitivity S=11+LS = \frac{1}{1+L} and Complementary Sensitivity T=L1+LT = \frac{L}{1+L} satisfy S+T=1S + T = 1. Increasing gain ∣L∣≫1|L| \gg 1 suppresses load disturbances (∣S∣→0|S| \to 0), but forces ∣T∣≈1|T| \approx 1, passing sensor noise directly to the actuator. In addition, Bode's sensitivity integral dictates that pushing ∣S∣|S| below 0 dB inevitably amplifies ∣S∣>1|S| > 1 over adjacent frequencies.

Related Components

  • Sum: Combines multiple input signals algebraically.
  • Product: Multiplies two or more dynamic time-varying signals together.
  • Constant: Injects fixed numeric values or offsets into block diagrams.
  • PIDController: Packaged three-term controller with configurable proportional, integral, and derivative gains.