Feedback

block Feedback "Output difference between commanded input 1 and feedback input 2"
    Interfaces.ComplexInput u1 annotation (Placement(transformation(extent = {
        {-100, -20}, 
        {-60, 20}})));
    Interfaces.ComplexInput u2 annotation (Placement(transformation(
        origin = {0, -80},
        extent = {
            {-20, -20}, 
            {20, 20}},
        rotation = 90)));
    Interfaces.ComplexOutput y annotation (Placement(transformation(extent = {
        {80, -10}, 
        {100, 10}})));
    parameter Boolean useConjugateInput1 = false "If true, input 1 is processed conjugate complex";
    parameter Boolean useConjugateInput2 = false "If true, input 2 is processed conjugate complex";
equation
    y = (if useConjugateInput1 then Modelica.ComplexMath.conj(u1) else u1) - (if useConjugateInput2 then Modelica.ComplexMath.conj(u2) else u2);

    annotation (
        Documentation(info = "<html>\n<p>\nThis blocks computes output <code>y</code> as <em>difference</em> of the\ncommanded input <code>u1</code> and the feedback\ninput <code>u2</code>. Optionally, either input <code>u1</code> or <code>u2</code> or both inputs can be processed conjugate complex, when parameters <code>useConjugateInput1</code> and <code>useConjugateInput2</code> are <code>true</code>, respectively.\n</p>\n<pre>\n  y = (if useConjugateInput1 then Modelica.ComplexMath.conj(u1) else u1)\n    - (if useConjugateInput1 then Modelica.ComplexMath.conj(u2) else u2);\n</pre>\n<p>\n<strong>Example</strong> parameters:\n</p>\n<ul>\n<li><code>useConjugateInput1 = true</code>,</li>\n<li><code>useConjugateInput2 = false</code></li>\n</ul>\n<p>\nresult in the following equation:\n</p>\n<pre>\n     y = Modelica.ComplexMath.conj(u1) - u2\n</pre>\n\n</html>"),
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Ellipse(
                    extent = {
                        {-20, 20}, 
                        {20, -20}},
                    lineColor = {0, 0, 127},
                    fillColor = {235, 235, 235},
                    fillPattern = FillPattern.Solid), 
                Line(
                    points = {
                        {-60, 0}, 
                        {-20, 0}},
                    color = {0, 0, 127}), 
                Line(
                    points = {
                        {20, 0}, 
                        {80, 0}},
                    color = {0, 0, 127}), 
                Line(
                    points = {
                        {0, -20}, 
                        {0, -60}},
                    color = {0, 0, 127}), 
                Text(
                    extent = {
                        {-14, 0}, 
                        {82, -94}},
                    textString = "-"), 
                Text(
                    extent = {
                        {-150, 94}, 
                        {150, 44}},
                    textString = "%name",
                    lineColor = {0, 0, 255})}),
        Diagram(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Ellipse(
                    extent = {
                        {-20, 20}, 
                        {20, -20}},
                    fillColor = {235, 235, 235},
                    fillPattern = FillPattern.Solid,
                    lineColor = {0, 0, 255}), 
                Line(
                    points = {
                        {-60, 0}, 
                        {-20, 0}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {20, 0}, 
                        {80, 0}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {0, -20}, 
                        {0, -60}},
                    color = {0, 0, 255}), 
                Text(
                    extent = {
                        {-12, 10}, 
                        {84, -84}},
                    textString = "-")}));
end Feedback;