The JMP block implements the
JMP ladder logic
instruction. When the rung conditions are true, the block skips a part of ladder logic and the
rung execution moves to the block referenced by the label block. Jump block can only skip the
rungs after it. The block does not support a backward jump.
Model and Generate Code for Jump and Label Ladder Diagram Instructions
This example shows how to model a ladder diagram in Simulink® that uses the
LBL instructions. Simulate the ladder diagram to verify its behavior and generate ladder diagram code from the model. The
LBL instructions branch and loop the ladder diagram code.
Open the Model
The model consists of:
A PLC Controller Suite block named
SequentialMotorControllerthat implements the
LBLinstructions and other logic to control motors
The blocks in the Human Machine Interface (
HMI), which you can use to interact with the model
Open the model.
mdl = "LadderDiagramJmpAndLblModel";
HMI section contains blocks that you can use to interact with the model simulation. This image shows the components of the
HMI section contains:
Inputs: You can use the
Sensor 3, and
Sensor 4rocker switches to change the value of the respective inputs. When the rocker switch is in the
Onposition, the value of the corresponding input is
Graphs: The Dashboard Scope blocks display the status of
Motor4signals, against time as the model simulation progresses.
PLC Controller Suite Block
The PLC Controller Suite block named
SequentialMotorController block contains a Program block that houses the ladder logic. To view the ladder logic, open
SequentialMotorController, Task block, and then the
Program block. This image shows the ladder logic implementation that uses the
LBL instructions for branching and looping.
The first rung contains the normally open (XIC) contact and a
JMP block that jumps to the label
Sensor4 is on. Rungs two and three turn on
Motor3 based on the states of
Sensor3. Rung four contains the
LBL instruction with the name
Simulate and Validate the JMP and LBL Instructions
JMP and LBL instructions are elements in ladder diagrams that control branching and looping in the control logic. The
JMP instruction enables conditional branching, which allows the control logic to choose between different paths. The
LBL instruction enables looping, which allows the control logic to repeat a set of instructions until a certain condition is met. The
LBL instructions should be used together and the
LBL instruction should be the first instruction on a rung. To validate the ladder diagram model:
Ensure that rungs two and three execute normally when the
LBLinstructions are disabled.
The outputs on rungs two and three do not change state when the
LBLinstructions are enabled.
Before simulating and validating the mode, load the built-in data types, by using the
To ensure that rungs two and three execute normally, turn on the
Sensor3 rocker switches in the top model and simulate the model. The Dashboard Scope blocks indicate that
Motor3 turn on as soon as
Sensor3 turn on.
To ensure that rungs two and three do not execute when the
LBL instructions are enabled, turn on
Sensor4, turn off
Sensor3 and simulate the model.
Motor4 turns on and
Motor3 stay on. This image shows that after
Sensor4 turn on and
Sensor3 turn off,
Motor3 stay on.
After validating the operation of the
LBL instructions, generate code for the PLC Controller Suite block. To generate ladder diagram code use the
generatedFiles = plcgeneratecode("LadderDiagramJmpAndLblModel/SequentialMotorController");
EnableIn — Enable Input
off (default) | on
Controls the execution of the block. EnableIn reflects the rung state preceding the block. If the rung state preceding the block is false, EnableIn is false, the block does not execute and the outputs are not updated.
EN — Enable Output
off (default) | on
By default, EnableOut follows the state of EnableIn. If the EnableIn input to the block is false, the logic implemented by the block is not executed and EnableOut signal is set to false.
Jump to Label — Name of the label
L (default) | character vector
Specify the name for associated
|Type: character vector
|Value: character vector
Introduced in R2019a