Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Numbering Systems

 Commonly used decimal number system is based on module 10 representation


 The system accommodates both integers and real numbers
 Real numbers have an integer part and a fraction part separated by a decimal
point
 The integer-part digits have increasing weight as you move to the left of the
decimal point, whereas the weights decrease for the fraction digits as you move
to the right of the decimal point
 Consider the decimal number 9623.154, which is equivalent to the following sum

 A normalized scientific representation is frequently used for real number as


follows

 PLCs, as well as digital computers, use the binary number system, or module 2
arithmetic
 Numbers, integers or real, are represented in fixed-size memory words
 A memory word is typically 1, 2, 4, or 8 bytes long
 Octal (base 8) and hexadecimal (base 16) representations are derivatives of the
binary system conveniently used in documentation

Dr.-Ing. Jackson G. Njiri EMT 2549 L-3: Basics of PLC programming 1


S7-1200 Data and Number Representation
 Variable used in the S7-1200 can be declared as real, integer, or Boolean
 The smallest memory unit is a bit, which can accommodate a Boolean variable as
a discrete I/O
 Eight consecutive bits form a memory byte
 Sixteen consecutive bits (2 bytes) constitute a memory word, which is often used
to represent integers
 Four consecutive bytes form a double word, which is used to accommodate real
and some integer variables
 Four consecutive bytes form a double word, which is used to accommodate real
and some integer variables
 Each such variable occupies one memory bit and carries the value 0 (FALSE/OFF)
or 1 (TRUE/ON)
 Each integer uses one-memory word (2 bytes) or double-memory word (4 bytes)
 Each real number uses double-memory words (4 bytes) or four-words (8 bytes)
 Several other data types are available, including characters, strings, arrays, and
other element-specific parameters/tags

Dr.-Ing. Jackson G. Njiri EMT 2549 L-3: Basics of PLC programming 2


Symbol of Allowed Addresses and Data Types
I/O Signals

Mnenonics Description Data Type Address Range


I Input bit BOOL 0.0-65535.7
IB Input byte BYTE, CHAR 0-65535
IW Input word WORF, INT, S5TIME, DATE 0-65534
ID Input double word DWORD, DINT, REAL, TOD, TIME 0-65532
Q BOOL 0.0-65535.7
QB Output bit BYTE, CHAR 0-65535
QW Output byte WORD, INT, S5TIME, DATE 0-65534
QD Output double word DWORD, DINT, REAL, TOD, TIME 0-65532

Dr.-Ing. Jackson G. Njiri EMT 2549 L-3: Basics of PLC programming 3


Symbol of Allowed Addresses and Data Types Cont’
Marker Memory
Mnenonics Description Data Type Address Range
M Memory bit BOOL 0.0-65535.7
MB Memory byte BYTE, CHAR 0-65535
MW Memory word WORF, INT, S5TIME, DATE 0-65534
MD Memory double DWORD, DINT, REAL, TOD, TIME 0-65532
word

Timers and Counters


T Timer TIMER 0-65535
C Counter COUNTER 0-65535

Data Blocks
DB Data block DB, FB, SFB, UDT 0-65532

Dr.-Ing. Jackson G. Njiri EMT 2549 L-3: Basics of PLC programming 4


Symbol of Allowed Addresses and Data Types Cont’
Peripheral I/O
Mnenonics Description Data Type Address Range
PIB Peripheral input BYTE, CHAR 0-65535
byte
PIW Peripheral input WORD, INT, S5TIME, DATE 0-65534
word
PID Peripheral input DWORD, DINT, REAL, TOD, TIME 0-65532
double word
PQB Peripheral output BYTE, CHAR 0-65535
byte
PQW Peripheral output WORD, INT, S5TIME, DATE 0-65534
word
PQD Peripheral output DWORD, DINT, REAL, TOD, TIME 0-65532
double word

Dr.-Ing. Jackson G. Njiri EMT 2549 L-3: Basics of PLC programming 5


Processor Memory Map and Program Organization
Memory Areas
 Divided into 3 sections
 Each memory area stores the user program, user data, and configuration
 Load memory: Nonvolatile storage for user program,
data, and configuration
 Work memory: Volatile storage work area for some
elements of user project
 Retentive memory: Nonvolatile storage for limited
quantity of work memory values

Memory map
 Divided into several data files
 Each data file consists of an operand and tags such as
I/P, O/P, and bit memory
 CPU identifies these operands based on a numerical
absolute address

Dr.-Ing. Jackson G. Njiri EMT 2549 L-3: Basics of PLC programming 6


Processor Memory Map and Program Organization
CPU Memory Addresses
 The CPU can access elements addressed in the formats
shown in figure
Discrete Input/Output Addressing Format

Code Blocks
 The CPU supports the following types of code blocks that
allow users to create an efficient modular program
– Organization blocks (OBs) define the structure of a
program.
– Functions (FCs) and function blocks (FBs) contain the
program code that corresponds to a particular task,
which can be executed frequently or as needed.
– Data blocks (DBs) store the data that can be used by
the different program blocks.
Functions are logic blocks without memory. After the function
has been executed, the data in the temporary variables
therefore are lost.
Dr.-Ing. Jackson G. Njiri EMT 2549 L-3: Basics of PLC programming 7

You might also like