Data processing instructions and function introduction and analysis

Publisher:DelightWish123Latest update time:2023-01-13 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Data processing instructions include batch reset instructions, encoding and decoding instructions, and average value calculation instructions. Among them, batch reset instructions can be used to initialize the data area, and encoding and decoding instructions can be used to compile a bit code that is set to 1 in a word component. A brief introduction is given below.


(1) Section reset command

The instruction mnemonic, instruction code, operand range, and program steps are shown in the table.

Section reset command element table

Command name Mnemonics Instruction code bits Operand range Program Step
D1 ( . ) D2 ( . )
Zone reset Z RS T
ZRST(P)
FNC40 ◥
(16)
T 、 M 、 S 、 T 、 C 、 D (D1 ≤ D2) ZRST, ZRSTP…5 steps






The interval reset instruction is also called the batch reset instruction, and its use is shown in the figure. When M8022 changes from OFF to ON, the interval reset instruction is executed. Bit components M500~M599 are reset in batches, word components C235~C255 are reset in batches, and state components S0~S127 are reset in batches.


The components specified by the target operands [D1] and [D2] should be of the same type, and the component number specified by [D1] should be less than or equal to the component number specified by [D2]. If the component number of [D1] is greater than the component number of [D], only the component specified by [D1] is reset.


This instruction is a 16-bit operation, but a 32-bit counter can be specified in [D1][D2]. However, they cannot be mixed, that is, a 16-bit counter cannot be specified in [D1] and a 32-bit counter cannot be specified in [D2].

8cb2720a-9029-11ed-bfe3-dac502259ad0.png

Figure 8-23 Instructions for using the ZRST interval reset instruction

(2) Decoding instructions

The instruction mnemonic, instruction code, operand range, and program steps are shown in the table.

Decoding instruction element table

Command name Mnemonics Instruction code bits Operand range Program Step
S ( . ) D ( . ) n
decoding DECO
DECO(P)
FNC38 ◥
(16)
K 、 H
X 、 Y 、 M 、 S
T 、 C 、 D 、 V 、 Z
Y 、 M 、 S
T 、 C 、 D 、
K 、 H
1≤n≤ 8
DECO, DECOP…7 steps

(a) When [D] is a bit element, the decimal code value represented by the n-bit continuous bit element with source [S] as the first address is Q. The DECO instruction sets the Qth bit (excluding the target element bit itself) of the target element with [D] as the first address to 1, and the other bits to 0. As shown in the figure, the source data Q=20+21=3, so the third bit M13 starting from M10 is 1. When the source data Q is 0, the 0th bit (i.e. M10) is 1.

8cd3ca18-9029-11ed-bfe3-dac502259ad0.png

If n=0, the program will not be executed; if n=other than 0~8, an operation error will occur. If n=8, the number of bits of [D] is 28=256. When the drive input is OFF, the instruction will not be executed, and the bit set to 1 in the last decoding output will remain unchanged.


If the instruction is of continuous execution type, it will be executed in each scan cycle, so please pay attention.

(b) When [D] is a word element, the decimal code Q represented by the lower n bits of the word element specified by the source [S], the DECO instruction sets the Qth bit (excluding the lowest bit) of the target word element specified by [D] to 1, and the other bits to 0. Explanation As shown in Figure 8-24 (b), the source data Q=20+21=3, so the third bit of D1 is 1. When the source data is 0, the 0th bit is 1.

If n=0, the program will not be executed; if n=other than 0~4, an operation error will occur. If n=4, the number of bits of [D] is 24=16. When the drive input is OFF, the instruction will not be executed, and the bit set to 1 in the last decoded output will remain unchanged.

The application of DECO instruction is shown in the figure. According to the value stored in D0, the same address number of M combination element is connected. The value of 0~15 is stored in D0. Take n=K4, then corresponding to the value of D0 (0~15), M0~M15 has a corresponding 1 point connected.

8ce8ca76-9029-11ed-bfe3-dac502259ad0.png

If n changes between K1 and K8, it can correspond to the value of 0 to 255. However, the soft element range of the target required for decoding is occupied, so be careful not to reuse it for other controls.

(3) Encoding instructions

The instruction mnemonic, instruction code, operand range, and program steps are shown in the table.

Table of elements for coded instructions

Command name Mnemonics Instruction code bits Operand range Program Step
S ( . ) D ( . ) n
coding ENCO
ENCO(P)
FNC42 ◥
(16)
X 、 Y 、 M 、 S
T 、 C 、 D 、 V 、 Z
T 、 C 、 V 、 Z 、 D 、 K 、 H
1≤n≤ 8
ENCO, ENCOP...7 steps

(a) When [S] is a bit element, the bit element with the source [S] as the first address and a length of 2n, the highest position set to 1 is stored in the element specified by the target [D]. The value in [D] is determined by n. Explanation As shown in Figure 8-26 (a), the length of the source element is 2n=23=8 bits M10~M17, and the highest bit set to 1 is M13, which is the 3rd bit. The "3" position number (binary) is stored in the lower 3 bits of D10.


When the first (i.e., the 0th) bit element of the source number is 1, 0 is stored in [D]. When there is no 1 in the source number, an operation error occurs.


If n=0, the program will not be executed; if n=other than 1~8, an operation error will occur. If n=8, the number of bits of [S] is 28=256. When the drive input is OFF, the instruction will not be executed and the last encoding output will remain unchanged.

8cffb150-9029-11ed-bfe3-dac502259ad0.png

If the instruction is of continuous execution type, it will be executed in each scan cycle, so please pay attention.

(b) When [S] is a word element, the highest bit set to 1 in its readable length of 2n bits is stored in the element specified by the target [D]. The range of the value in [D] is determined by n. Explanation As shown in Figure 8-26 (b), the readable length of the source word element is 2n=23=8 bits, and the highest bit set to 1 is the 3rd bit. The "3" position number (binary) is stored in the lower 3 bits of D1.


When the first (i.e., the 0th) bit element of the source number is 1, 0 is stored in [D]. When there is no 1 in the source number, an operation error occurs.


If n=0, the program will not be executed; if n=other than 1~4, an operation error will occur. If n=4, the number of bits of [S] is 24=16. When the drive input is OFF, the instruction will not be executed and the last encoding output will remain unchanged.

If the instruction is of continuous execution type, it will be executed in each scan cycle, so please pay attention.


Reference address:Data processing instructions and function introduction and analysis

Previous article:Summary of the most complete PLC programming algorithm
Next article:Analysis of communication technology based on OPCUA and Siemens PLC

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号