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!