Componentes personalizados
El lenguaje de Simscape permite definir componentes personalizados como archivos de texto, que se completan con parametrización, conexiones físicas y ecuaciones representadas como ecuaciones subyacentes. Los temas de esta página aportan información detallada sobre cómo declarar parámetros de componentes, variables y conexiones. Para ver otros aspectos sobre cómo definir componentes personalizados, consulte Ecuaciones, Eventos discretos y gráficos de modo y Componentes compuestos.
Para empezar a escribir componentes personalizados, consulte Crear componentes personalizados, que ofrece una visión general del flujo de trabajo general. Al final de esta página, los temas incluidos en Componentes de referencia de aplicación ofrecen ejemplos completos de componentes con explicaciones detalladas que ilustran las técnicas utilizadas en cada caso.
Sintaxis del lenguaje
annotations | Control appearance of Simscape block based on the component |
branches | Establish relationship between component Through variables and nodes |
component | Component model keywords |
inputs | Define component inputs, that is, physical signal input ports of block |
nodes | Define component nodes, that is, conserving ports of block |
outputs | Define component outputs, that is, physical signal output ports of block |
parameters | Declare domain or component parameters |
variables | Declare domain or component variables |
Temas
Técnicas básicas
- Crear componentes personalizados
Tipos de componentes, estructura de los archivos, flujo de trabajo de alto nivel. - Attribute Lists
Model attributes and member attributes used in Simscape language.
Declaraciones y ramificaciones
- Declaring Domains and Components
Declaration section of domain and component files: purpose, definitions, rules, member summaries. - Declare a Spring Component
The following diagram shows a network representation of a mass-spring-damper system, consisting of four components (mass, spring, damper, and reference) in a mechanical rotational domain. - Declare Component Parameters
Component parameters let you specify adjustable parameters for the Simscape block generated from the component file. - Declare Component Nodes
Component nodes define the conserving ports of a Simscape block generated from the component file. - Declare Component Inputs and Outputs
In addition to conserving ports, Simscape blocks can contain physical signal input and output ports, directional ports that carry signals with associated units. - Declare Component Variables
When you declare Through and Across variables in a component, you are essentially creating instances of domain Through and Across variables. - Define Relationship Between Component Variables and Nodes
How to connect Through and Across variables declared in a component file to the domain Through and Across variables. - Declaration Functions
Use MATLAB® functions to compute derived parameter values or initialize variables.
Variantes de componente
- Defining Component Variants
Use conditional sections to define variants within component file. - Defining Conditional Visibility of Component Members
Use annotation section to define conditional visibility of ports and parameters for component variants.
Técnicas avanzadas
- Enumerations
Specify a discrete set of acceptable values for parameters and event variables. - Creación de subclases y herencia
La creación de subclases permite obtener modelos de componentes basados en otros modelos de componentes por extensión.
Componentes de referencia de aplicación
- Model Linear Resistor in Simscape Language
Overview of how modeling in Simscape language works, using a linear resistor as an example. - Componente mecánico: muelle
El siguiente archivo,spring.ssc
, implementa un componente denominadospring
. - Componente eléctrico: condensador ideal
El siguiente archivo,ideal_capacitor.ssc
, implementa un componente denominadoideal_capacitor
. - No-Flow Component — Voltage Sensor
The following file,voltage_sensor.ssc
, implements a component calledvoltage_sensor
. - Grounding Component — Electrical Reference
The easiest way to implement a grounding component is to use a connection to an implicit reference node. - Composite Component — DC Motor
This example shows how to implement a DC motor model by means of a composite component. - Composite Component with Equations — RMS Voltage Sensor
TheVoltageSensorRMS
component implements a voltage sensor that measures the root mean square (RMS) value of AC voltage between two electrical nodes. - Triggered Delay Component
This example shows how to implement a triggered delay component. - Enabled Component
This example shows how to implement a component similar to a Simulink® enabled subsystem. - Interruptor con histéresis
En este ejemplo se muestra cómo modelar un componente utilizando gráficos de modo y enumeraciones. - Component Variants — Series RLC Branch
This example shows how to implement variants within a component file by using conditional sections. - Component Variants — Thermal Resistor
This example shows how to implement conditional visibility of component ports, parameters, variables, and a conditional custom block icon.