JMP
Libraries:
Description
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.
Examples
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 JMP
and LBL
instructions. Simulate the ladder diagram to verify its behavior and generate ladder diagram code from the model. The JMP
and LBL
instructions branch and loop the ladder diagram code.
Open the Model
The model consists of:
A PLC Controller Suite block named
SequentialMotorController
that implements theJMP
andLBL
instructions and other logic to control motorsThe blocks in the Human Machine Interface (
HMI
), which you can use to interact with the model
Open the model.
mdl = "LadderDiagramJmpAndLblModel";
open_system(mdl);
HMI
Section
The HMI
section contains blocks that you can use to interact with the model simulation. This image shows the components of the HMI
section:
This HMI
section contains:
Inputs: You can use the
Sensor 2
,Sensor 3
, andSensor 4
rocker switches to change the value of the respective inputs. When the rocker switch is in theOn
position, the value of the corresponding input is1
.Graphs: The Dashboard Scope blocks display the status of
Sensor2
,Sensor3
,Sensor4
,Motor2
,Motor3
, andMotor4
signals, 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 JMP
and LBL
instructions for branching and looping.
The first rung contains the normally open (XIC) contact and a JMP
block that jumps to the label Motor4
when Sensor4
is on. Rungs two and three turn on Motor2
and Motor3
based on the states of Sensor2
and Sensor3
. Rung four contains the LBL
instruction with the name Motor4
.
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 JMP
and 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
JMP
andLBL
instructions are disabled.The outputs on rungs two and three do not change state when the
JMP
andLBL
instructions are enabled.
Before simulating and validating the mode, load the built-in data types, by using the plcloadtypes
function.
plcloadtypes
To ensure that rungs two and three execute normally, turn on the Sensor2
and Sensor3
rocker switches in the top model and simulate the model. The Dashboard Scope blocks indicate that Motor2
and Motor3
turn on as soon as Sensor2
and Sensor3
turn on.
To ensure that rungs two and three do not execute when the JMP
and LBL
instructions are enabled, turn on Sensor4, t
urn off Sensor2
and Sensor3
and simulate the model. Motor4
turns on and Motor2
and Motor3
stay on. This image shows that after Sensor4
turn on and Sensor2
and Sensor3
turn off, Motor2
and Motor3
stay on.
Generate Code
After validating the operation of the JMP
and LBL
instructions, generate code for the PLC Controller Suite block. To generate ladder diagram code use the plcgeneratecode
function:
generatedFiles = plcgeneratecode("LadderDiagramJmpAndLblModel/SequentialMotorController");
Ports
Input
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.
Output
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.
Parameters
Jump to Label — Name of the label
L (default) | character vector
Specify the name for associated LBL
instruction.
Programmatic Use
Block Parameter:
PLCLabelTag |
Type: character vector |
Value: character vector |
Default: 'L' |
Version History
Introduced in R2019a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)