I just completed the “Simulink Foundamentals” course helded on Matlab training online platform.

certificate

The course allowed me to hone some skills in using and optimizing the simulation environment developed by MathWorks.

Simulink

Simulink is a simulation environment that, through block diagrams, allows you to design systems with multidomain models, perform simulations and then proceed with distribution without writing code. It is a graphical extension of Matlab and allows you to interact through blocks capable of representing elements of the system, inputs, outputs or subsystems.

One of the great advantages of Simulink is its ability to solve nonlinear equations and deal with complex systems by integrating with the potential of Matlab.

Simulink blocco block

It provides a library of building blocks and the possibility to create new ones and import them via add-ons. Once several blocks have been imported into the worksheet, it is possible to draw lines that join them and create a virtual system with the dynamics of real systems.

For example, the most classic example of the pendulum can be easily represented. Represented by the dynamic equation:

\ddot{\theta}+{g\over L}\sin \theta =0

It can be modeled and solved. It can be seen how, in ideal conditions without friction, the pendulum oscillates between +/- 30 °.

pendulum
simulink pendulum

3D printer controller

Within the course we proceed to the design of a controller for printing using 3D printers. Most printers follow the same principle: they divide the object into a set of layers and deposit the material layer by layer. The material is melted at a high temperature and then solidifies after being deposited.

3D printer simulink controller

Each layer must be completed before depositing the next and this allows you to see the 3D printing as a sequence of 2D layers. The overall system provides for the control of:

  • DC motor dynamic
  • Printer nozzle dynamic
  • Nozzle position control system
  • Read input from external sources
  • Visualize printer movements and printed layers

Modeling

The model, however simple, involves the interaction of different systems that can each be represented by a different block. A hierarchy of the model is then defined which allows to relate different subsystems.

Therefore it is possible to define communication ports and interfaces with the outside world and between different systems. Different blocks are created for the logic that controls the nozzle, printer, and controller.

Optimization

In modeling, one also has to deal with the difficulty of balancing accuracy and computation time. Simulink provides several ODE solvers.

optimization
ODE solver

Clearly, by simulating a discrete problem there will be no approximations while simulating a continuous system, numerical integration will have to be used. This introduces approximations and the need to evaluate how much the simulated system is actually representative of reality.