Rotational mechanical system in Simulink - matlab

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...

Related

Modelica : Simulation of temperature rise in a cable - How to do?

I am a beginner on modelica. I wanted to transpose a model found on a paper (on internet) to a modelica model.
Here is the paper :
Insulated Cable Temperature Calculation and Numerical Simulation
I am stuck in rewritting the fomulas. Second derivative on a variable different of time --> i don't know how to do.
Another way I was thinking is to use the Thermal/HeatTransfer library. But here too, I don't know how to put the blocks togethers... I think this is due to a big lack in thermodynamic knowledge from my side.
--> I don't know what block to use to simulate the conductor and the insulation layer.
Maybe this is something too difficult ?
If someone has an idea on how to start, it will be a pleasure to read you :)
I tried to use the Thermal library :
Using heat transfert lib.
I have a current source and a resistance.
The resistance will change depending on the temperature involved by the current in the resistance.
I use 0.004 as alpha for the relationship R=R20*(1+alpha(T-Tamb)).
Let's say I have a 1 meter copper conductor with a crossSection of S=16mm² = 15.10^-6m²
then the initial resistance is R = rho.L/S ≃ 1.07mΩ at 20°C
Following this example of cable : Bayka 16mm²
To get 70°C at the surface of the conductor, then the max current for a single 16mm² wire cable is 107A in air, and 160A in earth.
I took, in my example, random value of thermal conductance and capacity to get an approximative temperature near the one given in the table (~70°C).
Is this model is the good one for an insulated cable ? (no considering values)
Or I forgot something? Maybe I am wrong in the position of the blocks ?
What do you think ?
Looks reasonable to me, might be easier to use the same component for heat conduction (heat resistor or heat conductance, not both) in order to be able to compare the two values. The mathematical formulas for radial heat conduction can be found here e.g. https://web2.clarkson.edu/projects/subramanian/ch330/notes/Conduction%20in%20the%20Cylindrical%20Geometry.pdf

Iteratively display values during optimization process in MATLAB

I am using lsqnonlin in MATLAB to align a rigid skeleton model to raw joint center data recorded from a device that does not necessarily yield a rigid skeleton. Therefore, my objective function to be minimized is the distance between model joint locations and raw data joint locations.
My algorithm does a pretty good job (red is the rigid model and blue is the raw data):
except for some select frames where my skeleton is off:
I am interested in examining the solution process graphically so that I can visualize what lsqnonlin is trying to do for every frame. Ideally, I would output a History but this seems to be only available for other solvers.
For lsqnonlin it seems that I need to specify a plotting function for the PlotFcn option in optimoptions. I have extracted from the optimation Toolbox the function optimplotx.m which displays a bar graph of the state variables during the iteration process as lsqnonlin converges. My plan is to tweak this function to reproduce the plot for the red skeleton previously displayed.
My problem is that the quantity to be optimized is not the joint locations themselves, but joint angles. I have another function which does forward kinematics and gives me joint positions from joint angles. I would like to pass model parameters into optimplotx.m so that I may call my forward kinematics function and get the plot done but I am unsure how to do that.
These are the inputs to optimplotx.m:
It seems that somewhere deep in the Optimization Toolbox, MATLAB expects these inputs, and they are not to be changed. It is required that I call #optimplotx anonymously anyway, without passing in arguments. It seems that the only way I might be able to get around this is to make my model parameters global in both my main file and optimplotx. Is there any way around this?

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

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.

How to model mechanical stops to hydraulic cylinders in Modelica?

I was wondering how a mechanical stop can be modeled most efficiently.
I do a hydraulic simulation with a controlled hydraulic cylinder in OpenModelica. For the hydraulic cylinder I use the sweptVolume model from the Modelica Standard Library.
What bugs me about this model is that there is no mechanical stop if the piston reaches the bottom of the cylinder.
I tried several ideas with no good result. I tried to reset the displacement of the piston to zero, if it hits the bottom, via an if-expression. But this is not really a good option due to the fact that the volume is calculated using the piston's displacement.
I then tried to introduce a force that equals the force applied to the piston, if the piston hits the stop. This option didn't work either, because in this case the pressure inside the cylinder can not be calculated.
The third try was to use the MSL model of MassWithStopAndFriction linked to the translational flange of the sweptVolume model, but this model seems to be broken for me.
Now I count on you as a competent community to bring in some more ideas for me to test.
Depending on your application, you may deploy the Hydraulics library? The library aims to model (compressible) fluid power systems and contains cylinders with end-stops. Its scope is different than the Fluid package you are using.
Using when and/or if statements for this task, I'd strongly discourage from experience. You may get one cylinder to work, but using that in a larger system will definitely get you into numerical problems. Have a look at the Mechanics package and analyse if the ElastoGap can be of any use to you.

Can an integrator be used as a two way directional valve?

I am new to designing real time plant models in simulink, and i have to include a 2 way directional valve in my model, i could take the orifice model and make the pressure differentials zero when direction is from B->A. Can i use an integrator to do the same? or is there a more appropriate block that is less complicated?I am using MATLAB 2012b
Thank you!