Is the Motor Shaft Input (LdTrq) required in the Surface Mount PMSM block (MATLAB/SIMULINK 2020a)? - matlab

I am trying to implement FOC algorithm in Simulink using the Motor Control Blockset. I want to simulate the iPower Gimbal Motor GBM2804H-100T with the Surface mount PMSM block. However, I don't understand what the LdTrq input is or how to set it up. SInce it is a motor I do not understand why a motor shaft input torque is required. Also if I am required to use this input, could I use a constant or would I need to do something else ? Please any help would be really appreciated.
Surface Mount PMSM: https://www.mathworks.com/help/mcb/ref/surfacemountpmsm.html

I have no experience with this block, but a quick glance tells me that in order to calculate al the variables in 'info', such as 'Stator phase current A', and others, you will need to have the torque on the shaft, and the Voltages across the 3 phases. From this Simulink calculates all the info
It seems that the block also gives the option of selecting 'speed'. Either way, it needs an input in order to calculate the dynamics
By the way, if you have a certain load on the motor shaft and you want to exert a torque on that load, or you want to bring that load up to a certain speed, than you can provide a torque profile as input. That is why it is called LdTrq -> Load Torque.

Related

Is there a way to get text only voltage and current labels on Simscape circuits?

I am new to Simscape. I would like to find a minimalist way to display voltage and current at various points in a circuit. Ideally just floating text labels with no 'wires' or connections visible. For example "Vbe 0.4v" or "Ic 20mA"
Currently I am using 3 standard blocks to achieve this and the circuit looks cluttered.
Is there a way to do what I want with some coding?
Currently, you have several options, some involve more work. Here are two ideas:
A) If your circuit is 3-phase, you can use the Busbar block and enable Frequency and Time solver in the Solver Configuration block, to display the initial voltages (and also power flows). This uses the Load-Flow Analysis feature starting R2019b. Check out this simple example.
B) Connect Voltage Sensor blocks to the nodes you want to sense voltage on, and connect the voltage PS output to a Simulink Display block, which will display the numerical value in real-time.

How to take values generated from a MATLAB program and display them in a Simulink block?

I have a working MATLAB program hooked up to an Arduino and rotary sensor that displays the current angle. I would like to display this angle on a Simulink model, so I can control a motor based off the current angle. Is there any way to do this without creating an angle sensor in Simulink and just using my MATLAB code that already works?
Your question is not really clear and it depends if you are trying to do it before simulation or during simulation.
If you want to do it before the simulation, just create a constant block with a variable name that is taken from the workspace, and let your function to set that variable in the workspace.
If you want to do it during simulation, it is a little more difficult but still possible. Lets create a sample a MVCE. The simulink model mask.slx contains a constant the is set to 0, and this constant value is displayed in the display block on the right. The simulation time is set to inf, so when you play it, you must stop it manually.
It is possible to checge the value of the constant while the simulation is running using this simple Matlab call:
set_param('mask/Value_to_set', 'Value', '10')
you should also consider that the constanta must be a Tunable gain (it is by default).
(as you can see the simulation is running).
There are some additional (and surely better) solution you can use:
Include your Matlab function in a MATLAB User Defined Function block, and call it at each simulation iteration. If you have compilation issue you shall follow the coder.extrinsic way (here an example for fmincon)
Use the Simulink Support Package for Arduino Uno Hardware Add-on that is available in the Add on store.

Simscape Physical Signal: Why does is exist?

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.

How to use Revolute - Rotational Interface to connect SimScape motor to SimMechanics Joint

I tried to rotate the revolute joint of a machine in SimMechanics. The actuator is from SimElectronics, so I use the Revolute - Rotational Interface block to connect the motor and the joint together. The whole block model is as follows (also available here)
But when I tried to run the simulation, I got the following error:
Not enough input derivatives were provided for one or more Simulink-PS Converter blocks associated with the highlighted Solver Configuration block, for the solver chosen. Implicit solvers (ode23t, ode15s, and ode14x) typically require fewer input derivatives than explicit solvers, and local solvers never require any. You can provide more input derivatives by selecting different options (including turning input filtering on or increasing the number of user-provided input derivatives) on the Input Handling tab of Simulink-PS Converter blocks linked below:
...'R0x2D1000iA80F_1joint_motor/Revolute - Rotational Interface/Simulink-PS Converter' (1 required, 0 provided)
I've tried to control the machine using SimMechanics Joint Actuator, which gives a correct result. The error occurred when I tried to control it with the motor from SimElectronics.
What's the problem with the model and how to solve it? Thanks
A few suggestions to try out:
Try removing the Joint Initial Condition block and see if it allows the model to run
In the DC motor block, try setting the rotor inertia parameter to 0 (as the inertia is provided by the SimMechanics part of the model). See the Warning on the Revolute-Rotational Interface documentation page
Make sure the initial condition specified in the Joint Initial Condition block is consistent with the initial condition specified in the DC Motor block
I would change how you connected your interface block to the DC Motor so that port B is connected to R, and F to C. This is because your Follower in the SimMechanics is welded to ground, whereas the Base if free to move.
Arnaud

Rotational mechanical system in Simulink

I'm simulating a shaft system in Simulink, where I have to find the displacement of a mass. I'm not sure how to model this in Simulink because of the shaft and pulley. I'm looking through the documentation and the closest thing I see to a shaft is the wheel and axle block. But the shafts are connected by a flexible shaft, which is similar to a spring. Any ideas?
This is a fairly trivial task when using SimScape, which is especially made to simulate physical systems. You'll find most of the blocks you need ready from the library.
I've used SimScape to create a model of a complete hybrid truck... In Simulink it can be done, but you'll need to build your own differential equations for the task. In your case, the flexible axle could be translated to another block with a spring/damper system inside.
If you haven't got access to SimScape, you may also consider to use .m (matlab) files to write your differential equations. This can then be used as a block in Simulink, varying (only) a few parameters over time.
Take this step by step:
1. Draw a free body diagram, write out equations for all the forces as a function of displacement, velocity and acceleration of every element (including rotation obviously). For instance, you know that force on the box m will be *c*dy/dt* plus whatever the pulley experiences.
2. Sort out the rotation of the rod first. You know that *T=I*d(omega)/dt* if you get rid of the rest of the system. So, do something analogous to the car engine example of MatLab: Divide the input T by I to get the acceleration, integrate it to get velocity and one more time to get rotational displacement.
3. Keep adding bits one by one. First, you know that there will be a moment proportional to k*(theta_1-theta_2) acting. This will oppose the motion of rod 1 and act to create motion of rod 2. Add a new "branch" to your model to get theta_2 same way you got theta_1.
4. Go on including further elements...