Subclassing closed source Simscape components
2 次查看(过去 30 天)
显示 更早的评论
I would like to define a custom engine, starting from Simscape's Generic Engine. For instance, how should one replicate the engine braking example using inheritance?
The conserving port F has only speed properties. So, how can I add the braking torque?
Using the code below, I get an error saying that: 't' is not defined in this scope.
component MyEngine < sdl.engines.generic_engine
parameters(Size = variable)
TorqueEMB = {[-100 -200], 'N*m'}; % Engine motoring torque
SpeedEMB = {[ 600 1200], 'rpm'}; % Engine motoring speed
end
intermediates
Temb = tablelookup(SpeedEMB, TorqueEMB, F.w - B.w,...
interpolation = linear, ...
extrapolation = nearest); % Engine motoring brake torque
end
equations
t == -Temb;
end
end
0 个评论
回答(1 个)
Steve Miller
2022-10-10
The diagnostic you have received is telling you that the variable you have used is not defined. You need to define the torque relative to nodes in the block. Look at the source code for the Ideal Torque Source to see the definition there.
The torque defined in the Generic Engine block is "trq". You can see this from Simscape logging. I believe you want to add an additional torque, not redefine the existing "trq", so I would recommend completing the definition of "t" in your code above.
--Steve
2 个评论
Steve Miller
2022-10-20
Hi Geraldo - some engineers prefer to work in a schematic, some prefer to write equations in textual form. Using subsystem2ssc(), you can have both. The resulting set of equations will be the same once Simscape manipulates the equations, so whichever process you prefer, you can use.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Engines & Motors 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!