%% Create data for FOC Current                                               

%   Copyright 2014-2015 The MathWorks, Inc.

paramCurrentControlP = Simulink.Parameter;
paramCurrentControlP.Value = 8;
paramCurrentControlP.CoderInfo.StorageClass = 'ExportedGlobal';
paramCurrentControlP.Description = 'Proportional gain of current controller';
paramCurrentControlP.DataType = 'auto';
paramCurrentControlP.Min = 0;
paramCurrentControlP.Max = 100;
paramCurrentControlP.DocUnits = 'volt/ampere';

paramCurrentControlI = Simulink.Parameter;
paramCurrentControlI.Value = 2000;
paramCurrentControlI.CoderInfo.StorageClass = 'ExportedGlobal';
paramCurrentControlI.Description = 'Integral gain of current controller';
paramCurrentControlI.DataType = 'auto';
paramCurrentControlI.Min = 0;
paramCurrentControlI.Max = 3000;
paramCurrentControlI.DocUnits = 'volt/ampere';

paramCurrentControlSatVoltage = 13.856406460551021;

dataRange = struct;
dataRange.PhaseCurrent = struct;
dataRange.PhaseCurrent.Description = 'Phase current';
dataRange.PhaseCurrent.Units = 'ampere';
dataRange.PhaseCurrent.Max = 5;
dataRange.PhaseCurrent.Min = -5;
dataRange.PhaseVoltage = struct;
dataRange.PhaseVoltage.Description = 'Phase voltage';
dataRange.PhaseVoltage.Units = 'volt';
dataRange.PhaseVoltage.Max = 12;
dataRange.PhaseVoltage.Min = -12;
dataRange.DqVoltage = struct;
dataRange.DqVoltage.Description = 'Direct and quadrature voltage';
dataRange.DqVoltage.Units = 'volt';
dataRange.DqVoltage.Max = 13.856406460551021;
dataRange.DqVoltage.Min = -13.856406460551021;

pmsm = struct;
pmsm.RatedVoltage = 24;
pmsm.RatedSpeed = 418.87902047863906;
pmsm.CurrentMax = 5.4;
pmsm.VoltageMax = 24;
pmsm.PolePairs = 4;
pmsm.StatorPhaseResistance = 0.9;
pmsm.InductanceLd = 0.00105;
pmsm.InductanceLq = 0.00105;
pmsm.InductanceL0 = 0.00105;
pmsm.Inertia = 2.40092768E-6;
pmsm.FluxLinkage = 0.005661;
pmsm.BreakawayFrictionTorque    = 0.002130661;
pmsm.CoulombFrictionTorque      = 0.002130661;
pmsm.ViscousFrictionCoefficient = 1.33363e-5;
pmsm.RotorPositionInit = 0;
pmsm.RotorVelocityInit = 0;

inverter = struct;
inverter.BusVoltage = 24;
inverter.CurrentMax = 2;
inverter.GatesActiveHigh = true;
inverter.GatesComplementary = true;

disc = struct;
disc.Inertia = 9.5E-5;

sampleTime = struct;
sampleTime.CurrentControl = 2E-5;

