- 4
- 63 302
Electrification Enthusiasts
United States
Приєднався 17 січ 2020
Generating Code with Simscape Models
Learn how to set up your Simscape model to work with traditional code generation workflows in Simulink. This can be used for real-time applications, FMI/FMU applications, as well as DPI C workflows for verification.
Переглядів: 902
Відео
Simulink Crash Course/Tutorial Part 1
Переглядів 2,7 тис.2 роки тому
Unofficial tutorial to get started using Simulink. Working toward baseline technical skills for system modelling, control algorithm development, and hardware design. Covers: - Basic time domain modelling - Sinks, sources, and modifying signals - Vectors - Discrete (fixed step) vs continuous After a few more fundamentals, videos of this course will go deeper into aspects of Simulink geared mostl...
Simscape Electrical: Solver Settings - Best Practices
Переглядів 9 тис.3 роки тому
Focuses on actions you can take in selecting your solver settings. Example model here: www.mathworks.com/matlabcentral/fileexchange/100381-dab_converter?s_tid=srchtitle MathWorks happens to have free training courses as well: matlabacademy.mathworks.com/details/circuit-simulation-onramp/circuits
Simscape Electrical Crash Course/Tutorial
Переглядів 51 тис.4 роки тому
Unofficial tutorial to get started using Simscape Electrical. Covers: - Basic buck converter analysis - Generate PWM signals - Choose correct switch model fidelity - Difference between Simulink and Simscape - Create and log signals - Close the loop with PID control Simulink Onramp: www.mathworks.com/learn/tutorials/simulink-onramp.html
Good job! I thought you would do root mean square.
Thanks sir
Excellent.
Dude literally save my ass orz
what about code generation for this dc-dc converter? can we generate code?
why embedded coder for simscape? why dont we use simulink coder?
Elaborate on how to use different solvers for different modules of a model
Hi, I'm very interested in this topic. Can you share more use case / examples and what type of hardware you would typically deploy a Simscape model onto a target and why? And can you give some examples of what FMI/FMU/DPI workflow is and what types of problems it tries to solve?
The most commons use case is to deploy to speedgoat real-time hardware as MathWorks directly supports this vendor. However, you can use pretty much any real-time hardware for this workflow. This would be in order to implement real-time hardware in the loop testing. This allows testing without high voltage/current HW for initial test/debug of control hardware. FMI is a specific way of implementing models so that disparate models from different software vendors can be combined in a unified framework (the idea is usually nicer than the reality as its very hard to integrate models from different tools even if there is an interface for it). DPI C is a specific way of using c code to integrate with tools often used for chip design to do verification of designs. (xilinx/cadence are examples)
I am developing a custom power converter. I tried using Simscape to simulate it, but the results were completely nonsensical. This video provided invaluable information about the appropriate solver type that should be used for this type of task, along with a lot of other useful information. Thank you so much!
You should make more of these!
Can discrete state solvers be used for simscape models? If not, what models do I use to have a realtime deployment for eg. in a microautobox?
This is a reallyy good video! Thank you so much
Nice work! I use Simulink heavily for EV powertrain design and modeled our HV DCDC converter exactly the way you described. But like you described there's a lot of output ripple. What other methods of control loop other than a larger capacitor will minimize the current ripple? I heard there's peak current control which I haven't looked at yet.
For a given load and a specific topology, ripple is primarily controlled by the sizing of your components and switching frequency or switching approach (not all approaches have a fixed switching frequency). You can also put converts in a parallel with phase shifted carrier signals for PWM. Different control approaches can be used to improve harmonics, but at steady state, if operating at the same switching frequency, ripple will be the same across control methods.
Amazing video! Thank you very much for this content. Have you ever used LTspice components (SiC MOSFET) in Simscape Electrical? I know that the subcircuit2ssc function allows the conversion of .lib files and then the component can be generated in library browser. I have done all these steps. In the case of a buck converter, the signals are good. In the case of a single phase h bridge inverter, the simulation time becomes extremely slow, the signals are not good, etc. I have not found any examples or mathworks videos, using this approach with an inverter. You will save me if you make a video about it :D
Unfortunately, some of the LTspice models uses LTspice proprietary functions that don't import, so I have to look for PSPICE equivalents or hand modify the file to get the import to work. At that point I'm more likely to just use the n-channel mosfet and parameterize it from the data sheet.
@@electrificationenthusiasts8611hello, do you have a video about how to parametrize the n-channel mosfet from datasheet?
thank you
You're welcome
Man, I like your videos, please continue. You're doing a splendid job!
Thanks! I hope to, once I adjust to being a new father...
Is it possible for you to create such a video for a 3-phase power system project?
Love your videos :)
Thank you!
Hi, I follow your work but I cannot get the same result as yours. it just almost a straight line in the scope. Please advise
The most likely culprit would be that the dc voltage source is set to 0V, or that the PWM signal isn't actually turning on the Switch (check if it is correct value, and that it is connected). Other than that, a connection error is possible. MathWorks provides working examples that you can also work off of: www.mathworks.com/help/physmod/sps/ug/buck-converter_example-ee_switching_power_supply.html
excellent explanation, thank you
You are welcome!
Sir how to eliminate the time 0.00not finite in matlab simulink please help us sir
Unfortunately that is a pretty common error. It usually means the model as set up isn't realistic, but typically requires someone to look at the model and debug it to see what is wrong.
Brother how to take dc motor and centrifugal pump output in simscape
To get simscape outputs, you use sensor blocks or the probe under simscape utilities.
Great tutorial! Thank you!
Man, I like the way you explain the stuff, thank you very much for your awesome work here! I would be happy to see a course in Electrical Engineering done on Simscape by you. Take care and all the best!
Does the solver and the algorithm behind is distoring the simulation. For example, te solver itself makes the simulation more damped than it is. I ve been simulating converter with switch model and DPL. I tried to replicate high-frequency resonance, I suspect the simulation is overly damped than it should be. Could you please explain to us that how the solver changes the system damping
A computer simulation is almost always an estimation of numerical equations, and even those equations if solved analytically, are a simplification of reality. For an ODE solver, which plays a large role in Simulink, certain algorithms have a tendency to either over estimate, or under estimate the integral of an equation. This is particularly noticeable for first order methods like forward and backward Euler. If you are using a variable step solver such as ode23t or the DAE solver, you probably aren't going to see an issue with damping. However, to make sure, you can tighten your tolerance and see if the simulation changes. By default, the simulation tolerance is rel: 1e-3, and abs: auto. You can change both of these to 1e-5 and see if your simulation results change. If there is no difference, it is likely an issue with the model or model parameters, and not the solver. If the tighter tolerance makes a noticeable difference, then you have a particularly challenging topology for the solver to handle and will need to have slower simulations with the tighter tolerance to get accurate results. Having particularly fast frequencies on top of an otherwise slow system (think wide bandgap device turn on and turn off transients compared to line frequency) can be a reason you would need tighter tolerances. One thing that happens when the tolerance is made tighter, is essentially the solver takes smaller time steps (I'm leaving out why and how for brevity), and the smaller the time step, the more accurate the estimation of the integral. The integral error approaches 0 as the time step approaches 0, but it is physically impossible to have a time step of 0, so you always have some error.
Can you please explain advantages of simscape models over simulink models.....why should we prefer simscape models.
The simple reason is that is is much easier to put together complex models in Simscape than Simulink. Simscape supports bi-directional connections while all Simulink models must be represented by input and output ports. This makes Simscape models much easier to maintain and change compared to Simulink. Getting deeper into the math, the Simscape engine can solve DAEs which allows for more accurate representations of things like variable resistances and other physical realities that can't be represented as well by an ODE. A good exercise if you have free time, is to design your own RC circuit in Simulink and then in Simscape. Then add another RC circuit across the capacitor of that circuit. It is very easy to do in Simscape (just cut and paste), while it is hard to do in Simulink (your must rederive all of the equations).
Oh I see, your switching the transistors to control charge of capacitor to achieve desired voltage, I’m guessing that’s what the voltage control mechanism involves. I like this tutorial because of the emphasis on practical applications regarding the use of simscape to produce some predicted behaviors. This tutorial seems to convey the significance of simscape in that it’s an implicit modeling tool that’s more intuitive compared to simulink as an explicit modeling tool. As a result of feedback in simulink the need to avoid algebraic loop and so introduce an integrator in low pass filter. I guess you choose to impliment the control portion in simulink because there are more blocks to choose from. I say that because algebraic loops are avoided if the feedback is implemented with simscape physical signal blocks
You are correct. One rule of thumb I use to simplify the decision is this. If you are going to implement your controls in a digital/embedded system that is clocked, use Simulink, and break the loop with a unit delay representing the controller update rate. If you are implementing it analog, leave everything in simscape (granted, it's easier to tune the controller in Simulink). However, if you want to go to Simulink for the loop design, there is a trick to getting past the algebraic loop although it's a little bit of a hack. For instance, if you want to close the loop on the inductor's current, you can measure it's voltage with a sensor in Simscape and pass that signal through an integrator in Simulink, divided by the inductance. This will tell you the current very very very closely to what simscape will calculate, and having the integrator in the Simulink portion of the model breaks the loop. This would cause problems if the simulation was run for a very very long time, but the error is so small it takes a while to accumulate and is very useful for tuning gains and using the controls toolboxes for initial loop design before going back to the hardware design for implementation.
An extremely useful video, much appreciated! Waiting for more :) (P.S. liked and subscribed)
Thanks for the great explanation, I wish to know how to simulate constant voktage constant current charging of a battery using simscape . Thanks
I'm looking into this, they released an example here: www.mathworks.com/help/physmod/sps/powersys/ref/cccvbatterycharger.html but there are no files associated with it. It's a good document to explain the nuances, but doesn't provide a good starting point. This is a file exchange entry that has decent reviews that tries to implement it: www.mathworks.com/matlabcentral/fileexchange/72570-lithium-battery-charger-block?s_tid=srchtitle. The best way to do it is to model a converter that changes control modes from voltage to current, but this requires designing two closed loop control systems and coordinating the transition between them, which isn't an easy starting point. To do something simple, you could have a controlled voltage source behind an inductance in parallel with a controlled current source. Put an ideal switch on the output of each one and switch between which you want to use (there will likely be an artifact at the cross over point unless you add some snubbers/tune circuit paramters to clean it up.)
@@electrificationenthusiasts8611 please i wanna know how to creat a block of loss in simcape for an induction motor
Very good tutorial, thank you!
really cool tutorial, great work
Please make more videos on electromechanical system like Horn of bike, magneto assembly etc.. We will be very grateful to you please🙏🙏🙏
Great video waiting for more
Great video! May have just saved my semester lol. I would be curious to know how to do some of the more in depth options that you kind of skipped over for the sake of simplicity. You should definitely make some more tutorials.
It would be nice if you implement the buck converter in current mode control . Thank you
I wish you have more videos like this
Well done. Comparing to LTspice. Can you do C code blocks in Simscape Electrical?
You can bring c-code blocks into Simulink, you would need to interface them to the simscape network through controlled current and voltage sources.
Thanks a lot
This is a great tutorial. You should definitely do more.
Brilliant tutorial. Fair play to you.
I was having headache with the simulink to PS signal connection.. This saves my life..TT
This is the best video about matlab for power electronics that i have seen It is much better than the webinars from mathwor. Perfect balance to make a model to work. The webinars from matwork focuse too much in other aspecst and very little about the simscap issues For example; one webinar that uses the sepic comverter focused so much in the power electronics concepts and very little about the simscap solver
please do you have an idea about how to creat a block of loss in simcape for induction motor
Keep it up man !
I have seen using black resistance as load in some tutorials but I couldn’t get them in my libraries and the boundary connectors are not proper there All other part of my circuit are simulink modules(black coloured) Any solution or correction do you have
the black circuit elements are part of a sub library called specialized power systems. They use a different technology implementation and are not compatible with standard simscape components. There are ways to connect them, but generally make the simulation slow or unstable. Most times, there is a direct equivalent block in the simscape library that you can use instead.
I suspect the black mosfet is just to provide more of a physical interpretation to standard simulink blocks. While simscape is true implicit modeling with predictions for both current and voltage and so power delivery occurring at the terminals So I guess the black components are masked subsystems to be more representative of actual electrical components
very good and pedagocial video....
Thanks a lot, nice
Great video.
Please upload more! Great step by step introduction combining simulink and simscape components. *Subscribing*
Thanks a lot for this amazing tutorial. Are you working at Mathworks? Otherwise, do you have any blog/website where there is more materials about simscape/electronics?
Great Video