A data type specifies which type of value stored in memory of PLC. data type have fixed type of property. Each data type has a defined length. data types requires different amounts of memory and has some specific operations which can be performed over it. when you define data type they access system memory area. Memory location to store permitted value with in range. When you make a program for PLC, data type store data in reserved memory location but value is depend on different data type because each data type have minimum and maximum range to store data. if data exceeds maximum range limit than overflow bit set to 1 and if data is below minimum range underflow bit set. some time PLC stop due to overflow error . when you create variable memory location reserved for your variable. symbol is set of user defined character which are help to remember variable. Symbols are used in the program and they must be defined in the symbol table using STEP 7 , you can also define symbol during PLC programming. These data types known as Elementary Data Types in step7.
bit : binary digit 0 or 1
byte : group of of 8 bits binary digit
word : group of of 16 bits binary digit
double word : group of of 32 bits binary digit
Siemens BOOL Data Type
Boolean Types, only two values are possible either 1 or 0(true/false). bool data type are used to represent status of switch condition, flags in programs, status of plc, contact like NO, NC, reset, set, flip flop, various block output, comparison output, COIL, Enable(EN) and Enable output (ENO).Boolean 0 refers OFF(false) and 1 refers ON(true) . Boolean Types used where only two condition either ON or OFF like switch either ON or OFF, status of PLC FLAGS like overflow, under flow, error, plc status, status of motor running, sensors status. setting a 1 bit to coil of motor contactor, push button, limit status like high limit, low limit. output status of coil considered below example. for example I0.0 , Q0.0, m0.0 etc.
in this example all contacts (NO and NC) and coil are bool data type, push button assign for I0.0 if is set to 1 than motor start if any of the series contact are set to 1 motor stop and motor running status set to 0.
Siemens INT Data Type
Data Type INT (INTEGER) is 16 bit and Store Only Natural Numbers Without Decimal Places Like 12, 56 Etc. Value Like 33.45, 23.56 Not Stored In INTEGER Data Type, If Value Is 33.56 so INT Data Type Store Only 33. In Terms Of PLC Integer Value Comes From Analog Signal Or Memory Of CPU. For Example If You Connect Your Positioner Sensor For Positioning, Output Of Positioner Sensor Is Analog(4 To 20 MA) .This Analog Signal Converted Into Digital Signal By Analog Module Than We Make Program For Plc. When We Make Program Of These Type Of Analog Signal Scaling Or Calibration Is Required (We Discuss In Next Article). In Siemens Integer Represent Signed Decimal Number. INT Represent Only Integer Value. Maximum Allowed Range Or Maximum Allowed Value +32 767 And Minimum Allowed Value Or Minimum Range -32 768. When You Entered Value Below Minimum Range Underflow Status Bit Set To 1 And If Value Is More Than +32 767 For Example 32768 Overflow Bit Set To 1. Integer Value The Space That An Integer Occupies In The Memory Is One Word. Example Of Int Types: MW2, MW 4, IW 4, IW6 , QW 34, PIW 32.
in this example both inputs are int data type, first i done scaling of blocks and then i simply compare both int value and if the comparison is true then output coil set to 1 otherwise false.
Siemens Double INT Data Type
Data Type Double INT (DINT) is 32bit data tpe, Store Only Natural Numbers just like INT but range of DINT is more than int.double int is 32 bit and int is 16 bit. so the minimum range for DINT is -2 147 483 648 and maximum range is +2 147 483 647. example of DINT is MD 2, PID 40 etc.
in this example multiplication block used, all inputs are DINT, when input 1 is 16877206 and input 2 is 99090 than actual multiplication output is 1672362342540 but in our example output is out of range so overflow bit set to 1.
Siemens word Data Type
word is 16 bit data type and Word represent 3 digit BCD number, Binary number, Hexadecimal number. word store 3 digit BCD number, Binary number, Hexadecimal number. One group of 4 bits represents one digit of a signed decimal number or the sign of the decimal number. The groups of 4 bits are combined to form a word. The four most significant bits indicate the sign of the number where 1111 indicates minus and 0000 indicates plus sign. Range for word is -999 to +999 and 16 bit. for example mw 32, iw 34 etc.
in this example both inputs and outputs are word data type, wxor block have, two word values present at IN1 and IN2 bit by bit. The result store at the output OUT. if input_1 word = 3(in binary 0000_0000_0000_0011 / hexadecimal 3) and input_2 word = 12 (0000_0000_0000_1100 / hexadecimal c) then block compare xor logic bit by bit and gives output 15(0000_0000_0000_1111 /hexadecimal 15 ).
Siemens double word Data Type
word represent 3 digit BCD number signed, Binary number, Hexadecimal number. One group of 4 bits represents one digit of a signed decimal number or the sign of the decimal number. The groups of 4 bits are combined to form a word . The four most significant bits indicate the sign of the number where 1111 indicates minus and 0000 indicates plus sign. range for DWORD is -9 999 999 to +9 999 999.
in this example both inputs and outputs are double word data type.
Siemens REAL Data Type
data type real is 32 bit and store only real or float value in the memory. The Floating-point numbers are the real numbers with fractional component. float has 32 bit storage.The upper limit for float is ±3.402823e+38, and lower limit for float is ±1.175 495e-38. input and output of some of the instruction like SQRT, SQR, sin, cos, tan, EXP, ASIN, ACOS, ATAN, LN real data type. real value represent with decimal number
example of floating point number(real number) 1.3333, 12.456, 122.4345°C, 12.34 sqm, value of PI, etc . real type represent very large value as well as small values.
Floating-point numbers in STEP 7 follows the rule of ANSI/IEEE-754-1985 for Binary Floating-Point Arithmetic described by, IEEE-754 Standard .
format of real data type according to ANSI/IEEE
sign field - 1 bit, 0 represents minus sign and 1 represents + sign.
Exponent Field - 8 bit, store exponent.
Mantissa Field - 23 bit, store mantissa (significand).
in this example both inputs and outputs are double word data type.
Siemens Character (CHAR) data type
Character (char) data type store only ASCII Character like A, B, C, etc. char have 8 bit storage.
Siemens S5TIME Data Type
Data Type S5TIME is 16 bit and store time duration of Siemens timer in BCD format. for example S5T#10s, S5T#10ms,W#16#10s when timer start so timer value decrement by 1 until it reaches 0.
you can enter timer value by following syntax
S5T#aH_bM_cS_dMS : where a is timer value in hour, b timer value in minute, c timer value in second, d timer value in milliseconds. for example s5t#10s, s5t#1h, s5t#100ms, s5t#10M. The maximum time value which allowed in is 9,990 seconds, or 2H_46M_30S.
W#16#ABC : where W stands for timer base, and ABC represents timer value in BCD Format. for example W#16#9999.
in first example block when timer enable bit is set to 1 timer run for 10s, in second example preset value of timer is W#16#1199 so timer run 19 second and 900 milliseconds .
Siemens TIME (IEC time) data type
iec standard data type Time is 32 bit and store time value, where s5time is 16 bit but Time data type is 32 bit. data type time not used in Siemens timer directly.
above example convert time data type into s5time data type value.
Siemens date (IEC time) data type
iec standard data type store date. date data type is 16 bit and store only date format value. The DATE value must be between the limits DATE#1990-1-1 and DATE#2089-12-31.
Siemens date (IEC time) Time of day
iec standard time of day data type represent time of day in Hours: Minutes: Seconds: Milliseconds. time of day is 32 bit and store only day of time format value. A TOD data type is stored as an unsigned integer number in milliseconds, with zero equal to midnight.
in above example function block FC6 output store current date of OB1 and FC8 output return continuous time of day in hexadecimal format.