11 - 14 11 - 14
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
CDBI
Instruction
Convert DouBle to Integer
• Converts a double precision real number to a 2-word (32-bit) integer used by the PLC
CPU.
CDBI <double precision variable> , <array variable>
double precision variable
• • • •
Specify the double precision variable where the data
to be converted is stored.
Syntax
array variable
• • • •
Specify the one dimensional integer array variable
where the converted data is stored.
CDBI B#, A%(0)
• • • •
Converts the value of B# to an integer and stores in
A%(0) and A%(1).
Examples
L
H
L
H
A%(0)
A%(1)
B#
Lower word
Higher word
32 bits
Description
• The CDBI instruction converts a double precision real number to a 2-word (32-bit) integer
used by the PLC CPU.
• BASIC can handle a double precision real number of 2147483648 through 2147483647.
An
"
Over flow
"
error occurs if the value exceeds this range.
If the converting double precision real number contains a fractional part, the fractional part
is rounded down, then converted.
• The following illustrates handling of BASIC’s double precision real number by the PLC:
Example
PLC
CPU
BASIC
Stores in the data register.
Dn
Dn+1
PCWT
%( )
%(n)
%(n+1)
Converts to a
2-word integer.
#
For <control table>,
see process code1
of the PCWT instruction.
CDBI
%Value of (n)
%Value of (n+1)
2-word integer
(Control table) ,
• <array variable> uses a one dimensional integer array variable.
An “Illegal function call” error occurs if anything other than the one dimensional integer
array variable is specified.
Be sure to define the variable to use for <array variable> by the DIM instruction.
If it is not defined by the DIM instruction, an "Illegal function call" error occurs.