Main Content

电梯控制器l Simulation and Code Generation Using Ladder Logic

This example shows how to model a controller for a single-car elevator in Simulink® by using ladder logic. The elevator system is modeled as a MATLAB Function Block. The example also showcases ladder code generation.

Step 1: Opening the Model

Open the plcdemo_ladder_elevator by using:

>> plcdemo_ladder_elevator

Step 2: Model Initialization

When the model is opened, it sets the initial values of different parameters used in elevator controller from theplcdemo_ladder_elevator_init.mfile.

Step 3: Model Components

Floor Requests

Floor Requestsare a group of constant blocks. It specifies the indoor and outdoor floor requests to the controller. By default all the constant blocks are set to zero.

电梯控制器l System

电梯控制器l Systemis a subsystem which consists of Digital Input modules(DI), Digital Output modules(DO) and a PLC Controller. DI modules preprocess floor request input and other sensor inputs. Similarly, DO modules preprocess output of PLC controller and sets output contactors. PLC controller is the brain of the system. It performs all the calculations and control action.

Elevator

Elevatoris a MATLAB function block which show cases mathematical model of a single car elevator system.

Step 4: Run the Simulation

ClickRunbutton to start simulation. OpenHMIand use the following controls:

  • Exterior Buttons:Represents the exterior floor request buttons.

  • Interior Buttons:Represents the interior floor request buttons.

  • Photocell:Represents the door sensor.

Step 5: Ladder code generation

Open elevator control model:

>> plcdemo_ladder_elevator

Select theplcdemo_ladder_elevator/Elevator Control System/Elevator PLC Ladder Diagram System/Elevator Controllerblock and right-clickPLC Coder->Generate Codefor Subsystem to generate ladder code.