Encode And Decode Instructions - Siemens SIMATIC S7-200 System Manual

Programmable controller
Hide thumbs Also See for SIMATIC S7-200:
Table of Contents

Advertisement

S7-200 Programmable Controller System Manual

Encode and Decode Instructions

Encode
The Encode instruction (ENCO) writes the bit number of the
least significant bit set of the input word IN into the least
significant "nibble" (4 bits) of the output byte OUT.
Decode
The Decode instruction (DECO) sets the bit in the output
word OUT that corresponds to the bit number represented
by the least significant "nibble" (4 bits) of the input byte IN.
All other bits of the output word are set to 0.
SM Bits and ENO
For both the Encode and Decode instructions, the following
conditions affect ENO.
Error conditions that set ENO = 0
H 0006 (indirect address)
Table 6-21
Valid Operands for the Encode and Decode Instructions
Inputs/Outputs
IN
OUT
Example: Decode and Encode Instructions
112
Data Types
Operands
BYTE
IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *LD, *AC, Constant
WORD
IW, QW, VW, MW, SMW, SW, T, C, LW, AC, AIW, *VD, *LD, *AC, Constant
BYTE
IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *LD, *AC
WORD
IW, QW, VW, MW, SMW, SW, T, C, LW, AC, AQW, *VD, *LD, *AC
AC2
DECO
15
3
VW40
0000 0000 0000
1000
Network 1
//AC2 contains error bits.
//1. The DECO instruction sets
the bit in VW40
//
that corresponds to this error
//
code.
//2. The ENCO instruction converts
//
the least significant bit set to an
//
error code
//
that is stored in VB50.
LD
I3.1
DECO
AC2, VW40
ENCO
AC3, VB50
15
3
AC3
0
VB50
9
0
1000 0010 0000 0000
ENCO
9

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents