With the latest release of MBDT for S32K, we provided with our library a couple of blocks designed to cover most of the MC3377xB family functionalities. Because the article has created a great community interested in using the NXP parts in the Simulink Models, we decided to add native Simulink support for the battery cell controllers.
#Statcom matlab simulink model how to
Since one of the greatest education theories is ‘learning-by-doing’ we chose to present the custom code insertion as a hands-on approach on how to add support in Simulink for a family of battery cell controllers, the MC3377xB. By presenting this MathWorks feature, we provided to our users the power of using the familiar libraries or C pieces of code directly in their models, making our controllers capable to connect to any external devices. You can read more about GUI for Simulink here.A couple of months ago, we've posted an article titled How to use your own C code in our Toolbox. The aim of the article was to provide a step by step guide on how to use custom code in the Simulink models. So now you can create common Matlab GUI and work at this variables! There is no any difficulties. t- time array, y - matrix of all outports values (it already double and contain only values without times, but for each simulation time!) We have one more method to take output values: = sim('model_name') Yout.get(2).Values.Data - give you values of this outport at each time Get the values of any of outports: yout.get(1).Values But if you add outport block (like at my image) you also get another variable in workspace yout. After you run simulation you get tout variable in main workspace. Interesting that the last solution give you ability to change parameters during the simulation!Ībout getting output. Read more about sim and about finding current blocks. You even can find any block in your model and change it's properties. By the way: you can change some parameters of your model using sim. There are different properties of sim function, read about them in help this can be useful for you. Name_of_model must contain path if model is not in the active MATLAB folder (active folder you can see in your matlab window just under the main menu). Now you can run your simulation using sim function: sim('name_of_model')
![statcom matlab simulink model statcom matlab simulink model](https://fr.mathworks.com/help/examples/sps_product/win64/power_dstatcom_pwm_01.png)
(There are different callbacks - on Loading, on Starting and etc.). You can do it by adding script name in Simulink/Model Explorer/Callbacks. One more useful way is to create script containing all your variables and load it at Simulink model starts. There are several ways to initialize this constants for Simulink. So you can change your variables values at command window (or just at your script) and run Simulink model. One option I personally don't recommend is using a for-loop and calling the simulink model with a different value of roll and pitch for i = 1:numberOfTimestepsĪ second and more efficient approach is changing the constant blocks to other source blocks like ramp signals or sinusoid signalsįirst of all Simulink model use main Matlab workspace. There are multiple ways of achieving time dependent input variables: You can put a variable which is defined in the calling script. You can define the duration of your simulation in the block diagram editor. To get the outputs to your workspace you can use the simout block (make sure to put Save format to array).Ĭonnect outputs of your simulink model to the simout blocks.
![statcom matlab simulink model statcom matlab simulink model](https://d3i71xaburhd42.cloudfront.net/501861c39a20855e9b636b050cce7aece1c19799/2-Figure1-1.png)
I got a warning saying: Input port 1 of 'SimpleDroneDynamics/.' is not connected. It takes in two inputs (roll cmd, pitch cmd) and outputs velocity x, velocity y, position x, and position y.įrom here, it seems like I can open the system by calling open_system('myModel.slx', 'loadable') īut how do I put inputs and get output values? slx Simulink model for drone dynamics system. I'm a super beginner in Simulink models and control systems.