Open
Description
The following model demonstrates that the quantization function may output more levels than the number of bits allows, which is
However, the number of unique output levels is 5:
Full model, implemented with OpenModelica
OpenModelica 1.24.0~dev-16-gaa27cc1
OMSimulator 2.1.2-linux-notlm-debug
model quanrt
Modelica.Clocked.RealSignals.Sampler.SampleWithADeffects sample1(limited = true, quantized = true, bits = 2) annotation(
Placement(transformation(origin = {0, 22}, extent = {{-6, -6}, {6, 6}})));
Modelica.Blocks.Sources.Sine sine1(f = 1) annotation(
Placement(transformation(origin = {-28, 22}, extent = {{-10, -10}, {10, 10}})));
Modelica.Clocked.ClockSignals.Clocks.PeriodicRealClock periodicClock1(period = 0.01) annotation(
Placement(transformation(origin = {18, 2}, extent = {{-6, -6}, {6, 6}})));
Modelica.Clocked.RealSignals.Sampler.AssignClock assignClock1 annotation(
Placement(transformation(origin = {36, 22}, extent = {{-6, -6}, {6, 6}})));
equation
connect(sine1.y, sample1.u) annotation(
Line(points = {{-17, 22}, {-7, 22}}, color = {0, 0, 127}));
connect(periodicClock1.y, assignClock1.clock) annotation(
Line(points = {{25, 2}, {36, 2}, {36, 14}}, color = {175, 175, 175}));
connect(sample1.y, assignClock1.u) annotation(
Line(points = {{7, 22}, {28, 22}}, color = {0, 0, 127}));
annotation(
uses(Modelica(version = "4.0.0")));
end quanrt;