Trouble while generating a 3D custom component in Simscape Environment.

I'm facing issues while trying to generate my custom simscape component
  1. The declarations, parameters, nodes definitions etc as a prerequisites required are correctly fulfilled.
  2. I'm trying to make a 3D custom simscape component and hence using a tablelookup in one of muy equations.
  3. The data set of input values are defined using the Link provided by Mathworks.
  4. The input vectors are defined as provided in the figure below. I'm also providing the array and its sizes.
  5. The equation for fd i.e. output function is as provided below
  6. While running <ssc_build('MyComponent')> I'm getting the error as shown below
What is that I've done incorrectly and where I need to make changes in order to make the Simscape model generate MyComponent effectively

 Risposta accettata

Hello Mihir,
I wonder if your problem lies in how you are declaring/setting SOC, T, or Cycle. I copied your text to make a test part and everything else seems to work: You should probably share your entire part definition when looking for help.
component testPart
nodes
p = foundation.electrical.electrical; % +:left
n = foundation.electrical.electrical; % -:right
end
parameters (Size=variable)
R_LUT = {ones(5,3,9),'Ohm'};
SOC_LUT = {[0 0.1 0.5 0.9 1], '1'};
Temp_LUT = {[273.15 298.13 313.13],'K'};
Cycle_LUT = {[1 50 100 150 200 250 300 350 400],'1'};
end
equations
R == tablelookup(SOC_LUT,Temp_LUT,Cycle_LUT,R_LUT,{0.1,'1'},{273.15,'K'},{50,'1'},...
interpolation=linear,extrapolation=nearest);
v == i*R;
end
variables
i = { 0, 'A' }; % Current
v = { 0, 'V' }; % Voltage
R = { 1, 'Ohm'}; % Resistance
end
branches
i : p.i -> n.i;
end
end

3 Commenti

Hi Joel Van Sickel,
As you mentioned the ssc files doesn't had such of an issue. This is when I commented some of the lines in the matlab script. Can you explain the impact of the commented part that caused the ssc_build function to not build a custom model. The script is as follows
component Resistance_LUT
nodes
p = foundation.electrical.electrical; % +:left
n = foundation.electrical.electrical; % -:right
end
inputs
T = {293.15,'K'}; % T:left
SOC = {1,'1'}; % SOC:left
Cycle= {1,'1'}; % Cycle No:left
end
outputs
pow = {0,'W'}; % POW:right
end
parameters (Size=variable)
R_LUT = {1e-3*ones(5,9,3),'Ohm'}; % R_table (SoC,T,Cycle.No)
SOC_LUT = {[0 0.1 0.5 0.9 1],'1'}; % SoC
Cycle_LUT ={[1 50 100 150 200 250 300 350 400],'1'}; % Cycle.No
Temp_LUT = {[273.15 298.13 313.13],'K'}; % T
end
variables(Access=private)
i = { 0, 'A' }; % Current
v = { 0, 'V' }; % Voltage
end
% function setup %#simple
% % Check parameter values
% if any(any(value(R_LUT,'Ohm')<=0))
% pm_error('simscape:GreaterThanZero','Matrix of resistance values, R(SOC,T)');
% end
% if any(value(SOC_LUT,'1')<0)
% pm_error('simscape:GreaterThanOrEqualToZero','State of charge (SOC) breakpoints');
% end
% if any(value(Temp_LUT,'K')<0)
% pm_error('simscape:GreaterThanOrEqualToZero','Temperature (T) breakpoints');
% end
% if any(value(Cycle_LUT,'1')<0)
% pm_error('simscape:GreaterThanOrEqualToZero','Cycle (No) breakpoints');
% end
% end
branches
i : p.i -> n.i;
end
equations
v == p.v - n.v;
let
% Perform the table lookup
R = tablelookup(SOC_LUT,Cycle_LUT,Temp_LUT,R_LUT,SOC,Cycle,T,...
interpolation=linear,extrapolation=nearest)
in
% Electrical Equations
v == i*R;
pow == v*i;
end
end
end
you need a third any() function for your Resistance lookup table
Thanks for the answer. Highly grateful for your response sir.

Accedi per commentare.

Più risposte (0)

Prodotti

Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by