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.
Open the plcdemo_ladder_elevator by using:
>> plcdemo_ladder_elevator
When the model is opened, it sets the initial values of different parameters used in elevator controller from the plcdemo_ladder_elevator_init.m file.
Floor Requests
Floor Requests
are 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.
Elevator Control System
Elevator Control System
is 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
Elevator
is a MATLAB function block which show cases mathematical model of a single car elevator system.
Click Run
button to start simulation. Open HMI
and 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.
Open elevator control model:
>> plcdemo_ladder_elevator
Select the plcdemo_ladder_elevator/Elevator Control System/Elevator PLC Ladder Diagram System/Elevator Controller
block and right-click PLC Coder->Generate Code
for Subsystem to generate ladder code.