필터 지우기
필터 지우기

Subclassing closed source Simscape components

조회 수: 2 (최근 30일)
Geraldo Rebouças
Geraldo Rebouças 2022년 10월 3일
댓글: Steve Miller 2022년 10월 20일
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

답변 (1개)

Steve Miller
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
Geraldo Rebouças
Geraldo Rebouças 2022년 10월 20일
Hi Steve,
Thanks for the input, and sorry for the long time to reply.
I want to redefine the existing torque "trq", so that one has full propulsion torque when throttle "Thr" is 1 and full engine braking torque when throttle is zero.
I contacted MW support on this issue and he (Nicholas Wong) oriented me to model what I want to achieve using blocks and then use the "subsystem2ssc" command to generate an .ssc file. It does not use subclassing concepts, but solves the problem.
Now, this question is just a curiosity matter, as it seems not necessary/useful to customize using the OO approach as it seems there is no difference in developing models using blocks or code.
Steve Miller
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 CenterFile Exchange에서 Engines & Motors에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by