VoltageCenterTap2mPulse

model VoltageCenterTap2mPulse "Control of 2*m pulse center tap rectifier"
    import Modelica.Constants.pi;

    extends Icons.Control;

    parameter Integer m(final min = 3) = 3 "Number of phases";
    parameter Modelica.SIunits.Frequency f = 50 "Frequency";
    parameter Boolean useConstantFiringAngle = true "Use constant firing angle instead of signal input";
    parameter Modelica.SIunits.Angle constantFiringAngle = 0 "Firing angle"
        annotation (Dialog(enable = useConstantFiringAngle));
    parameter Modelica.SIunits.Angle firingAngleMax(min = 0, max = Modelica.Constants.pi) = Modelica.Constants.pi "Maximum firing angle";
    parameter Boolean useFilter = true "Enable use of filter"
        annotation (Dialog(tab = "Filter"));
    parameter Modelica.SIunits.Frequency fCut = 2 * f "Cut off frequency of filter"
        annotation (Dialog(
            tab = "Filter",
            enable = useFilter));
    parameter Modelica.SIunits.Voltage vStart[m] = zeros(m) "Start voltage of filter output"
        annotation (Dialog(
            tab = "Filter",
            enable = useFilter));
    Modelica.Blocks.Interfaces.RealInput firingAngle if not useConstantFiringAngle "Firing angle (rad)"
        annotation (Placement(transformation(
            extent = {
                {-20, -20}, 
                {20, 20}},
            rotation = 90,
            origin = {0, -120})));
    Signal2mPulse twomPulse(final useConstantFiringAngle = useConstantFiringAngle, final f = f, final constantFiringAngle = constantFiringAngle, final firingAngleMax = firingAngleMax, final m = m, final useFilter = useFilter, final fCut = 2 * f, final vStart = vStart) annotation (Placement(transformation(
        extent = {
            {-10, -10}, 
            {10, 10}},
        origin = {10, 0})));
    Modelica.Electrical.MultiPhase.Interfaces.PositivePlug ac(final m = m) annotation (Placement(transformation(extent = {
        {-110, -10}, 
        {-90, 10}})));
    Modelica.Blocks.Interfaces.BooleanOutput fire_p[m] annotation (Placement(transformation(
        extent = {
            {-10, -10}, 
            {10, 10}},
        rotation = 90,
        origin = {-60, 110})));
    Modelica.Blocks.Interfaces.BooleanOutput fire_n[m] annotation (Placement(transformation(
        extent = {
            {-10, -10}, 
            {10, 10}},
        rotation = 90,
        origin = {60, 110})));
    Modelica.Electrical.MultiPhase.Basic.MultiDelta delta(final m = m) "Delta connection"
        annotation (Placement(transformation(
            extent = {
                {10, -10}, 
                {-10, 10}},
            origin = {-80, 0})));
    Modelica.Electrical.MultiPhase.Sensors.PotentialSensor voltageSensor(final m = m) "Voltage sensor"
        annotation (Placement(transformation(extent = {
            {-60, -10}, 
            {-40, 10}})));
    Modelica.Blocks.Math.Gain gain[m](final k = fill(-1, m)) annotation (Placement(transformation(extent = {
        {-28, -10}, 
        {-8, 10}})));
equation
    connect(ac,delta.plug_n) annotation (Line(
        points = {
            {-100, 0}, 
            {-90, 0}},
        color = {0, 0, 255}));
    connect(firingAngle,twomPulse.firingAngle) annotation (Line(
        points = {
            {0, -120}, 
            {0, -80}, 
            {10, -80}, 
            {10, -12}},
        color = {0, 0, 127}));
    connect(gain.y,twomPulse.v) annotation (Line(
        points = {
            {-7, 0}, 
            {-2, 0}},
        color = {0, 0, 127}));
    connect(twomPulse.fire_n,fire_n) annotation (Line(
        points = {
            {16, 11}, 
            {16, 80}, 
            {60, 80}, 
            {60, 110}},
        color = {255, 0, 255}));
    connect(twomPulse.fire_p,fire_p) annotation (Line(
        points = {
            {4, 11}, 
            {4, 80}, 
            {-60, 80}, 
            {-60, 110}},
        color = {255, 0, 255}));
    connect(voltageSensor.phi,gain.u) annotation (Line(
        points = {
            {-39, 0}, 
            {-30, 0}},
        color = {0, 0, 127}));
    connect(voltageSensor.plug_p,delta.plug_p) annotation (Line(
        points = {
            {-60, 0}, 
            {-70, 0}},
        color = {0, 0, 255}));

    annotation (
        defaultComponentName = "adaptor",
        Icon(
            coordinateSystem(
                preserveAspectRatio = false,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(
                    points = {
                        {-40, -20}, 
                        {-40, -24}, 
                        {-20, -24}, 
                        {-20, -40}, 
                        {-40, -40}, 
                        {-40, -60}},
                    color = {255, 0, 255}), 
                Line(
                    points = {
                        {20, -20}, 
                        {20, -44}, 
                        {40, -44}, 
                        {40, -60}, 
                        {20, -60}, 
                        {20, -60}},
                    color = {255, 0, 255}), 
                Text(
                    extent = {
                        {-40, 60}, 
                        {40, 0}},
                    lineColor = {255, 0, 255},
                    textString = "2*%m%")}),
        Documentation(
            revisions = "<html>\n</html>",
            info = "<html>\n\n<p>\nGeneral information about controllers is summarized in\n<a href=\"modelica://Modelica.Electrical.PowerConverters.ACDC.Control\">Control</a>.\n</p>\n</html>"));
end VoltageCenterTap2mPulse;