The document provides a summary of IEC 61131-3, which defines the syntax and semantics of instruction list programming languages for programmable logic controllers. It outlines common control structures like IF-THEN-ELSE and CASE structures. It also describes common data types, operations, conversions, and functions for string and numeric processing, and timing functions.
The document provides a summary of IEC 61131-3, which defines the syntax and semantics of instruction list programming languages for programmable logic controllers. It outlines common control structures like IF-THEN-ELSE and CASE structures. It also describes common data types, operations, conversions, and functions for string and numeric processing, and timing functions.
The document provides a summary of IEC 61131-3, which defines the syntax and semantics of instruction list programming languages for programmable logic controllers. It outlines common control structures like IF-THEN-ELSE and CASE structures. It also describes common data types, operations, conversions, and functions for string and numeric processing, and timing functions.
The document provides a summary of IEC 61131-3, which defines the syntax and semantics of instruction list programming languages for programmable logic controllers. It outlines common control structures like IF-THEN-ELSE and CASE structures. It also describes common data types, operations, conversions, and functions for string and numeric processing, and timing functions.
IF <condition(s)> THEN Provides one or more options and Data Structure Object Prefix <code> selects one (or none) of its SR_ Program ELSIF <condition(s)> THEN statement components for FB_ Function block <code> execution. ELEIF and ELSE are FC_ Function ELSE optional. A_ Action <code> ST_ Struct END_IF ET_ Enum CASE <var> OF Select one of several alternative IF_ Interface <int>: program sections. ELSE are IO Prefix <code> optional. iq_ VAR_IN_OUT <int>: i_ VAR_INPUT <code> q_ VAR_OUTPUT ELSE p_ VAR PERSISTENT <code> r_ VAR RETAIN END_CASE rp_ VAR RETAIN FOR <var> := <int> TO <int> BY <step> DO Repeat a sequence of statements PERSISTENT <code> as long as a control variable is g_ VAR_CLOBAL END_FOR within the specified range of values *) VAR CONSTANT REPEAT Repeat a sequence of statements ioi_ IO Input <code> until condition(S) is true. Note ioq_ IO Output UNTIL <condition(S)> minimum one execution. cani_ CAN Input END_REPEAT canq_ CAN Output WHILE <condition(s)> DO Repeat a sequence of statements mbi_ Modbus Input <code> as long as condition(S) is true. mbq_ Modbus Output END_WHILE Variable Prefix EXIT Terminates the FOR, WHILE or x BOOL REPEAT loop in which it resides by BYTE without regard to any condition si/usi Short integer SINT w WORD RETURN Terminates Program, Function i/ui Integer – INT / UINT block call dw Double Word - DWORD Prefix Structure di/udi Double integer _ PP_ppName PP = Data structure / IO prefix DINT / UDINT pp = Variable prefix li/uli Long integer _ LINT Name = Name of object / ULINT Example r REAL ioi_xStartMachine Digital input lr Long Real - LREAL FB_MyMachine Data structure of function block s STRING fbMyMachine Instance of function block tim TIMEL xMachineState Local Boolean variable tod Time of day – TOD date Date – DATE dt Date and time - DT Shortcut ws Unicode– WSTRING Input Assistant Instance Prefix Auto Declare fb Function block st Struct Start/Run if Interface Step into Toggle breakpoint *) No Prefix – Use capital letter. Ex: wCOLOR or g_wCOLOR Build / Compile Auto Complete Write online change
Data Types Operations BOOL 0 – 1 (FALSE – TRUE) Assignment BYTE 0 - 255 := Assignment SINT -128 – 127 * Multiplication WORD 0 – 65535 / Division INT -32768 – 32767 MOD Modolo division UINT 0 – 65535 + Addition DWORD 0 – 4294967295 - Subtraction UDINT 0 – 4294967295 Comparison DINT -2147483648 – 2147483647 < Less than LINT -2^63 – 2^63-1 > Greather than ULINT 0 – 2^64-1 <= Less than or equal to REAL 1.401e-45...3.403e+38 >= Greater than or equal to LREAL 2.2250738585072014e- = Equal to 308...1.7976931348623158e+308 <> Not equal to STRING ‘String’ Logical WSTRING “Wstring” NOT Negation TIME T#2s, t#100ms AND And TOD TOD#16:00:00 XOR Exclusive or DATE D#2017-10-18 OR Or DT DT#2017-10-17-09:00:00 Parentheses () Parentheses Conversion [] Array index <DataType>_TO_<DataType> Example Processing string BOOL_TO_INT LEN Length of string WORD_TO_DINT CONCAT Connect two strings BYTE_TO_REAL LEFT Returns N characters from the left REAL_TO_LREAL RIGHT Returns N characters from the right TIME_TO_DINT MID Returns N1 characters from N2 INSERT Insert string at N Numeric DELETE Delete a substring REPLACE Replace a substring ABS Number FIND Find a substring in a string SQR Square root LN Natural logarithm LOG Common logarithm Selecting Values EXP E to the power of IN SEL Select SIN Sine MAX Maximum COS Cosine MIN Minimum LIMIT Limit TAN Tangent MUX Select from N ASIN Arc sine ACOS Arc Cosine ATAN Arc Tangent Timers EXPT IN1 to the power of IN2 TP Pulse timer TON On delay timer TOF Off delay timer Counters CTU Counter up CTD Counter down Edge detection / Trigger CTUD Counter up and down R_TRIG Rising edge F_TRIG Falling edge
Bit Shift Functions
ROL Rotate left by N Conversion ROR Rotate right by N TRUNC Returns hole number as DINT SHL Shift left by N TRUNC_INT Returns hole number as INT SHR Shift right by N