This example shows how to pause service in an N-Server block using functionality available on the block Service control tab. For more information, see Service control Tab.
The example uses the N-Server block to model a linear conveyor belt in an industrial manufacturing setting.
The conveyor belt transports finished parts—entities—that are ready for final packaging. The basic operation of the conveyor belt system is:
When the operator presses the start button, the conveyor belt begins to transport parts.
Each time that the conveyor belt system transports
five hundred parts, the belt pauses to allow the operator to perform
a quick maintenance inspection. After
the conveyor belt automatically restarts. If the operator requires
more time to perform the inspection, he selects the emergency stop
Whenever the operator selects the emergency stop switch, the conveyor belt is held in the stopped state. The belt does not restart until the operator deselects the emergency stop switch and presses the start button.
The following graphic shows the top-level view of the conveyor belt model.
At the top level, the model is comprised of four blocks:
A Conveyor Belt Controller subsystem that contains a Stateflow® Chart. The Stateflow Chart executes the transitions between the running, paused, and stopped states of the belt.
A Parts Feeder subsystem that contains a Time-Based Entity Generator block. The generated entities represent finished parts that the conveyor belt transports for final packaging.
A Linear Conveyor Belt subsystem that
consists primarily of an N-Server block. The N-Server block
represents a conveyor belt that can transport
at any time.
An Analysis block that is a renamed Simulink® Scope block. When the simulation is complete, the Analysis block shows the status of the belt (running or stopped/paused) throughout the simulation, and the total number of parts transported.
The Conveyor Belt Controller subsystem executes transitions between the running, paused, and stopped states of the belt, in response to updates of various signals in the model.
In the real system, the operator uses buttons and switches to provide the start and emergency stop signals. In the model, the Signal Builder block mimics this operator input.
MaintDelay signal enters the subsystem
as feedback from the Linear Conveyor Belt subsystem.
This signal is an on/off signal that changes to a nonzero value (
each time that the conveyor belt transports five hundred parts.
The Control block of the Conveyor Belt Controller subsystem contains a Stateflow Chart.
When the simulation starts, the belt is in the
Start signal puts the belt in the
Each time that the conveyor belt transports five hundred parts, causing
MaintDelay signal to be nonzero, the belt transitions
Paused state. After
MaintDelay returns to a value of zero, the
belt reenters the
Running state. If an operator
EmergencyStop button, the belt returns
Stopped state. To restart the belt, the
operator must deselect the
The Parts Feeder subsystem generates entities representing the parts that the conveyor belt transports for packaging.
A Time-Based Entity Generator block generates entities to represent finished parts. If the conveyor belt motor is running, entities immediately depart the Time-Based Entity Generator block, which represents loading parts onto the conveyor belt. If the belt motor is stopped, entities do not depart the Time-Based Entity Generator block.
The Linear Conveyor Belt subsystem is comprised
mainly of an N-Server block that represents a conveyor
belt with capacity for
The MotorRun signal is a Boolean signal that
enters the conveyor belt subsystem directly from the Conveyor
Belt Controller subsystem. If the value of the MotorRun signal
True, indicating that the conveyor belt is running,
the signal entering the pause port of the N-Server block
False. The N-Server continues
to service entities.
If the operator selects the emergency stop switch, or if the
conveyor belt pauses for maintenance, the MotorRun signal
False. In this case, the signal entering
the pause port of the N-Server block
True. Servers in the N-Server block
are disabled. The remaining service time in each server is paused.
When the Stateflow chart
in the Conveyor Belt Controller subsystem returns
Running state, indicating either that the
operator has deselected the emergency stop switch, or that the maintenance
delay period has expired, entity service resumes with the previously
paused service time remaining. For more information on the pause functionality
of the N-Server block,
see Service control Tab.
The blocks connected to the #n port of
the N-Server block calculate each time that the conveyor
belt has transported five hundred parts. The gain parameter of the Gain block
is set to
1/500. Therefore, when the N-Server services
1000, 1500.... entities, the first input to the Subtract block
1, 2, 3..... The Unit Delay block
delays the second input to the Subtract block by 60 seconds,
representing the short time that the belt is paused for inspection.
During this time, the
MaintDelay signal value is
1, 2, 3.....
After 60 seconds, the Subtract block
produces a result of
0 that feeds back to the Conveyor
Belt Controller subsystem. If the operator has not also selected
the emergency stop switch, the belt returns to the
The output of the Analysis block shows the simulation results.
The top plot shows the status of the conveyor belt throughout
the simulation. When the output is
1, the belt
is running. At time zero, the operator presses the start button. The
bottom plot shows that it takes about
for the first parts to travel along the conveyor belt, where they
are then packaged and removed. The travel time of a part along the
belt is the service time of the N-Server block. When
entities begin to depart the N-Server block—corresponding
to removal from the belt—the #d output
value of the block starts to increase. The bottom plot shows this
110 seconds, five hundred parts
have been transported by the conveyor belt. The belt pauses for the
maintenance delay period of
60 seconds. The bottom
plot show this pause, with no increase in the number of departed entities
110 seconds and
Once the maintenance delay period ends, the belt restarts. When the
belt restarts, the remaining travel time of each part corresponds
to the remaining service time of each entity in the N-Server block.
420 seconds, the operator selects
the emergency stop switch.
10 seconds later,
the operator removes the emergency stop signal and presses the start
button. The bottom plot shows this stoppage, with no increase in the
number of departed entities between