diff --git a/Modelica/Clocked/RealSignals/Sampler/Utilities/Internal/Quantization.mo b/Modelica/Clocked/RealSignals/Sampler/Utilities/Internal/Quantization.mo index 13ac12cb59..ff6aebad90 100644 --- a/Modelica/Clocked/RealSignals/Sampler/Utilities/Internal/Quantization.mo +++ b/Modelica/Clocked/RealSignals/Sampler/Utilities/Internal/Quantization.mo @@ -9,12 +9,11 @@ extends Clocked.RealSignals.Interfaces.PartialClockedSISO; parameter Integer bits(min=1)=8 "Number of bits of quantization (if quantized = true)"; protected - parameter Real resolution = if quantized then ((yMax - yMin)/2^bits) else 0; + parameter Real resolution = if quantized then ((yMax - yMin)/(2^bits-1)) else 0; equation if quantized then - y = resolution*floor(abs(u/resolution) + 0.5)* - (if u >= 0 then +1 else -1); + y = resolution*floor(((u-yMin)/resolution) + 0.5)+yMin; else y = u; end if; @@ -22,6 +21,10 @@ equation
The clocked Real input signal is value discretized (the discretization is defined by parameter bits). + +This is a mid-riser quantization, which for a symmetric interval imply that it will not output zero.
+