diff --git a/EmbeddedControl.mo b/EmbeddedControl.mo index 785c0ab..8a96df7 100644 --- a/EmbeddedControl.mo +++ b/EmbeddedControl.mo @@ -10,27 +10,31 @@ package EmbeddedControl Placement(transformation(origin = {-122, 2}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin = {-120, 0}, extent = {{-20, -20}, {20, 20}}))); Modelica.Blocks.Interfaces.IntegerOutput y annotation( Placement(transformation(origin = {86, -34}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}))); + Modelica.Blocks.Interfaces.BooleanInput tickInput annotation( + Placement(transformation(origin = {-130, -88}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin = {0, -120}, extent = {{-20, -20}, {20, 20}}, rotation = 90))); protected discrete Integer yInt(start=0, fixed=true); - + algorithm - yInt := integer(floor((scale*u)/stepSize+ 0.5)); + when tickInput then + yInt := integer(floor((scale*u)/stepSize+ 0.5)); + end when; equation y = yInt; annotation( Documentation(info = " -
Integer analog-to-digital conversion block.
-The real-valued input u is quantized to an integer code using:
y = floor((scale*u)/stepSize + 0.5)
This produces a rounded integer representation of the scaled input, intended for embedded-style control chains that operate on integer counts.
-Parameters:
-stepSize: physical value represented by one integer stepscale: additional scaling applied before quantizationInteger analog-to-digital conversion block.
+The real-valued input u is quantized to an integer code using:
y = floor((scale*u)/stepSize + 0.5)
This produces a rounded integer representation of the scaled input, intended for embedded-style control chains that operate on integer counts.
+Parameters:
+stepSize: physical value represented by one integer stepscale: additional scaling applied before quantization