Running an Efficiency Map in WSM - (Show in WSM)

Define the model

motormodel = "ACKMotorPackage.Models_SVM.ACKDynoWolframConference"

motorsm = SystemModel[motormodel]

Simulate the model for various loads and speeds  grab torque, speed and efficiency

spds = N[{20*2*Pi}];
lds = Range[0,40,2];

generateRampTable[lds_,spds_,rampTime_, holdTime_]:=N[Flatten[Prepend[MapThread[{Prepend[#1,#2+rampTime],Prepend[#1,#2+holdTime]}&,{Tuples[{lds,spds}],Range[0,holdTime*(Length[lds]*Length[spds]-1),holdTime]}],{{0.,0.,0.}}],1]]

table = generateRampTable[lds,spds,0.5,2]

Export["/Users/nsing/Documents/SystemModeler/Motor_Software/systemModeler/baseModel/table.mat","table"->table, "LabeledData"]

Compute the Run Time

endTime = Last[table][[1]]+2

Simulate the model

motorsim =SystemModelSimulate[motormodel,{"Load_Speed_Table.y[1]","Load_Speed_Table.y[2]","Efficiency.y"},endTime]

View the Raw Results

{load,speed,efficiency}=motorsim[{"Load_Speed_Table.y[1]","Load_Speed_Table.y[2]","Efficiency.y"},t];

Plot[load,{t,0,endTime}]

Plot[efficiency,{t,0,endTime}]

Plot the Efficiency Map

ListLinePlot[Map[{load,speed,efficiency}/.t->#&,Range[3.75,endTime-.25,2]][[All,{1,3}]],PlotMarkers->{Automatic, 10},PlotLabel->"Efficiency at "<>ToString[speed/.t->5]<>" rads/sec", PlotStyle->Darker@Green,PlotLegends->{"AC Kinetics"},
Axes->True,Frame->True,GridLines->Automatic,FrameLabel->{"Torque (Nm)","Motor Efficiency (%)"},ImageSize->Large,
BaseStyle->{FontWeight->"Bold",FontSize->16},PlotRange->{Automatic,{65,95}}]

Compare the Efficiency Map to a Hardware Test

AC Kinetics Dynamometer

Mathematica Instrumentation Control

Wolfram Language Enables

1. Control/Coordination of all Instruments
2. Reliability/Documentation of Tests
3. Automatically Stores Data on our Servers for Traceability
4. Eliminates Human Error
5. Streamlines Report Generation

Design of a controller for a Modelica Model from Wolfram SystemModeler

SystemModel;WSM`$WSMVersion

Define the model - (Show in WSM)

model = "Conference2018.ElevatorModel"

sm = SystemModel[model]

Simulate the model to Steady State and grab the model from WSM

sim =SystemModelSimulate[model,All,500,Method->{"StopAtSteadyState"->True}]

lsm=WSM`LocalizedSystemModel[sim,"StopTime"]

lsm["Properties"]

Now get the simplified Equations

simp = lsm["SelectOutputs",{"HeightOut"}]

simp2 = simp["Simplify"]

simp2["Properties"]

Examine the Equations, Operating Point and Parameters

simp2["DisplayEquations"]

initialCond =simp2["OperatingPoint"];
parameterVals = simp2["ParameterValues"];

Insert Parameter Values

simp2["DisplayEquations"]/. parameterVals

equations = simp2["Equations"]

vars = simp2["Variables"]

inputvars = simp2["Inputs"]

outputvars = simp2["Outputs"]

LQG Servo Design Demo

Descriptor State Space System Model of Elevator

demoSysDescriptor = simp2["Linearization"]/. parameterVals

Create a state-space model from the State-Space Model:

tf=TransferFunctionModel[demoSysDescriptor]

Transform the demo model from descriptor form to regular state-space:

demoSysUnbalanced=
StateSpaceModel[
tf,
StateSpaceRealization->"ControllableCompanion"]

Balance the model so the scaling is better:

{p,demoSys}=InternallyBalancedDecomposition[demoSysUnbalanced]

Create and merge an Integrator into the system

Add a second input identical to the first; one for u-feedback, one for u-w for compatibility with LQGRegulator[ ] convention.

sumDualIn=StateSpaceModel[{{{}},{{}},{{}},{{1,1}}}]
demoSys2In=SystemsModelSeriesConnect[sumDualIn,demoSys]

Create a state space model of a simple integrator with a single  input, and no output.
A slight bit of damping added

intUo = StateSpaceModel[{{{-0.0001}},{{1}},{{}},{{}}}]

Merge the integrator (intUo) into the demo system (demoSys2In)

demoSysUo=SystemsModelMerge[{intUo,demoSys2In}]

Connect the feedback to the integrator, Next design the LQG Regulator

Add feedback from the output of the simple system to the input of the integrator. The regulator will try to zero this first input by adjusting the feedback position. Use a plus sign on the feedback so the regulated system will travel in the desired direction.

demoSysUoFb=SystemsModelFeedbackConnect[demoSysUo,{{1,1,1}}]

Generate an LQG regulator for compSysUoFb, note that the first input will be our servo reference.

demoSysUoFbReg=
LQGRegulator[
{demoSysUoFb,1,2,1},
{{{1}},{{0.001}}},
{DiagonalMatrix[{10,1,1,1,1}],{{.01}}}]

Now we can test the new regulator by simulating it in Mathematica, First Connect the regulator and the system

Cascade the regulator simpSysUoFbReg with the un-modified (not simpSysUo) simple system,
connecting the output of the regulator (port 1) to the input of simpSys (port 1)

demoSysUoFbRegDemoSys=SystemsModelSeriesConnect[demoSysUoFbReg,demoSys,{{1,1}}]

Hook the  output of the serial combined system (port 1) simpSysUoFbRegSimpSys to the regulator sensor input (port 2)

demoSysServ=SystemsModelFeedbackConnect[demoSysUoFbRegDemoSys,{1,2,-1}]

Simulate and plot the response

Original open-loop system and closed-loop LQG servo system

tmaxDemo=5;
demoSysOut=OutputResponse[demoSys2In,{1,0}*UnitStep[t],{t,0,tmaxDemo}];
demoSysServOut = OutputResponse[demoSysServ,{1,0}*UnitStep[t],{t,0,tmaxDemo}];
Grid[{{Prepend[Sort[Eigenvalues[Normal[demoSys][[1]]]],"   EigenValues:"]//TableForm,Plot[demoSysOut,{t,0,tmaxDemo},GridLines->Automatic,PlotRange->All,ImageSize->Large,PlotLabel->"Open-Loop Response"]}}]
Grid[{{Prepend[Sort[Eigenvalues[Normal[demoSysServ][[1]]]],"   EigenValues:"]//TableForm,Plot[demoSysServOut,{t,0,tmaxDemo},PlotRange->All,GridLines->Automatic,ImageSize->Large,PlotLabel->"Closed-Loop LQG Servo Response"]}}]

Load the regulator into WSM

regmodel=CreateSystemModel["Conference2018.Regulator",demoSysUoFbReg];