CurrentSensor

model CurrentSensor "Sensor to measure the current in a branch"
    extends Modelica.Icons.RotationalSensor;

    Interfaces.PositivePin p "positive pin"
        annotation (Placement(transformation(extent = {
            {-110, -10}, 
            {-90, 10}})));
    Interfaces.NegativePin n "negative pin"
        annotation (Placement(transformation(extent = {
            {90, -10}, 
            {110, 10}})));
    Modelica.Blocks.Interfaces.RealOutput i(unit = "A") "Current in the branch from p to n as output signal"
        annotation (Placement(transformation(
            origin = {0, -110},
            extent = {
                {10, -10}, 
                {-10, 10}},
            rotation = 90)));
equation
    n.i = -i;
    p.i = i;
    p.v = n.v;

    annotation (
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Text(
                    extent = {
                        {-29, -11}, 
                        {30, -70}},
                    textString = "A"), 
                Line(
                    points = {
                        {-70, 0}, 
                        {-90, 0}},
                    color = {0, 0, 255}), 
                Text(
                    extent = {
                        {-150, 80}, 
                        {150, 120}},
                    textString = "%name",
                    lineColor = {0, 0, 255}), 
                Line(
                    points = {
                        {70, 0}, 
                        {90, 0}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {0, -100}, 
                        {0, -70}},
                    color = {0, 0, 127})}),
        Diagram(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Text(
                    extent = {
                        {-153, 79}, 
                        {147, 119}},
                    textString = "%name",
                    lineColor = {0, 0, 255})}),
        Documentation(
            revisions = "<html>\n<ul>\n<li><em> 1998   </em>\n       by Christoph Clauss<br> initially implemented<br>\n       </li>\n</ul>\n</html>",
            info = "<html>\n<p>The current sensor converts the current flowing between the two connectors into a real valued signal. The two connectors are in the sensor connected like a short cut. The sensor has to be placed within an electrical connection in series.  It does not influence the current sum at the connected nodes. Therefore, the electrical behavior is not influenced by the sensor.</p>\n</html>"));
end CurrentSensor;