Quantizer
DiscontinuousDiscretizes continuous signal amplitude into discrete staircase quantization levels. Supports two operational modes: Resolution mode, which rounds incoming signals to the nearest integer multiple of a specified step interval , and ADC mode, which simulates physical Analog-to-Digital Converter behavior parameterized by input voltage range and bit depth . Essential for modeling sensor resolution limits, ADC word-length effects, finite precision embedded arithmetic, and quantization noise in digital control systems.
Mathematical Model
In Resolution mode (mode = "resolution"), the output rounds the input to the nearest multiple of interval :
The instantaneous quantization error is strictly bounded by half the step size:
In ADC mode (mode = "adc"), the signal is first clamped to the range and quantized across discrete levels:
The resulting discrete integer code and reconstructed output voltage are:
The theoretical Signal-to-Quantization-Noise Ratio (SQNR) for a full-scale sinusoidal input is:
Inputs & Outputs
| Direction | ID | Label | Type | Status |
|---|---|---|---|---|
| → In | in |
Input | number | Required |
| ← Out | out |
Output | number | Output |
Parameters
| Parameters | Label | Type | Default | Description |
|---|---|---|---|---|
mode |
Mode | select | resolution |
Resolution: specify quantization interval directly. ADC: specify min, max, and bit depth. |
interval |
Quantization Interval | number | 1 |
Used in Resolution mode |
minValue |
Min Value | number | 0 |
Minimum input range (ADC mode) |
maxValue |
Max Value | number | 5 |
Maximum input range (ADC mode) |
bits |
Number of Bits | number | 8 |
Bit depth for ADC quantization (ADC mode) |
Usage Examples
Example 1: 10-Bit Embedded Microcontroller ADC Modeling
In microcontroller sensor interfaces (e.g. STM32 or Arduino), analog sensors are digitized by a 10-bit ADC spanning to . Setting mode = "adc", minValue = 0.0, maxValue = 3.3, and bits = 10 produces discrete voltage steps of , reproducing realistic ADC quantization noise and code-stepping in simulation.
Example 2: Discrete Actuator Power Throttling in Resolution Mode
In industrial thermal management, a high-power immersion heater's thyristor controller only accepts discrete power demands in increments. Connecting a continuous PID controller's output to a Quantizer configured with mode = "resolution" and interval = 250.0 converts the smooth control signal into discrete stair-step commands (), preventing continuous micro-adjustments.
Remarks & Best Practices
- Live Quantization Staircase Preview: The property editor displays the discrete staircase transfer curve , reporting LSB step size , peak error, or ADC dynamic range and theoretical SNR.
- Quantization Noise Statistics: For dynamic signals crossing multiple quantization bands, quantization error approximates white noise with uniform distribution and variance .
- Dual Mode Flexibility: Resolution mode provides symmetric unbounded quantization around zero, while ADC mode enforces physical voltage clipping and discrete bit depth.
- Closed-Loop Limit Cycles: When placed inside high-gain feedback loops, quantization non-linearities can induce small-amplitude sustained limit-cycle oscillations.
- Deterministic High Speed: Evaluated in Rust using branchless math, ensuring fast simulation execution with zero dynamic memory allocation.
Related Components
- DeadZone: Suppresses signals within an insensitivity interval around zero.
- Saturation: Clamps signal amplitudes between upper and lower limits without stair-stepping.
- Relay: Two-state hysteretic threshold switching.
- MathFunction: Evaluates mathematical rounding, floor, and ceiling operations.