Subclassing closed source Simscape components
    4 views (last 30 days)
  
       Show older comments
    
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 Comments
Answers (1)
  Steve Miller
    
 on 10 Oct 2022
        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 Comments
  Steve Miller
    
 on 20 Oct 2022
				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.
See Also
Categories
				Find more on Simscape Driveline in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!