PLC conditional jump, subroutine call, etc.

Publisher:冷漠之心Latest update time:2023-10-19 Source: elecfansKeywords:PLC Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Conditional jump instructions:

The instruction name, mnemonics, instruction codes, and program steps are as follows:

97166360-04fe-11ee-90ce-dac502259ad0.jpg

Program steps can be executed continuously or in pulses. CJ execution is 3 steps and CJ(P) is 1 step.

Instruction format:

972ac13e-04fe-11ee-90ce-dac502259ad0.jpg

When we press X000, the program jump instruction starts to run, and the location where the program jumps is the location of the program pointer, which is label 10. Here we should note that the program pointer is written on the left side of the left bus. When we start the jump instruction, the X001 program will be skipped and not executed.


When X0 is ON, the program between the jump CJ command and the label is not executed. During the jump process, if Y, M, S are driven by OUT, SET, RST instructions to change the input, the state before the jump will remain. For example, after the jump occurs through X1 driving output Y10, even if X0 becomes ON during the jump process, the output Y10 is still valid.


Note:
1. For T and C, if the timer or counter is in action when jumping, the counting will be interrupted or stopped immediately, and the timing or counting will continue after the jump. However, the timers T192~T199 and high-speed counters C235~C255 in action will continue to work regardless of whether there is a jump or not.

2. Functional instructions are not executed during jump, except for PLSY, PLSR, and PWW instructions.

Subroutine call and return instructions:

The instruction name, mnemonics, instruction codes, and program steps are as follows:

9742ff24-04fe-11ee-90ce-dac502259ad0.jpg

Instruction format:

975d5a40-04fe-11ee-90ce-dac502259ad0.jpg

In the figure, FEND indicates the end of the main program. The program before FEND is called the main program, and the program after FEND is called the subprogram. SRET indicates the end of the subprogram, or the subprogram return. We should note that the program between FEND and SRET is called the first subprogram, and the program before the second SRET is called the second subprogram. When we press X001, the pointer is called to P11, and the program starts to execute from top to bottom from P11. When the first SRET is encountered, the program returns to the main program. However, if X002 is turned on in this program, the program pointer is called to P12, and the program starts to run from top to bottom. When the second SRET is encountered, the program returns to P12, and then returns to the main program when the first SRET is encountered. Because the P12 program is nested in the P11 program, we should note that this kind of program nesting can only use 5 levels at most in PLC.

Interrupt instruction:

There are 3 interrupt instructions in total. We use a table to explain them in detail:

976600b4-04fe-11ee-90ce-dac502259ad0.jpg

Here, the main program is before FEND, and the interrupt subroutine is after FEND. Whether the interrupt subroutine can be carried out is related to the interrupt condition and the interrupt pointer, so here we have to tell you the format of the interrupt pointer:

Interrupt pointer:

977d9b2a-04fe-11ee-90ce-dac502259ad0.jpg

Timed interrupt:

97921bae-04fe-11ee-90ce-dac502259ad0.jpg

Program example:

97a511dc-04fe-11ee-90ce-dac502259ad0.jpg

Let us first introduce this program to you: the program before FEND indicates the main program, the one after it indicates the interrupt subroutine, EI indicates interrupt enable, IRET indicates interrupt return instruction, I610 pointer indicates that the interrupt time is 10mm, and 6 indicates the highest interrupt level.


When we press X000, the data of K1 is transferred to D1, the data of K255 is transferred to D2, M1 is set and turned on, and the interrupt subroutine runs. RAMP means ramp instruction, which means generating a data D3, and the range of D3 is from D1 to D2, that is, from 1 to 255. Since this is a timed interrupt program, when M1 is turned on, the program is interrupted every 10ms. K1000 means 1000 scan cycles, because the range of D3 is from 1 to 255, and it takes 1000 10ms, that is, the time from X0 turning on to D3 becoming 255 is 1000X10ms=10 seconds. When D3 is equal to 255, M8029 is turned on, M1 is reset and disconnected, and then the interrupt instruction and ramp instruction are disconnected, and then the program returns when the IRET instruction is encountered.


Keywords:PLC Reference address:PLC conditional jump, subroutine call, etc.

Previous article:A brief discussion on the PID control technology function of Siemens S7-1200PLC
Next article:Analysis of EMC interference and suppression technology in servo system

Recommended ReadingLatest update time:2024-11-16 13:33

S7 Communication Server Solution for S7-1200 PLC
The PROFINET communication port of S7-1200 can be used as the server or client of S7 communication (CPU V2.0 and above). S7-1200 only supports S7 unilateral communication. You only need to configure (as shown in Figure 1) and connect and program (as shown in Figure 2) on the client side, and the server side only nee
[Embedded]
Using Atmel89c2051 to simulate PLC control method
Using Atmel89c2051 to simulate PLC control can combine the advantages of microcontroller control and PLC control. As the core technology of embedded systems, microcontroller control has high reliability and cost-effectiveness, and is compact and low-cost. The ladder diagram programming in PLC control is similar to the
[Microcontroller]
Using Atmel89c2051 to simulate PLC control method
Steps to run and debug plc
Many electrical novices are not sure how to start debugging after designing electrical control cabinets and PLC programs. Or some people have caused problems such as PLC burnout due to inappropriate debugging methods. So how should the designed electrical system be debugged? You can follow the following seven steps.
[Embedded]
How to display timer time in Mitsubishi PLC
Mitsubishi PLC (Programmable Logic Controller) is a device widely used in the field of industrial automation. Timer is a basic function in PLC, which is used to realize delay control, timing control and other functions. In Mitsubishi PLC, the display and setting of timer is very important. The following will introdu
[Embedded]
Reasons for the programmable controller PLC crashing during operation
Programmable controller PLC may crash during operation, which will cause unpredictable losses to industrial production. Therefore, we must first understand the cause of PLC crash and investigate the cause. Software or hardware errors may cause PLC crash. The following are introduced separately: 1. Hardware
[Embedded]
PLC control circuit for sequential start/stop of two motors
The PLC control circuit diagram is as follows: PLC control l/O allocation table is as follows: The ladder diagram is as follows: The specific startup process is: When the start button sB2 of the motor M1 is pressed, it sets ×2 in pLc to 1, that is, the contact is connected, so t
[Embedded]
PLC control circuit for sequential start/stop of two motors
Siemens S7-200PLC has integrated high-speed counting function
Siemens S7-200 PLC integrates high-speed counting function, which is a very important function of PLC. In the industrial field, pulse instruments, such as rotary encoders, are generally used to measure rotation speed and cycle. The frequency of such instruments is much greater than the acquisition frequency of PLC,
[Embedded]
Siemens PLC floating point program case sharing
Siemens S7-200 passed the test, the program came from the Internet, dedicated to those who need it! 1. Main program call: The 64-bit floating-point number is stored in the storage area starting from VB0, and the converted 32-bit floating-point number is stored in VD100. 2. Subroutine symb
[Embedded]
Siemens PLC floating point program case sharing
Latest Embedded Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号