Programming instructions

45
LESSON 5 – Numeric Data in PLCs
Most PLC applications will require the handling of data, whether manipulating counter
and timer values, reading data from a Special Function Module and processing then
information, or high-level mathematical computations. It is critical that the programmer
understand how the PLC ‘sees’ and handles the different types of data that can be
encountered.
Lesson Objectives: At the conclusion of this lesson, you will be able to…
9 Describe how a PLC handles integer and decimal numbers.
Materials: FX-Series PLC Training Manual
5.1 Integer Handling
A very important fact to note is that the PLC handles only integer data by default.
This means that it sees numbers only as whole numbers…a 1, 10, -2, etc. The
PLC doesn’t recognize fractional numbers like 3.14159. Attempting to enter a
number like this will cause an error. If a mathematical operation like 5 divided by
3 (answer is 1.667) is performed, the PLC will drop the decimal part and give an
answer of 1. The remainder, in this example 2, is stored in the data register
following the destination register of the math instruction.
16 BIT NUMBERS
Integers in PLCs are 16 bit numbers, unless otherwise declared by
programming. Remembering back to the binary number lesson, this
means that the numeric range for integers is: 0000 0000 0000 0000 to
1111 1111 1111 1111. When converted to decimal, this means the
integer range for the PLC is 0 to 65,535.
The integer range is actually -32,768 to + 32,767. This is due to the fact
that the bit that is farthest to the left (bit 15) is used by the PLC as the sign
bit. This bit is also known as the Most Significant Bit (MSB). If it is a 1,
the number is negative, if a 0 it is positive. Thus the actual largest positive
number is 0111 1111 1111 1111 which is 32,767. If the program is
incrementing and goes above 32,767 it goes to –32,768. If the program is
decrementing a number and goes below –32,768, it goes to 32,767.
1000 0000 0000 0000 = -32,768. Why is this?