Professional Documents
Culture Documents
AN INTRODUCTION TO THE
DECODE INSTRUCTION (DECO, FNC41)
Introduction Parameter a) - DECO Statement
The DECO instruction has one variable which gives a
There are many ways to save time when program-
possibility of two different instruction forms. The avail-
ming. The quickest and most reliable method is to use
able forms are:-
special instructions found in the PC. The FX family of
PCs has such a set of special instructions. These are I) DECO - a standard DECO statement can
called ’Applied Instructions’. The DECO or DECOde access data up to a maximum of 16 bits.
instruction is a member of these applied instructions. The instruction will act continuously
DECO has a special function number of 41. while the control signal is ON. In the
sample program this occurs when X010
The DECO Instruction
is switched on. This instruction accounts
The DECO instruction is a method of retrieving the for seven (7) steps in the program.
address of an encoded active bit, which forms part of
II) DECOP - a modified DECO statement
a range of specified bits. The retrieval method is by now acting once on the rising edge of the
decoding the stored offset of the active bit. This offset control signal. In the sample program this
is applied to the head address of the destination data. occurs when X010 switches from OFF to
The basic components of a DECO instruction are; ON. The ’P’ suffix stands for pulse. This
a) The DECO statement instruction accounts for seven (7) steps
in a program.
b) The head address of the encoded source FX0 users should note that this variation
data of the DECO instruction is not available
on the FX0.
c) The head address of the destination for
the decoded data Parameter b) - The Head Address Of The Source
Data
d) The number of bits that has been used
This identifies what form the encoded source data has,
as the storage device where it is located in the PC and how much there is of
it. This can be regarded as the head address of the
PARAMETER
source data. The data can be in any of the following
forms;
a) b) c) d) Constant Numeric Values: Decimal values (K),
X010 Hexadecimal values (H)
DECO X000 Y000 K 3 Numeric Data Values: Data Registers (D),
Counters (C), Timers (T), Index Registers (V ,Z)
Bit Devices: Inputs (X), Outputs (Y),
The same line of ladder logic written in instruction Auxiliary Coils (M), State Coils (S)
format would look like;
Parameter c) -
Each of the parameters required for the DECO instruc- The Head Address Of The Destination Data
tion will now be described in detail.
This identifies the head bit address for the storage of
PROGRAM the decoded data. This address can be supplied in
INSTRUCTION PROGRAM many formats;
STEP No.
Numeric Data Values: Data Registers (D),
0 LD X 010 Counters (C), Timers (T)
1 DECO 41 Bit Devices: Outputs (Y), Auxiliary Coils (M), State
Coils (S)
X 000
Y 000
K 3
FX-SAD411A
DATE: NOVEMBER 1993
TM PAGE: 2 OF 5
© MITSUBISHI ELECTRIC
AN INTRODUCTION TO THE
DECODE INSTRUCTION (DECO, FNC41)
Parameter d) - The Number Of Bits To Be Used I) Decoding Bit Devices to Bit Devices
As The Source Device
X017
The number of bits to be used can be specified in
DECO X000 M100 K 5
hexadecimal (H) or decimal (K). This parameter can-
not be indexed. When the destination device is a bit,
i.e. an output/auxiliary coil or a state relay parameter
d) may have a value in the range of 1 to 8. If the One of the most important points to identify is the
destination device is designated as a data device, i.e. number of bits that have been used to form the source
a data register, counter or timer, then parameter d) data. This has great significance as it can be used to
must have a value in the range of 1 to 4. When determine how many devices will be required as a
parameter d) is specified it identifies the quantity of destination. In the example K5 is identified as the
source data which will be decoded. This is an impor- number of source bits. This means devices X000 to
tant factor when bit devices are used as the destina- X004 have been used, i.e. 5 devices. Any data stored
tion data. The following table identifies how many outside of these devices will NOT be part of this
destination bit devices will be required for each of the example DECO instruction.
available settings of parameter d); To identify how many destination devices are re-
quired, the maximum encoded number must be found.
PARAMETER d) This is carried out by assuming all of the source bits
NUMBER OF
NUMBER OF BITS equal 1. The source bit pattern is then decoded to
DESTINATION BITS
THE ENCODED DATA
REQUIRED reveal the maximum decodable number.
IS STORED IN
K1 2 SOURCE DATA FOR DECODING
K2 4 X X X X X X7 X6 X5 X4 X3 X2 X1 X0
14 13 12 11 10
K3 8 THESE BIT DEVICES ARE 1 1 1 1 1
IGNORED BY THIS DECODE
K4 16 EXAMPLE AS THEY FALL OUTSIDE on on on on on
THE
K5 32 DESIGNATED SOURCE AREA MAXIMUM VALUE
K6 64
X7 X6 X5 X4 X3 X2 X1 X0
K7 128
K8 256 ----- 1 1 1 1 1
Decodes to;
If parameter d) is set to 0 then the DECO instruction
acts as if it has been disabled. 1 x X4 = 1 x 16
1 x X3 = 1 x 8
How Does It Work? 1 x X2 = 1 x 4
1 x X1 = 1 x 2
The DECO instruction can be split into four proce- 1 x X0 = 1 x 1
dures;
AN INTRODUCTION TO THE
DECODE INSTRUCTION (DECO, FNC41)
Worked example II) Decoding Data Devices To Data Devices
M 40
S 20
DECO X000 Y000 K 7
DECO D 10 D 4 K 4
Important:
Please remember ALL of these steps are automat-
ically carried out by the DECO instruction. They are
shown here to help explain how the instruction works.
All that is required is that correct and valid data is
entered into the DECO instruction.
FX-SAD411A
DATE: NOVEMBER 1993
TM PAGE: 4 OF 5
© MITSUBISHI ELECTRIC
AN INTRODUCTION TO THE
DECODE INSTRUCTION (DECO, FNC41)
When monitoring a destination data device, please Worked Example
remember that although the DECO instruction is set-
ting only one destination bit, the actual value moni-
tored will be the decimal conversion of that decoded
bit, i.e. If bit 7 is set then the monitored value is 128 S 50
decimal. The following table lists the expected data DECO D 0 D6 K 3
value, against which bit has been decoded/set.
AN INTRODUCTION TO THE
DECODE INSTRUCTION (DECO, FNC41)
Special Feature
The bit device which was turned on by the DECO
instruction remains set according to the last value
decoded even when DECO is turned off.
Further Reference
For more detailed information an the ENCO (FNC 42) instruction please reference datasheet FX-SAD421.
Information on bit and data devices can be found on the following sheets