| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → SimMechanics |
| Contents | Index |
| Learn more about SimMechanics |
| On this page… |
|---|
This demo model uses a few blocks in the library to simulate a simple machine with feedback control. You will see how SimMechanics features build upon standard Simulink features to model a mechanical system.
The demo model simulates a conveyor belt loading mechanism. A simple controller (not shown), with a sensor and an actuator, guides the mechanism with a saturation limit and anti-windup logic for the applied torque. The controller is user-adjustable and sets the stopping point for the pusher.
Conveyor Loader Mechanism

Click here to open a detailed mechanical drawing of the conveyor.
The conveyor mechanism demo illustrates some important SimMechanics features:
Representing bodies and degrees of freedom with Body and Joint blocks, respectively
Using SimMechanics blocks with normal Simulink blocks
Feeding Simulink signals to and from SimMechanics blocks with Actuator and Sensor blocks, respectively
Encapsulating groups of blocks into subsystems
Visualizing and animating a mechanism by its component bodies
Caution You might want to make modifications to this demo model. To avoid errors,
|
To get started quickly with the conveyor demo model, follow either of these steps:
Enter mech_conveyor at the MATLAB command line.
Online Help users can click the model name mech_conveyor here.
You can open the complete SimMechanics demos list by:
Clicking the Start button on the lower left of the MATLAB desktop.
In the pop-up menu, selecting Simulink, then SimMechanics, and then Demos.
This opens the SimMechanics demos list in the MATLAB Help browser.
You can locate and select any specific demo entry from the list of models.
Alternatively, you can open the same SimMechanics demos list by entering demo simulink simmechanics or demo('simulink','simmechanics') at the MATLAB command line.
The block diagram model opens in a model window.

Here are some critical features of the model:
Ignore the Position Controller, Joint Sensor, and Joint Actuator blocks for a moment. Note that the loading mechanism follows the tree of bodies and joints shown in the figure, Conveyor Loader Mechanism:
There are four rotating link bodies and one sliding pusher body, as well as three ground points on the immobile mounting represented by Ground blocks. Double-click the Body and Ground blocks to see their dialog boxes.
The pusher slides and the links rotate relative to one another and to the ground points on the mounting. There are seven apparent degrees of freedom (DoFs) in the system, represented by seven Joints, but the geometry constrains the motion to one actual DoF. Double-click the Revolute blocks to see how rotational DoFs are expressed in their dialog boxes.
The Prismatic block expresses the linear motion of Pusher relative to Ground_2. The Revolute block expresses the angular motion of Link4 (the crank of the whole mechanism) relative to Ground_1.
The Joint Sensor detects the position of Pusher via the Prismatic block. The Joint Actuator applies torque to Link4 via the Revolute block. Double-click the Sensor and Actuator blocks to view how the mechanical motions and forces/torques are transformed into Simulink signals.
The Position Controller subsystem converts the Pusher position information into a feedback signal to actuate Revolute and thus Link4. You can open the Position Controller block to view this subsystem, which is made of normal Simulink blocks.

The Reference Position block gives you control over the stopping position of the pusher by modulating the control signal that actuates Revolute. Maintaining the initial pusher position requires a fixed torque on Revolute.
Open the Scope block. You can view both the Pusher position in millimeters (mm) relative to Ground_2 as the Measured Position plot and the torque in newton-meters (N-m) applied to Link4 relative to Ground_1 as the Torque plot.
You can now run the model as it is when you first open it:
In the Simulation menu, select Configuration Parameters. The Configuration Parameters dialog box appears. Select the Solver node:
The preset Stop time is inf, so the simulation keeps running once you start it. You should leave it at inf and stop the simulation manually the first few times you run it.
Later you can apply a finite stop time (in seconds) if you want.
Leave the Solver options entries at default values and close the box.
From the Simulation menu, select Start. In Microsoft Windows®, you can also click the Start button in the model window toolbar.
The measured position of the pusher and the torque applied to maintain that position start and remain essentially constant in the Scope plots. The applied torque is adjusted to maintain the initial pusher position.

