Main Content

Model Distributed Traffic Control System by Using Messages

This example shows how to model a distributed control system for an intersection of one-way roads. To coordinate the state of the traffic lights, the two charts communicate with each other by using messages. The design of the two charts is identical.

You can interact with the traffic signals through a MATLAB® UI. To request a pedestrian crossing, click one of the dark gray request buttons at the bottom of the traffic signal.

The controller for each road is implemented by the traffic light controller subsystems Traffic Light 1 and Traffic Light 2.

In each subsystem, the Controller chart describes the main logic of the traffic controller through the various states of the traffic signal.

This model takes advantage of these semantic features of messages:

  • Messages are not discarded if they are not acted upon immediately. For example, in this model, pedestrian requests are queued up until the controller can react to a request when the traffic light turns red.

  • You can set up message loops between different components. These loops do not result in algebraic loops in your model.

  • Normally, input messages are destroyed at the end of the time step in which they are evaluated. However, you can preserve these input messages for use at a later time by temporarily forwarding them to a local "holding" queue. For example, when the Controller chart exits the Go state, it uses the local queue pedRequestLocal to store pedestrian requests made on the other road. The chart checks for those requests later, when it exits the PrepareToStop state.

To change the speed of the simulation, in the Simulation tab, select Run > Simulation Pacing. In the Simulation Pacing Options dialog box, adjust the slider setting. For more information, see Simulation Pacing Options (Simulink).

See Also


Related Topics