11 - 36 11 - 36
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
CSNI
Instruction
Convert SiNgle to Integer
• Converts a single precision real number into a 2-word (32-bit) integer to be used by the
PLC CPU.
CSNI (single precision variable> , <array variable>
single precision variable
• • • •
Specify the single precision variable where the data
for conversion is stored.
Syntax
array variable
• • • •
Specify the one dimensional integer array variable
where the converted data is stored.
CSNI B!, A%(0)
• • • •
Converts the value of B! into 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 CSNI instruction converts a single precision real number into a 2-word (32-bit) integer
that is used by the PLC CPU.
• BASIC can handle a single precision real number 2.09 through 2.09.
An "Over flow" error occurs if the value exceeds this range.
If the converting single precision real number contains a fractional part, the fractional part
is rounded down, then converted.
• The following shows handling of BASIC’s single precision real number by the PLC CPU:
Example
PLC
CPU
BASIC
Stores in the data register.
Dn
Dn+1
PCWT (Control table) , %( )
%(n)
%(n+1)
Converts into a
2-word integer.
!
For <control table>,
see process code
1 of the PCWT instruction.
CSNI
%Value of (n)
%Value of (n+1)
• <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 used for <array variable> by the DIM instruction.
If it is not defined by the DIM instruction, an "Illegal function call" error occurs.