To see greater detail at the simulation start, stop the simulation before the time passes 20 seconds and zoom in on the Scope plots.
Here is a modification of the demo you can try. It illustrates the simple user-driven controller you can adjust to change the motion of the pusher.
To make these modifications, it is best to close and restart the demo.
The Reference Position block is actually a Simulink Slider Gain block (from the Simulink Math Library) and controls where the pusher comes to rest.
You can adjust the Reference Position block to change where the pusher stops:
Open the Reference Position block. You see an adjustable slider to set the position of the pusher's rest point.
Enter values in the Low and High fields to set the lower and upper limits of the allowed slider range. The defaults in this demo are 0 and 0.2, with implied units of meters (m).
Enter a value in the central field to set the pusher stopping point, which you can also adjust by clicking and dragging the slider between the lower and upper limits. The default is 0 (meters).
You can apply changes to the reference position to the simulation in two ways:
Reset the Reference Position block first, then start the demo. You see the pusher trajectory track differently now, toward the new stopping point.
For example, resetting the Reference Position to 0.1 and restarting the demo produces these Scope plots, with Autoscale and zooming applied. The asymptotic measured position now tends to 100 mm (0.1 m), and the torque applied to keep the pusher there has changed:

Start the demo with the Reference Position block open and move the slider up and down as the simulation runs. Watch the Scope. The measured position and necessary torque change to follow the new reference position.
Another modification you can make illustrates a powerful SimMechanics feature, visualization of a mechanism and animation of its simulated motion.
You can visualize and animate the conveyor mechanism by opening the SimMechanics visualization window. This window lets you display the bodies in two standard abstract forms:
Equivalent ellipsoids use the inertia tensors and masses of the bodies. Each body has a unique homogeneous ellipsoid equivalent to it in mass and inertia tensor.
Convex hulls use the attached Body coordinate systems (CSs) of the bodies to define a shape outlined by the CS origins.
First try visualizing the conveyor with bodies displayed as convex hulls:
From the Simulation menu, select Configuration Parameters. The Configuration Parameters dialog box appears.
Select the SimMechanics node. In the Visualization area, select the Display machines after updating diagram and Show animation during simulation check boxes.
Leave the other defaults as they are and close the dialog. From the Edit menu, select Update Diagram.
A SimMechanics visualization window appears, displaying the conveyor at rest in its initial state.
The bodies are displayed in the default geometry, as convex hulls. The bodies and Body coordinate system axis triads are also displayed as defaults.
Change Reference Position to a nonzero value such as 0.1 or 0.2.
Restart the simulation. The window animates the conveyor in motion. You can compare this motion to the plots in the scope.

Click a body in the visualization window. In the model window, the corresponding Body block is highlighted in red. The block name appears at the lower left of the visualization window.
Examine the visualization window menus and tool bar.
Here, you can reconfigure the display properties: bodies, Body CS axis triads, colored fill-in body surface patches connecting Body CSs on the same body, and user viewpoint orientation.
Leave the visualization window open for the next set of steps.
Now visualize the conveyor with bodies displayed as ellipsoids:
From the Model menu in the menu bar, select Body Geometries > Ellipsoids, so that a check mark appears beside the menu entry.
The display in the visualization window changes. The conveyor appears at rest in its initial state but with the bodies displayed as equivalent ellipsoids.
Restart the simulation. The viewer now animates the conveyor in motion.
Use the menus to experiment with the visualization settings. The toolbar contains most of these functions as well.

While the animation is running, open the Reference Position block and move the slider up and down. In addition to what you can see in the Scope plots, the window directly animates the pusher trajectory in space as the mechanism responds to your adjustment.
If you are connected to the Internet, have an AVI-compatible media streaming application installed on your system, and want to play a recorded animation of this system:
Click the following link. When the download dialog opens, choose Save to file and specify a file name and location on your system.
Click OK to save the AVI file to your system.
Once the downloading is complete, start the AVI animation on your system.
If you do not have an AVI-compatible application, consider using the MATLAB aviread and movie commands instead.
This is a compressed AVI recording, which requires that you have the Indeo 5 video codec installed to decompress and play.
The animation shows the conveyor mechanism pulled back and forth by the motion of the slider control. The animation steps through the predefined viewpoints to show different perspectives on the mechanism.
![]() | Related Products | What Can You Do with SimMechanics Software? | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |