Simscape Physical Signal: Why does is exist? - matlab

What is the added value of simscape physical signals compared to normal simulink signals? As far as I can see, from a functional perspective there is no difference between the two types of signals: I can add units to both types, they both have a direction of flow, and they both have similar function blocks like adding, substracting... Only for physical signals the available types of blocks is very limited. Why didn't the matlab guys just use normal simulink lines instead of the physical signals?

Physical signals, unlike Simulink signals, have units associated with them. This means that they follow a number of rules, for example to ensure that the right unit is used (e.g. you can't add kg and m/s). From the documentation:
Using the Physical Signal Ports
The following rules apply to Physical Signal ports:
You can connect Physical Signal ports to other Physical Signal ports with regular connection lines, similar to Simulink signal
connections. These connection lines carry physical signals between
Simscape blocks.
You can connect Physical Signal ports to Simulink ports through special converter blocks. Use the Simulink-PS Converter block to
connect Simulink outports to Physical Signal inports. Use the
PS-Simulink Converter block to connect Physical Signal outports to
Simulink inports.
Physical Signals can have units associated with them. Simscape block dialogs let you specify the units along with the parameter
values, where appropriate. Use the converter blocks to associate units
with an input signal and to specify the desired output signal units.
Any sensor block in Simscape (in whatever physical domain) will output a physical signal. You can then convert it into a normal Simulink for feed to your controller. Similarly, any source block in Simscape (in whatever physical domain) will take a physical signal as input.

I suggest you just read the Simscape product page
In particular,
Simscape components represent physical elements, such as pumps, motors, and op-amps. Lines in your model that connect these components correspond to physical connections in the real system that transmit power.
Accompanying that description is the following image, which shows how Simscape models can be far more intuitive to build than a model which uses standard signal. This means models are far more maintainable and clearer to, for example, engineers who may not have a comp-sci background.
Let's delve into what a "physical connection" is somewhat.
[Simscape] employs the Physical Network approach, which differs from the standard Simulink modeling approach and is particularly suited to simulating systems that consist of real physical components.
[ ... ]
Each system is represented as consisting of functional elements that interact with each other by exchanging energy through their ports.
You stated in your question that both methods have a flow direction. This is wrong!
Simscape blocks try and balance the energy between the inlet(s) and outlet(s). For instance a fixed orifice in a fluid system may have high pressure on one side. Simscape will try and solve the pressure balance each iteration. You would need some custom Simulink subsystem to achieve this if not for Simscape.

What is the added value of simscape physical signals compared to normal simulink signals?
What is it that you think Simscape physical signals provide? Is it one number? How do you solve a mass-spring-damper system with just position? It's position AND it's speed AND it's acceleration.
I can add units to both types
No you can't. You put whatever you want in Simulink. You don't get to choose anything about what's in the physical signal in Simscape. You can specify units in the blocks that the signals connect, but you don't get to pick what the pipe itself is carrying.
they both have a direction of flow
No they don't. Your head and your torso are connected. There's no directionality to this. They're just connected. The physical signal is likewise just showing that (things) are physically connected. Again, the mass-spring-damper system: If the damper points to the mass, and the spring points to the mass, then is there any possibility that the damper could affect the spring? Yes, of course. The damper affects the spring because the damper affects the mass and the mass affects the spring.
The spring affects the mass, and the mass affects the spring. The signal is bidirectional. You're confusing signal directionality with kinematic chains.
they both have similar function blocks like adding, substracting
If you're on a train that's going 30 mph, and you're walking forward at 3 mph, how fast are you going relative to the world frame? What if you're walking backward? There is a physical meaning in adding and subtracting physical signals.
[For] physical signals the available types of [function blocks are] very limited
What is it that you're thinking they're missing? Can you also provide a description of what the physical meaning of that function block would be?
Why didn't the matlab guys just use normal simulink lines instead of the physical signals?
Because they're not the same. The biggest point is probably that Simscape is signal + derivative + second derivative, but again they're just conceptually different. Simulink is an easy way to write code - do this step, move along the arrow, do the next step, etc. Simscape is a pictorial representation of a physical system. The physical signal lines just show that things are connected. The system gets solved simultaneously.

I don't think it's mainly about the enforcement of physical signal units, nice though this is.
I think it's about the solver - and before it gets to the solver, about the choice of states and equation causality - rearranging the equations ready to be solved.
Simulink doesn't have any truck with this and just gets straight on with integrating signals as a succession of samples. I know it gets complicated with variable step solvers, but they are only doing extra fancy numerical analysis with the sampled data. Integration and the here-and-now is what it's all about!
Simscape just starts with a bucket of variables and a bucket of equations that variously depend on said variables. A 'bipartite graph', I believe they call it.
Just as we have to navigate a route through simultaneous equations to pick off the simple ones and substitute (or the matrix equivalents of this) Simscape has to do likewise in software so wants to keep alive augmented info on signals like which equations they are in and whether it knows or can easily obtain their derivatives, what they are, etc. Physical signals behave for us users just like Simulink signals, but I reckon they are there to provide the valuable service to Simscape of keeping this augmented info alive and linked between blocks so that one massive matrix equation can be formed for the whole system, not separate ones that get sampled as Simulink systems between Simulink blocks.
This rearrangement of equations ready for the more conventional solver getting stuck in is a black art indeed! We learn very little of how Simscape does it from the MathWorks docs, but you can install OpenModelica for free and see how that does it.

Related

Converter control simulation on simulink

I am struggling with a little project I decided to tackle. I am trying to replicate an example I found on a book using matlab simulink but I have no experience with simulink and control theory (I do understand the principles etc.).
The control block diagram is given but I do not understand some blocks and how to add my input (sine wave block on simulink)?
Here are the details:
Example I wish to reproduce
Schematic of the converter and desired control block diagram
If anyone could give me a little insight or direct me to some examples from which I could build on an understanding would be great!
Thank you in advance.
The portion entitled controller is the closed-loop feedback control for the system. K(s) would typically contain some type of PI control. In a more complicated control system, the structure of K(s) may be a little different, but will usually always contain an integration in order to ensure that the system eventually settles at the desired value.
The input Iref is your current command. In this case you would inject your sinusoid here which would produce a current waveform matching your desired output. If your desired output.
Output m is the modulating waveform produced by the controller. Everything inside the half-bridge converter section is a representation of the converter and everything that it is interfaced to (voltage sources).
The feedforward filter here is also a very important component. Since Vs contains an alternating waveform, the feed forward filter allows the system to respond to changes in Vs without relying on feedback compensation K(s). This helps to decouple current regulation from changes in voltage VD.
To start with the project, you can probably build the half bridge converter as shown. You can inject 400*cos(377t - pi/2) as VD.
For the feedback compensator K(s) you can feed the input into two gains (Ki and Kp) which you will select values for later. At the output of Ki insert an integrator (1/s) then sum the output of Kp and the integrator together.
For the feed-forward filter, you should probably just use a low pass filter with a gain of 1 at DC. The low pass filter prevents noise from entering the system. In this case you are running a simulation, so there will be no noise. However, the filter will eliminate any algebraic loops, which can cause warnings or errors in the simulation.
You can input your control signal at Iref.

Simulink: Make signal available in all subsystems

I have a larger model with many subsystems. In some of those subsystems I repeatedly use the same signal (e.g. the exact same noise signal). What is the correct way to make a signal available in all subsystems? I was thinking of Data Store or From/Goto, but From/Goto does no work (for me) with subsystems.
I'm aware, that using in blocks would do the trick, but I already have many in/out blocks and it just makes the whole model unclear.

How to implement math operations to bus signal MATLAB

I work in Simulink and have bus signal (now it consists of 11 signals, every signals is a vector). And I want to make some operations on this bus. It means to make the same operations at each of this 11 signals included in Bus.
I tried this way:
Just implement all my functions and operations at whole Bus. And some blocks (for example, Zero-Order Hold) works fine (it implements correctly to all it's signals). but next block - integrator - works fine (it really integrate all signals) but that crashes my Bus! It returns one vector. It has size equal to the sum of all Bus's signals.
I know I can use Bus Selector block to create 11 parallel signals and copy all my operations for each of them.
How to get Bus signal in more efficient way?
I made it this way (don't attach it like an answer, because Corey Z give the answer at the same time):
Is there any reason that you don't want to convert your bus to a vector to put it through the integrator?
Each vector signal in the bus will be appended to a 1-dimensional vector signal. The vector will come out of the integrator in the same dimensions that it went in and then can be turned back into a bus if need be using the bus creator tool under the signal routing toolbox.
On another note, it seems that you have some discrete time domain elements mixed into your block model along with your continuous-time integrator. If that gives you errors you may need to look into the Discrete-Time Integrator block.

Using labels with simpower simulink library

I was simulating a winding generator using the simpower library from Matlab's simulink and the schematic turn to be quite big. That when I discovered that labels (blocks "Goto" and "From" in simulink) don't connect to simpower wires. What are the options to solve this?
The SimPowerSystems connections are physical connections, they are not like normal Simulink signals. You cannot have Goto/From blocks for physical connections, it doesn't make sense, plus it would make the model completely unreadable. If you think about it in a physical sense, you cannot break a physical shaft half-way through and say "go and pick the other half at this place".

Input/output port in Simulink

Is there a way to create an input/output port in Simulink (some workaround)? The port would be a bus and some signals are set from outside the block while some signals are set by the block. Here is an example:
Given the following bus:
Flow (scalar)
Composition (vector)
Enthalpy (scalar)
I would like Flow to be set from outside the block (there's a pump downstream which sets this value). Composition and Enthalpy are computed by the block.
My solution so far: Make Flow an input into the block and with direct feedthrough set it on the outport. I don't find this solution intuitive because from a graphical point of view the outflow becomes an input into the block (which is true from a math point of view - but I would like to make the Simulink diagram intuitive). I've seen in Modelica the possiblity to create input/output ports (RealPort) and the signal could be read or written by the block. I would need such a feature in Simulink.
It sounds like you need to use Simscape and SimHydraulics, which do excatly what Modelica does, but within Simulink. Each physical domain is represented with through and across variables, which are flow rate and pressure for the hydraulic domain. However, that's extra $$/££/€€ and a new modelling paradigm (you don't think in terms of inputs and outputs anymore)...
If you stay with Simulink blocks, there isn't much else you can do above what you've already done, although I assume you mean the flow is set on the input, not the output.