File tree 1 file changed +6
-3
lines changed
Modelica/Clocked/RealSignals/Sampler/Utilities/Internal
1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -9,19 +9,22 @@ extends Clocked.RealSignals.Interfaces.PartialClockedSISO;
9
9
parameter Integer bits(min = 1 )= 8
10
10
"Number of bits of quantization (if quantized = true)" ;
11
11
protected
12
- parameter Real resolution = if quantized then ((yMax - yMin)/ 2 ^ bits) else 0 ;
12
+ parameter Real resolution = if quantized then ((yMax - yMin)/ ( 2 ^ bits- 1 ) ) else 0 ;
13
13
equation
14
14
15
15
if quantized then
16
- y = resolution* floor (abs (u/ resolution) + 0.5 )*
17
- (if u > = 0 then + 1 else - 1 );
16
+ y = resolution* floor (((u- yMin)/ resolution) + 0.5 )+ yMin;
18
17
else
19
18
y = u;
20
19
end if ;
21
20
annotation (Documentation(info="<html>
22
21
<p>
23
22
The clocked Real input signal is value discretized
24
23
(the discretization is defined by parameter <strong>bits</strong>).
24
+
25
+ This is a mid-riser quantization, which for a symmetric interval imply that it will not output zero.
25
26
</p>
27
+ </html>" , revisions="<html>
28
+ <p>2024-09-04: Corrected off-by-one error in number of output levels, and handle non-symmetric limits.</p>
26
29
</html>" ));
27
30
end Quantization;
You can’t perform that action at this time.
0 commit comments