|On this page…|
This example 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 example 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. You can adjust the controller and set the stopping point for the pusher.
Conveyor Loader Mechanism
The conveyor mechanism example 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 example model. To avoid errors,
The following figure shows a detailed schematic of the conveyor belt loading mechanism.
To get started quickly with the conveyor example model, follow either of these steps:
Enter mech_conveyor 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:
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.
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.
Here is a modification of the example you can try. It illustrates the simple controller that you can adjust to change the motion of the pusher.
To make these modifications, it is best to close and restart the example.
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:
You can apply changes to the reference position to the simulation in two ways:
Reset the Reference Position block first, then start the example. 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 example 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 example 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:
First try visualizing the conveyor with bodies displayed as convex hulls:
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.
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 viewpoint orientation.
Now visualize the conveyor with bodies displayed as ellipsoids:
The display in the visualization window changes. The conveyor appears at rest in its initial state but with the bodies displayed as equivalent ellipsoids.
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.