Home
GM Instruction and programming
Contents
1. A 1 If input variable SET1 becomes 1 output variable RESULT will be ON 2 The output variable RESULT becomes 0 when input variable SET1 becomes 0 and RESET1 ON 8 195 8 Basic Function Function Block Librar TOF OFF Delay Timer function block Model GM GV Application Input IN timer operation condition els e 2 PT preset time TOF BOOL 4 IN BOOL ETF TIME Output timer output ET elapsed time Function If IN is 1 will be 1 And after IN becomes 0 and the preset time PT of TOF passes becomes 0 After IN becomes 0 the elapsed time ET will be shown If IN becomes 1 before ET reaches the preset time ET will be 0 again Time Chart IN ET Program Example TOF INS TOF IN T OFF 105 LD INS TOF Q ET TIME 5 LD INS TOF ET ST ET TIME 8 196 8 Basic Function Function Block Library TIMER OK 0s Preset time 10s ET_TIME 1 Output variable TIMER OK is 1 when input variable T OFF becomes 1 2 TIMER OK is 0 only if 10 seconds passes after
2. nnns 7 9 HAD DatasExchange Function oi iere 7 9 7 1 6 Comparision 7 10 7 1 7 Character String 7 10 7 1 8 of Day Date and Time of Day Function 7 11 7 1 9 System Control Function enne 7 11 7 1 10 Data Manipulation 7 12 7 1 11 Stack Operation 7 12 7 2 MK MASTER K Function 7 13 7 3 Array Operation Function or cet eei te a ed be arte Pads 7 13 7 4 Basic Function r ee ee aarin 7 13 7 4 1 Bistable Function 2 7 13 7 4 2 Edge Detection Function 7 13 PAO GOUDtel adno e 7 14 ya HIT 7 14 7 4 5 Other Function eee 7 14 Table of Contents Ch 8 Basic Function Function Block Library IV 8 1 Basic Function Library iiie tee 8 1 ABS 8 2 AGOS 8 3 8 4 toe eto 8 5 Up 8 6 TO STRINGS t ite b Pete dde tute 8 7 ASIN M Lem 8 8 A
3. EN executes the function in case of 1 MN minimum value IN the value to be limited MX maximum value Output without an error it will be 1 OUT value in the range MN IN MX OUT should be the same data type m Function gt If input IN value is between MN and MX the IN will be an output That is if MN x IN lt MX OUT IN gt If input IN value is less than MN MN will be an output That is if IN lt MN OUT MN gt If input IN value is greater than MX MX will be an output That is if IN gt MX OUT MX Program Example LIMIT LOW LIMIT MN CURRENT RESULT IN VALUE MX LIMIT HIGH ST OUT VAL MM 2 Output variable OUT VAL for lower limit input LIMIT LOW upper limit input LIMIT HIGH and limited value input IN VALUE will be as follows LIMIT LOW IN VALUE LIMIT HIGH OUT VAL 1000 2000 3000 2000 1000 3000 1000 1000 4000 3000 3000 Input MN LIMIT LOW INT 1000 IN IN VALUE INT 4000 MX IN VALUE INT 3000 V LIMIT Output OUT OUT VAL INT 3000 8 46 8 Basic Function Function Block Library LINT TO LI NT type conversi on Model M M G6 Application Input EN executes the function in case of 1 IN long integer value to convert Output ENO without an error it will be 1 OUT type converted data Func
4. e 2 e 2 Input R1 Reset condition S Set condition Output Q1 Operation result B Function i If R1 is 1 output Q1 will be 0 regardless of the state of S The output variable Q1 is 1 when it maintains the previous state R1 is 0 and S is 1 it will be 1 The initial state of Q1 is 0 Time Chart Program Example LD RESET RESULT S SETI LD INS 1 ST RESULT 1 The output variable RESULT is 0 and maintains its value when the input variables SET1 and RESET1 become simultaneously ON 2 The output variable RESULT is 0 and maintains its value when RESET1 becomes SET1 is OFF 3 The output variable RESULT is 1 and maintains its value when SET1 becomes ON and RESET1 is OFF 8 190 8 Basic Function Function Block Library R TRIG Rising Edge Detection function block Model MI GW Application e R TRIG Input CLK input signal BOOL Q BOOL Output rising edge detection result E Function The output Q of function block R TRIG is 1 with the rising pulse input to CLK And 1 scan later without further falling pulse input the output is 0 ever aft
5. NES After 8 164 8 Basic Function Function Block Library RTC SET Writes Time data Model QR a4 Application e e Input RIG SET REQ executes the function with rising pulse input BOQ REQ DOE BOOL DATA TIME data to input ANY DATA STAT USI NT Output DONE without an error it will be 1 STAT If an error occurs an error code is written E Function gt It writes data to Clock Device with a rising pulse input Variable Content Example Variable Content Example DATA O Last 2 digit number of years 16201 DATA 4 Minutes 164430 DATA 1 Months 16403 DATA 5 Seconds 16445 DATA 2 Dates 16415 DATA 6 Days 16403 DATA 3 Hours 16 18 DATA 7 First 2 digit number of years 16 20 The above example is 2001 03 15 18 30 45 Thursday Days are indicated as follows Mon 0 Tue 1 Wed 2 Thu 3 Fri 4 Sat 5 Sun 6 gt The above DATA variables are declared as array Byte variables and set as BCD data B Error If CPU does not support RTC function or RTC data is out of range the output is 0 and the error code is written at STAT Error code Description 00 No error 01 No RTC module installed GM6 GM6 CPUB and GM6 CPUC support RTC GM7 G7E RTCA should be installed 02 Wrong RTC data Example 14 Months 32 Da
6. Function block Description Input down counter pulse input CTD LD loads a preset value BOOL4 CD QF BOOL PV preset value INT 4 PV INT Output down counter output CV current value m Function gt Down counter function block CTD decreases the current value CV by 1 with every rising pulse input gt CV decreases only when CV is more than the minimum value of INT 32768 after reaching it CV does not change its value gt When LD is 1 PV is loaded into CV CV PV gt Output is 1 when CV is 0 or a negative number B Time Chart LD preset val ue i nput CD down counter i nput ke PV setti ng current value 1 0 gt nnn Max coef fi ci ent 32768 down counter out put 8 183 8 Basic Function Function Block Library B Program Example This is the program that sets the output contact 00 3 0 when the down counter pulse input enters the input contact 10 1 14 five times IL LD j CAL CTD COUNT 0 10 1 14 CD 10 1 14 COUNT Q LD 109 COUNT CU j PV 5 LD COUNT D Q 5 ST COUNT Q LD COUNT D OV ST COUNT CV COUNT Q 00 3 0 S LD COUNT_Q S 00 3 0 1 Register the name of CTD function block COUNT D 2 Make the input contact 10 1 14 attached to CD 3 Make the flag 10N 1 scan ON contact that loads PV into CV 4 Set the PV value as 5 5 Set the CV value as the random o
7. i Q S Bo LD 10 0 0 10 020 LSB LD EN TASK EN T sT 4 0 EN EI ST EN OK LSB If EN TASK is 1 a task program starts normally If El function permits running for a task program output OK will be 1 8 32 8 Basic Function Function Block Library EQ Equal to comparison Model M M M Application e e EN executes the function in case of 1 IN1 the value to be compared IN2 The value to compare Input variable number can be extended up to 8 IN1 IN2 should be the same type ENO without an error it will be 1 OUT comparison result value E Function If IN1 IN2 IN3 INn n input number output OUT will be 1 In other cases OUT will be 0 B Program Example LD VALUE1 VALUEl EQ IN1 CURRENT RESULT 2 VALUE2 VALUEZ IN3 VALUES ST Q0 0 1 VALUE 1 If the transition condition 9610 1 0 is EQ function will be executed 2 If VALUE1 300 VALUE2 300 VALUES 300 comparison result VALUE1 VALUE2 VALUES output Q0 0 1 1 Input IN1 VALUE1 INT 300 16 012C o o o ojo o o 1 of of 1 of 1 1 of 0 EQ 2 VALUE2 INT 300 16 012C 0 1 of 1 1 of oj EQ IN3 VALUE1 INT 300 160125 0 1 of of 11 oj 1 1 of o
8. 0 ww mo woww owe oo 0 TD TO SR NG TO LVERD 7 7 7 Function and Function Block 7 1 2 Arithmetic Function 7 1 2 1 Numerical Operation Function with One Input It supports GM1 GM2 Note ABS function supports GM3 GM4 GM6 GM7 Funct i on Descri pti on General functi on 1 ABS Absol ute val ue operati on Cal cul ate SCRT Square root operati Logari thm 2 g Natural ogari thmoperati on se 10 l ogari thmoperati on tural exponenti operati on Tri gononetri c functi on Si ne operati on Cosi ne operati on angent operati on Si ne operati on Arc Cosi ne operati on c Tangent operati on z Angl e functi on Convert degree i nto radi an Convert radi an i nto degree 7 1 2 2 Basic Arithmetic Function EXPT supports GV only XCHG supports GV n Fuxio scription Cperati on functi on of which input nuntper n be extended up to 8 1 AD Addition INL 1 1 MD QT INL py eta lt IN 8 Exchangestwoinputdata Cd 7 Function and Function Block 7 1 3 Bit Array Function 7 1 3 1 Bit shift Function m ooo Shift left HR 4 a tate 6 ROWEC Rotates a designatedairecton ooo 7 1 3 2 Bit Operation Function m Function
9. ol o o 8 Basic Function Function Block Library CONCAT Concatenates a character string Model GM M 6 Application e EN executes the function in case of 1 CONCAT IN1 input character string IN2 input character string BOOL MEN ENO STRING 4IN1 STRING STRING IN2 Input variable number can be extended up to 8 ENO without an error it will be 1 OUT output character string m Function It concatenates the input character string IN1 IN2 IN3 INn n input number in order and produces output character string OUT m Error If the sum of character number of each input character string is greater than 30 then the output CONCAT is the concatenate string of each input character string up to 30 letters and ERR LER flags will be set 110 2 1 j LD TEXT1 CONCAT IN1 CURRENT RESULT OUT TEXT IN2 IN_TEXT2 ST OUT_TEXT 2 2 THERE 1 If the transition condition 9610 2 1 is on CONCAT function will be executed 2 If input variable IN TEXT1 ABCD and IN TEXT2 DEF then OUT TEXT ABCDDEF Input IN1 IN TEXT1 STRING ABCD IN2 TEXT2 STRING DEF V CONCAT Output OUT OUT TEXT STRING ABCDDEF 8 13 8 Basic Function Function Block Library CONCAT TIME Concatenates date and time of day
10. ol 16 0007 The negative number of INT type is represented as the 25 compliment form refer to 3 2 4 Data Structure 8 Basic Function Function Block Library ACOS Arc Cosine operation Model MM G6 Application e Input EN executes the function in case of 1 IN input value of Arc Cosine operation Output without an error it will be 1 OUT Arc Cosine radian IN OUT should be the same data type m Function It converts input IN into its Arc Cosine value and produces output OUT The output range is between 0 OUT ACOS IN m Error Unless an IN value is between 1 0 and 1 0 ERR LER flags are set ST RESULT o 1 If the transition condition 0 is on ACOS function will be executed 2 If INPUT is 0 8660 V 3 2 RESULT will be 0 5235 1 6 rad 30 ACOS V3 2 1 6 COS 6 N 3 2 Input IN1 INPUT REAL 0 866 5 Output OUT RESULT REAL 5 23499966 01 REAL type representation is based on IEEE Standard 754 1984 refer to 3 2 4 Data Type Struct
11. of of of of 1 oj of 1 o 1 1 1 MOD IN2 VALUE2 INT 10 1640004 Output OUT OUT VAL INT 7 1680007 0 of of of of of of of af 8 59 8 Basic Function Function Block Library MOVE Appl i cati on Input executes the function in case of 1 IN value to be moved Output ENO without an error it will be 1 OUT moved value Variables connected to IN and OUT are the same type m Function Moves an IN value to OUT Program Example This is a program that transfers the 8contact inputs 10 0 0 10 0 7 to the variable D and then moves them to output Q0 4 0 Q0 4 7 100 0 0 0 0 4 0 1 If the transition condition 100 is ON MOVE function is executed 2 It moves 8 contact input module data to the variable D by the first MOVE function and moves them to Q0 4 0 96Q0 4 7 Input IN1 1 0 0 0 BYTE 165418 of of of 1 1j of of o V move D BYTE 16418 oj of of if of of o V MOVE Output OUT QB0 4 0 BYTE 16418 0 of of 1 1 of of ol 8 60 8 Basic Function Function Block Library MUL Multiplication Med ar as Aoplication e o Input EN executes the function in case of 1 IN1 multiplicand IN2 multiplier BOOL EN ENOf BOOL ANY NUM IN1 NUM ANY NUMe IN2 Input is available to extend up to 8
12. wth integer setti ng wth integer setti ng SUN step Control er Scan setti ng QV 8 Basic Function Function Block Library 8 Function Function Block Library 8 1 Basic Function Library This chapter describes the basic function library respectively When a function error occurs please refer to the following instruction gt Function error If an error occurs when a function is run ENO will be 0 and the error flag ERR LER will be 1 Unless an error occurs ENO will be equal to EN EN and ENO are used in LD only gt Error flag ERR Error After function execution of which error is described ERR value will be changed as follows There s no change in ERR value as long as there s no function error In case of an operation error it will be 1 In other cases it will be 0 LER Latched Error In case of an error after execution LER will be 1 and maintained until the end of the program Itis possible to write 0 in the program m Program Example This is a program that moves VALUE1 data to OUT VAL without executing SUB function if an ADD function error occurs 1 An error occurs in ADD function when its two inputs are as follows Input IN1 VALUE1 SINT 100 16464 2 VALUE2 SINT 50 16432 Output OUT OUT VAL SINT 106 1652296 2 As an output value is out of range of its data type the abnormal value will be stored in the OUT VAL SINT At this time ENO of ADD fu
13. cetus dst edu ts ted dt 8 140 BYTE WORD tid cd MER etes 8 141 ECTS 8 142 8 143 E EA and tuis 8 144 eet ree E ES oA 8 145 DWORD EWOQORD gettin e Po EL edid 8 147 DWORD WORD hainn mp we lxi beet bru iens 8 148 ENCO BW D IE 5 socer ittis ud qi o 8 149 GET CHAR oee nutu titer cal hte piter edet ivt 8 150 ING BWD E uictor fre o ra tdi te ied tt ih dope 8 151 EWORD BW ORD did ip eo Med eite 8 152 Ner IE m 8 153 MGOSODEU het bene he eta on aie bn dr 8 155 MEQ mE 8 156 8 158 RAD nde auium 8 159 ROTATE ASAE s zac name E a NP T tc e 8 160 ROTATE 8 163 os ad ceu 8 165 SEG T 8 168 SEIT ASSI oie dedere dtd ote hee HP eds oe Fas 8 170 8 173 OWA A aS 8 175 Tp 8 176 WORD BYTE nitir 8 178 WORD DWOPRD 353 rt terere 8 179 XGEIQ A T 8 180 8 3 Basic Function Block 8 182 e p M 8 183 eu em E EM 8 185 o Hd eH ep Hae 8 187 masc 8 189 pvp LIRE 8 190 8 191
14. 9e MO JMPN 27 10 XOR CURRENT RESULT IN2 ST 0 0 0 ZZ 1 If the transition condition 96MO is ON function will be executed 2 If input variable 10 11001100 ABC 11110000 the result of operation for two inputs will be 0 0 0 00111100 Input 1 MB10 BYTE 16 CC Lif of of sf if of o XOR 2 ABC BYTE 16 F0 1 Gq V Output OUT QB0 0 0 BYTE 1683C 00 1 1 1 8 106 8 Basic Function Function Block Library 8 2 Application Function Library This chapter describes application function library MASTER K and others 8 107 8 Basic Function Function Block Library ARY ASC TO BCD o o v Funcdin Description Input EN executes the function in case of 1 IN1 ASCII Array input Output ENO without an error it will be 1 OUT Dummy output In Out IN2 BCD Array output m Function It converts a word array input ASCII data to a byte array output BCD data B15 B12B11 B8 B7 B4 B3 BO B7 B4 B3 BO ZBRBBIC ue gt B Error gt If the number of each input array is different there s no change in IN2 data ERR LER flags are set gt If the elements of IN1 array are not between 0 and 9 hexadecimal its responding elements of IN2 array are 16400 while other elements of IN1 are normally converted and ERR and LER flags are set B Program ex
15. if you extract 4 character from this string output variable OUTPUT is 16 447 8 150 INC 8 Basic Function Function Block Library Increase data by 1 Model 4 GJ Application e Function Input EN executes the function in case of 1 IN Input data to increase Output ENO without an error it will be 1 OUT result data after increase If EN is 1 itincreases IN bit string data by 1 and produces an output An error does not occur when there s an overflow the result is 1620000 in case of 16 FFFF Input data types are BYTE WORD DWORD and LWORD LWORD is available only for GM1 2 FUNCTION IN OUT type Description INC BYTE BYTE INC WORD WORD INC DWORD DWORD You can select one of these functions according to the data type INC_LWORD LWORD E Program example OO JMPN BBB LD 9 eMW 100 INC WORD ST MW 100 AAA 1 If the transition condition is on INC WORD function is executed 2 If input variable MW100 16 0007 2 0000 0000 0000 0111 then output variable MW 100 16 0008 2 0000 0000 0000 1000 8 151 8 Basic Function Function Block Library LWORD DWORD vi des LWIRD i nto two DARD data Mde GfM Gu Ge as aw aw e Application e e Input EN executes the function in case of 1 IN LWORD Inp
16. 2 bt bo JL c4 cs c2 c1 co 82 1 2 41 40 gt Ifthe sum of value set by SEG exceeds the bit number of input data type ERR and LER flags are set gt If the number of arrays of IN and SEG is different output OUT is 0 ERR LER flags are set 8 176 8 Basic Function Function Block Library AMO ARY RESULT SEG ARY 1 If the transition condition is on UNI WORD function is executed 2 If input IN ARY and SEG are as below ARY O SEG ARY 0 ARY 1 SEG ARY 1 ARY 2 SEG ARY 2 ARY 3 SEG ARY 3 output RESULT 2400 1010111 0110 101 16 2BB5 8 177 8 Basic Function Function Block Library WORD BYTE vi des WIRD i nto two bytes Model aw aw aw Application e e Input EN executes the function in case of 1 IN WORD Input Output ENO without an error it will be 1 OUT dummy output In Output LOW lower BYTE output HIGH upper BYTE output E Function gt Itdivides one word data into two byte data LOW lower byte output HIGH upper byte output B Program example DUMMY BYTE OUTM 20 BYTE OUT 1 If the transition condition is WORD BYTE function is executed 2 If input variable INPUT is 16 ABCD then BYTE OUT1 16 CD and BYTE OUT2 16 8 178 8 Basic Func
17. Model QR M M 26 Application e e e m Function EN executes the function in case of 1 IN1 date data input IN2 Time of day data input ENO without an error it will be 1 OUT DT Date and Time of Day output It concatenates IN1 date and IN2 time of day and produces output OUT DT Program Example r TIME LD 1 JMPN AA LD START DATE CONCAT TIME INt CURRENT RESULT IN2 START TIME ST START DT 1 If the transition condition 1 is CONCAT TIME function will be executed 2 IF START DATE D 1995 12 06 and START TIME TOD 08 30 00 then output START DT DT 1995 12 06 08 30 00 Input IN1 START DATE1 DATE D 1995 12 06 CONCAT TIME 2 START TIME TOD TOD 08 30 00 Output OUT START DT DT DT 1995 12 06 08 30 00 8 Basic Function Function Block Library COS Cosine operation Model a6 GW Application Input EN executes the function in case of 1 IN radian input value of Cosine operation Output without an error it will be 1 OUT result value of Cosine operation IN and OUT should be the same data type m Function It produces IN s Cosine operation value OUT COS IN Program Example 10 1 3 JMPN CCC LD INPUT INPUT COS ST RESULT CCC 1 If the transition condi
18. j _ 168FFFFFFFF 16 i ST REF OK i AAA 1 Input the slot and base number in which an output module installed 2 Set MASK L as 162FF000000 because the output data to produce are the lower 24 bits among the output contacts 3 If the transition condition 9610 0 0 is off function DIREC_O will be executed and the data of the output module will be updated as 2 0150100 DJECIEJEI 1111 0000 1111 0000 1111 0000 during the scan Maintains the previous value 8 26 8 Basic Function Function Block Library DIV Division Model GM a GW Application e e e EN executes the function in case of 1 IN1 the value to be divided dividend IN2 the value to divide divisor Output without an error it will be 1 OUT the divided result quotient The variable connected to IN1 IN2 and OUT should be all the same data type E Function It divides IN1by IN2 and produces an output omitting decimal fraction from the quotient OUT IN1 IN2 7 2 3 i Decimal fraction omitted 7 2 3 7 2
19. 5 23 5 IL 5 4 Calling of Function and Function Block V VV Calls a function using its name as an operator When calling a function CR is stored as the first input If a function has more than one input assign the input value and then call a function The output value of a function will be stored in CR A data type of CR will be the output data type a function Example LD VAL SIN ST RESULT VAL and RESULT are regarded as a REAL data type If you store the value of VAL in CR at the first row and call SIN function at the second row then the CR value will be stored in SIN function as a first input And it does not need other inputs because SIN function has only one input and the output value will be stored in CR after executing SIN function At the third row CR will be stored in RESULT variable LD 961X0 0 0 SEL G CURRENT RESULT INO VAL1 IN1 VAL2 ST VAL3 This is the example of a function that has several inputs CR is set at the first row and is loaded in SEL function as a first input value If you assign each value for the rest inputs and call SEL function the result will be stored in CR and CR value will be stored in variable VAL3 5 24 5 IL gt JMP JMPN JMPC instructions are used to call a function conditionally Example LD 961X0 0 0 JMPN THERE LD VAL 1 ADD IN1 CURRENT RESULT IN2 VAL2 IN3 VAL3 ST VALA THERE 961X0 0 0 value is loaded in CR whose data ty
20. The priority is from O to 7 Priority O is the highest priority When scheduling the task with the highest priority is executed first And if there are some tasks with the same priority they re executed in execution condition occur order The task used by the reservation in system contains ERR SYS H INIT and INIT task ERR SYS System Error available in GM1 2 H INIT Hot Restart _ INIT Cold Warm Restart 2 3 2 The Structure of Software 2 3 2 Configuration Global Variable gt variables defined in Configuration Global Variables can be used in any resource program All the data to be shared among resources are defined in Configuration Global Variable gt If users want to use configuration global variables in their programs variables are supposed to be declared as VAR EXTERNAL Reference For a variable type refer to 3 3 2 Variable Declaration gt Configuration global variable can be defined only in GM1 that can have several resources 2 3 3 Access Variable The variable defined in Access Variable can be used in other PLC system Reference For the use of access variable refer to the User s Manual Communication part 2 4 3 Common Elements 3 Common Elements The elements of GLOFA PLC program programs functions function blocks can be programmed in other languages such as IL LD SFC etc respectively Those languages however have grammar elements in common 3 1 Expr
21. 4 3 3 Parallel Branch Simultaneous Branch gt When a processor executes the parallel simultaneous branch the processor scans the branch from left to right top to bottom It appears that the processor executes each path in the branch simultaneously gt In case of connecting by parallel branch if the transition condition connected to the next is 1 all steps tied to this transition will be activated The extension of each branch will be the same as serial connection At this time the steps in the state of activation are as many as the number of branches gt In case of combining in parallel branch if the transition condition is 1 when the state of all the last steps of each branch is activated the step connected to the next will be activated Example If the transition condition of T1 is 1 when S1 is active S2 S6 and S8 will be activated and S1 will be deactivated If the transition condition of T4 is 1 when S4 S7 and S8 are activated S5 will be activated and S4 S7 and S8 will be deactivated The order of activation S 1 4 gt S2 gt S3 gt S4 gt 5 4 3 4 Jump gt If the transition condition connected to the next is 1 after the last step of SFC is activated the initial step of SFC will be activated 4 9 4 5 order of activation 1 52 gt S3 gt E gt It is possible to extend to the place using a jump gt Jump only be place
22. STOP VAL CON N CON2 gt Only one power flow line can be connected to a function or function block Example Wrong only one power flow line can be connected 6 7 7 Function and Function Block 7 Function and Function Block It s a list of function and function block For each function and function block please refer to the next chapter 7 1 Function 7 1 1 Type Conversion Function It converts each input data type into an output data type ARY_ASC TO BYTE ARY_ASC TO ETE ARY BYTE TO ARY_BYTE_TO ASC ARY TO ARY BCD ASC TO U NT BCD TO UD NT BD BCD TO UI NT BD UN BCD TO ASC ere we S m oe Cun eoue a LREN TO DN 7 1 7 Function and Function Block Functi on group Functi on Input data typelOtput data woon ux o LREAL TO LRELTOUIN UN OO j UREA TOLWRO ID OT LREAL TOREA Jof sSNTOIN SNTOUN O O sNTOUFT SNTOUN SN To sNTOBRDL O O SNTOBE e SN WD O O O SN DVD SN gt SN BE
23. TIME 5 16446 _ _TIME 6 16 1 _ TIME 7 16 19 _RTC_TIME n 0 7 8 167 8 Basic Function Function Block Library SEG Converts BCD or HEX into 7 segment display code Model GM Gv GJ e e Application e e Input EN executes the function in case of 1 IN Input data to covert into 7 segment code Output ENO without an error it will be 1 OUT result data converted into 7 segment data E Function If EN is 1 it converts BCD or HEX hexadecimal of IN into 7 segment display code as below and produces output OUT If an input is BCD type it is available to display a number between 0000 and 9999 And in case of HEX input it s available to display a number between 0000 and FFFF on 4 digit 7 segment display Display example 1 4 digit BCD gt 4 digit 7 segment code use SEG function 2 4 digit HEX gt 4 digit 7 segment code use SEG function 3 INT gt 4 digit BCD type 7 segment code use INT_TO_BCD function first and SEG function 4 INT gt 4 digit HEX type 7 segment code use INT TO WORD function first and SEG function 5 When 7 segment display digits are more than 4 A in case of BCD HEX type use SEG function after dividing them into 4 digits B INT 8 digit BCD type 7 segment code Divide INT by 10 000 and convert quotient and remainder into upper lower 4 digit 7 segment code using INT_TO_BCD and SEG fun
24. n input number output OUT will be 1 Otherwise it will be 0 B Program Example LD VALUE1 VALUE 200 0 2 LE INt CURRENT RESULT IN2 VALUE2 ee IN3 VALUES ST Q0 0 1 1 If the transition condition 0 is on LE function will be executed 2 If input variable VALUE1 150 VALUE2 200 and VALUES 250 output Q0 0 1 1 VALUE1 lt VALUE2 lt VALUE3 Input IN1 VALUE1 INT 150 1690096 0101010101000 2 VALUE2 INT 200 16 00 8 1909006 13 VALUE1 INT 250 1640064 01010 0 0 of 1 0 Output OUT 00 0 1 BOOL 1 16 1 lt 8 8 Basic Function Function Block Library LEFT Takes the left side of a character string Model GR M Go GW Application e e EN executes the function case of 1 IN input character string L length of character string LEFT BOOL 4EN ENO STRING 4IN OUT F STRING INT L ENO without an error it will be 1 OUT output character string E Function It takes a left character string L of IN and produces output OUT B Error 0 ERR LER flags will be set B Program Example LD IN TEXT IN TEXT LEFT _ IN CURRENT RESULT L LENGTH Ve ST OUT TEXT FF 1 If the transition condition 0 is on function LEFT function will be executed 2 If input variable IN TEXT ABCDEFG and LENGTH
25. 8 Basic Function Function Block Library FIFO Load Unload data to FIFO stack Model GW First In First Out Application e o Input requires to execute the function block IN input data to be stored at FIFO stack LOAD FB is on the input mode if it s on UNLD FB is on the output mode if it s on RST pointer value reset Output DONE it s 1 after first execution OUT on output mode it s the data from FIFO stack PNT pointer for input data of FIFO stack FULL if FIFO stack is full it s 1 EMTY if FIFO stack is empty it s 1 In Output FIFO array used as FIFO stack Function It loads IN to FIFO or unloads data from FIFO If Input and Output mode are set at the same time it executes In Output simultaneous If data is unloaded from FIFO then the output is the lowest element of stack the rest elements are shifts PNT value is decreased by 1 and the element position of PNT is cleared 0 If RST is loaded to FIFO PNT is initialized as 0 EMTY is on and all the data of FIFO stack are cleared as 0 The stack number is the input array number set by In Output variable FIFO If you want to keep the data of FIFO array variables and FIFO function block instance in case that power is off or power failure occurs set them as RETAIN Reset functions without REQ input PNT shows the position of IN to be loaded next time or t
26. Function gt It fills an array with the input data gt If LEN is minus it fills an array from INDX to INDX LEN 8 120 8 Basic Function Function Block Library B Error gt If it is designated beyond the array range ERR and LER flags are set gt lf an error occurs there s no change in arrays and OUT is off An error occurs when INDX 0 or INDX max element number of IN INDX LEN gt max element number of IN IN ARY 0 1 2 3 2 4 7 8 9 z a a oe es o Fills 4 elements starting from IND 1 If input condition 0 is on FLL INT function is executed 2 It fills 4 elements of IN ARY starting from INDX with 34 3 If LEN is 9 it is beyond the array range and an error occurs ERR and LER flags set and the output 01 13 15 is on 8 121 8 Basic Function Function Block Library ARY MOVE Array nove Mie an Galan as as ae aur micio e le Input EN executes the function in case of 1 MOVE NUM array number to move IN1 array variable to move STRING type unavailable IN2 array variable to be moved STRING type unavailable IN1 INDX starting pointer of array to move IN2 INDX starting pointer of array to be moved Output ENO without an error it will be 1 OUT without an error it will be 1 m Function gt If EN is 1 it moves IN1 data to IN2 gt It copies MOVE NUM elements of IN1 from
27. 1 VAL2 Moves CR value in other place and stores the value of VAL2 whose data type is INT in CR SUB VAL3 After SUB operation for CR and the value of VAL3 whose data type is INT stores the result in CR After comparison operation for the current CR value and the moved CR value stored in other place stores the result in CR As the stored gt current CR CR will be 0 Stores the CR value in B_VAL3 whose data type is BOOL B VAL2 FALSE 5 19 5 IL 18 JMP Jumps to the specified label Modifier C If CR whose data type is BOOL is TRUE 1 it jumps to the specified label If CR whose data type is BOOL is FALSE 0 it does not jump to the specified label but executes the next instruction N If CR whose data type is BOOL is FALSE 0 it jumps to the specified label If CR whose data type is BOOL is TRUE 1 it does not jump to the specified label but executes the next instruction If there is no modifier it jumps to the label regardless of CR value Examples This is a program that stores the value of VAL1 or VAL2 in VAL3 according to the value of B VAL1 whose data type is BOOL B VAL1 The value of B VAL1 whose data type is BOOL is loaded in CR 1 If CR is 1 it jumps to THERE1 label if CR is 0 it executes the next instruction LD VAL1 CR lt VAL1 JMP THERE2 Jumps to THERE2 label unconditionally THERE1 THERE1 label LD VAL2 lt 1 VAL2 THERE2 THERE2 label ST VAL3 VAL3 lt
28. CR This is a program that executes SEL function if the value of B VAL2 whose data type is BOOL is 1 B VAL2 lt VAL2 THERES If CR is 0 FALSE it jumps to THERES label VALUE CR lt B VALUE Calls SEL function CURRENT RESULT VAL1 IN2 VAL2 ST VAL3 VAL3 lt CR THERES THERES label 5 20 5 IL 19 CAL Calls the function block whose name is described in the operand section Modifier C if CR whose data type is BOOL is TRUE 1 it calls a function block If CR whose data type is BOOL is FALSE 0 it does not call a function block N if CR whose data type is BOOL is FALSE 0 it calls a function block If CR whose data type is BOOL is TRUE 1 it does not call a function block If there is no modifier it calls a function block regardless of CR Function block name Function blockname ooo o Examples This is a program that if the value of B VAL1 whose data type is BOOL is 1 TRUE calls the TON on delay timer LD B VAL1 The value of B VAL1 whose data type is BOOL is loaded in CR CALC TON TIMER 1 If CR is 1 it calls the on delay timer TON whose instance is T INPUT TIMER1 PRE TIME This is a program that calls the CTU up counter if the value of B VAL2 whose data type is BOOL is 0 FALSE LD B VAL2 The value of VAL2 whose data type is BOOL is loaded in CR CTU COUNT1 If CR is 1 it calls the up counter whose instance is CU U
29. Despa 1663 8 123 8 Basic Function Function Block Library ARY ROT C remm moo ju o o n n BDescrpio Input EN executes the function in case of 1 STRT starting bit to rotate END ending bit to rotate N number to rotate BOOL ANY BIT ARY U NT BOOL_ARY Output ENO without an error it will be 1 OUT without an error it will be 1 In Out SRC Source Array to rotate CYO output Carry bit Array B Function gt It rotates as many bits of array elements as they re specified gt Setting Scope it sets a rotation scope with STRT and END Rotation direction and time it rotates N times from STRT to END Output the result is stored in ANY BIT ARY and a bit array data from END to STRT is written at CYO d c 4 word array 2 CYO Before l Jemm nu After evo seei 1 0 0 010 0101011 0 Function In out Array type ARY ROT C BYTE ARY ROT C WORD WORD It rotates elements of an array as many bits as they ARY ROT C DWORD DWORD specified ARY ROT C LWORD LWORD 8 124 8 Basic Function Function Block Library B Error gt If the number of SRC and CYO Arrays are different ERR and LER flags are set gt If STRT and END are out of bit range of SRC an error occurs gt When an error occurs there s no change in SRC and CYO B Program example 1 If the input condition 2 is on ARY
30. PV preset value QU up counter output QD down counter output CV current value Function gt Up Down counter function block increases the current value CV by 1 with every rising up counter pulse input CU and decreases by 1 with every rising down counter pulse input CD Note that CV is between 32768 and 32767 INT When LD is 1 PV is loaded into CV When the reset input R is 1 CV is cleared 0 When CV reaches PV the output QV is 1 when CV is 0 or a negative integer the output QD is 1 The operation for each input signal is executed in order of R LD CU CD Note that if the input signals are fed to the input CU CD R and LD of CTUD at the same time the operation of CTU follows the above priority m Time Chart LD loading PV R reset CU CTU input CD CTD input CV current value QU CTU output QD CTD output 8 187 8 Basic Function Function Block Library MiProgram Example MTS LD IL CAL CTUD INS_CUD INS CUD CU 10 1 0 210 1 0 STACK FUL L CD 11 1 0 R 11 1 0 i i LD 1 STORED NU MBER 5 Fr LD INS CUD QU iMi ST STACK FULL _ LD INS CUD OD ST STACK EMPTY LD INS CU CV ST STORED NUMBER Conditions are the temporary loading part STACK MAX is 100 IN is 1 with every material input signal while OUT is 1 with every materia
31. SCON Step Controller Model GR MLC GW Application e Input REQ if it s 1 the function block is executed SCCN S O if 0 SET function is enabled REQ if 1 OUT function is enabled ST 0 1 SET step number 0 99 QRS Output DONE without an error it will be 1 S produces an set bit array CUR_S produces a current step number Function gt Setting of step controller group The instance name of function block is the name of step controlling group Examples of FB declaration 500 G01 Manu1 Examples of step contacts S00 S 1 GO1 S 1 Manu1 S 1 gt In case of SET function ST O JP 1 2 0 In the same step controller group the present step number can be on when the previous step number is on If the present step number is on it keeps its state even when the input is off Only one step number is on even when several input conditions are on at the same time If Sxx S 0 is on all the SET output is cleared gt In case of JUMP function ST O JP 1 1 In the same step controller group only one step number is on even when several input conditions are on If input conditions are on at the same time last programmed one is produced If the present step number is on it keeps its state even when the input is off If SXx S 0 is on it returns to its first step B Error gt Anerror occurs when step s
32. Si eee ee LD 10 1 0 i puri JMPN LSB LD VAL IN VAL EXPT 1 1 CURRENT RESULT IN2 VALUE VALUE ST OUT_VAL LSB 1 If the transition condition 9610 1 0 is on EXPT exponential function will be executed 2 If input IN VAL 1 5 VALUE 3 output OUT VAL 1 5 1 5 x 1 5 1 5 3 375 Input IN1 IN VAL REAL 1 5 IN2 VALUE INT 3 V EXPT Output OUT OUT VAL REAL 3 37500000E 00 8 36 8 Basic Function Function Block Library FIND Finds a character string Model GM M M Application e EN executes the function in case of 1 IN1 input character string BOOL IN2 character string to find STRING STRING Output without an error it will be 1 OUT location of character string to be found E Function It finds the location of character string IN2 from input character string IN1 If the location is found it shows a position of a first character of character string IN2 from character string IN1 Otherwise output will be 0 LD IN TEXT POSITION FIND CURRENT RESULT 2 IN TEXT2 ST POSITION XYZ 2 If input character string IN_TEXT1 ABCEF and IN_TEXT2 BC then output variable POSITION 2 3 The first location of IN_TEXT2 BC from input character string IN_TEXT1 ABCEF is gw Input IN1 IN TEXT1 STRING
33. 8 92 tte eet uut 8 93 TRUNG t e t tenete end tee ete ete eed debe eee 8 94 su iani rii 8 95 ON P 8 97 Table of Contents VI SEQ Se ei dao Tete ot 8 99 5 oni 8 101 su ient i 8 103 WORD 8 105 E 8 106 8 2 Application Function 8 107 5 gt 8 108 ARY ASC TO BYTE chc ipee aac 8 110 ARYVAVB S eam ec eu ore NAT oM Cete 8 112 ARYSBGDATO ASC So USO 8 114 ARY BYTE TO ASGL iari attin 8 116 GOME S sin inscite meia ic rn 8 118 ARN Pe ie a ee ey 8 120 aede Rt abe ea 8 122 8 124 ARY 8 126 5 edu 8 128 RYO WAP oF ons nica 8 130 ASC TO BOD iter nid nuu veau 8 132 ASG TOBY A ioi oer er ARD a 8 133 uie d eet Het 8 134 teo tette edat tdeo nd 8 135 55653 en Eos ui 8 136 ON exu c n egt ees 8 138 m 8 139
34. ABCEF FIND IN2 IN TEXT2 STRING BC V Output OUT POSITION INT 2 8 37 8 Basic Function Function Block Library GE Appl i cati on Greater than or equal to comparison Model 041 GW EN executes the function in case of 1 IN1 the value to be compared IN2 the value to compare Input variable number can be extended up to 8 IN1 IN2 should be the same data type ENO without an error it will be 1 OUT comparison result value E Function If IN1 gt IN2 gt INS gt INn n input number an output will be 1 Otherwise it will be 0 MARNE lI LD JMPN LD m GE IN1 VALUEZ N 2 IN3 VALUES ST YY 1 If the transition condition 77 is on GE funtion will be executed IL 77 VALUE1 CURRENT RESULT VALUE2 VALUES 00 0 1 2 If input variable VALUE1 300 VALUES 200 comparison result will be VALUE1 gt VALUE2 gt VALUES The output Q0 01 1 Input IN1 VALUE1 INT 300 1640120 0 0 0 1 of of 1 o 1 1 of ol gt GE 2 VALUE2 INT 200 1640068 o o o o o o o of 1 1 ofo 1 of oj o gt GE N3 VALUES INT 100 1640064 1 1 of of 1 o o Output OUT 00 0 1 BOOL 1 164 8 38 V 8 Basic Function Function Block Library GT Greater than
35. Bit String BOOL 1 bit range 0 1 8 bits range 240000 0000 2 1111_1111 16 00 16 FF 16 bits range 2 0000_0000 _0000_0000 2 1111_1111_1111_1111 16 0000 16 FFFF 31 1615 0 DWORD 32 bits range 2 0000_ 000 2 1111_ 111 16 00000000 16 FFFFFFFF 0 LWORD 64 bits range 2 0000_ 000 2 1111_ 111 16 0000000000000000 16 FFFFFFFFFFFFFFFF Unsigned Integer USINT 8 bits range 0 255 UINT 16 bits range 0 65 535 31 16 15 0 UDINT 32 bits range 0 4 294 967 295 3231 0 64 bits range 0 24 1 Integer Negative number is expressed as 2 s Complement 7 0 SINT 8 bits range 128 127 15 87 0 INT 1 16 bits range 32 768 32 767 31 16 15 0 DINT 11 32 bits range 2 147 483 648 2 147 483 647 63 3231 0 O E 64 bits range 2 259 1 3 6 3 Common Elements Real based on the IEEE Standard 754 1984 31 30 23 22 0 REAL Exponen __ Fraction 32 bits range 1 401298 45 3 402823 38 LREAL Exponent 63 62 5251 0 64 bits range 4 9406564E 324 1 7976931E308 S sign If it s 0 the data is a positive number otherwise a negative number Exponent exponent of 2 22727 for REAL for LREAL e be2bs1 bs2 Fraction a decimal fraction Fraction for REAL f2b55b bo for LREAL e bs51bs2 b9 Time TIME 32 bits r
36. DESTINE WORD 16 0 00 ojojo 0j 110 11 0 jo o Jo o o 8 137 8 Basic Function Function Block Library Counts on bit nunber of input ar mia ave Ld sies Tole e ee le Input EN executes the function in case of 1 IN input data to detect ON bit Output ENC without an error it will be 1 OUT Result data sum of on bit number m Function If EN is 1 it counts bit number of 1 among IN bit string and produces output OUT Input data types are BYTE WORD DWORD LWORD LWORD is available only for GM1 2 FUNCTION IN type BSUM BYTE BYTE BSUM WORD WORD BSUM DWORD DWORD You can select one of these functions according to input data BSUM _LWORD LWORD Program example 10 0 0 SWITCHS ON COUNT 1 If the transition condition 0 is on BSUM WORD function is executed 2 If input SWITCHS WORD 240000 0100 0010 1000 then it counts on bit number So the output ON COUNT INT 3 8 138 8 Basic Function Function Block Library BYTE BIT Dudes byte into 8 lits anon aa aa Eee festeniafe Tele elo ole Description Input BYTE_BIT EN executes the function in case of 1 IN byte input Output ENO without an error it will be 1 OUT Dummy output In Out QO1 8 bit output m Function It divides one byte into 8 bits QO1 QO2 008 MSB Most Significant Bit QO1 LSB Least Significa
37. INPUT1 10 RESULT INPUT2 1 HIGH 1 If the transition condition 11 is on DWORD LWORD function is executed 2 If input variable INPUT1 16 1A2A3A4A5A6A7A8A and INPUT2 1648C7C6C5C4C3C2C10 then output variable RESULT 16 8C7C6C5C4C3C2C1C1A2A3A4A5A6A7A8A 8 147 8 Basic Function Function Block Library DWORD WORD vi des i nto 2 VERD data Model aw aw aw Application e e Input EN executes the function in case of 1 IN DWORD Input Output ENO without an error it will be 1 OUT Dummy Output In Out LOW lower WORD Output HIGH upper WORD Output E Function It divides one DWORD into two WORD data LOW lower WORD Output HIGH upper WORD Output B Program example INPUT 4IN 0 DUMMY WORD OUT 14 OW WORD_OUT24 GH 1 If the transition condition M5 is on DWORD WORD function is executed 2 If input variable INPUT 16 11223344AABBCCDD then WORD_OUT1 16 AABBCCDD and WORD_OUT2 16 11223344 8 148 8 Basic Function Function Block Library ENCO Encodes the on bit position of IN Model GM GV6 GW Application Input EN executes the function in case of 1 IN input data to be encoded Output without an error it will be 1 OUT result data after encoding B Function If EN is 1 the out
38. USER S MANUAL LG PROGRAMMABLE LOGIC CONTROLLER GLOFA GM Instruction Programming LG Industrial Systems Table of Contents Ch 1 Overview 1 1 Characteristics of IEC 1131 3 Language see 1 1 1 2 Type of 1 1 Ch 2 The Structure of Software 21 OVENIOW EN 2 1 2 2 PIOJecb icc cote te eid C iG a ite 2 1 2 92 GonflgULatlOr a diti ho va e eR 2 1 2 9 1 ROSOUN CO s Ea iR e i 2 2 2 39 11 Program edd een d dene pec 2 2 2 3 1 2 Resource Global Variable sse 2 2 2 3 4 9 LAK ests bb NU DIE Ee edt iens 2 3 2 3 2 Configuration Global Variable sene 2 4 2 3 3 Access Variable 2 4 Ch 3 Common Elements M de 3 1 31 51 Identifiers 1 aui ii Hie avn aed 3 1 351 2 Data EXpression ip o a a ae 3 1 3 1 2 1 Numb rs crece reme dec vene leen 3 2 3 1 2 2 Character String ire teet eerte obe ede 3 2 3 1 2 3 Time Letters ruines ieu eei 3 2 3 1 2 921 aei it cette 3 2 3 1 2 3 2 Time of Day and Date see 3 3 3 2 Data E diti dot a eio stehe 3 4 3 2 1 Basic Data Type n actui n 3 4 3 2 2 Data Type Hierarchy Chart
39. gt n case of expressing exponent plus minus signs can be used The letter E standing for the exponent does not distinguish capitals from small letters gt When using real numbers with exponents the followings are not allowed 12E 5 x 12 0E 5 gt Integer includes binary octal hexadecimal numbers not to mention decimal which be distinguished by placing in front of each number gt 0O 9andA F are used including small letters a f in expressing hexadecimal gt available to have plus minus signs in expressing hexadecimal gt Boolean data may be expressed as an integer 0 or 1 3 1 2 2 Character String gt Character string covers all the letters surrounded with single inverted commas gt length is limited up to 16 letters in case of character string constant and for an initialization case it does within 30 letters Ex CONVEYER 3 1 2 3 Time Letters gt Time letters are classified into these 1 Duration data which is calculating and controlling the elapsed time of a controlling event 2 Time of Day and Date data which is displaying the time of the starting ending point of a controlling event 3 1 2 3 1 Duration gt Duration data starts with the reserved word or gt Several data types such as date d hour h minute m second s and millisecond ms should be written in order and duration date can start with any unit among them Millisecond ms the minimum unit can be
40. 7 Function and Function Block indes tus ice quam MET D o o wworsw wo o TES LWRD O LWROTOUSN LWRD IWPDTOUN D LWROTOUIN LWRD IWPDTOUIN D LWROTOBOL IWPDTOBE WD LWROTOWRD LWRD LWROTO IWRDTODWED LWRD LWROTOLREL LWRD IWPDTODT LWRDTOSIRNS LWRD STRING _TO SINT STRI NG 7 6 7 Function and Function Block fo dote tps tot COT Ter GR 2 7 smm sm o SHNS TOUSN ISBN O JO oO SIRNS TOUN UN o SIRNS TOUIN SING o o STRING UN oO SIRNS TORO po J o lo STRING TOBE STNG ETE O O o owo STRI NG ae SIRNG TO m STRING Towa sme o STRING TORE STRNG o STRING ra 0 SIRNS smn o J o o STNG TODNE DNE O O O TOTD XD o o sins Jj o o NMTOSTRNG NMTOSTRNG AWNM mue O O nemouN j O TM TO TM DVD O TMTOSRNG TM mue O O O woun ow uw ow o mrmsmwo wt
41. DIS Output ENO without an error it will be 1 OUT Dummy Output In Out IN2 distributed WORD array Output B Function It distributes input data over IN2 after segmenting input data by bit number set by SEG Description DIS BYTE BYTE DIS WORD WORD DIS DWORD DWORD It segments IN1 input by bit number set by SEG and produces 1 2 array 01 LWORD LWORD 3ER 8 sE data distribution 16 sun ANA a A seg 87 mp TT B Error If the sum of designated number of SEG exceeds input variable bit number ERR LER flags are set 8 145 8 Basic Function Function Block Library B Program example 1 If the transition condition 0 is on DIS WORD function is executed 2 If input variable WORD 1623456 SEG ARY 8 4 5 4 then output variable DIS DATA is DIS DATA 0 1620006 DIS DATA 1 16 000A DIS DATA 2 1640008 DIS DATA S 1640003 8 146 8 Basic Function Function Block Library DWORD LWORD Conbi nes two DARD data i nto Mde GfRM Gu ae as aw aw e Application e e Input EN executes the function in case of 1 LOW lower DWORD Input HIGH upper DWORD Input Output ENO without an error it will be 1 OUT LWORD Output E Function combines 2 DWORD data into one LWORD data LOW lower DWORD Input HIGH upper DWORD Input B Program example
42. Output ENO without an error it will be 1 OUT If STOP function is executes it will be 1 B Function gt If EN and REQ 1 stop running and return to STOP mode gt If function STOP is executed the program stops after completing scan program in executing gt Program restarts in case of power re supply or the change of operation mode from STOP to RUN B Program Example 10 0 0 LOG OUT SHUT OFF 1 If the transition condition 9610 0 0 and LOG OUT is 1 it becomes to STOP mode after completing the scan program in executing 2 It is recommended to turn off the power of PLC in the stable state after executing STOP function declared as input variable 8 82 8 Basic Function Function Block Library STRING TO STRING type conversion ae av Adictim e e e jejeje o Input EN If EN is 1 function converts STRING TS IN character string Output ENO without an error it will be 1 OUT type converted data B Function Converts the IN type and outputs it as OUT Converts STRING into SINT type STRING TIME TIME Converts STRING into TIME type B Error If input character type does not match with output data type ERR and LER flags will be set 8 83 8 Basic Function Function Block Librar B Program Example LD 0 p JMPN 22 STRING TO REAL LD IN VAL EN ENO STRING TO REAL ST OUT VAL 77 IN OUT
43. ST BCD VAL AAA 1 If the input condition MO is ON function SINT TO BCD will be executed 2 If input variable IN VAL SINT 64 240100 0000 output variable OUT VAL BCD type 16464 240110 0100 Input 1 IN VAL SINT 64 16 40 Lo 1L o of of of of o SINT BCD Output OUT OUT VAL BCD 16 64 16 64 o 1 1 of of 1 of 0 8 80 8 Basic Function Function Block Library SQRT Calculate SQRT Square root operation ar as ae eje Input executes the function in case of 1 IN input value of square root operation Output ENO without an error it will be 1 ANY_REAL OUT square root value IN OUT should be the same data type Function It finds the square root value of IN and output it as OUT OUT IN E Error If the value of IN is a negative number ERR and LER flag will be set 0 RESULT 1 If the transition condition 96MO is ON function SQRT square root operation will be executed 2 If the value of input variable declared as INPUT is 9 0 RESULT declared as output variable will be 3 0 49 0 3 0 Input IN1 INPUT REAL 9 0 Y SQRT Output OUT RESULT REAL 3 0 8 81 8 Basic Function Function Block Library STOP Amictim e e o Input EN executes the function in case of 1 RE requires the operation stop by program
44. av Application e e e jejeje o Input EN executes the function in case of 1 IN Bit string to be converted 16 bit Output ENO without an error it will be 1 OUT type converted data B Function It converts the IN type and outputs it as OUT WORD TO DATE DATE Converts into DATE type without changing the internal bit array WORD TO STRING STRING Converts WORD into STRING type 0 JMPN PO LD IN VAL WORD TO INT ST OUT VAL PO IN_VAL 1 If the input condition is ON function WORD TO INT will be executed 2 If input variable IN VAL WORD 240001 0001 0001 0001 output variable OUT VAL INT 4096 256 16 1 4 369 Input IN1 IN VAL WORD 1641111 o o oj1 o o oj i of of of 1 o d o i WORD TO INT Output OUT OUT VAL INT 4369 1641111 1 of olal of of of 1 dg d 1 8 105 8 Basic Function Function Block Library XOR Exclusive OR ar anlar aw Aoolication e fe jejeje le Input EN executes the function in case of 1 IN1 the value to be XOR IN2 the value to be XOR Input variable number can be extended up to 8 ANY_BIT ANY_BIT Output ENO without an error it will be 1 OUT the result of XOR operation IN1 IN2 OUT should be all the same data type m Function Do XOR operation for IN1 and IN2 per bit and produces OUT 1111 0000 XOR 2 1010 1010 OUT 0101 1010 Program Example
45. can be extended upto 1 AD Loci AD QT ADI AD ADIN O 2 m lga IN RING RIN 4 NY Rweselojc QT e NY IN 7 1 4 Selection Function i Function Descri pti on n can be extended up to 8 3 MN Produces mni umval ue anong input IN IM a umt Limits upper and lover bondry 7 1 5 Data Exchange Function m 00 00 02 Swaps upper nibble for lower nibble data 2 Swaps upper byte for lower byte data Swaps upper word for lower word data LVIFD Swaps upper double word for lower double word data ARY SWP BYTE Swaps upper lower nibble of byte elements ARY SWAP VWIFD Swaps upper lower byte of WORD elements ARY SWMP D TRD Swaps upper lower WORD of DWORD elements ARY SWP LVIRD Swaps upper lower DWORD of L WORD elements 7 Function and Function Block 7 1 6 Comparison Function mf mim _ Descri pti on can be extended up to 8 Geater than conpari son lt 1 amp 15 6 amp 1 1 gt Geater than or equal to conpari son lt 1 5 amp 129 amp amp INF 1 N Equal to conpari son lt INIHN2 amp I NANB amp amp 1 Less than or equal to conpari son INE N lt 4 amp amp INF 1 IN Less than conpari son lt INIdN2 amp 148 amp amp lt 1 MN Not equal to c
46. comparison Model GM GW Application e e EN executes the function in case of 1 IN1 the value to be compared IN2 the value to compare Input variable number can be extended up to 8 IN1 IN2 should be the same data type ENO without an error it will be 1 OUT comparison result value E Function If IN1 gt IN2 gt ING gt n input number an output will be 1 Otherwise it will be 0 B Program Example LD VALUE1 VALVEL 00 0 1 GT IN1 2 CURRENT RESULT IN2 VALUE2 VALUEZ IN3 VALUE3 VALUE ST 00 0 1 1 If the transition condition 96MO is on GT function will be executed 2 If input variable VALUE1 300 VALUE2 200 and VALUES 100 comparison result will be VALUE1 gt VALUE2 gt VALUES The output Q0 0 1 1 Input IN1 VALUE1 INT 300 16 012C oToTo o o o o 1 of of if of 1 1 of ol gt GT IN2 VALUE2 INT 200 16 00C8 _ o o o 0 0 0 0 oL 0 o gt IN3 VALUES INT 100 16 0064 oTo o o o o o o o i 1 oL o 1 o o V Output OUT 00 0 1 BOOL 1 164 8 39 8 Basic Function Function Block Library INSERT Inserts a character string Model GR GM 94 9 GW Application e e Input EN executes the function case of 1 IN1 character string to be inserted IN2 chara
47. gt Once DI function is executed a task program does not start even if REQ input is 0 gt In order to start a task program normally please use El function gt If you want to partially stop the task program for the troubled part otherwise miss the continuity of operation process due to the execution of other task program it is available to use this function V The task programs created while its execution is not invalidated will be executed according to task program types as follows Single task it will be executed after EI function or current running task program execution In his case it repeats a task program as many as the state of single variable changes Interval task interrupt Interval task interrupt the task occurred when it is not permitted to execute will be executed after El function or the current running task program execution But if it occurs more than 2 times TASK ERR is ON and TC CNT the number of task collision is counted 8 18 8 Basic Function Function Block Librar B Program Example This is the program that controls the task program increasing the value per second by using DI Invalidates 1 Scan program TASK program control 1 Scan program TASK program control LDN 100 TNT JMPN KK LD 10 1 14 10 1 14 DI DI ST DI OK KK 34100 d LDN 100 10 1 15 EI JMPN LL LD 10 1 15 ST EI OK LL 2 Task program increasing by execu
48. 1 m A 8 5 8 Basic Function Function Block Library AND Logical AND Logical multiplication Model GR GM G4 G6 GW Application e e EN executes the function in case of 1 IN1 input 1 IN2 input 2 Input variables can be extended up to 8 BOOL ANY BIT ANY BIT BNET Output ENO without an error it will be 1 OUT AND result IN1 IN2 and OUT should be all the same data type m Function It performs logical AND operation on the input variables by bit and produces output OUT INT 1111 0000 IN2 1010 1010 OUT 1010 0000 m Program Example AND IN1 2 CURRENT RESULT 10B0 0 0 IN2 ABC j ST QB0 0 0 AA 1 If the transition condition 9610 1 1 is on AND function will be executed 2 If INI MB10 and IN2 ABC the result of AND will be shown in OUT QBO0 0 0 Input 1 10 BYTE 16 1 1 of of 1 1 of 0 amp AND IN2 ABC BYTE 16 F0 1 1 of of of Output OUT QB0 0 0 BYTE 16 CO 1T a of o 0 ol of 0 8 6 8 Basic Function Function Block Librar ARY TO STRING Converts a byte array into a string MIEL AB G4 GJ e Application EN executes the function in case of 1 IN byte array input ENO without an error it will be 1 OUT string output m Function It converts a byte
49. 14555 QU QUT 81 1 1 UNLOAD 5 LIFO 1ZZFO PNTF PNT INDEX 11 1 15 1 LOAD FULL FULL FLAG LOAD 0 FLAG UNLOAD an RESET RST LOAD FULLPFFULL FLAG UNLOAD UNLOAD 1 UNLD EMTYPEMTY FLAG THOS OUT RESET LIFO PNT_ INDEX 0 LOAD FULLFULL_FLAG 1 FLAG RESET LIFO function block is used as the above The two examples of the above execute the same operation The left one is a program which executes input and output functions at the same time to use only one function block while the right one is a program which executes input and output functions independently to use input function and output function respectively Note that the instance name should be the same on the right program 1 If the input conditions 11 1 0 11 1 1 9611 1 15 on LIFO TM is executed 2 If input contact 11 1 0 is on load function is executed T 55S is loaded to LIFO stack and PNT INDEX increased by 1 3 If input contact l1 1 1 is on unload function is executed T 55S is unloaded from LIFO stack and PNT INDEX decreased by 1 4 If input contact 11 1 15 is on reset function is executed All the stack of LIFO is cleared as T 0S PNT INDEX is initialized as 0 and EMTY FLAG is on 8 213 8 Basic Function Function Block Library LOAD 6l1 1 0is ON 555 PNT 4 PNT 5 UNLOAD 1 1 1 is LIFO LIFO 8 214 8 Basic Function Function Block Library
50. BYTE BYTE DECO WORD WORD DECO DWORD DWORD You can select one of these functions according to output data type DECO LWORD _ LWORD Error If input data is a negative number or bit position data is out of output type range in case of DECO WORD it s more than 16 then OUT is 0 and ERR LER flags are set 0 ON POSITION DECO WORD ST RELAYS 1 If the transition condition 0 is DECO WORD function is executed 2 If ON POSITON INT 5 then RELAYS WORD 240000 0000 0010 0000 8 143 8 Basic Function Function Block Library DEG kkk Converts radian into degree ar mia ave aw micio ojoj Description Input EN executes the function in case of 1 IN radian input Output ENO without an error it will be 1 OUT degree output B Function It converts radian input into degree output Inputtype Output type DEG REAL BEAL REAL It converts input radian into output degree DEG LREAL LREAL LREAL P aor B Program example 1 If the transition condition 96MO is on DEG LREAL function is executed 2 If input variable RAD VAL 1 0 then output variable DEG VAL 5 7295779513078550e 001 8 144 8 Basic Function Function Block Library DIS 500000 Description Input EN executes the function in case of 1 IN1 input data SEG designated bit array for data distribution
51. Block Library BCD TO ASC Converts B to ASC data ave ave 2665 Input EN executes the function in case of 1 BCD TO ASC BCD input Output ENO without an error it will be 1 OUT ASCII Output W Function It converts two BCD data to two ASCII data B Error If IN is not between 0 and 9 its output is 16223030 00 ERR LER flags are set 1 If the transition condition 0 is on BCD TO ASC function is executed 2 If input VAL BYTE 16885 output ASCII VAL WORD 1623835 85 8 134 8 Basic Function Function Block Library BIT BYTE ele ele le le micio Description Input BI T BYTE EN executes the function in case of 1 IN1 IN8 Bit input Output ENO without an error it will be 1 OUT Byte output m Function It combines 8 bits into one byte IN8 MSB Most Significant Bit IN1 LSB Least Significant Bit 1 If the transition condition 3 is BYTE function is executed 2 If 8 input are from INPUT1 to INPUT 8 0 1 1 0 1 1 0 0 OUTPUT BYTE 2300110110 8 135 8 Basic Function Function Block Library BMOV_ Moves part of a bit string R Gave Input BMOV ENO EN executes the function in case of 1 IN1 String data having bit data to be combined IN2 String data having bit data to be combin
52. Elements 3 4 Reserved Word Reserved words are previously defined words to use in the system And these reserved words cannot be used as an identifier CASE ELSE END CASE CONFIGURATION END CONFIGURATION DATE Ds FOR BY DO END FOR IF THEN ELSIF ELSE END IF TC Operator IL language Operator ST language TASK WITH TIME OF DAY TOD TRANSITION FROM END TRANSITION END TYPE VAR END VAR VAR INPUT END VAR VAR OUTPUT END VAR VAR IN OUT END VAR VAR EXTERNAL END VAR STRUCTURE END STRUCTURE 3 17 3 Common Elements 3 5 Program Type gt There are three types of program function function block and program gt It is not available to call its own program in the program reflexive call is prohibited 3 5 1 Function gt A function has one output Example If there is function A that is to add input IN1 and IN2 and then add 100 to the sum of IN1 and IN2 and the output 1 lt IN1 IN2 100 this function will be correct However if the above function has one more output output 2 lt IN1 IN2 100 this will not be a function because it has 2 outputs output 1 and output 2 gt function does not have data to preserve its state inside This means if an input is constant an output value should be constant which is a function Example If there is function B whose contents a
53. Function Block Library CTR Ring Counter Model M AW Aplication Input CD pulse input of Ring Counter PV preset value RST reset Output Q Ring Counter output CV current value E Function t CTR function block Ring Counter functions current value CV increases with the rising pulse input CD and if after CV reaches PV CD becomes 1 then CV is 1 gt When CV reaches PV output is 1 gt If CV is less than PV or reset input RST is 1 output Q is 0 B Timing Chart R Reset CD Pulse input PV Preset Value CV Current Val ue Q CTR Out put 8 203 8 Basic Function Function Block Library B Program Example COUNT Q 01 3 0 Set 1 1 0 to the input contact of CD referring to the above Set 10 to PV Set 1 1 10 to RST resetting CV Set random variable COUNT_NUM to CV Set random output variable COUNT_Q to Q After a program is complete compile and write it to PLC When Write is complete do Mode Change Stop gt Run CV COUNT NUM increases by 1 in number with the rising input pulse of 11 1 0 CD 0 With 10 time rising input pulse of input contact CV is 10 which is the same as PV and output variable COUNT 1 11 If COUNT Q is 1 output contact Q1 3 0 is on 12 If the rising input pulse is loaded into input contact 1 1 0 then CO
54. INDX max number of IN INDX LEN gt max number of IN 8 112 8 Basic Function Function Block Library IN ARY 9563 18764 7765 29215 21004 10048 _ 433 16045 10 6 array 1 If input transition condition 1 1 6 is on ARY AVE INT function is executed 2 If an array is as the above it finds an average between INDX 3 and 9 8 The output value is rounded off 8 113 8 Basic Function Function Block Library ARY BCD TO ASC mmm Description Input ARY BCD T EN executes the function in case of 1 IN1 BCD array input Output ENO without an error it will be 1 OUT dummy output In Out IN2 ASCII array output m Function It converts a byte array input BCD to a word array ASCII B7 B4 B3 BO B15 B12B11 B8 B7 B4 B3 BO IN1 0 IN2 0 1 IN2 1 m Error gt If the number of each input array is different there s no change 2 data and ERR LER flags are set gt If the elements of IN1 array are not between 0 and 9 hexadecimal its responding elements of IN2 array are 16 3030 00 while other elements of IN1 are normally converted and ERR and LER flags are set B Program example 1 If the transition condition 0 is on ARY BCD 5 function is executed 2 If the input BCD_ARY is as below 8 114 8 Basic Function Function Block Library The In out ARY is as follows 5 ARY 0 3031
55. JUmp itd eL Lo EU eii I a pere e ee pedi 4 9 Ch 5 IL Instruction List Mel 5 1 5 2 Current Result CEU cte iot eet ein ede 5 1 5 3 Instr ctlons i 5 2 5 91 ede em etie ie 5 2 5 3 2 Modlfler ee tread e diee de de 5 2 5 3 9 echte ett rez bd eter exeo rg 5 3 3 1 51 enne enn 5 5 5 4 Calling of Function and Function 5 24 II Table of Contents Ch 6 LD Ladder Diagram mE MIR 6 1 6 2 Bus Line anc E E ETE hein ERR e Pe dr 6 1 6 3 Connection Liri 2 oreet re Urge be o Peine 6 2 iei IE eei Eee deii e te PE n ere PE eee 6 3 ER ELE AUS E cete 6 4 6 6 Calling of Function and Function 6 5 Ch 7 Function and Function Block Fei 7 1 7 1 1 Type Conversion 4 0 7 1 7 1 2 Arithmetic 7 8 7 1 2 1 Numerical Operation Function with One 7 8 7 1 2 2 Basic Arithmetic 7 8 7 53 BEATA F UNCION iat etta ot tot mensas 7 9 Bit shift UNCON sec ene triente rerit eret 7 9 7 1 3 2 Bit Operation 7 9 7 1 4 Selection Function
56. Library OUT ARY data is as follows 8 131 8 Basic Function Function Block Library ASC TO BCD Converts ASA to R Gave ave avi aw Description Input EN executes the function in case of 1 ASCII input EN OUT Output ENO without an error it will be 1 OUT BCD output B Function It converts two ASCII data into two digit BCD Binary Coded Decimal data B Error If IN is not hexadecimal number between 0 9 the output is 16200 and ERR and LER flags will be set B Program example 1 If the transition condition is on ASC TO BCD function is executed 2 If input variable ASCII VAL WORD 16 3732 72 output variable BCD VAL BYTE 164272 8 132 8 Basic Function Function Block Library ASC TO BYTE Converts ASQ to BYTE data oR Gaon ae aspera micio le Description Input ASC TO BYTE EN executes the function in case of 1 y IN ASCII input Output ENO without an error it will be 1 OUT BYTE Output B Function It converts two ASCII data to 2 digit hexadecimal HEX B Error If IN is not between 0 and F its output is 0 and ERR LER flags are set B Program example 1 If the transition condition 0 is on TO BYTE function is executed 2 If input ASCII VAL WORD 1624339 output BYTE VAL BYTE 16 C9 8 133 8 Basic Function Function
57. OUT minimum value among input values IN1 IN2 OUT should be all the same data type B Function Produces the minimum value among input IN1 IN2 INn n input number B Program Example 100 VALUE1 IN1 2 CURRENT RESULT IN2 VALUE2 OUT VALUE 1 If the transition condition 100 is ON MIN function is executed 2 The output is OUT VALUE 100 because its minimum value is 100 as the result of comparing VALUE1 100 to VALUE2 200 ut N1 VALUE NT 100 1640064 MIN 2 VALUE2 INT 200 16 00C8 Jd ddd 14d d id d V 0 0 Output OUT OUT VAL NT 100 1640064 8 58 8 Basic Function Function Block Library MOD Appl i cati on Input executes the function in case of 1 IN1 dividend IN2 divisor ANY INT Output ENO without an error it will be 1 ANY INT OUT dividing result remainder IN1 IN2 OUT should be all the same data type Function Divides IN1 by IN2 and outputs its remainder as OUT OUT IN1 IN1 IN2 x IN2 if IN2 0 OUT 0 IN2 7 2 1 7 2 1 z 2 2 100 JMPN BB LD VALUE1 1 1 CURRENT RESULT IN2 VALUE2 ST OUT_VAL BB 1 If the transition condition M100 is ON MOD function is executed 2 If the dividend VALUE1 37 and the divisor VALUE2 10 the remainder value OUT VAL is 7 as a result of dividing 37 by 10 Input IN1 VALUE1 INT 37 1620025
58. OUT VAL 1 If the input condition 0 is ON function STRING TO REAL will be executed 2 If input variable IN VAL STRING 1 34E12 output variable OUT VAL REAL 1 34E12 Input IN1 IN VAL STRING 1 34E12 STRING TO REAL Output OUT OUT VAL REAL 1 34E12 8 84 8 Basic Function Function Block Library STRING TO ARY Convert a string into a byte array ar anjar fas Apictim e e fe le le Input EN If EN is 1 function converts IN string input STRI NG Output ENO without an error it will be 1 OUT dummy output In Out 2 converted byte array output B Function It converts a string into 30 byte arrays B Program Example 1 If the transition condition 2 is on STRING BYTE function is executed 2 If input variable INPUT is GM4 CPUA In Out variable BYTE is as follows 16 22 47 G 4D M 34 4 2D 43 C 50 P 55 U 41 A 22 8 85 8 Basic Function Function Block Library 55558588 Amictim e lelelele Puno O Input EN executes the function in case of 1 IN1 the value to be subtracted IN2 the value to subtract Output ENO without an error it will be 1 OUT the subtracted result value The variables connected to IN1 IN2 and OUT should be all the same data type m Function It subtracts IN2 from IN1 and outputs it as OUT OUT IN1 IN2 B Error If output value i
59. Output ENO without an error it will be 1 OUT multiplied value Variables connected to IN1 IN2 OUT are all the same data type m Function Multiplies an IN1 IN2 INn n input number and outputs the result as OUT OUT IN1 2 x B Error If an output value is out of its data type range ERR LER flags are set E Program Example 0 JMPN ABC LD VALUE1 MUL IN1 CURRENT RESULT 2 VALUE2 IN3 VALUES OUT_VAL 1 If the transition condition is ON MUL function is executed 2 If input variables of MUL function VALUE1 30 VALUE2 20 VALUES 10 then the output variable OUT_VAL 30 x20 x10 6000 of of of of 1 q MUL IN2 VALUE INT 20 16 0014 ojo o o o ojo o of of of i o VALUES INT 10 16 000A 01 1 a of 1 a o gd of Input 1 VALUE1 INT 30 16 001E Output OUT OUT VAL INT 6000 164770 8 61 8 Basic Function Function Block Library MUL TIME Time multiplication aw Aictim e Input EN executes the function in case of 1 IN1 time to be multiplied IN2 multiplying value Output ENO without an error it will be 1 OUT multiplied result B Function Multiplies the IN1 time by IN2 number and outputs the result time as OUT W Error If an output value is out of its TIME data range ERR LE
60. ROT C WORD function is executed 2 It rotates 2 times the bit from 4 to 13 bit arrays of SRC_ARY from STRT to END 3 The result is stored at SRC_ARY and the carry bit arrays are written in CYO BOOL Array CYO Before SRC ARY 16 7 7 o0 m 16 E3E3 0 Bl Before 16 C1C1 210 m 16 8080 0 m N 2 After SRC ARY 16 FDF7 TUIS 16 E8F3 16 C071 el m 1648020 i After CYO 241100 so m 3 101010101010 1010 3 10 m 8 125 8 Basic Function Function Block Library ARY SCH are 000008 Description Input ARY SCH EN executes the function in case of 1 E DATA data to search IN array to search EN Output ENO without an error it will be 1 OUT if it finds it will be 1 In Out P first position of an object array N total number of array elements equal to an object Function It finds an equal value of input in arrays and produces its first position and total rumber When it finds at least one which is equal to an object in arrays OUT is 1 8 126 8 Basic Function Function Block Library IN ARY 10 byte array 3 1 2 X pu 1 If the input condition 1 is on ARY SCH BYTE function is executed 2 When is a 10 byte array if you search for 22h in this array three bytes are found as the above 3 The result is 1 1 the first position of an array is stored at POS 2 3 the total number
61. The connection to a function and function block will be done by putting suitable data or variable to their input output Example CLK_U FULL START REG1 CLK D STOP VAL 1 RESET DOW SWITCH PLAN Function Function block gt There should be at least one BOOL type input and BOOL type output in a function or function block if you want to enable them EN and ENO are BOOL type input output in a function while a data type of the first input and first output are BOOL type in a function block Example Bool type input output of Function Bool type input output of Function Block 6 5 6 LD Function in LD is different from that of IL By convention the ladder logic connected Boolean input to a function is called EN and the corresponding output Boolean is called ENO or enable out If the value of EN is 1 then the function is executed otherwise it is not executed In all cases the default is for the value of EN to be copied to the output ENO If for whatever reason an error occurs in the execution of a function the function is responsible to set ENO to FALSE BOOL 0 EN is connected to the power flow line but ENO doesn t have to be connected to it However when connecting the power flow line to the function output instead of ENO output data type should be a BOOL type Note that only one power flow line can be connected to a function when connecting the power flow line to the function output not ENO do not connect an
62. VALUE2 INT 200 164008 Output OUT Q0 0 1 BOOL 1 16 1 8 64 8 Basic Function Function Block Library NOT Reverse Logic Logic inversion as ae Adictim e e e jejeje o Input EN executes the function in case of 1 IN the value to be logically inverted BOOL Output ENO without an error it will be 1 BIT OUT the inversed NOT value IN OUT should be the same data type B Function It inverts the IN by bit and produces output OUT IN 1100 1010 OUT 0011 0101 B Program Example 0 10 CURRENT RESULT 0 0 0 1 If the transition condition 0 is on NOT function will be executed 2 If NOT function is executed input data value of MB10 will be inversed and will be written in 96 QBO 0 0 Input MB10 BYTE 16 if i d 4 V NOT Output OUT 0 0 0 BYTE 16833 8 65 8 Basic Function Function Block Library NUM TO STRING Converts number to a character string Me ae aw tale ielelelelele EN executes the function in case of 1 IN input data to be converted to STRING Input POOL Output ENO without an error it will be 1 STRING OUT converted data character B Function It converts the numeric data of IN to the character data and produces output OUT B Program Example 0 3M0 NUM TO STRING EN ENO JMPN
63. array input into a string m Program Example BYTE STRI NG EN 2 INPUT OU RESULT 1 If the transition condition 2 is on BYTE STRING function will be executed 2 Input variable INPUT is converted into string type variable OUTPUT For example if INPUT is 16 22 47 G 4D M 34 4 2D 43 C 50 P 55 U 41 A 22 the RESULT will be GM4 CPUA 8 7 8 Basic Function Function Block Library ASIN Arc Sine operation Model MM G6 Application e e Input EN executes the function in case of 1 IN input value of Arc Sine operation Output ENO without an error it will be 1 OUT radian output value after operation IN and OUT should be the same data type m Function It produces an output Arc Sine value of IN The output value is between 2 and 7 2 OUT ASIN IN m Error If an input value exceeds the range from 1 0 to 1 0 ERR and LER flags are set 2 If INPUT variable is 0 8660 V 3 2 the RESULT will be 1 0471 3 radian 60 ASIN 2 3 Therefore SIN 3 V 3 2 Input 1 INPUT REAL 0 866 ASIN Output OUT RESULT REAL 1 04714680E 00 8 8 8 Basic Function Function Block Library ATAN Arc Tangent operation Model GM M M Application e e Input executes the funct
64. at the end of SFC program or the end of a selection branch It is not allowed to jump into the inside or outside of parallel branch it is allowed to jump within parallel branch Example 1 Jump at the end of selection branch 1 S2 will be activated after S5 4 10 4 5 2 Jump within parallel branch 4 11 5 IL 5 IL Instruction List 5 1 Overview gt dLisalow level assembler like language gt Lis applicable to simple PLC systems gt Label 45 THERES 46 LDN START Switch input reading N Operand Line No Operator Identifier Comment 5 2 Current Result CR gt In IL there is a register that stores an operation result by that time which is called CR current result gt Only one CR exists in IL gt CR is able to be any data type gt operator that puts a certain value to CR and determines its data type is LD Load Example LD IX0 0 0 is to put the value of IX0 0 0 to the CR Now the data type of CR is BOOL because the data type expressed as X is BOOL If variable VAL is declared as INT and is written as LD VAL it writes the value of VAL to CR and the data type of CR is INT gt ST operator stores the current result CR in a variable Example If variable VAL is declared as INT and is written as ST VAL this means that CR is stored in variable VAL At this time the data type of CR should be INT Unless
65. be 1 B Function gt It compare two arrays whether they have the same value gt If LEN is minus it compare two arrays between INDX Array INDX and LEN Function niput array Description type USINT USINT Compares two USINT Arrays ARY CMP UINT UINT Compares two UINT Arrays 8 118 8 Basic Function Function Block Library B Error gt If itis designated beyond the array range ERR and LER flags are set X An error occurs when IN1 INDX 0 or IN1 INDX max number of IN1 IN2 INDX 0 or IN2 INDX max number of IN2 IN1 INDX LEN gt max number of IN1 IN2 INDX LEN gt max number of IN2 1 If the input transition condition is on ARY CMP TIME function is executed 2 When ARY1 is a time array with 100 elements and IN ARY2 is a time array with 10 elements if the elements from 11 to 20 of IN ARY1 and the elements of IN ARY 2 are equal the output Q1 3 2 is on 8 119 8 Basic Function Function Block Library ARY FLL Description Input ARY FLL EN executes the function in case of 1 EN ENO DATA the data to fill an array DATA QUT INDX starting point of an array to be filled IN LEN number of array elements to be filled NDX LEN Output ENO without an error it will be 1 OUT without an error it will be 1 In Out IN an array to be filled
66. e e e jejeje o Input EN executes the function in case of 1 USINT TO IN Unsigned Short Integer value to be converted Output ENO without an error it will be 1 OUT type converted data B Function It converts the IN type and outputs it as OUT USINT TO LREAL LREAL Converts USINT into LREAL type E Error If a conversion error occurs ERR and flags will be set If error occurs it takes as many lower bits as a bit number of output type and produces an output without changing its internal bit array 8 101 8 Basic Function Function Block Library E Program Example 0 m 3M0 USINT TO SINT ENO JMPN LL LD IN VAL IN U L OUT USINT TO SINT ST OUT VAL LL 1 If the input condition 0 is ON function ULINT TO SINT will be executed 2 If input variable IN VAL USINT 123 output variable OUT VAL SINT 123 Input IN1 IN VAL USINT 123 16 7 V ULINT TO SINT Output OUT OUT VAL SINT 123 16 7 8 102 8 Basic Function Function Block Library WDT RST Initialize Watch Dog timer ae ae av Amictim e e je je Input EN executes the function in case of 1 REQ requires to initialize watchdog timer Output ENO without an error it will be 1 OUT After Watch_Dog timer initialization output will be 1 Function It resets Watch Dog Timer among the programs Available to use in case
67. error it will be 1 OUT Sine operation result value IN OUT should be the same data type B Function Finds the Sine operation value of IN and produces output OUT OUT SIN IN B Program Example 10 0 0 RESULT 1 If the transition condition 10 0 0 is ON function SIN Sine operation will be executed 2 If the value of input variable INPUT is 1 0471 v3 60 RESULT declared as output variable will be 0 8660 V 3 2 3 V 3 2 0 8660 Input 1 INPUT REAL 1 0471 5 Output OUT RESULT REAL 8 65976572 01 8 78 8 Basic Function Function Block Library SINT TO SINT type conversion ar mja as ae Application e e e jejeje o Input executes the function in case of 1 IN short Integer value SINT TO Output ENO without an error it will be 1 OUT type converted data B Function It converts the IN type and outputs it as OUT Output type SINT TO BYTE BYTE Converts into BYTE type without changing the internal bit array B Error If a conversion error occurs ERR and LER flags will be set If an error occurs take the lower bits as many as bit number of output type and output it without changing the internal bit array 8 79 8 Basic Function Function Block Library 0 1MO SINT TO ECD up JMPN AAA LD IN VAL vaL var SINT TO BCD
68. function block or a program inside the function gt function has a variable whose name is the same as that of the function and whose data type is the same as the data type of the result of the function This variable is automatically created when making a function and the result value of the function will be written in the output Example If a function name is WEIGH and a data type of a result value is WORD a variable whose name is WEIGH and whose data type is WORD will be automatically created inside the function Users can store the result of function in variable WEIGH ST WEIGH example in IL 3 5 2 Function Block gt gt A function block has several outputs A function block has data inside A function block should declare the instance as it declares variables before using them Instance is a set of variables used in a function block A function block should have its data memory to preserve the output value as well as variables used inside which is called as instance A program is a kind of a function block and also needs to declare instance However users cannot call a program inside a program or a function block for use contrary to a function block In order to use the output value of a function block it is required to place a period between the name of instance and the output name 3 19 3 Common Elements Example Tl Instance name TCN IN Q PT ET Output Input General examples
69. it will be 1 OUT type converted data B Function It converts the IN type and produces OUT Function Output type TIME TO UDINT UDINT Converts TIME into UDINT type It converts only data type without changing the data internal bit array state TIME TO DWORD DWORD Converts TIME into DWORD type It converts only data type without changing the data internal bit array state TIME TO STRING STRING TIME into STRING type B Program Example 0 3M0 TIME TO UDINT EN ENO JMPN AA LD IN VAL TIME TO UDINT ST OUT VAL AA 1 If the transition condition 0 is ON function TIME TO UDINT will be executed 2 If input variable IN VAL TIME T 120MS output variable OUT VAL UDINT 120 Input IN1 IN VAL TIME T 120Ms 16578 o o ojo o o of of o af af i 1 d of d 1 V TIME TO UDINT Output OUT OUT_VAL UDINT 120 16578 o olol olol o d d dq 8 92 8 Basic Function Function Block Library TOD TO TOD bos conversion ar as ae Apictim e jejejeje Function O Input executes the function in case of 1 IN time of a day data to be converted TOD_TO_ Output ENO without an error it will be 1 OUT type converted data B Function It converts the IN type and outputs it as OUT ue cesa Converts anys data type without changing a data internal bit array state C EIE only data type
70. sss 3 5 3 23 Iriitial Value citt n es Pec iecit eie EE 3 5 3 2 4 Data Type 5 000 3 6 9 9 VANMABIC 3 8 3 3 1 Variable 3 8 3 3 2 Variable Declaration uet eee te 3 9 3 3 3 Reserved IEPEN 3 12 Table of Contents 3 4 Reserved assis iui ier Hie mag ide A ag ia 3 17 3 5 Program itia n D REM Ov Ri Ote laedi d 3 18 3 51 FUNCION wt ape e eee e E ae de 3 18 3 5 2 Function ir et eet ete ctt tete t 3 19 3 5 9 iii dae dad a dias 3 20 Ch 4 SFC Sequential Function Chart 4 1 OVerview nius dece Rn Herd e ee p dera d 4 1 42 SEG tnit aree uq 4 1 oie eie SU a E tus Nan te ots a rts ter ed 4 1 4 2 2 eset o een peru el ee e ul is us 4 2 PNE 4 2 4 24 Action Qualifietic etn eei ditat od 4 3 4 3 Extension 04000 4 8 4 3 1 Serial 44 0 1000001 entente enne 4 8 4 3 2 Selection 4 8 4 3 3 Parallel Branch Simultaneous 4 9 4 9 45
71. than Jump to label Call a function or function block Return from a function or function block Evaluation deferred operation used with 5 3 5 IL gt Operators from no 4 to 16 execute the following functions CR zz CR Operation Operand After executing the operation made between CR and operand value is done it stores the result in CR Example AND IX1 0 0 is interpreted as follows CR lt CR AND IX1 0 0 gt Comparison operator stores its Boolean result in CR after a comparison operation made between CR and the right operand Example For GT MW10 if CR is greater than the value of internal memory word 10 the value of CR will be BOOL 1 Otherwise it will be 0 gt data type of CR is not modified by most of the operation instructions However in case of comparison operators a data type of CR is changed Example LD VAL a EQ GROSS 0 AND 9e1X0 0 0 ST START d assume that variable START is declared as BOOL and variable VAL and GROSS as INT At a row the INT value of VAL is put in CR At b row after comparing the CR to INT value of GROSS if the value is same it puts BOOL 1 in CR if not CR is BOOL 0 At this time a data type of CR changes from INT to BOOL Accordingly instructions of c and d rows are normal without making an error 5 4 5 3 3 1 Basic Operator 2 ST 1 LD Meaning It loads a value in the current result A data type of CR changes according
72. that scan time exceeds Watch Dog Time set by the condition in the program If scan time exceeds the scan Watch_Dog Time please change the scan time with the setting value of scan Watch_Dog Timer in the Basic Parameters of GMWIN gt Care must be taken so that either the time from 0 line of program to WDT_RST function T1 or the time from WDT_RST function to the time by the end of program T2 does not exceed the setting value of scan Watch Dog Timer Program starting WDT RST Program Ending T1 T2 WDT RST function is available to use several times during 1 scan 8 103 8 Basic Function Function Block Library Program Example This is the program that the time to execute the program becomes 300ms according to the transition condition in the program of which scan Watch Dog timer is set as 200ms Program that has 300MS scan Program that has 300MS scan Program that has 150MS scan Program that has 150MS scan time LD JMPN LD WDT_RST Program that has 150MS scan a ime Program that has 150MS scan time 1 If the transition condition is ON function WDT RST will be executed 2 If WDT RST function is executed it is available to set the program that extends the scan time to 300ms according to the transition condition of program within the scan Watch Dog Time 200mg 8 104 8 Basic Function Function Block Library WORD TO WORD type conversion 96
73. ti ne ns 5 5 Current task execution ti ne RIC TI ME ARRAY CF BYTE Current ti ne _SYS ERR U NT Error type 7 Communication Module Information Flag n is a slot number where a communication module is installed n 0 7 Reserved variable _CnVERNO _CHTXECNT CnRXECNT _CnSVCFCNT _CnSCANMX _CnSCANAV _CnSCANMN CnCRDER _ 5 5 _CHIFERR _CnINRING 3 15 3 Common Elements 8 Remote Control Flag m is a slot number where a communication module is installed m 0 7 Reserved variable FSMm_RESET BOOL able to write Remote O station reset control reset 1 FSMm IO RESET BOOL able to write Output reset control of remote station reset 1 FSMm st no USINT able to write Station number of corresponding remote station 9 Detailed High speed Link Information Flag m is a high speed link parameter number m 1 2 3 4 Reserved variable Datatype HSmRLINK BOOL HS RUN LINK information _ HSmLTRBL BOOL Abnormal information of HS Link Trouble General communication status information of k data HSmSTATE ARRAY OF BOOL plock ao TRUE ARRAY BOOL parameter Run 1 Other 0 Communication status information of data block at HS HSmTRX ARRAY OF BOOL ink parameter Normal 1 Abnormal 0 e E ARRAY OF parameter Normal 0 Error 1 3 16 3 Common
74. whose data type is BOOL 5 6 5 IL b AND Meaning After logical AND operation for CR and the operand value stores the operation result in CR At this time a data type of both CR and the operand should be the same The operand value does not change Modifier N If the operand data type is BOOL logical AND operation is made between the operand value and CR after negating the operand value If a data type of operand is BOOL moves CR value in other place for a while and stores the operand value in CR deferred operation Operand Only BOOL BYTE WORD DWORD LWORD data types are available Constant is also available moved CR value stored in other place stores the result in CR B VALUEA Stores CR value in B VALUEA whose data type is BOOL Examples LD VALUE 1 The value of B VALUE1 whose data type is BOOL is loaded in CR At this time a data type of CR is BOOL AND B VALUE2 After logical AND operation for CR and the value of B VALUE2 whose data type is BOOL stores the result in CR ANDN B VALUES After negating the value of B VALUES logical AND operation is made between CR and the value of B VALUES whose data type is BOOL B VALUEA Stores CR value in B VALUEA whose data type is BOOL B_VALUE4 lt VALUE1 AND VALUE2 AND NOT B VALUE3 W VALUE1 The value of W VALUE1 whose data type is WORD is loaded CR At this time a data type of CR is WORD W VALUE2 After logical AND operation for CR an
75. without changing a data internal bit array state TOD TO STRING STRING Converts TOD into STRING Converts TOD into STRING type 0 TO STRING x JMPN AA ENO LD IN VAL IN VAL OUT OUT AL DATE TO STRING ST OUT VAL AA 1 If the transition condition is ON function TO STRING will be executed 2 If input variable IN VAL TOD TOD 12 00 00 output variable OUT VAL STRING TOD 12 00 00 Input IN1 IN VAL TOD TOD 12 00 00 TOD TO STRING Output 2 OUT VAL STRING TODst12 00 00 8 93 8 Basic Function Function Block Library TRUNC Set TRUNC Round off the decimal fraction of IN and as aa ae converts into integer number Apictim e Input executes the function in case of 1 IN REAL value to be converted Output ENO without an error it will be 1 OUT the Integer converted value W Function Input type Output type TRUNC REAL DINT Round off the decimal fraction of input IN and outputs LREAL LINT the Integer value as OUT E Error ERR LER flags will be set 1 if the converted value is greater than maximum value of data type connected to OUT 2 if the variable connected to OUT is Lhsigned Integer and the converted output value is a negative number the output is 0 E Program Example REAL VALUE INT VALUE 1 If the transition condition 96MO is ON func
76. 0 0 BYTE 16 FC 8 67 8 Basic Function Function Block Library REAL TO REAL type conversion as ae av eje Input EN executes the function in case of 1 IN the REAL value to be converted Output without an error it will be 1 OUT type converted data REAL TO B Function It converts the IN type and outputs it as OUT Function Output type SINT If integer part of input is 128 127 normal conversion Otherwise an error occurs Decimals round off INT If integer part of input is 32768 32767 normal conversion Otherwise an error occurs Decimals round off DINT If integer part of input is 2 2 1 normal conversion Otherwise an error occurs Decimals round off LINT If integer part of input is 29 29 1 normal conversion Otherwise an error occurs Decimals round off USINT If integer part of input is 0 255 normal conversion Otherwise an error occurs Decimals round off UINT If integer part of input is 0 65 535 normal conversion Otherwise an error occurs Decimals round off UDINT If integer part of input is 0 23 1 normal conversion Otherwise an error occurs Decimals round off ULINT If integer part of input is 0 2 1 normal conversion Otherwise an error occurs Decimals round off REAL TO DWORD DWORD Converts into DWORD type without changing the internal bit array REAL TO LREAL LREAL Converts RE
77. 000000000 Oe Cee 72 w rwomD ebi ste 000000002 D 1pouetewoRD 82 bits size 00000 Expression format Location Prefix Size Prefix n1 n2 n3 Nx dw 4 2 Base number starting from 0 n1 data according to size prefix starting from 0 Slot number starting from 0 n2 bit of n1 data starting from 0 available to omit n3 data according to the size prefix Not used starting from 0 3 8 3 Common Elements Examples 96QX3 1 4 or Q3 1 4 4 output of no 1 slot on no 3 base 16 W2 4 1 1 word input of no 4 slot on no 2 base 16bits MD48 48 double word memory MW40 3 3 bit of 40 word memory Internal memory doesn t have a base or slot number gt Small letter is not allowed as a prefix gt Avariable without a size prefix is treated as 1 bit gt Direct variables are available to use without a variable declaration 3 3 2 Variable Declaration gt Program elements programs functions function blocks etc have declaration parts to edit their variables to use gt Users should declare variables first to use them in the program elements gt contents of a variable declaration are as follows 1 Variable types how to declare variables Variable types General variable available to read write VAR RETAIN Retaining data keeping variable VAR CONSTANT Read Only Variable VAR EXTERNAL Declaration to use the variable declared as VAR GLOBAL R
78. 1 And if elapsed time reaches preset time timer output is 0 gt ETincreases its value from when IN is 1 keeps its value at PT and is cleared when IN is 0 gt It doesn t matter whether IN changes its state or not while timer output is 1 during a pulse output gt If RST is 1 output and ET are 0 Timing Chart Preset Ti ne PT 8 230 8 Basic Function Function Block Library Program Example OK 05 ET TIME 1 1 12 Preset Ti ne 10s ET Tl M 10s 1 If input variable T TP RST is 1 output variable TIMER OK is 1 And 10 seconds later TIMER OK is 0 Once TP RST timer is executed input T RST doesn t matter 2 ET TIME value increases and stops at 10S And if T TP RST is O it is O 3 If input contact l1 1 12 is 1 OK and ET TIME are all cleared 8 231 8 Basic Function Function Block Library TP UINT TP with integer setting Model M AW Application e Input IN operation condition for Timer PT preset time UNIT time unit of setting time RST reset Output Q timer output ET elapsed time E Function If IN is 1 is 1 And if elapsed time reaches preset time timer output Q is 0 ET increases its value from when IN is 1 keeps its value at PT and is cleared when IN is O It doesn t matter whether IN changes its state or not while t
79. 3 ae B Error If the value to divide divisor is 0 ERR LER flags will be set LD 10 0 0 10 0 0 JMPN LL LD VALUE1 uri DIV IN1 CURRENT RESULT IN2 VALUE2 VALUEZ ST OUT VAL LL 1 If the transition condition 10 0 0 is on DIV eN will be executed 2 If input VALUE1 300 and VALUE2 100 then output OUT_VAL 300 100 3 Input IN1 VALUE1 INT 300 16 012 0 0 DIV IN2 VALUE2 INT 100 16 0064 oTo o o o o o o o 1 1 0 o 1i o o Output QUT OUT VAL INT 3 16 3 010101010101010 0 0 0 0 0 0 111 8 Basic Function Function Block Library DIV TIME Time division Model GM M M GB M Go Application e e e o o EN executes the function in case of 1 IN1 Time to divide IN2 The value to divide Output without an error it will be 1 OUT divided result time B Function It divides IN1 time by IN2 number and produces output OUT divided time B Error If a divisor IN2 is 0 ERR and LER flags will be set B Program Example This is the program that calculates the time required to produce one product in some product line if the working time of day is 12hr 24min 24sec and product quantity of a day is 12 a product line LD IL LD 40 1 0 10 1 0 JMPN SS LD TOTAL TIME iiir cun TIME IN1 CURRENT RESULT IN2 PRODUCT COUNT PRODUC
80. 3 output character string OUT TEXT ABC Input IN1 IN TEXT STRING ABCDEFG IN2 LENGTH INT 3 V LEFT Output OUT OUT TEXT STRING ABC 8 44 8 Basic Function Function Block Library LEN Finds a length of a character stri ng Model GR GM GV 94 9 Application e e Input EN executes the function in case of 1 IN input character string Output ENO without an error it will be 1 OUT the length of a character string STRING B Function It produces a length character number of the input character string IN LD IN TEXT LENGTH IN CURRENT RESULT ST LENGTH amp J 1 If the transition condition is on LEN function will be executed 2 If input variable IN TEXT ABCD output variable LENGTH 4 Input IN1 IN TEXT STRING ABCD V LEN Output OUT LENGTH INT 4 8 45 8 Basic Function Function Block Library LIMIT Limits upper and over boundary Model GR G6 GW Application e e
81. 8 227 8 Basic Function Function Block Library TON UINT TON with integer setting Model GR M a GAW Application e Input IN operation condition for Timer PT preset time UNIT time unit of setting time Output Q timer output ET elapsed time E Function gt Elapsed time is produced at ET after IN is 1 gt Elapsed time ET is O if IN is O before ET reaches PT gt QisO if IN is after Qis 1 gt Preset time is PT x UNIT ms Timing Chart Preset Ti ne PT x UNT ET 8 228 8 Basic Function Function Block Library Program Example 1 Preset time is PT x UNIT s 10 x 1000 s 10 5 2 If 10 seconds passes after input variable TON is on output variable TIMER OKis 1 3 Elapsed time is produced at ET TIME after input variable T TON is on 4 If T TON is 0 before elapsed time ET TIME reaches 10 seconds TIME is 0 5 If T TON is 0 after TIMER OK is 1 TIMER OK and ET TIME are 0 Preset Tine 10 000 d 10x 1000 TI MER 8 229 8 Basic Function Function Block Library TP RST TP with Reset Model GP a4 Application e Input IN operation condition for Timer PT preset time RST reset Output Q timer output ET elapsed time E Function gt IfINis 1 Qis
82. A LWORD LWORD ROTATE A SINT SINT ROTATE A INT INT ROTATE A DINT DINT ROTATE A LINT LINT ROTATE USINT USINT It rotates designated elements of an array block in the chosen ROTATE_A_UINT UINT direction ROTATE A UDINT UDINT ROTATE A ULINT ULINT ROTATE A REAL REAL ROTATE A LREAL LREAL ROTATE A TIME TIME ROTATE A DATE DATE ROTATE A TOD TOD ROTATE A DT DT B Error gt If STRT or END exceed the range of SRC array element ERR LER flags are set gt error occurs there s no change SRC and output OUT is the initial value of each variable type i e INT 0 TIME T 0S Program example N 0 OUT 1 If input condition 2 is on ROTATE A BYTE function is executed 2 It rotates designated elements from 2nd to 8th elements of ARY in the chosen direction set by STRT and END from index 8 to index 2 refer to the diagram on the opposite page 3 The overflowing data 16244 is written at OUT 8 161 8 Basic Function Function Block Library SRC ARY SRC ARY 8 162 8 Basic Function Function Block Library ROTATE C Rotates a designated bit array of SRC bit arrays Model GME GJ e e Application e e Input EN executes the function in case of 1 ROIATE C STRT starting bit position of SRC bit array to EN ENO rotate SRC END ending bit position of SRC bit array to STRT rotate END N bit numb
83. AAA LD IN VALUE quem ovx NUM STRING ST OUT STRING OUT STRIN 1 If the transition condition is ON function NUM TO STRING will be executed 2 If IN VALUE INT 123 OUT STRING will be 123 if IN VALUE REAL 123 0 OUT STRING will be 1 28bE2 Input IN1 IN VALUE INT 123 NUM TO STRING Output OUT OUT STRING STRING 123 8 66 8 Basic Function Function Block Library OR Logical OR ar aa Ge fas 94 Aictim e e fe le le Input EN executes the function in case of 1 input 1 IN2 input 2 Input variables can be extended up to 8 BOOL IN1 OUT ANY ANY_BIT f IN2 Output ENO without an error it will be 1 OUT OR result IN1 IN2 OUT should be all the same data type B Function It performs a logical OR on the input variables by bit and produces output OUT INT 1111 0000 OR IN2 1010 1010 OUT 1111 1010 B Program Example 0 JMPN AAA LD 10 OR CURRENT RESULT IN2 ABC ST 0 0 0 1 If the transition condition 0 is on function OR will be executed 2 The result of a logic sum OR for MB10 11001100 and ABC 11110000 will be produced in 0 0 0 11111100 Input 1 10 BYTE 16 CC Fifi of of 1 Logical OR operation IN2 ABC BYTE 16 F0 of of 0 1 1 1 1 1 1 1 1 11 01 0 Output OUT QB0
84. AL into LREAL type normally B Error If overflow occurs an input value is greater than the value to be stored in output type ERR LER flags will be set If an error occurs the output will be 0 8 68 8 Basic Function Function Block Librar 0 m 3M0 REAL TO DINT ENO JMPN AAA LD REAL VAL REAL U R Jini ovr piNT REAL TO DINT ST DINT VAL 1 If the transition condition is ON function REAL DINT will be executed 2 If REAL VAL REAL type 1 234 4 DINT VAL DINT 12340 Input 1 REAL VAL REAL 1 234E4 Vj REAL TO DINT Output OUT DINT VAL DINT 12340 8 69 8 Basic Function Function Block Library REPLACE Replace a string Character string replacement Me ae aca lat ted wil sla Input EN executes the function in case of 1 IN1 character string to be replaced IN2 character string to replace L the length of character string to be replaced STRING STRING STRING INT INT P position of character string to be replaced Output ENO without an error it will be 1 OUT output character string m Function Its function is to remove the L length charter from IN1 starting from P and put IN2 in the removed position as output OUT Error ERR LER flags will be set if gt lt lt 0 gt P gt input character number of IN1 gt character number of result gt 30 0 JMPN MBC LD IN TEX
85. B o jojo SINT NEMPE RET SN OT iNTOSN IN 8 J O iNTOUN iNTOUN INT 0O iNTOUSN IN inun IN UN jJ O iNTOUN LIEU INT TO RA O n wx 7 2 7 Function and Function Block Functi on group Input data type Output data PED 9477 uvNTOSN om SN 0 IN o f UN TOUN UIN J O UN JJ O DN wn UN O O O UN TOWD WD 1 om O UN TOlWD O uNTOED UN O O D NT RA D NT UNE TO Tus USI NT 7 3 7 Function and Function Block QR 2 7 LSI NT Rico LBI NE TO 2 REAL unrtoinr im unrtounr UN o unrtouinr U NT UD NT O O un o U NT w oea UNTOBT UN UNLTOWID UNE eR UNTODCDO UN om O O O un towe UN twr o
86. Basic Function Function Block Library DEC kkk Decrease N data by 1 bit ar mia ave o o e Input DEC EN executes the function in case of 1 IN input data to decrease Output ENO without an error it will be 1 OUT result data Function If EN is 1 it produces an output after decreasing bit string data of IN by 1 Even though the underflow occurs an error won t occur and if the result is 1640000 then the output result data is 16 FFFF Input data types are BYTE WORD DWORD and LWORD LWORD is available only for GM1 2 Program example 0 MW100 DEC_WORD ST MW20 KKK 1 If the transition condition 0 is on DEC WORD function is executed 2 If input variable MW100 1650007 240000 0000 0000 0111 output variable MW20 1640006 240000 0000 0000 0110 8 142 8 Basic Function Function Block Library DECO Decodes the designated bit position R Gv Jupes Input DECO EN executes the function in case of 1 IN input data for decoding Output ENO without an error it will be 1 OUT decoding result data Function If EN is 1 it turns on the designated position bit of output bit string data according to the value of IN and produces an output Output data types are BYTE WORD DWORD and LWORD LWORD is available only for GM1 2 FUNCTION OUT type DECO
87. CD TO SINT JMPN ABC EN ENO LD BCD VAL vaL ovr var j BCD TO SINT i ST OUT_VAL ABC 1 If the transition condition is on BCD TO function will be executed 2 If BCD VAL BYTE 16 222 2480010 0010 then the output variable OUT VAL SINT 22 220001 0110 Input 1 BCD VAL BYTE 16422 o o 1 0 of of 1 o y Beb TO SINT Output OUT OUT VAL SINT 22 GIGS 8 Basic Function Function Block Library BOOL TO BOOL type conversion Model a6 GJ Application e e e Input executes the function in case of 1 IN bit to convert 1 bit BOOL_TO_ FNO Output ENO without an error it will be 1 OUT type converted data Function It converts input IN type and produces output OUT type INT DINT If the input value BOOL is 2 0 it produces the integer number 0 and if it is 241 it does the integer number 1 according to the output data type It converts BOOL into the output data type of which upper bits are filled with 0 Progr
88. CR is an INT type an error occurs when compiling 5 1 5 IL Please read the following LD 961X0 0 0 ST VAL assume that variable VAL is declared as INT CR is assigned as BOOL in the first row and declared as INT in the second row which results in an error when compiling LD 961X0 0 0 ST START LD 20 ST VAL assume that variable START is declared as BOOL and variable VAL as INT The above example is executed normally because the data type to store CR respectively is the same 5 3 Instructions gt ILis alist of instructions gt Each instruction must begin on a new line and must contain an operator completed with optional modifiers and if necessary for the specific operation one or more operands separated with commas 5 3 1 Label gt A label followed by a colon may precede the instruction gt Labels are used as operands for some operations such as jumps 5 3 2 Modifier gt modifier character must complete the name of the operator with no blank characters between them There re three types of modifiers N C gt modifier indicates a Boolean negation of the operand Example ANDN 1 2 0 0 is interpreted as CR lt CR AND NOT 2 0 0 When N is attached to JMP CAL and RET with no blank character between them this means it executes the instruction when CR is BOOL O gt Modifier delays the operation of an operator until it meets operator y As
89. D type conversion Model GV 898 94 a6 GW Application executes the function in case of 1 IN bit string to convert 64bit ENO without an error it will be 1 OUT type converted data E Function It converts input IN type and produces output OUT LWORD TO SINT Converts input value into STRING type LWORD TO UINT UINT Takes the lower 16 bits and converts into UINT type LWORD TO UDINT UDINT Takes the lower 32bits and converts into UDINT type LWORD TO ULINT ULINT Converts into ULINT type without changing the internal bit array 8 54 8 Basic Function Function Block Librar B Program Example PANE CERNERET NOSE S LD 0 i LWORD_TO_LINT EN ENO JMPN PPP LD IN_VAL IN vaL ovr var LWORD TO LINT OUT VAL 1 If the input condition 0 is on LINT function will be executed 2 If input variable IN VAL LWORD 16 FFFFFFFFFFFFFFFF output variable OUT VAL LINT will be 1 16 FFFFFFFFFFFFFFFF Input IN1 IN VAL LWORD 168FFFFFFFFFFFFFFFF V LWORD TO LINT Output OUT OUT VAL LINT 1 8 55 8 Basic Function Function Block Library MAX Ma
90. E TO GO 1 If the transition condition 9610 0 0 is ON function SUB TIME time subtraction will be executed 2 If total working time declared as input variable TARGET TIME is TZ2H30M the elapsed time ELAPSED TIME is T 1H10M30S300MS the remaining working time declared as output variable TIME TO GO will be T 1H19M29S700MS Input 1 TARGET TIME TIME T 2H30M SUB TIME IN2 ELAPSED TIME TIME T41H10M30S300MS Output OUT TIME TO GO TIME T 1H19M29S700MS 8 89 8 Basic Function Function Block Library SUB TOD TOD Subtraction wa as 4 ae Amictim e e je je Input executes the function in case of 1 IN1 standard time of day IN2 the time of day to subtract Output ENO without an error it will be 1 OUT the subtracted result time B Function It subtracts the IN2 specific time of day from IN1 standard time of day and outputs the time difference as OUT B Error If the result subtracting the time of day from the time of day is a negative number an error occurs B Program Example 10 0 0 JMPN AAA LD END TIME SUB TOD CURRENT RESULT 2 START TIME ST WORK TIME END TIME 4191 OUT UOREK TIME 1 If the transition condition 9610 0 0 is ON function SUB TOD time of day subtraction will be executed 2 If END TIME declared as input variable is TOD 14 20 30 5 and the starting time to work START TIME is TOD 12 00 00 the requi
91. EE 8 192 SB nte E Rae eb nds Gen eee ates 8 195 TOF er 8 196 8 198 DE 8 200 8 4 Application Function Block 8 202 rU MEINES 8 203 BUTY oi Em 8 205 dd AA E EE E E E ETE 8 207 cores S E 8 211 SOON zeit teneo ue 8 215 TMP ena i UL I T 8 218 TMR ELK dote 8 220 TMBSUINT ette pce inet te deett tcc E E betta etate Be kn 8 222 tene ds MM Du DM Mu DM 8 224 TOF secet iac dedecore e Pes 8 226 2 ale nena ian teenie alte a lenis 8 228 TPSBS I dr 8 230 TR UNT e 8 232 WERT ERE 8 234 8 236 Table of Contents VII 1 Overview 1 Overview This instruction describes languages that support GM1 GM7 GLOFA PLC GLOFA PLC is based on the standard language of IEC International Electrotechnical Commission 1 1 Characteristics of IEC 1131 3 Language The characteristics of IEC language newly introduced are as follows gt Available to support several data types gt introduction of program elements such as functions function blocks etc enables the bottom up design and top down design and the structural creat
92. EE E a cS deat ee 8 49 LOG vise EE 8 50 EREAL T7 ei eto dE dot itte 8 51 MEER 8 53 LWORD TO 8 54 V de CT E 8 56 MD inti ee o ettet ett tete s 8 57 MIN da cette tn iere tet tede ten 8 58 MOD d niet evant ai isis eerie ES pup neis 8 59 8 60 HR 8 61 MUL TIME eee tee ee eee 8 62 IA 8 63 INE Le ect oe e Md 8 64 eg 8 65 TO STRING Lu iiiter tee reote en teg etn Erbe cr etr emt e 8 66 Ors 8 67 REALE TO Lcid dde eee andes 8 68 REPLACE a tice Ree eem red uten Satie 8 70 RIGHT i ei En Pub d i 8 72 ROL faa iia egeret aede x Ede degree ea ae 8 73 gio E 8 74 M tyes uM t 8 75 SIE tese tiet aet 8 76 SHR vit ices is ERAN 8 77 Sic 8 78 SINT TE 8 79 SORT ddr d 8 81 STO Piss dte pee dte re EU dub d pee grid e Uds 8 82 STRING esf pte e He dee 8 83 STRING E ORE CORREDOR RS 8 85 SU r 8 86 ire ten eR Me RE 8 87 sue E ERU d EUER EE RUD Re DA vlads 8 88 SUB TIME item etate b tete iate etat ie 8 89 a rari Re to uc a SER ERE 8 90 i ite ie envi 8 91 Bec
93. EN executes the function in case of 1 IN1 reference time time of date IN2 time to add Output ENO without an error it will be 1 OUT added result of TOD or time IN1 IN2 and OUT should be the same data type If IN1type is TIME DAY OUT type will be also TIME OF DAY Function If IN1 is TIME added TIME will be an output If IN1is TIME OF DAY it adds TIME to reference TIME OF DAY and produces output TIME OF DAY If INTis DATE AND TIME the output data type will be DT Date and Time of Day adding the time to the standard date and time of day VV Vo Error If an output value is out of range of related data type ERR LER flag will be set An error occurs 1 when the result of adding the time and the time is out of range of TIME data type T 49D17H2M47S295MS 2 the result of adding TOD Time of Day and the time exceeds 24hrs 3 the result of adding the date and DT Date and the Time of Day exceeds the year 2083 VV m Program Example oci de LD START TIME ADD TIME IN1 CURRENT RESULT START E END TIME 2 WORK TIME ST END TIME WORK 2 ABC 1 If the transition condition 10 1 0 is ADD TIME function will be executed 2 If START TIME is TOD 08 30 00 and WORK TIME is T 2H10M20S500MS END TIME will be TOD 10 40 20 5 Input 1 START TIME TOD TOD 08 30 00 ADD TIME 2 WORK TIME TIME T 2H10M20S500MS Output OUT END TIME TOD TOD
94. EN ENO BOOL L length of character string to delete STRING IN OUT STRING P position of character string to delete INT L INT P ENO without an error it will be 1 OUT output character string mFunction After deleting a character string L from the P character of IN produces output OUT m Error If P lt or L lt 0 or If P gt character number of IN ERR and LER flags will be set DELETE EN ENO LD IN_TEXT IN_TEXT OUT TEXT i DELETE IN CURRENT RESULT LENGTH LENGTH P POSITION ST OUT_TEXT POSITION JP KKK 1 If the transition condition 10 0 0 is ON DELETE function will be executed 2 If input variable IN TEXT ABCDEF LENGTH 3 and POSITION 3 then OUT TEXT STRING will Input IN IN TEXT STRING ABCDEF L LENGTH INT 3 P POSITION INT 3 V DELETE Output OUT OUT VAL STRING 8 Basic Function Function Block Librar DI Invalidates task program Not to permit task program starting Input EN executes the function in case of 1 REQ requires to invalidate task program starting Model Application e 2 e 9 2 POOL EN ENO BODE Output ENO without an error it will be 1 BOOL REQ OU BOOL OUT If DI is executed it will be 1 m Function gt If EN 1 REQ 1 it stops a task program single interval interrupt
95. Gb GW Application e e Input EN executes the function in case of 1 IN input value of common logarithm operation Output without an error it will be 1 OUT the value of common logarithm operation IN OUT should be the same data type B Function It finds the value of Base 10 Logarithm of IN and produces output OUT OUT 10910 IN log IN B Error If input value IN is or a negative number _ ERR and LER flags will be set ST RESULT 1 If the transition condition 0 is on LOG function will be executed 2 If input variable INPUT is 2 0 output variable RESULT will be 0 3010 2 0 0 3010 Input IN1 INPUT REAL 2 0 LOG Output OUT RESULT REAL 3 01030010E 01 8 50 8 Basic Function Function Block Library LREAL TO LREAL type conversion Model GR M 94 9 GW Application e e Input EN executes the function in case of 1 IN LREAL value to convert Output without an error it will be 1 OUT type converted data B Function It converts input IN type and produces output OUT Function Output type If integer number of input is 128 127 normal conversion LREAL_TO_SINT SINT Otherwise an error occurs decimal round off If integer number of input is 32768 32767 normal conversion LREAL TO INT INT Otherwise an error occur
96. H 1 3839H ASC ARY 2 3435H 8 115 8 Basic Function Function Block Library ARY BYTE TO ASC Description Input EN executes the function in case of 1 IN1 BYTE array input Output ENO without an error it will be 1 OUT Dummy output In Out IN2 ASCII Array Output m Function It converts a byte array input HEX to a word array ASCII B15 B12B11 B8 B7 B4B3 IN2 0 IN2 1 IN1 n b 2 3 B Error If the number of each input array is different there s no change in 2 data and ERR and LER flags are set B Program example 1 If the transition condition 0 is on ARY BYTE ASC function is executed 2 If the input BYTE is as below BYTE 0 BYTE ARY BYTE ARY 2 8 116 8 Basic Function Function Block Library The output ARY is as follows ASC ARY 0 3441H ASC ARY 1 3346H _ 2 3239H 8 117 8 Basic Function Function Block Library ARY CMP Array conpari son R Gan ave ave ee 125222224 Input EN executes the function in case of 1 IN1 first array to compare IN1 INDX starting point in P array for comparison IN2 second array to compare IN2 INDX starting point in 29 array for comparison LEN number of elements to compare Output ENO without an error it will be 1 OUT if two arrays are equal it will
97. IGHT CURRENT RESULT L LENGTH ST OUT_TEXT LENGTH 1 If the transition condition 10 0 0 is on function RIGHT to take the right of character string will be executed 2 If character string declared as input variable TEXT and the length of character string to output LENGTH 3 output character string variable OUT TEXT EFG Input IN1 IN TEXT STRRING 1 LENGTH INT 3 RIGHT Output OUT OUT TEXT STRRING 8 72 8 Basic Function Function Block Library ROL Rotate to left ar anjar fas Amictim e e fe jejeje le Input EN executes the function in case of 1 IN the value to be rotated N bit number to rotate BOOL ANY_BIT ANY_BIT NT Output ENO without an error it will be 1 OUT the rotated value Function It rotates input IN to the left as many as N bit number B Program Example This is the program that rotates the value of input data 1100 1100 1100 1100 164CCCO to the left by 3 bits if input 10 0 0 is on 10 0 0 JMPN PPP LD IN VALUE ROL CURRENT RESULT N 3 ST OUT VALUE 1 Set input variable IN VALUE to rotate 2 Set the value to be rotated 3 3 Set output variable to output the rotated data value as OUT VALUE 4 If the transition condition 10 0 0 is ON function ROL will be executed and a data bit set as input variable will be rotated to the left by 3
98. IME SHIFT A DATE DATE SHIFT A TOD TOD SHIFT A DT DT B Error gt IfSTRT or END exceed the range of SRC array element ERR and LER flags are set gt error occurs there s no change SRC and output OUT is the initial value of each variable type i e 0 05 E Program example SRC_ARY 15 2 STRT 8 END 3 N If the input condition 2 is on SHIFT A INT function is executed It shifts designated elements from 2nd to 8th elements of SRC_ARY It shifts three times the designated elements The empty elements after shifting from array index 2 to array index 3 are filled with input 555 1 2 3 4 5 The overflowing data 1234 carry output is written at OUT 2 2 5 we 8 171 8 Basic Function Function Block Library SRC ARY SRC ARY 8 172 SHIFT C 8 Basic Function Function Block Library Shift wth Carry Model aH Application e e Input EN executes the function in case of 1 CYI Carry Input STRT starting bit position of SRC bit array to shift END ending bit position of SRC bit array to shift N bit number to shift Output ENO without an error it will be 1 OUT carry output In Out SRC variable for shifting B Function gt Itshifts a designated bit array of SRC bit arrays times in the chosen direction gt Setting Scope STR
99. IN1 INDX and pastes it in IN2 from IN2 INDX gt and IN2 are the same data type The number of each array can be different gt The data size is as follows Variable type BOOL BYTE SINT USINT WORD INT UINT DATE DWORD DINT UDINT TIME TOD B Error gt An error occurs when IN1 and IN2 data size are different gt An error occurs when 1 the array number of IN1 Array IN1 INDX MOVE NUM 2 the array number of IN2 Array IN2 INDX MOVE NUM Then ARY MOVE function is not executed OUT is 0 ENO is off and ERR and LER flags are set 8 122 8 Basic Function Function Block Library ARY MOVE EN ENQ Row 1 MOVE an DONE NUM Row 2 ARV Row 3 ARY DES Row 4 Row 5 Row 6 Variable type ONT 10 ARY SRC INT ARY DES WORD 1 If the transition condition A is on ARY MOVE function is executed 2 It moves 5 elements from ARY SRC 5 to ARY DES 10 Now the data type of ARY DES is WORD it s hexadecimal Before After ARY 0 0 DES o 1640 ARY SRO o ARY DES 1640 22 iet ARY SRO 22 1642 ARY 5 44 ARY DESI 1684 44 ARY DESM 1684 ARY SRO 6 1646 SRCI7 ARY DESI 1687 ARY SRCI7 ARY DESI 1647 1648 m mors we oo coesm me A 16 pry Desi tee jAnvpesug t6 ary DESI 16 58
100. INT in CR SUB After SUB operation for CR and the value of VAL3 whose data type is INT stores the result in CR After comparison operation for the current CR value and the moved CR value stored in other place stores the result in CR As the stored gt current CR CR will be 0 Stores the CR value in B VAL3 whose data type is BOOL B VAL2 FALSE 5 18 5 IL 17 LT Meaning After comparison operation for CR and the operand value stores the BOOL result in CR CR will be 1 only if CR is greater than operand A data type of both CR and the operand should be the same The operand value does not change After operation a data type of CR will be BOOL regardless of the operand data type deferred operation Constant is also available Examples In case that VAL1 50 VAL2 100 IVAL 3 70 The value of VAL2 whose data type is INT is loaded in CR After comparison operation for CR and the value of VAL1 whose data type is INT stores the result in CR As VAL1 lt 1 VAL2 CR will be 0 Stores CR value in B VAL1 whose data type is BOOL B VAL1 lt FALSE The value of VAL1 whose data type is INT is loaded in CR After comparison operation for CR and the value of VAL2 whose data type is INT stores the result in CR As VAL1 lt VAL2 CR will be 1 Stores CR value in B VAL2 whose data type is BOOL B VAL2 TRUE LD VAL 1 The value of VAL1 whose data type is INT is loaded in CR
101. INn will be an output B Error is greater than or equal to the number of input variable INn then INO will be an output and _ERR LER flags will be set K CURRENT RESULT INO VALUEO IN1 2 VALUE1 IN2 VALUE2 OUT VAL 1 If the transition condition is on MUX function will be executed 2 Input variable is selected by selection variable S and is moved to OUT Input K S INT 2 2 INO VALUEO WORD 16811 IN1 VALUE1 WORD 167222 IN2 VALUE2 WORD 16833 Output OUT OUT VAL WORD 16 33 8 63 8 Basic Function Function Block Library NE Not equal to comparison Me ae aw aca lat tle oil sla Input EN executes the function in case of 1 IN1 The value to be compared IN2 The value to be compared IN1 IN2 should be the same data type Output ENO without an error it will be 1 OUT the compared result value B Function If IN1 is not equal to IN2 output OUT will be 1 If INI is equal to IN2 output OUT will be 0 B Program Example 10 0 0 JMPN PP LD VALUE 1 NE IN1 CURRENT RESULT 2 VALUE2 ST Q0 0 1 PP 1 If the transition condition 10 0 0 is on NE function will be executed 2 If input variable VALUE1 300 VALUE2 200 the compared result VALUE1 and VALUE2 are different output result value will be Q0 0 1 1 Input IN1 VALUE1 INT 300 16 012C gt NE N2
102. K TMR_FRK 40 1 1 5 TH5S 10 ET TIME If input variable T TMR is 1 TMR function block is executed Output contact QX1 1 5 is 1 during 5 seconds set by ON after input variable T TMR FRKis 1 1 2 3 Output contact QX1 1 5 is 0 during 2 seconds set by OFF after 5 seconds set by ON 3 TON time ON when is 1 and TOF time OFF when is 0 are produced at ET TIME by turns while T TMR FRKis 1 4 If input variable T TMR FRK is 0 then it keeps its time and output contact QX1 1 5 is O If T TMR FRK is 1 it is executed again 8 221 8 Basic Function Function Block Library TMR UNIT TMR with integer setting Model GR M a GAW Application e Input IN operation condition for Timer PT preset time UNIT time unit of setting time RST reset input Output Q timer output ET elapsed time E Function Elapsed time is produced at ET after IN is 1 Even if IN is O before ET reaches PT ET keeps its value If IN is 1 again elapsed time is produced at ET integrating its previous value Q is 1 when elapsed time reaches preset time If RST is 1 Q and ET are 0 Setting time is PT x UNIT ms gt gt VVV B Timing Chart Setting Ti ne AMAA PT x UNT ET ue tenti 8 222 8 Basic Function Function Block Library E Progr
103. NT D_VALUE4 lt D VALUE1 D VALUE2 D VALUE3 5 13 5 IL 12 GT Meaning After comparison operation for CR and the operand value stores the BOOL result in CR CR will be 1 only if CR is greater than operand A data type of both CR and the operand should be the same The operand value does not change After operation a data type of CR will be BOOL regardless of the operand data type deferred operation Constant is also available Examples In case that VAL1 50 VAL2 100 IVAL 70 The value of VAL1 whose data type is INT is loaded in CR After comparison operation for CR and the value of VAL2 whose data type is INT stores the result in CR As VAL1 1 VAL2 CR will be 0 Stores CR value in B VAL1 whose data type is BOOL B VAL1 lt FALSE The value of VAL2 whose data type is INT is loaded in CR After comparison operation for CR and the value of VAL1 whose data type is INT stores the result in CR As VAL1 I VAL2 CR will be 1 Stores CR value in B VAL2 whose data type is BOOL B VAL2 TRUE LD VAL 1 The value of VAL1 whose data type is INT is loaded in CR GT VAL2 Moves CR value in other place and stores the value of VAL2 whose data type is INT in CR SUB After SUB operation for CR and the value of VAL3 whose data type is INT stores the result in CR After comparison operation for the current CR value and the moved CR value stored in other place stores the
104. NT 4 RESET 6l1 1 15 is ON FIFO FIFO 8 210 8 Basic Function Function Block Library LIFO Load Unload data to LIFO stack Model GW Last In First Out Application e o Input REQ requires to execute the function block IN input data to be stored at LIFO stack LOAD FB is on the input mode if it s on UNLD FB is on the output mode if it s on RST pointer value reset Output DONE it s 1 after first execution OUT on output mode it s the data from LIFO stack PNT pointer for input data of LIFO stack FULL if LIFO stack is full it s 1 EMTY if LIFO stack is empty it s 1 In Output LIFO array used as LIFO stack E Function It loads IN to LIFO or unloads data from LIFO If LOAD and UNLD are on at the same time input IN is produced as output OUT If data is unloaded from LIFO by unload function of LIFO_ unloaded data is deleted in stack and initialized as 0 If RST is loaded to LIFO PNT is initialized as 0 EMTY is on and all the data of LIFO stack are cleared as 0 The stack number is the array number set by In Output variable LIFO If you want to keep the data of LIFO array variables and LIFO function block instance in case that power is off or power failure occurs set them as RETAIN Reset functions without REQ input PNT shows the position of IN to be loaded next time or the number of pointers to be l
105. Output type DINT TO SINT SINT If input is 128 127 normal conversion Except this an error occurs If input is 32768 32767 normal conversion DINT TO INT INT Except this an error occurs DINT TO LINT LINT Converts normally into LINT type If input is 0 255 normal conversion DINT TO USINT USINT Except this an error occurs If input is 65535 normal conversion DINT TO UINT UINT Except this an error occurs If inputis 0 2147483647 normal conversion DINT TO UDINT UDINT Except this an error occurs If inputis 0 2147483647 normal conversion DINT TO ULINT ULINT Except this an error occurs DINT TO BOOL BOOL Takes the low 1 bit and converts into BOOL type DINT TO BYTE BYTE Takes the low 8 bit and converts into BYTE type DINT TO WORD WORD Takes the low 18 bit and converts into WORD type DINT TO DWORD DWORD Converts into DWORD type without changing the internal bit array DINT TO LWORD LWORD Converts into LWORD type filling the upper bytes with 0 If input is 0 99 999 999 normal conversion DINT_TO_BCD DWORD Except this an error occurs C rts DINT into REAL type DINT REAL REAL OREL oi During conversion an error caused by the precision may occur C rts DINT into LREAL type DINTTOAPREAL erem ee T During conversion an error caused by the precision may occur B Error If a conversion error occurs ERR LER flags will be set When an error oc
106. P COUNT1 RESET PV 100 This is a program that calls the CTD down counter regardless of CR CTD COUNT2 Calls the CTD down counter whose instance is COUNT2 CD B_DOWN LD B LDV PV 300 5 21 5 IL 20 RET Returns from a function or function block C if CR whose data type is BOOL is TRUE 1 it returns If CR whose data type is BOOL is FALSE 0 it does not return N if CR whose data type is BOOL is FALSE 0 it returns If CR whose data type is BOOL is TRUE 1 it does not return If there is no modifier it returns regardless of CR None LD VAL 1 MUL VAL2 ST VAL3 LD ERR RETN LD 0 ST VAL3 RET This is a function that stores the result in VAL3 after MUL operation for the value of VAL1 whose data type is INT and the value of VAL2 whose data type is INT At this time if an operation error occurs in MUL operation it returns after storing O inl VAL3 CR system error flag If CR is 0 instance will return VAL3 lt Returns unconditionally 5 22 21 5 IL Evaluation deferred operation used with None None LD ADD MUL ST LD ADD MUL ST VAL 1 VAL2 VAL3 VAL4 VAL 1 VAL2 VAL3 VAL4 L VAL1 L VAL2 L_VAL3 L_VAL4 L_VAL5 L_VAL6 L_VAL7 VAL4 lt I VAL1 IVAL2 VALS3 VAL4 lt VAL1 IVAL2 VAL3 L VAL7 L VAL1 L VAL2 X L VAL3 L VALA L_VAL5 L_VAL6
107. R flags are set B Program Example This is the program that sets the required working time the average estimated time per unit product is 20min 2sec and the number of product to produce a day is 20 in one product line LD 0 JMPN ABC LD UNIT TIME MUL TIME 1 1 CURRENT RESULT PRODUCT C 2 PRODUCT COUNT TS ST TOTAL TIME UNIT 1 Write input variable IN1 the estimated time per unit product UNIT TIME 20 25 2 Write input variable IN2 quantity of production PRODUCT COUNT 20 3 Write TOTAL TIME to the output variable OUT total required working time 4 If the transition condition 0 is on T 6H40M40S will be produced in output TOTAL TIME Input 1 UNIT TIME TIME T 20MS2S MUL TIME IN2 PRODUCT COUNT INT 16 18 Output OUT TOTAL TIME TIME T 6H40M40S 8 62 8 Basic Function Function Block Library MUX Selection from multiple inputs Me ae aw Input EN executes the function in case of 1 K selection INO the value to be selected IN1 the value to be selected Input variable number can be extended up to 8 Output ENO without an error it will be 1 OUT the selected value INO IN1 OUT should be the same time W Function Selects one among several inputs INO IN1 INn with value and produces it If K 0 INO will be an output if K 1 IN1 will be an output if K n
108. R value stored in other place stores the result in CR As the stored CR current CR CR will be 1 Stores the CR value in VAL3 whose data type is BOOL B VAL3 TRUE 5 15 5 IL 14 EQ Meaning After comparison operation for CR and the operand value stores the BOOL result in CR CR will be 1 only if CR is greater than operand A data type of both CR and the operand should be the same The operand value does not change After operation a data type of CR will be BOOL regardless of the operand data type deferred operation Constant is also available Examples In case that VAL1 50 VAL2 100 IVAL 3 50 The value of VAL1 whose data type is INT is loaded in CR After comparison operation for CR and the value of VAL2 whose data type is INT stores the result in CR As VAL1 1 VAL2 CR will be 0 Stores CR value in B VAL1 whose data type is BOOL B VAL1 lt FALSE The value of VAL2 whose data type is INT is loaded in CR After comparison operation for CR and the value of VAL1 whose data type is INT stores the result in CR As VAL1 1 VAL3 CR will be 1 Stores CR value in B VAL2 whose data type is BOOL B VAL2 TRUE The value of VAL1 whose data type is INT is loaded in CR Moves CR value in other place and stores the value of VAL2 whose data type is INT in CR After SUB operation for CR and the value of VAL3 whose data type is INT stores the result in CR After comparison operation fo
109. RD DWORD Converts into DWORD type filling the upper bits with O UINT TO LWORD LWORD Converts into L WORD type filling the upper bits with 0 UINT TO BCD f input is 0 99 999 999 normal conversion Otherwise an error occurs UINT TO REAL REAL Converts UINT into REAL type UINT TO LREAL LREAL Converts UINT into LREAL type UNIT TO DATE DATE Converts into DATE type without changing the internal bit array t D n OOL t Y UINT TO WORD WORD Converts into WORD type without changing the internal bit array E Error If a conversion error occurs ERR and flags will be set If error occurs it takes as many lower bits as a bit number of output type and produces an output without changing its internal bit array 8 97 8 Basic Function Function Block Library 3M0 UINT TO WORD JMPN PO EN ENO LD IN VAL IN VaL ovT var UINT TO WORD ST OUT VAL PO 1 If the input condition is ON function UINT TO WORD will be executed 2 If input variable IN VAL UINT 255 240000 0000 1111 1111 output variable OUT VAL WORD 240000 0000 1111 1111 Input IN VAL 255 i if fa ip o dy UINT_TO_WORD Output OUT OUT_VAL WORD 16 FF o of of of of of of o 1 af 1 d id d 8 98 8 Basic Function Function Block Library ULINT TO ULINT conversion ar as ae Apict e Jojo union O Input EN e
110. T C miis ST TIME PER PRO SS 1 If the transition condition 9610 1 0 is on DIV TIME function will be executed 2 If it divides TOTAL TIME T 12H24M24S by PRODUCT COUNT 12 the time required to produce one product TIME PER PRO T 1H2M2S will be an output That is it takes 1hr 2min 2sec to produce one product Input 1 TOTAL TIME TIME 12 24 245 DIV TIME 2 PRODUCT COUNT INT 12 Output OUT TIME PER PRO TIME T 1H2M2S 8 28 8 Basic Function Function Block Library DT TO DT type conversion Model G6 GJ Application e e e Input EN executes the function in case of 1 IN date and time of day data to convert Output without an error it will be 1 OUT type converted data E Function It converts Input IN type and produces output OUT Function Outputtype DT TO LWORD LWORD Converts DT into L WORD type The inverse conversion is available as there is no internal data change DT TO DATE DATE Converts DT into DATE type DT TO TOD Converts DT into TOD type DT TO STRING STRING Converts DT into STRING type MADRE LD 20 20 TO DATE i JMPN L EN ENO LD VAL OUT VAL DT TO DATE i ST OUT_VAL L 1 If the transition condition M20 is on DT TO DATE function will be executed 2 If
111. T OFF becomes 0 3 If T OFF becomes 1 again in 10 seconds after it turned OFF TOF will be initialized TIMER OK 1 4 After T OFF becomes 0 the elapsed time ET TIME will be measured and shown 8 197 8 Basic Function Function Block Librar TON ON Delay Timer function block Model GR IG GW Application Input IN timer operation condition PT preset time TON BOOL IN Q BOOL TIME PT TIME Output timer output ET elapsed Time Function Elapsed time ET is measured and shown after IN becomes 1 When IN becomes 0 before ET reaches the preset time ET will be 0 If IN becomes 0 after is 1 will be 0 Time Chart Preset time PT Program Example INS TON IN PT T H10S D INS TIMER D INS_TON ET ST ET_TIME 8 198 8 Basic Function Function Block Library T ON TIMER OK 05 Preset time10s ET TIME 1 The output TIMER OK 1 ten seconds later after the input ON is asserted T ON 1 3 When T ON 0 before TIME reaches the preset time 10s ET TIME will be 0 1 2 Elapsed time ET TIME is measured and shown after the input T ON becomes 1 3 4 ON 0 after TIMER_OK 1 then 0 and TIME 0 8 199 8 Basic Functio
112. T and END set bit data to shift Shifting direction and time shifts N times from STRT to END Input data setting fills empty bit after shifting with input data CYI Output the result is written at ANY BIT designated by SRC and the overflowing bit data by shifting from END to STRT is written at OUT END 12 STAT 0 Function SRC type Description SHIFT C BYTE BYTE SHIFT C WORD WORD SHIFT DWORD DWORD It shifts a designated bit array of SRC bit arrays N times SHIFT C LWORD LWORD 8 173 8 Basic Function Function Block Library B Error gt If STRT or END exceed the bit number of SRC variable type ERR and LER flags are set gt There s no change in SRC data B Program example AM 3 STRT 13 END 2 N 1 If the transition condition 2 is on SHIFT WORD function is executed 2 16 A5A5 is shifted from STRT to END by 2 bits and the empty bits after shifting are filled with 1 CYI 3 SRC after shifting is 16 969D and the overflowing bit data 0 is written at OUT after 2 bit shifting END 13 STRT 3 Before CYI o 1101011 0 111 011 0 0 1 1 1 011 After 8 174 8 Basic Function Function Block Library SWAP Swaps upper data for lower data Model GM GJ e Application e e Input EN executes the function in case of 1 IN Input Output ENO without an er
113. T1 REPLACE IN1 2 CURRENT RESULT IN2 TEXT2 L LENGTH P POSITION OUT_TEXT IN 2 4142 LENGTH POSITION JP 8 70 8 Basic Function Function Block Library 1 If the transition condition is ON function REPLACE character string replacement will be executed 2 If input variable of character string to be replaced IN TEXT1 ABCDEF input variable of character string to replace TEXT2 X input variable of character string length to be replaced LENGTH and input variable of character string position designation to be replaced POSITION 2 then BCD of IN TEXT will be replaced with X of IN TEXT2 and output variable OUT TEXT will be AXET Input IN1 IN TEXT1 STRING ABCDEF IN2 IN TEXT2 STRING X L LENGTH INT 3 POSITION INT 2 Y Output OUT OUT TEXT STRING 8 71 8 Basic Function Function Block Library RIGHT To take the right of character string ar as ae Adictim e e e jejeje o Input EN If EN is 1 function executes IN input character string L length of character string STRING STRING NT Output ENO without an error it will be 1 OUT output character string B Function It takes a right L length character string of IN and produces output OUT E Error 0 ERR and LER flags will be set B Program Example 10 0 0 LD IN TEXT IN TEXT R
114. TAN el oc Ma ee eee ee nea 8 9 A E O ue T 8 10 21610 XP aU REET 8 11 BYTE Oe M tu M idu 8 12 IU e PED CN ha tn i ie ee 8 13 TIME Bade e ava 8 14 COS 8 15 LE cA IE tdm 8 16 DELETE eee dede ese rns 8 17 DIE eim dan datis aes 8 18 Mi TUO III IDE 8 20 DIREG INi rn nnus anui 8 22 DIREC QS andae ea ian 8 25 BIV hada 8 27 DIN IME tit ea teen aden 8 28 DI DOS uniri id t TL MUS ier E UIT 8 29 DWORD TO T oe Reeve iy ET aee 8 30 zt 8 32 d E 8 33 ESTOB2 uit tasti ru eR teli rt ac tete sin 8 34 E Milde ee 8 35 EXPT E 8 36 8 37 M EE 8 38 cip EE 8 39 INSERT OH etel E Eus 8 40 MING ON dr 8 41 LE suene tete A 8 43 oet i ted oe i ota tt tone cate 8 44 LEN ED 8 45 iieri ete hm cte eee eet gs 8 46 TERI ES 8 47 Table of Contents EN cedo eMe
115. There must be a transition between step and step Tl TRANI Ti The content of TRAN1 90 0 1 0 1 3 TRANS e 0 0 2 When TRANS is on S1 will be deactivated and S2 activated TRANS is the internally declared variable A transition condition of all transition should be output in TRANS variable 4 2 3 Action Each step is able to connect up to two actions gt step without action is regarded as a waiting action and it is required to wait until the next transition condition will be 1 gt Action is composed of PLC language such as IL or LD and the content of action will be executed while the step is activated gt Action qualifier will be used to control action gt When action becomes deactivated state after activating the contact output in action will be 0 However S R function and function block output retain their state before they become non activating Rer 1 4 2 4 5 The content of ACTION1 0 0 1 990 0 0 0 0 2 content of ACTION2 10 0 480 0 2 10 0 3 0 0 3 e ACTION1 will be executed only when S1 is activated ACTION2 will be executed until S1 meets R qualifier after activated It goes on executing even if S1 is deactivated When action is deactivated this action is Post Scanned and then passes to the next step Reference Post Scan When action is deactivated this action is scanned again As it is scanned as if ther
116. UM 105 105 1 TIMER OK is 1 during 10 seconds after input variable T TRTG becomes 1 from 0 If T TRTG becomes 1 from 0 after timer is executed ET TIME is set as 0 and increased again 2 TIMER OK is 1 during 10 seconds even when T TRTG becomes 0 from 1 3 TIME value increases and stops at T 10S And it is 0 when T TRTG is 0 4 If input contact 11 1 15 is 1 OK and TIME are all cleared ET 8 235 8 Basic Function Function Block Library TRTG UINT TRTG with integer setting Model M a GW Application e Input IN operation condition for Timer PT preset time UNIT time unit of setting time RST reset Output Q timer output ET elapsed time E Function gt IfINis 1 Qis 1 And if elapsed time reaches preset time timer output Q is 0 gt If IN turns on again before elapsed time reaches preset time then elapsed time is set as 0 and increased again And if it reaches PT Q is 0 gt If RST is 1 timer output and elapsed time ET 0 gt Preset time is PT x UNIT ms Timing Chart 8 236 8 Basic Function Function Block Library 1 1 1 51 RST 1 Preset time is PT x UNIT ms 10 x 1000 ms 10 5 2 TIMER OK is 1 during 10 seconds after input variable T TRTG becomes 1 from 0 If T TRTG becomes 1 from 0 after timer is executed ET TIME is set as 0 and increased ag
117. UNT Q is 0 and output contact Q1 3 0 is off 8 204 8 Basic Function Function Block Library DUTY Scan setting On Off Model GR GW Application Input requires to execute the function block SON scan number to turn on SOFF scan number to turn off Output DONE it is 1 when REQ is and both input variables are not less than 0 OUT output is 1 during on scan time E Function gt DUTY function block produces a pulse which is on during the SON scan time and off during the SOFF scan time while REQ is on If SON 0 OUT is always off If SON gt 0 and SOFF 0 OUT is always on If REQ is off OUT is off If SON 0 or SOFF 0 then DONE is off and OUT is 0 4 iming Chart EU Ti ning Pul se NEM NE ENT NN SCN Scan SCF Scan 8 205 8 Basic Function Function Block Library B Program Example INS DUTY 11 1 0 DUTY REQ DON 01 3 0 3 SON OU 4 SOFF 1 Define DUTY function block as DUTY_C 2 Set 11 1 0 to REQ the input contact of DUTY 3 Set 3 to SON 4 Set 4 to SOFF 5 Set Q1 3 0 to output OUT 6 After a program is complete compile and write it to PLC 7 When Write is complete do Mode Change Stop gt Run 8 If input contact 1 1 0 is on output contact Q1 3 0 is on during 3 scan times and off during 4 scan times 8 206
118. URRENT DATE is D 1995 12 15 and START DATE is D 1995 11 1 the working days declared as output variable WORK DAY will be T 44D Input 131 CURRENT DATE DATE D 1995 12 15 SUB DATE IN2 START DATE DATE D 1995 11 1 Output OUT WORK DAY TIME T amp 44D 8 87 8 Basic Function Function Block Library SUB DT Date and Time subtraction _ ar mlar as 4 ae Amictim e e Input executes the function in case of 1 IN standard date and time of day IN2 date and time of day to subtract BOOL Output ENO without an error it will be 1 DATE OUT the subtracted result time B Function It subtracts IN2 specific date and time of day from IN1 standard date and time of day and outputs the time difference as OUT B Error If output value is out of range of TIME data type ERR and LER flags will be set If the result of date and time of day subtraction operation is a negative number an error occurs E Program Example 0 JMPN PPP LD CURRENT DT SUB DT IN1 2 CURRENT RESULT IN2 5 DT ST WORK TIME START DT JIN2 1 If the transition condition is ON function SUB DT Time and Date subtraction will be executed 2 If the current date and time of day CURRENT DT is DT 1995 12 15 14 30 00 and the starting date and the time of day to work START DT is DT41995 12 13 12 00 00 the continuous working time dec
119. VALUE2 whose data type is BOOL in CR B VALUE3 After logical AND operation for CR and the value of B VALUES whose data type is BOOL stores the result in CR After logical XOR operation for the current CR value and the moved CR value stored in other place stores the result in CR B VALUE4 Stores CR value in B_VALUE4 whose data type is BOOL B VALUE4 lt B VALUE1 VALUE2 AND B VALUE3 5 9 5 IL 8 ADD Meaning After addition operation for CR and the operand value stores the operation result in CR At this time a data type of both CR and the operand should be the same The operand value does not change Moves CR value in other place for a while and stores the operand value in CR deferred operation Only SINT INT DINT LINT USINT UINT UDINT ULINT REAL LREAL data types are available Constant is also available Examples VALUE1 The value of VALUE1 whose data type is INT is loaded CR At this time a data type of CR is INT VALUE2 After ADD operation for CR and the value of VALUE2 whose data type is INT stores the result in CR VALUES Stores CR value in VALUES whose data type is INT VALUES lt VALUE1 1 VALUE2 LD D VALUE1 The value of D VALUE1 whose data type is DINT is loaded in CR At this time a data type of CR is DINT ADD D VALUE2 Moves CR value in other place and stores the value of D VALUE2 whose data type is DINT CR DIV D VALUES After DIV operatio
120. a PLC language gt SFC splits an application program into step and transition and provides how to connect them each other Each step is related to action and each transition is related to transition condition gt SFC should contain the state information only program and function block among program types are available to apply this SFC D Type Action name Action Selection Step branch Transition 111 112 Jump 4 Transition name Parallel za branch Label UN s THERE a Qualifier 4 2 SFC Structure 4 2 1 Step gt Step indicates a sequence control unit by connecting the action gt When step is in an active state the attached content of action will be executed gt initial step is one to be activated first Initial step Transition condition Step gt If a next transition condition of activated initial step S1 is established step 1 51 that is currently activated becomes deactivated and Step 2 S2 connected to S1 becomes activated 4 1 4 5 4 2 2 Transition Transition indicates the execution condition between steps gt A transition condition should be described as a PLC language such as IL or LD The result of a transition condition should always be a BOOL type and the variable name should be TRANS for any transition gt Incase that the result of transition condition is 1 the current step is deactivated and the next step is activated gt
121. able Name Variable Kind Data Type Initial Value Memory Allocation NT ao BIPOLAR VAR RETAN REAL LIMIT SW BOOL 1 0 2 GLO sw VAR EXTERNAL DWORD _ Amo READ BUF ARRAY OF INTL Auto 3 11 3 Common Elements 3 3 3 Reserved Variable gt Reserved Variable is the variables previously declared in the system These variables are used for special purposes and users cannot declare other variables with the Reserved Variable names gt Users can use these reserved variables without variable declaration gt For further information please refer to Users Manual 1 User Flag err Boor Operation eror latch contact on time ON contact orr Boor time OFF contact _INIT_DONE BOOL Initial program completion T10S BOOL 10 sec clock contact _ERR _LER BOOL 2 sec clock contact _ OFF DATE DATE Current date of RTC RTC Current time of RTC _ WEEK UINT Current day of RTC 3 12 3 Elements 2 System Error Flag Heavy trouble detection error of external device Scan Watch Dog error _ BOOL 3 System Error Release Flag Reserved Variable Data Type Description ER M BYTE System error heavy trouble release 4 System Alarm Flag Reserved variable Data type Description System Alarm Alarm message RTC data error Data backup error Hot restart una
122. actual contacts of an input module will be updated in the image scope gt DIREC IN function is available to use when you want to change the ON OFF state of input l during the scan gt Generally it s impossible to update input data during 1 scan executing a scan program because scan synchronized batch processing mode executes the batch processing to read input data and produce output data after a scan program It s available to update related input data if you use DIREC IN function during program execution 8 22 8 Basic Function Function Block Library B Program Example 1 This is the program that updates a 16 contact module installed in the 4th slot slot number is 3 of the 3rd 1110 1011 LD 0 7 JMPN ABC 3 a Arr OE DIREC_IN BASE CURRENT RESULT SLOT 3 MASK 1 16 FFFF0000 16 FFFF00 MASK_H 16 FFFF0000 16 ST REF OK 00 1 If the input condition 0 is on function DIREC_IN will be executed 2 The image scope to update will be IW3 3 0 and IW3 3 0 will be updated with 2 1010_1010_1110_1011 during the scan because a 16 contact module is installed and the lower 16 bit data update is allowed MASK L 164FFFF0000 3 It doesn t matter what data are set in MASK_H because a 16 contact module is installed 2 This is the program that updates the lower 16 bit data of the 32 contact module installed in the 4th slot slot number is 3 of the exte
123. ain 3 TIMER OK is 1 during 10 seconds even when T TRTG becomes 0 from 1 4 ET TIME value increases and stops at 10000 And it is 0 when TRTG is 0 5 If input contact 96IX1 1 5 is 1 OK TIME are all cleared T TRIG __ E 96 Xl 1 5 Preset Ti ne ceret Mw TIU M j 10 000ns EI TE 10x 1000 TI MER 8 237
124. am Example Ne NO UU _ gt Rane PORT Se LD MO i JMPN ABC 2M0 BOOL_TO_BYTE i LD BOOL_VAL EN ENO i BOOL TO BYTE BO0L V L IiN1 OUT_VAL i ST OUT VAL ABC 1 If the transition condition is on BOOL_TO_ function will be executed 2 If input BOOL VAL BOOL 2 1 then output OUT VAL BYTE 240000 0001 Input IN1 BOOL VAL BOOL 21H V BOOL TO SINT Output OUT OUT VAL BYTE 16 1 o o of o of of 0 iJ 8 Basic Function Function Block Library BYTE TO BYTE type conversion Model GR M G6 Application e e Input executes the function in case of 1 IN bit string to convert 8 bits Output ENO without an error it will be 1 OUT type converted data m Function It converts input IN type and produces output OUT Converts into ULINT type filling the upper bits with 0 Converts into DWORD type filling the upper bits with 0 Program Example 10 BYTE_TO_SINT LD IN VAL EN ERO BYTE SINT vaL ovr var i ST OUT VAL 1 If the transition condition 10 is on BYTE SINT function will be executed 2 IFIN VAL BYTE 220001 1000 OUT VAL SINT 24 240001 1000 Input IN1 IN VAL BYTE 16418 Lo of of 1 1 of of o 1 1 BYTE TO SINT Output OUT OUT VAL SINT 24
125. am Example 1 Setting time is PT x UNIT ms 10 x 1000 ms 10 5 2 Output variable TIMER_OK is 1 if 10 seconds passes after input variable T_TMR is 1 3 Elapsed time is produced at ET_TIME after input variable T_TMR is 1 4 Even if T_TMR is 0 before ET_TIME reaches preset time 10 seconds ET_TIME keeps its value 5 6 If input variable T TMR is 1 again elapsed time is produced at ET integrating its previous value If input contact IX1 1 5 is 1 elapsed time TIME and output contact TIMER OK are all cleared T TM 96 Xl 1 5 Setti ng Ti ne 10000ns ET Tl ME 8 223 8 Basic Function Function Block Library TOF RST TOF with Reset Model QR MIG Application es 2 Input IN operation condition for Timer PT preset time RST reset Output Q Timer output ET elapsed time E Function gt Qis 1 when IN is 1 and is 0 after preset time PT after IN is 0 gt Elapsed time is produced at ET after IN is 0 gt Elapsed time is 0 if IN is 1 before ET reaches PT p IFRSTis 1 Qand ET are O B Timing Chart Preset Time PT 8 224 8 Basic Function Function Block Library E Program Example OK THIOS ET ET TIME 1 1 1 15 RST 96 X1 1 15 Preset Time 105 ET TI MER CK NEN 1 If input variable T TOF RST is 1 output variable TIMER OK is 1 An
126. ample 1 If the transition condition is on ARY ASC TO BCD function is executed 2 If the input data is ASC ARY O 3031H ASC 1 3839H ASC ARY 2 3334H 8 108 8 Basic Function Function Block Library In Out BCD ARY data is as follows 8 109 8 Basic Function Function Block Library ARY ASC TO BYTE o o o o Input EN executes the function in case of 1 IN1 ASCII Array input Output ENO without an error it will be 1 OUT Dummy Output In Out IN2 BYTE Array Output m Function It converts a word array input ASCII data to a byte array output hexadecimal B15 B12B11 B8 B7 B4 B3 BO IN1 O 4 E Error gt If the number of each input array is different there s change IN2 data and ERR LER flags are set gt If the elements of array are not between 0 and F hexadecimal its responding elements of IN2 array 0 while other elements of IN1 are normally converted and ERR and LER flags are set 1 If the transition condition is 0 is on ARY ASC TO BYTE function is executed 2 Input ARY is as below 8 110 8 Basic Function Function Block Library In Out BYTE ARY data is as follows 8 111 8 Basic Function Function Block Library ARY AVE Input EN executes the function in case of 1 IN data array for average INDX starting point to
127. and produces the output without changing the internal bit array 8 95 8 Basic Function Function Block Library B Program Example LD 9e MO UDINT TO TIME PR Ad JMPN 22 LD IN VAL IN ovr var UDINT TO TIME ST OUT VAL 77 1 If the input condition 0 is ON function UDINT TO TIME will be executed 2 If input variable IN VAL UDINT 123 output variable OUT VAL TIME T 123MS Input IN1 IN VAL UDINT y Output OUT OUT VAL TIME T 123MS 8 96 8 Basic Function Function Block Library UINT TO UINT type conversion ar as ae Apictim e jejejeje eje Input executes the function in case of 1 pui IN Unsigned Integer value to be converted Output ENO without an error it will be 1 OUT type converted data W Function It converts the IN type and outputs it as OUT Description If input is 0 127 normal conversion Otherwise an error occurs f input is 032 767 normal conversion Otherwise an error occurs Converts UINT into UDINT type normally Converts UINT into ULINT type normally f input is 07255 normal conversion Otherwise an error occurs IN Converts UINT into UDINT type normally D UINT TO ULINT ULINT Converts UINT into ULINT type U UINT TO BOOL B Takes the lower 1 bit and converts into BOOL type B UINT BYTE Takes the lower 8 bits and converts into BYTE type UINT TO DWO
128. ange 0 4 294 967 295ms T 49d17h2m47s295ms Date _0 DT 00 64615 range DT 1984 01 01 00 00 00 DT 2163 12 31 23 59 59 999 15 0 DATE 16bits range D 1984 01 01 D 2163 6 6 31 _0 TOD 32bits range TOD 00 00 00 TOD 23 59 59 999 BCD BYTE 8bits range 0 99 WORD 16bits range 0 9999 DWORD 2 4 32bits range 0 99 999 999 16 15 _0 LWORD 10 64bits range 0 9 999 999 999 999 999 3 7 3 Common Elements 3 3 Variable A variable data used in the program has its own value Variable means something that can vary such as an input output of PLC memory etc 3 3 1 gt Variable Expression Variables can be expressed in two ways one is to give a name to a data element using an identifier Variable by Identifier and the other is to directly assign a memory address or an input output of PLC to a data element Direct Variable A variable by identifier should be unique within its effective scope program area where the variable was declared in order to distinguish it from other variables A direct variable is expressed as one which starts with the percent sign 96 followed by the location prefix a prefix of the data size and more than one unsigned integer numbers divided by a period The prefix are shown as below Location prefix No ff tn Output Location Memory Location Size prefix x imse o 2 noe 000
129. ared as GLOBAL so that its access is available in the programs requiring the resource Each program to claim the same resource should be designated as the same priority Not available to use between multi CPU modules in GM1 Internal execution structure of SEMA function block VAR X BOOL 0 END VAR BUSY X IF CLAIM THEN 1 ELSIF RELEASE THEN BUSY 0 X 0 END_IF Time Chart The access right to control the same resource is transferred between the program block A and the program block B RELEASE BUSY 8 192 8 Basic Function Function Block Library Example LD CAL SEMA PRINTER START RELEASE END LD PRINTER BUSY ST NOT AVAIL When you want to produce a printer output in different program blocks with the printer attached to the PLC system you can easily control it by declaring the instance PRINTER GLOBAL and using SEMA function block named as PRINTER in each program If you execute SEMA function block PRINTER when START is 1 and END is 0 and claim the right to control the printer while the printer is used in other program block BUSY is 1 If the printer is not used in other program block BUSY will be 0 which means you can start the program to produce the printer output with it After completing the print control execute SEMA with START 0 and END 1 so that other program can get the right to control it VAR EXTERNAL clai
130. ation for the current CR value and the moved CR value stored in other place stores the result in CR D VALUE4 Stores the CR value in D VALUEA whose data type is DINT D_VALUE4 lt D VALUE1 D VALUE2 X D VALUE3 5 IL 10 MUL Meaning After multiplication operation for CR and the operand value stores the operation result in CR At this time a data type of both CR and the operand should be the same The operand value does not change Modifier Moves CR value in other place for a while and stores the operand value in CR deferred operation Operand Only SINT INT DINT LINT USINT UINT UDINT ULINT REAL LREAL data types are available Constant is also available Examples VALUE1 The value of VALUE1 whose data type is INT is loaded CR At this time a data type of CR is INT VALUE2 After MUL operation for CR and the value of VALUE2 whose data type is INT stores the result in CR VALUES Stores CR value in VALUES whose data type is INT VALUES lt VALUE1 X VALUE2 D VALUE1 The value of D VALUE1 whose data type is DINT is loaded in CR At this time a data type of CR is DINT D VALUE2 Moves CH value in other place and stores the value of D VALUE2 whose data type is DINT CR D VALUE3 After SUB operation for CR and the value of D VALUES whose data type is DINT stores the result in CR After MUL operation for the current CR value and the moved CR value stored in other place stores th
131. average in an array LEN number of array elements for average ARY AVE Output ENO without an error it will be 1 OUT average of an array B Function gt ARY AVE function finds an average for a specified length of an array gt Input and output array is the same type gt If LEN is a minus value it finds an average between INDX Array index and INDX LEN gt Its output is rounded off Funcion Output type 1 Descrpion 0005 LARY AVE SINT SINT Finds an average for SINT value decimal is rounded off LARY INT Finds an average for INT value decimal is rounded LARY AVE DINT DINT Finds an average for DINT value decimal is rounded off LARY AVE LINT LINT Finds an average for LINT value decimal is rounded LARY AVE USINT Finds an average for USINT value decimal is rounded off LARY AVE UNT UINT Finds an average for value decimal is rounded off LARY AVE UDINT UDINT Finds an average for UDINT value decimal is rounded off _ LARY AVE ULINT ULINT Finds an average for ULINT value decimal is rounded off ARY_AVE_REAL REAL REAL 1 0 0 00 0 0 0 0 00 0 ARY AVE LREAL LREAL 0 0 B Error gt If itis designated beyond the array range ERR and LER flags are set gt If an error occurs the output is 0 X An error occurs when INDX 0 or
132. bits and produces output OUT VALUE Input IN1 IN VALUE WORD 16 3 Output OUT OUT_VALUE WORD 16 6666 8 Basic Function Function Block Library ROR Rotate to right Ge fas Apictim e o Input EN executes the function in case of 1 IN the value to be rotated N bit number to rotate ROR BOOL ENO BOOL ANY IN OUT LANY N Output ENO without an error it will be 1 OUT the rotated value B Function It rotates input IN to the right as many as N bit number B Program Example This is the program that rotates input data value 1110001100110001 16 E331 to the right by 3 bits if input 10 0 0 is ON 10 0 0 IN VALUE1 CURRENT RESULT 3 OUT VALUE 1 Set input variable of a data value to rotate as IN VALUEt1 2 Insert bit number 3 into bit number input N 4 If the transition condition 10 0 0 is ON function ROR rotate Right will be executed and data bit set as input variable will be rotated to the right by 3 bits and produces output OUT VALUE Input IN1 IN VALUE1 WORD 16 331 3 Output OUT OUT VALUE WORD 16 3C66 8 74 8 Basic Function Function Block Library SEL Selection from two inputs as 96 av Adictim e e e jejeje o Input EN executes the function in case of 1 G selection INO the value to be selected IN1 the val
133. ble error AB SD ER BOOL Abnormal Shutdown Task conflict normal cycle external task Battery error Light trouble detection of external device Over high speed link parameter 1 Over high speed link parameter 2 Over high speed link parameter 3 Over high speed link parameter 4 3 13 3 Common Elements 5 Detailed System Error Flag UINT Module type inconsistency slot number Module type inconsistency location Module installation slot number Module installation location Fuse shortage slot number Fuse shortage slot location module read write error slot number module read write error slot location Heavy trouble detection of external device Light trouble detection of external device Alarm message detection bit map of external device Task conflict mark Task conflict counter Battery voltage drop down time Shutdown counter Instantaneous service interruption histor 3 14 3 Elements 6 Information of System Operation Status Reserved variable Data tvne Descri pti on CPU TYPE Svstem Tvne VER PLC O S Version number MEM TYPE Menary nodul e type SYS STATE PLC node and status RST TY Restart node i nf ornati on INT RUN niti al i zi ng SCAN Max scan ti ne ns SCAN MN Mn scan ti ne ns SCAN AR Current scan tine ns STSK_NUM Task requi ri ng execution ti ne check STSK Max task execution ti ne ns STSK MN Mn task executi on
134. cter string to insert P position to insert a character string INSERT BOOL 4EN ENO BOOL STRING 4IN1 OUT STRING STRING 4 IN2 INF Output ENO without an error it will be 1 OUT output character string B Function It inserts character string IN2 after the P character of IN1 and produces output OUT B Error If P lt 0 character number of variable IN1 P or if the character number of result exceeds 30 just 30 characters are produced then ERR LER flags will be set Program Example M H C LD 0 JMPN AA j TEXT1 1191 QVT TEXT INSERT 1 1 CURRENT RESULT IN2 2 IN TEXT2 POSITION ST OUT TEXT AA IN 2 4142 POSITION JP 1 If the transition condition 96MO is on INSERT function will be executed 2 If input variable IN TEXT1 ABCD IN TEXT2 XY and POSITON 2 output variable OUT TEXT ABXYCD Input IN1 IN TEXT1 STRING ABCD IN2 IN TEXT2 STRING XY P POSITION INT 2 FIND Output OUT OUT TEXT ABXYCD 8 40 8 Basic Function Function Block Library INT INT type conversion Model M GW Application e e e Input EN executes the function in case of 1 IN integer value to convert INT TO N FNO Output ENO without an error it will be 1 OUT type conver
135. ction B Program example LD IL mm UE RE JMPN BBB LD BCD DATA SEG d ST SEG PATTERN SEG BCD D T 411 RN 8 168 8 Basic Function Function Block Library 1 If the transition condition 0 0 Ong O SEGfunction is executed 2 If input variable BCD DATA WORD 1641234 the output is 2400000110 01011011 01001111 01100110 which is displayed as a 7 segment code 1234 and written at SEG PATTERN DWORD Input 1 BCD DATA WORD 1641234 of 1 0jo 1 o jo jo j1 1 0 1 0 O SEQ Output OUT SEG PATTERN DWORD upper o o 01 1 jo 1 1 1 0 1 1 16406584666 lower 11 11 1 1 10011 110 7 segment configuration Conversion table for 7 segment code BCD HEX B7 B6 B5 B4 B3 B2 B1 BO Data 0 MEA EE D 1 2 3 E Ew Ej pog EN X MEINT uem oj O O O O O O O 5 7 7 A 1 O ol o Ool ol ol ol ol o Ol Ol ojl Oj ojl o oF k 0 6 8 09 B az a ENT EN NE p p 8 169 8 Basic Function Function Block Libra
136. curs it takes as many lower bits as the bit number of the output type and produces an output without changing the internal bit array 8 20 8 Basic Function Function Block Librar B Program Example LD PENDIENTE EEEE NEEN LD 1 pv i DINT TO SINT JMPN LSB f EN LD DINT VAL vaL ovr siwT var DINT TO SINT ST SINT VAL 1 If the transition condition 1 is on DINT TO SINT function will be executed 2 If INI DINT VAL DINT 77 SINT VAL SINT 77 Input IN1 DINT VAL DINT 2 77 upper lower rj 1 of of 1 DINT TO SINT Output OUT OUT VAL SINT 77 8 Basic Function Function Block Library DIREC IN Update input data Model GM M M Application e e Input executes the function in case of 1 BASE base number of an input module installed SLOT slot number of an input module installed MASK L designates bits not to be updated among lower 32 bit data of input MASK H designates bits not to be updated among upper 32 bit data of input Output without an error it will be 1 OUT if update is completed output will be 1 B Function gt If EN is 1 during the scan DIREC IN function reads 64 bit data of an input module from the designated position of BASE and SLOT and updates them gt Atthis time only the
137. d TIMER OK is 0 after 10 seconds after T TOF RST is O 2 If T OF RST is 1 within 10 seconds after it turns off TOF RST is initialized 3 Elapsed time is produced at ET TIME 4 If input contact IX1 1 15 is 1 elapsed time TIME and output contact TIMER OK are all cleared 8 225 8 Basic Function Function Block Library TOF UINT TOF with integer setting Model GR M a GAW Application e Input IN operation condition for Timer PT preset time UNIT time unit of setting time RST reset Output Q Timer output ET elapsed time E Function is 1 when IN is 1 And is 0 if setting time PT passes after IN is 0 Elapsed time is produced at ET after IN is O If IN is 1 before ET reaches PT ET is O If RST is 1 Q and ET are 0 Setting time is PT x UNIT ms VVVVV Timing Chart Preset Ti ne PT x UNT 8 226 8 Basic Function Function Block Library Program Example 1 1 1 53 RST 1 Preset time PT x UNIT ms 10 x 1000 ms 10 s 2 If input variable T_TOF is 1 output variable TIMER_OK is 1 TIMER_OK is 0 if 10 seconds passes after T_TOF is 0 3 If T TOF is 1 within 10 seconds TOF_UINT is initialized 4 Elapsed time is produced at ET_TIME 5 If input contact IX1 1 5 is 1 TIME are all cleared T TCF 96 Xl 1 5 Preset Ti ne 10 x 1000 ET
138. d the value of W VALUE2 whose data type is WORD stores the result in CR W VALUES3 Stores CR value in W VALUES whose data type is WORD W VALUES3 lt W VALUE1 AND W VALUE2 B VALUE 1 The value of B VALUE1 whose data type is BOOL is loaded in CR At this time a data type of CR is BOOL B VALUE2 Moves CH value in other place and stores the value of B VALUE2 whose data type is BOOL in CR B VALUES After logical OR operation for CR and the value of B VALUE3 whose data type is BOOL stores the result in CR After logical AND operation for the current CR value and the B_VALUE4 lt VALUE1 AND B VALUE2 OR B VALUE3 5 7 Meaning Modifier Operand Examples After logical OR operation for CR and the operand value stores the operation result in CR At this time a data type of both CR and the operand should be the same The operand value does not change N If the operand data type is BOOL logical AND operation is made between the operand value and CR after negating the operand value If a data type of operand is BOOL moves CR value in other place for a while and stores the operand value in CR deferred operation Only BOOL BYTE WORD DWORD LWORD data types are available Constant is also available LD VALUF1 OR VALUE2 ORN B VALUES B_VALUE4 W_VALUE1 W_VALUE2 W_VALUE3 LD B_VALUE1 OR B VALUE2 AND B VALUES ST VALUEA The value of B VALUE1 whose data type is BOOL is loaded
139. d value does not change Modifier N If the operand data type is BOOL logical AND operation is made between the operand value and CR after negating the operand value If a data type of operand is BOOL moves CR value in other place for a while and stores the operand value in CR deferred operation Operand Only BOOL BYTE WORD DWORD LWORD data types are available Constant is also available Examples LD B VALUE1 The value of B VALUE1 whose data type is BOOL is loaded in CR At this time a data type of CR is BOOL XOR VALUE2 After logical operation for CR and the value of VALUE2 whose data type is BOOL stores the result in CR XORN B VALUE3 After negating the value of B VALUES logical operation is made between CR and the value of B VALUES whose data type is BOOL B VALUEA Stores CR value in B VALUEA whose data type is BOOL B_VALUE4 lt B VALUE1 XOR B VALUE2 NOT B VALUES W_VALUE1 The value of W VALUE1 whose data type is WORD is loaded CR At this time a data type of CR is WORD W VALUE After logical operation for CR and the value of W VALUE2 whose data type is WORD stores the result in CR W VALUE3 Stores CR value in W VALUES whose data type is WORD W VALUES lt W VALUE1 XOR W_VALUE2 B VALUE1 The value of B VALUE1 whose data type is BOOL is loaded in CR At this time a data type of CR is BOOL B VALUE2 Moves CR value in other place and stores the value of B
140. e following basic data types bits toe e unr umen emm REAL Real Numbers 32 3 402823E38 1 401298E 45 1 7976931 308 4 9406564E 324 4 9406564E 324 1 7976931E308 DATE D 1984 01 01 D 2163 6 6 TIME_OF_DAY Time of Day TOD 00 00 00 TOD 23 59 59 999 DT 1984 01 01 00 00 00 ME DT 2163 12 31 23 59 59 999 17 BiSkngofLengna 8 LINT ULINT REAL LREAL LWORD available GM1 and GM2 only 2 3 4 3 2 2 Data Hierarchy Chart Data types used in GLOFA PLC are as follows 3 Common Elements ANY ANY NUM ANY BIT ANY STRING ANY DATE TIME m LWORD 1 2 ATE_AND_TIME ANY REAL INT DWORD DATE GM1 2 LINT GM1 2 WORD TIME OF DAY LREAL DINT BYTE REAL INT BOOL SINT ULINT GM1 2 UDINT UINT USINT gt LINT ULINT LWORD and REAL LREAL REAL are available GM1 and GM2 only gt Data expressed as ANY NUM includes LREAL REAL LINT DINT INT SINT ULINT UDINT UINT USINT hereafter gt For example if a data type is expressed as GM3 it can use one of the following data types DWORD WORD BYTE and BOOL 3 2 3 Initial Value If an initial value of data were not assigned it would be automatically assigned as below 3 5 3 Common Elements 3 2 4 Data Type Structure
141. e of CR is DATE Stores the value of CR in variable D VALUE1 of which data type is DATE 5 5 5 IL 3 S Set Meaning E 4 R Reset Meaning If CR is BOOL 1 the operand value of which data type is BOOL will be 1 No operation is processed if CR is BOOL 0 The current result is not modified by this operation Only BOOL data type is available Constant is not available LD FALSE B VALUF1 TRUE B VALUE2 The value of BOOL 0 is loaded in CR At this time a data type of CR is BOOL No operation is processed because CR is 0 The value of B VALUE1 does not change The value of BOOL 1 is loaded in CR At this time a data type of CR is BOOL As CR is 1 the value of B VALUE2 whose data type is BOOL will be 1 If CR is BOOL 1 the operand value whose data type is BOOL will be 0 No operation is processed if CR is BOOL 0 The current result is not modified by this operation Only BOOL data type is available Constant is not available FALSE B VALUE1 TRUE B VALUE2 B VALUES The value of BOOL 0 is loaded in CR At this time a data type of CR is BOOL No operation is processed because CR is 0 The value of B VALUE1 does not change The value of BOOL 1 is loaded in CR At this time a data type of CR is BOOL As CR is 1 the value of B VALUE2 whose data type is BOOL will be 0 The value of CR does not change The value of CR Boolean 1 is stored in B VALUES
142. e result in CR D VALUE4 Stores the CR value in D VALUE4 whose data type is DINT D VALUEA lt D VALUE1 X D VALUE2 D VALUES 5 12 11 DIV 5 IL After division operation for CR and the operand value stores the operation result in CR At this time a data type of both CR and the operand should be the same The operand value does not change Modifier Moves CR value in other place for a while and stores the operand value in CR deferred operation Only SINT INT DINT LINT USINT UINT UDINT ULINT REAL LREAL data types are available Constant is also available LD VALUE1 The value of VALUE1 whose data type is INT is loaded in CR At this time a data type of CR is INT DIV VALUE2 After DIV operation for CR and the value of VALUE2 whose data type is INT stores the result in CR ST VALUES Stores CR value in VALUES whose data type is INT VALUE lt _VALUE1 _VALUE2 LD D VALUE1 The value of D VALUE1 whose data type is DINT is loaded in CR At this time a data type of CR is DINT DIV D VALUE2 Moves CHR value in other place and stores the value of D VALUE2 whose data type is DINT CR ADD D VALUES After ADD operation for CR and the value of D VALUES3 whose data type is DINT stores the result in CR After DIV operation for the current CR value and the moved CR value stored in other place stores the result in CR ST D VALUEA Stores the CR value in D VALUEA whose data type is DI
143. e set gt An error occurs if STRT and END are out of SRC range gt When an error occurs there s no change in SRC and CYO 1 If input condition M2 is on ARY SFT C WORD function is executed 2 It shifts a bit array from 4 to 13 bit of SRC 3 times from STRT to END 3 The bit array after shifting is filled with 240011 4 It produces its shifting result at SRC_ARY and a carry bit array is written at CYO Before d 5 efore 3 4 word array c 240011 LE 13 Lib is SRC ARY 16 F7F7 40 16 40 16 1 1 16 8080 81912141810 015121819 40 3 After sini SRC ARY 16 C6F7 16 C473 After 16 F831 11 16 B810 CYO 281110 8 129 8 Basic Function Function Block Library ARY SWAP o o o micio o e e Description Input EN executes the function in case of 1 IN1 array input ARY SWAP Output ENO without an error it will be 1 OUT Dummy output In Out IN2 array output after swapping m Function It swaps upper lower elements after dividing an array LWORD B Error ERR and LER flags are set if two arrays are different there s no change in an 2 array B Program example 1 If the transition condition 0 is on ARY SWAP WORD function is executed 2 If IN ARY data is as below IN ARY 2 34CDH 8 130 8 Basic Function Function Block
144. e were a contact contact with the value of 0 in the beginning part of an action program the program output which is composed of contacts will be 0 Function function block S R output etc are not included 1 postscan C To 0 00 0 0 0 Arema In this figure as the contact of postscan is 0 C Q0 0 0 will be 0 4 2 4 Action Qualifier gt Whenever action is used action qualifier will be followed gt action of step defines an executing point and time according to the assigned qualifier gt Types of action qualifier are as follows 4 3 4 5 1 Non Stored Action is executed only when the step is activated Active state Step connected by N Action PERO 2 S Set It continues the action after the step is deactivated until the action is reset by R qualifier R Step connected A byS 5 81 ction Step connected R1 byR Step connected by S Action EE Step connected by R 3 R Overriding Reset It terminates the execution of an action previously started with the S SD SL or DS qualifier 4 4 4 5 4 L Time Limited It start the action when the step becomes active and continue until the step goes inactive or a set time elapses Step connected byL Action Step connected byL T DER HL 5 D Time Delayed Start a delay timer when the step becomes active after the time delay the action starts if step stil
145. ecuted 2 If input variable IN VAL LINT 123 456 789 output variable OUT VAL DINT 123 456 789 Input IN1 IN VAL LINT 123 456 789 of of of oJ o of oTo 16 75BCD15 Lo ojo o o o o oj o of of of of of 0 0 Lojojo o o r 1 1 o rj o 1 1 ofif of 1 o rj of V LINT TO DINT Output OUT OUT VAL DINT 123 456 789 1 o 1 o 1 1 of 8 8 Basic Function Function Block Librar LN Natural ogari thmoperati on Model Application e e Input EN executes the function in case of 1 IN input value of natural logarithm operation LN BOOL BOOL Output without an error it will be 1 ANY REAL 4 IN OU ANY REAL OUT natural logarithm value IN OUT should be the same data type B Function It finds a natural logarithm value of IN and produces output OUT OUT In IN B Error If an input is 0 or a negative number ERR and LER flags will be set ST RESULT 1 If the transition condition 96MO is on LN function will be executed 2 If input variable INPUT is 2 0 output variable RESULT will be 0 6931 In 2 0 0 6931 Input IN1 INPUT REAL 2 0 LN Output OUT RESULT REAL 6 93147182E 01 8 49 8 Basic Function Function Block Library LOG Base 10 Logarithm operation Model GR GM M
146. ed IN1 P Start bit position on IN1 set data IN2 P Start bit position on IN2 set data N Bit number to be combined Output ENO without an error it will be 1 OUT Combined bit string data output B Function gt If EN is 1 it takes bits of IN1 starting from the IN1 P bit and moves it to IN2 starting from IN2 P bit gt If N12 1111 0000 1111 0000 IN2 0000 1010 1010 1111 IN1 P 4 IN2 P 8 4 then output data is 0000 1111 1010 1111 Input data types are B BYTE W WORD D DWORD L LWORD L LWORD are available for GM1 2 You can use one of functions ENCO B ENCO W ENCO D ENCO L according to input data E Error If IN1 P and IN2 P exceed the data range is negative or bit of INT P and IN2 P exceeds the data range ERR and LER flags are set B Program example LSB SOURCE BMOV W IN1 CURRENT RESULT IN2 DESTINE IN1_P 0 2 8 4 DESTINE DESTINE DEST INE 8 136 8 Basic Function Function Block Library 1 If the transition condition is on W function is executed 2 If input SOURCE 280101 1111 0000 1010 DESTINE 240000 0000 0000 0000 INT P 0 IN2_P 8 4 then the result DESTINE is 2420000 1010 0000 0000 Input IN1 SOURCE WORD 16 5 0 0 1 0 11 1 ah jo o 1 0 ilo N2 DESTINE WORD 164000 o o o oj lo ojo o o o o Jo o INI P 0 IN2 8 4 W Output OUT
147. ee value into a radian value E Program example DEG_VAL RAD_VAL t 2 If input variable DEG VAL 127 its output RAD VAL 2 21656823 8 159 8 Basic Function Function Block Library ROTATE A Rotates array el enents Model 4 GJ e Application e e Input EN executes the function in case of 1 A N element number to rotate EN ENO STRT starting position to rotate in an array block SRC QUT END ending position to rotate in an array block STRT END Output N ENO without an error it will be 1 OUT overflowing data In Out SRC array block to rotate E Function gt Itrotates designated elements of an array block in the chosen direction gt Setting Scope STRT and END set a data array to rotate Rotation direction and time rotates times in the chosen direction set by STRT and END STRT ND Input data setting fills an empty element after rotation with Input data IN Output the result is written at ANY ARY designated by SRC and the data to rotate from END to STRT is written at OUT SRC SRC Before After 8 160 8 Basic Function Function Block Library Function In Out array type Description ROTATE A BOOL BOOL ROTATE A BYTE BYTE ROTATE A WORD WORD ROTATE DWORD DWORD ROTATE
148. eference When declaring Resource Global Variable and Configuration Global Variable variable formats are VAR GLOBAL VAR GLOBAL RETAIN and VAR GLOBAL CONSTANT VAR EXTERNAL is not available for them 2 Data type sets a variable data type 3 Memory allocation assigns memory for a variable Auto the compiler sets a variable location automatically Automatic Allocation Variable Assign AT a user sets a variable location using a direct variable Direct Variable 3 9 3 Common Elements Reference The location of Automatic Allocation Variable is not fixed If variable VAL1 for example was declared as BOOL it is not fixed in the internal memory the compiler and linker fix its location If the program is compiled again after modification the location may change The merit of Automatic Allocation Variable is that users don t have to care the location of the internal variables because its location is not overlapped as long as a variable name is different from others It is recommended not to use Direct Variable except 9el and 96Q because the location of a variable is fixed and it could be overlapped in a wrong used case gt Initial Value Assignment assigns an initial value A variable is set with an initial value as is shown in 8 2 3 Initial Value if not assigned Reference The initial value is not assigned when it comes to VAR EXTERNAL In case of Variable Declaration you cannot assign an initial value t
149. er Time Chart EL es NL NUN 1 scan or R_TRIG execution time Program Example LD IL CAL R TRIG INS RT INS RT CLK IN_SIGNAL IN_SIGNAL R_TRIG RISE_DETE i CLK Q LD INS_RT Q ST RISE_DETECT If the input variable IN SIGNAL changes from O to 1 while detecting its state the output variable RISE DETECT will be 1 And 1 scan later the output variable RISE DETECT will be 0 8 191 8 Basic Function Function Block Library SEMA Semaphore System resource allocation Model SE E OF GIO CIE Application e Input CLAIM signal to claim a resource monopoly RELEASE release signal Output BUSY waiting signal not to obtain the claimed resource Bi Function This function block is used to get an exclusive control right for system resources BUSY is 1 when SEMA function is executed CLAIM 1 or 0 RELEASE 0 and other program is using the resource If you want to obtain the resource control right wait until BUSY will be 0 after executing SEMA function block CLAIM 1 RELEASE 0 When BUSY is 0 it controls the associate resource and after completing the control it transfers the control right executing SEMA function block once again with CLAIM 0 and RELEASE 1 At this time the program that has the control right can execute SEMA function block with CLAIM 0 and RELEASE 1 The instance of SEMA should be decl
150. er to shift N Output ENO without an error it will be 1 OUT carry output In Out SRC variable for rotation E Function gt Itrotates a designated bit array of SRC bit arrays in the chosen direction gt Setting Scope STRT and END set a bit data to rotate Rotation direction and time rotates N times in the chosen direction set by STRT and END STRT ND Output the result is written at ANY ARY designated by SRC and the data to rotate from END to STRT is written at OUT END 12 5 0 Before EEEE 8 87 86 85 8 83 2 ater Function SRC type Description ROTATE C BYTE BYTE ROTATE C WORD WORD It rotates a designated bit array of SRC bit arrays N times in the ROTATE C DWORD DWORD chosen direction ROTATE C LWORD LWORD B Error gt If STRT or END exceed the bit number of SRC variable type ERR and LER flags are set gt There s no change in SRC data 8 163 8 Basic Function Function Block Library 13 STRT 3 END 2 N 1 If the transition condition 2 is on ROTATE C WORD function is executed 2 It rotates the designated bit array from STRT 13 to END 3 of SRC 16 A5A5 2 times in the chosen direction set by STRT and END from STRT to END refer to the diagram as below 3 The result data after rotation is written at SRC 16 896D and the overflowing bit 0 is written at OUT STRT 13 END 3
151. ession 3 1 1 Identifiers gt Alphabet and all letters starting with underline and all the mixed letters with numbers and underlines can be identifiers gt Identifiers are used as variable names gt Blank space is not allowed in identifiers gt case of variables identifiers are generally 16 letters of the alphabet while input output variable and instance 8 letters of the alphabet gt There s no difference between small letters and capitals in alphabet all the letters of the alphabet are recognized as capitals Capital letters and numbers IW210 IW215Z QX75 IDENT Capital letters numbers and underline LIM SW 2 LIMSW5 ABCD AB CD Capital letters and numbers starting with the MAIN 12V7 ABCD underline _ 3 1 2 Data Expression The data GLOFA PLC is numbers a string of characters time letters etc Examples Integer 12 0 123 456 986 12 0 0 0 0 456 3 14159 26 1 34 12 1 0E 6 1 234E6 2 1111_ 1111 2 1110_0000 8 377 decimal 255 8 340 decimal 224 16 FF decimal 255 16 E0 decimal 224 BOOL data 0 1 TRUE FALSE Octal number Hexadecimal number 3 1 3 Common Elements 3 1 2 1 Numbers gt There are integer and real numbers gt Discontinuous underline _ can be placed between numbers and it doesn t have any meaning gt Decimal complies with general decimal literal expression and if there is a decimal point this will be real numbers
152. etting SET is out of its range 0 99 gt error occurs DONE is off and step output maintains its previous step 8 215 8 Basic Function Function Block Library B Program Example In case of SET function ST O JP 1 0 using SC1 group z input condition toclear SC1 S BIT 1 S BIT 2 S BIT 2 Step control produces an output when the previous step is on and its present condition is on 8 216 8 Basic Function Function Block Library B Program Example In case of JUMP function ST_O JP_1 1 using SC2 group last input priority Row 0 Row 1 Row 2 Row 3 Row 4 Row 5 Row 6 Row 7 Row 8 Row 9 Row 10 Row 11 Row 12 Row 13 Row 14 NO 1 M2 M3 M4 S O 1 S_Of23 S 98 S O 0 1 On Off Off Off 2 3 On On On Off 4 8 217 8 Basic Function Function Block Library TMR Integration Timer Model GR M a GAW Application Input IN operation condition for Timer PT preset time RST reset Output Q timer output ET elapsed time E Function gt When IN is 1 elapsed time is produced at ET D Even if IN is O before ET reaches PT ET keeps its value If IN is 1 again elapsed time is produced at ET integrating its previous value gt If ET reaches PT iis 1 gt IFRSTis 1 Q and ET a
153. f VAL3 whose data type is INT stores the result in CR After comparison operation for the current CR value and the moved CR value stored in other place stores the result in CR As the stored CR current CR CR will be 0 Stores the CR value in VAL3 whose data type is BOOL B VAL2 FALSE 5 IL 16 LE Meaning After comparison operation for CR and the operand value stores the BOOL result in CR CR will be 1 only if CR is greater than operand A data type of both CR and the operand should be the same The operand value does not change After operation a data type of CR will be BOOL regardless of the operand data type deferred operation Constant is also available Examples In case that VAL1 50 VAL2 100 IVAL 3 70 The value of VAL2 whose data type is INT is loaded in CR After comparison operation for CR and the value of VAL1 whose data type is INT stores the result in CR As VAL1 I VAL2 CR will be 0 Stores CR value in B VAL1 whose data type is BOOL B VAL1 lt FALSE The value of VAL1 whose data type is INT is loaded in CR After comparison operation for CR and the value of VAL2 whose data type is INT stores the result in CR As VAL1 I VAL2 CR will be 1 Stores CR value in B VAL2 whose data type is BOOL B VAL2 TRUE LD VAL 1 The value of VAL1 whose data type is INT is loaded in CR LE 1 VAL2 Moves CR value in other place and stores the value of VAL2 whose data type is
154. gram Example This is the program that sets the output contact 00 3 1 when the increase counter pulse input enters the input contact 10 1 15 ten times CAL CTU COUNT U CU 10 1 15 R 10 1 5 10 LD COUNT V Q ST COUNT Q LD COUNT CV Q ST COUNT CV LD COUNT Q S 00 3 0 8 Basic Function Function Block Library 1 2 3 4 Register the name of CTU function block COUNT U Make the input contact 10 1 15 attached to CU Set the PV value as 10 1 2 3 4 Assign input contact 10 1 5 to the reset input 5 Set the CV value as the random output variable COUNT CV 6 Set the value as the random output variable COUNT Q 7 8 9 0 1 15 10 When the up counter pulse input enters the input contact 10 1 15 ten times CV COUNT OV will be 10 and Q COUNT CV 1 12 If COUNT is 1 the output contact 00 3 0 will be set Compile and write your program to the PLC after completing the program After writing change the PLC mode Stop Run The current value CV COUNT OV increases by 1 when the pulse input enters the input contact 8 186 8 Basic Function Function Block Library CTUD Up Down Counter function block Model ae Application CU up counter pulse input CD down counter pulse input R reset LD loads a preset value
155. has its instance name This instance contains data to be executed in this program Reference For the instance refer to 3 5 2 Function Block 2 3 1 2 Resource Global Variable gt variables defined in resource global variable can be used any program of the resource All the data to be shared among programs are defined in resource global variables gt If users want to use resource global variables in their programs variables are supposed to be declared as VAR EXTERNAL Reference For a variable type refer to 3 3 2 Variable Declaration 2 2 2 The Structure of Software 2 3 1 3 Task gt gt Task means a condition to execute program Task definitions contain designation of program execution condition and priority There are 3 types of program execution conditions as follows 1 Single executes once if the setting condition is satisfied The condition is set as a name of BOOL variable 2 Interval executes periodically per a setting time The condition is set as elapsed time value Refer to 3 1 2 3 1 Duration for how to set the elapsed time value 3 Interrupt executes once if the contact of an interrupt card is ON The condition is set as the contact number of an interrupt card Execution conditions Set ng 96IX0 0 1 Executes once if input contact point 96IX0 0 1 is ON Interval 15 Executes per second Interrupt 4 Executes once if the contact 4 of an interrupt card is ON
156. he number of pointers to be loaded If it s on the input mode output OUT is O 8 207 8 Basic Function Function Block Library Function FIFO variable type Description FIFO Q BOOL It functions as FIFO for BOOL type data FIFO B BYTE It functions as FIFO for BYTE type data FIFO W WORD It functions as FIFO for WORD type data FIFO DW DWORD It functions as FIFO for DWORD type data FIFO LW LWORD It functions as FIFO for LWORD type data FIFO SI SINT It functions as FIFO for SINT type data 1 It functions as for INT type data FIFO DI DINT It functions as FIFO for DINT type data FIFO LI LINT It functions as FIFO for LINT type data FIFO USI USINT It functions as FIFO for USINT type data FIFO UI UINT It functions as FIFO for UINT type data FIFO UDI UDINT It functions as FIFO for UDINT type data FIFO ULI ULINT It functions as FIFO for ULINT type data FIFO R REAL It functions as FIFO for REAL type data FIFO LR LREAL It functions as FIFO for LREAL type data FIFO TM TIME It functions as FIFO for TIME type data FIFO DAT DATE It functions as FIFO for DATE type data FIFO TOD TOD It functions as FIFO for TOD type data FIFO DT DT It functions as FIFO for DT type data IN 8 FIFO 2 FIFO 2 EM t FIFO 1 FIFO 0 Before FIFO 3 FIFO 2 Before E After 8 208 8 Basic Function Function Block Library E Program Examp
157. i vi de DARD i nto 2 V RD data WRD DRD into Coni ne tvo data i LVERD Convert a string into a byte array ARY TO STR NG Convert a byte array into a stri ng 7 1 11 Stack Operation Function ooo FI FO First In First Qt LI FO Last In First Qt 7 Function and Function Block 7 2 MK MASTER K Function Descri pti on n be extended up to 8 Output a positi on of bit by Turn a sel ected bit on 2 3 a of On bit Convert BCD HEX i nto 7 segnent code 6 Increase IN data Decrease IN data 7 3 Array Operation Function m Function 0 O a Filling an array wth deta 6 arsch bit shift left weh carry 00000 02 8 suet am shift array elenmts 00000 02 9 Rotates array ___ 7 4 Basic Function Block 7 4 1 Bistable Function Block Function B ock Set preference bi stabl e BI ol Reset preference bi stabl e 3 SM 7 4 2 Edge Detection Function Block Function B ock n ams Rising edge detector EJ Falli ng edge detector 7 Function and Function Block 7 4 3 Counter m Function Block Description ooo 2 CID 2 CD mome SSS O Dom Counter CR anome S O 7 4 4 Timer TP_RST TP wth reset wth integer setti ng TP wth integer setti ng
158. imer output Q is 1 during a pulse output If RST is 1 output and ET are 0 Preset time is PT x UNIT ms VVVVV Timing Chart RST Preset Ti ne UN T 8 232 8 Basic Function Function Block Library Program Example 2 If input variable TP is 1 output variable OK is 1 And 10 seconds later TIMER OK is 0 Once TP UINT timer is executed input T TP doesn t matter 3 ET TIME value increases and stops at 10000 And if T TP is O it is O 4 If input contact IX1 1 5 is 1 OK and TIME are all cleared 96 Xl 1 5 Preset Ti ne 10 000ns ET 8 233 8 Basic Function Function Block Library TRTG Retriggerable Timer Model M a AW Application e Input IN operation condition for Timer PT preset time RST reset Output Q timer output ET elapsed time Function p IfINis 1 Qis 1 And if elapsed time reaches preset time timer output Q is 0 gt If IN turns on again before elapsed time reaches preset time then elapsed time is set as 0 and increased again And if it reaches PT Q is O gt IF RST is 1 timer output Q and elapsed time ET are 0 E Timing Chart 8 234 8 Basic Function Function Block Library Program Example TIMER OK ET TIME 1 1 15 Preset Ti ne
159. in CR At this time a data type of CR is BOOL After logical OR operation for CR and the value of B VALUE2 whose data type is BOOL stores the result in CR After negating the value of B VALUES logical OR operation is made between CR and the value of B VALUES whose data type is BOOL Stores CR value in B VALUE4 whose data type is BOOL B_VALUE4 lt B VALUE1 OR B VALUE2 OR NOT B VALUE3 The value of W VALUE1 whose data type is WORD is loaded in CR At this time a data type of CR is WORD After logical AND operation for CR and the value of W VALUE2 whose data type is WORD stores the result in CR Stores CR value in W VALUES whose data type is WORD W VALUES lt W VALUE1 ORW VALUE2 The value of B VALUE1 whose data type is BOOL is loaded in CR At this time a data type of CR is BOOL Moves CH value in other place and stores the value of B VALUE2 whose data type is BOOL in CR After logical AND operation for CR and the value of B VALUES3 whose data type is BOOL stores the result in CR After logical OR operation for the current CR value and the moved CR value stored in other place stores the result in CR Stores CR value in B_VALUE4 whose data type is BOOL VALUE4 lt VALUE1 OR VALUE2 AND B VALUE3 5 8 5 IL 7 XOR Meaning After logical XOR operation for CR and the operand value stores the operation result in CR At this time a data type of both CR and the operand should be the same The operan
160. in alphabet and for more information please refer to 3 1 1 Identifiers Configuration contains resource configuration global variables and access variables 2 1 2 The Structure of Software 2 3 1 Resource gt Resource means one CPU module And it is available to define 4 resources in the GM1 Configuration For GM2 GM5 only one resource is available to define This resource has its own name that is also used for communication The resource name is limited up to 8 letters in alphabet and it complies with 3 1 1 Identifiers gt Resource has programs resource global variables and task definitions 2 3 1 1 Program gt Itis an application program that is actually executed on PLC In GLOFA PLC it is available to create several application programs for one resource and set program conditions to run For example you can make programs as follows program A is a general scan program program B is a program executed once in a second program C is an event program that is executed with certain inputs These conditions to execute the program are called Task Users should make an application program as well as set the conditions task definitions Unless task definitions are set this program will be regarded as a scan program Reference Scan program application program that repeats a series of execution from the start to the end after reading input data from input modules and writing the results in output modules gt A program
161. input IN VAL DT DT 1995 12 01 12 00 00 output OUT VAL DATE D 1995 12 01 Input IN1 IN VAL DT DT 1995 12 01 12 00 00 DT TO DATE Output OUT OUT VAL DATE D 1995 12 01 8 29 8 Basic Function Function Block Library DWORD TO DWORD type conversion Model GM m G6 GW Application Input EN executes the function in case of 1 IN bit string to convert 32bit Output ENO without an error it will be 1 OUT type converted data B Function It converts Input IN type and produces output OUT DWORD TO BYTE BYTE Takes the lower 8 bits and converts into BYTE type DWORD TO WORD WORD Takes the lower 16 bits and converts into WORD type C C DWORD TO REAL REAL Converts into REAL type without changing the internal bit array C C DWORD TO LWORD LWORD onverts into L WORD type filling the upper bits with 0 DWORD TO TIME TIME onverts into TIME type without changing the internal bit array DWORD TO TOD onverts into TOD type without changing the internal bit array DWORD TO STRING STRING Changes input value into decimal and converts into STRING type 8 30 8 Basic Function Function Block Librar B Program Example i LD 0 JMPN AA a DUORD TO i LD IN_VAL ERO i a DWORD TO WORD ST OUT VAL IN vaL ovr var 1 If the
162. ion Block Library PUT CHAR Puts a character in a string Model GM L Application els els 5 Input EN executes the function in case of 1 DATA Byte input to insert a string IN string input N setting position in a string Output ENO without an error it will be 1 OUT string output Function It overwrites one byte input on a specific position N string B Error gt If N value exceeds a byte number of a string ERR LER flags set gt error occurs the output is 16800 Program example INPUT RESULT 1 If the transition condition 1 is on PUT CHAR function is executed 2 If input variable INPUT 16441 and STRING IN TOKEN and 2 then output RESULT is TAKEN 8 158 8 Basic Function Function Block Library RAD Converts degree i nto radi an Model GR M a GV6 GW Application e e Input EN executes the function in case of 1 IN degree Input Output ENO without an error it will be 1 OUT radian output E Function gt a degree value into a radian value gt Ifthe degree is over 360 its converts normally For example if input is 370 output is 370 360 10 Function Inputtype Output type Description RAD REAL REAL REAL RAD_LREAL LREAL LREAL It converts a degr
163. ion in case of 1 IN Input value of Arc Tangent operation Output without an error it will be 1 OUT radian output value after operation IN OUT should be the same data type Function It produces an output Arc Tangent value of IN value The output value is between 2 and 7 2 OUT ATAN IN rogram Example ST RESULT 1 If the transition condition 0 is ATAN function will be executed 2 If INPUT 1 0 then output RESULT will be RESULT 2 4 0 7853 1 2 4 TAN 7 4 1 Input IN1 INPUT REAL 1 0 y ATAN Output OUT RESULT REAL 7 85398185E 01 8 9 8 Basic Function Function Block Library BCD TO Converts BCD data into an integer number Model MGR GH GW Application e Input executes the function in case of 1 IN ANY BIT BCD Output ENO without an error it will be 1 OUT type converted data m Function It converts input IN type and produces output OUT Function Inputbpe Output type BCD_TO_SINT BYTE SINT INT It converts BCD data into an output data type It coverts only when the input date type is a BCD value BYTE If an input data type is WORD only the part of its data 0 1649999 will be normally converted m Error If IN is not a BCD data type then the output will be 0 ERR LER flags will be set Program Example 2M0 E
164. ion of PLC program gt program created by the user shall be stored like as a library system so that it can be used in other environment which enables to reuse the software gt Available to support various languages so that the user can select the optimal language suitable for the environment to apply 1 2Type of Language The PLC language standardized by IEC consists of two illustrated languages two character languages and SFC gt Illustrated languages a LD Ladder Diagram A graphical language that is based on the relay ladder logic b FBD Function Block Diagram A graphical language for depicting signal and data flows through function blocks re usable software elements gt Character language a IL Instruction List A low level assembler like language that is based on similar instruction list languages b ST Structured Text A high level language of PASCAL type gt SFC Sequential Function Chart A graphical language for depicting sequential behavior of a control system It is used for defining control sequences that are time and event driven 1 1 1 Overview The languages supported by GLOFA PLC at present are IL LD and SFC E 7 E EN x Choose the language to use SP Peeing PONCUGA ET CHO HICE rein 1 2 2 The Structure of Software 2 The Structure of Software 2 1 Overview Before making a PLC program you should have an overall PLC system
165. is ON function SHL shift Left will be executed and data bit set as input variable shifts to the left by 3 bits and produces output OUT VALUE Input IN1 IN VALUE WORD 16 CCCC N 3 SHL Output OUT OUT_VALUE WORD 16 6660 1 of 0 1 11 0 O o O 8 76 8 Basic Function Function Block Library SHR Shift Righ ar anjar fas aaf Apictim e Input EN executes the function in case of 1 IN bit string to be shifted N bit number to be shifted ANY BIT ANY BIT INT Output without an error it will be 1 OUT the shifted value Function It shifts input IN to the right as many as N bit number N number bit on the leftmost of input IN will be filled with O N will be filled with O B Program Example 0 JMPN AAA LD IN VALUE SHR IN CURRENT RESULT N SHIFT NUM ST OUT VALUE 1 If the transition condition 96MO is on function SHL Shift Left will be executed 2 Data bit set as input variable shift to the right by 3 bits and produces outputs OUT VALUE Input IN1 IN VALUE WORD 16 E331 N 3 WV SHR Output OUT OUT VALUE WORD 16 1C66 ol o of i i o d alal 8 77 8 Basic Function Function Block Library SIN Sine operation ar as ae Adictim e e e jejeje o Input EN executes the function in case of 1 IN input value of Sine operation radian Output ENO without an
166. is stored at NUM The total number is 3 so the output 1 3 0 is on 8 127 8 Basic Function Function Block Library ARY SFT C Array bit shift left wth carry ar mia aw aw micio Fund n scription Input EN executes the function in case of 1 ARY SFT C CYI Input Carry bit Array STRT starting bit to shift END ending bit to shift N bit number to shift Output ENO without an error it will be 1 OUT without an error it will be 1 In Out SRC Source Array to shift CYO Output Carry bit Array after shift B Function gt It shifts as many bits of array elements as they re specified gt Setting Scope it sets a shifting scope with STRT and END Shifting direction and time it shifts N times from STRT to END Input data it fills the empty bits with input data CYI Output the result is stored in ANY BIT ARY and an overflowing bit array data from END is written at CYO E 4 word array 9 CYO J 1 em 0 Before 0 aL BENED In Out Array type ARY SFT C BYTE BYTE ARY SFT C WORD WORD z ARY SFT C DWORD DWORD It shifts as many bits of array elements as they re specified ARY C LWORD LWORD 8 128 8 Basic Function Function Block Library B Error gt If the number of CYI SRC and CYO Array are different ERR and LER flags ar
167. j Output OUT 00 0 1 BOOL 1 16 1 8 33 8 Basic Function Function Block Library ESTOP Emergency running stop by program Model GM GM GW Application e Input executes the function case of 1 REQ requires the emergency running stop Output without an error it will be 1 OUT If ESTOP is executed an output will be 1 E Function gt If transition condition EN is 1 and the signal to require the emergency running stop by program REQ is 1 program operation stops immediately and returns to STOP mode gt In case that a program stops by ESTOP function it does not start despite of power re supply gt If operation mode moves from STOP to RUN it restarts gt If ESTOP function is executed the running program stops during operation if it is not a cold restart mode an error may occur when restarts Program Example SIMS a ie ta 2 lL ha at NS oe sit lean LD 0 2 0 ir dede JMPN SSS LD ACCIDENT ACCIDENT JREQ DUMMY ESTOP P ST DUMMY 1 If the transition condition 9610 2 0 is on ESTOP function will be executed 2 If ACCIDENT 1 the running program stops immediately and returns to STOP mode In case of emergency it is available to use it as a double safety device with mechanical interrupt 8 34 8 Basic Function Function Block Library EXP Natural exponential operation Mode
168. l 9 GJ Application e e e Input EN executes the function in case of 1 IN input value of exponent operation Output ENO without an error it will be 1 OUT result value IN OUT should be the same data type B Function It calculates the natural exponent with exponent IN and produces output OUT OUT e rogram Example ST RESULT 1 If the transition condition 5 is on EXP function will be executed 2 If INPUT is 2 0 RESULT will be 7 3890 e 73890 Input IN1 INPUT REAL 2 0 High ojo o ojojo ojo oj of of of of of of ol Low 16 40000000 Output OUT RESULT REAL 7 38905621 00 in Lo ojo o o o o o of of of of of ofofo EeloTeToToToT1Ti1T 1T 3 1T oT 1 of of o 16 40EC7326 8 35 8 Basic Function Function Block Library EXPT Exponential operation Model Application e e EN executes the function in case of 1 IN1 real number IN2 exponent Output ENO without an error it will be 1 OUT result value IN1 and OUT should be the same data type B Function It calculates IN1 with exponent IN2 and produces output OUT OUT IN1 E Error If an output is out of range of related data type ERR and LER flags will be set Program Example TONNEN
169. l active and continues until deactivated Step connected IN XN Q byD Action T PT ET Step connected S Action EE MEN 4 5 4 5 6 P Pulse It starts the action when the step becomes active and executes the action only once R TRIG Step connected CLE Action by P Step connected by P 1 scan Action 7 SD Stored amp Time Delayed It starts a delay timer when the step becomes active after the time delay the action starts and continues until reset regardless of step activation deactivation Step connected by SD Step connected by R Step connected by SD T Action o A eee Step connected LL by R 4 6 4 5 8 DS Delayed amp Stored It starts a delay timer when the step becomes active after the time delay the action starts if step still active and continues until reset by R qualifier Step connected by DS Action Step connected byR Step connected by DS c gt Action EE 1 Step connected by R 9 SL Stored amp Timed Limited It starts the action when the step becomes active and continues for a set time or until the action is reset regardless of step activation deactivation Step connected by SL Action Step connected by R Step connected by SL Action Step connected HEN by R 4 7 4 5 4 3 Extension Regulation 4 3 1 Serial Connection gt 2
170. l output signal If the material input process is faster than the material output one and every material is loaded so that the STACK MAX is equal to or more than 100 then QU is 1 STACK FULL 1 if there s no material left in the loading part QD is 1 STACK EMPTY 1 At the STORED NUMBER the number of remaining material in the loading part is shown 1 o 0 10 1 0 11 1 0 STORED NUMBE STACK FULL STACK EMPTY 8 188 8 Basic Function Function Block Library F TRIG Falling Edge Detection function block Model GM GP Application input signal F TRIG BOOL Q BOOL Output falling edge detection result Function The output of function block F_TRIG is 1 with the falling pulse input to CLK And 1 scan later without further falling pulse input the output is 0 ever after B Time Chart oll d uer es 4 1 scan or F_TRIG execution time B Program Example CAL F TRIG INS FT CLK 10 0 0 LD INS FT Q ST FALL DETECT If the input variable 9610 0 0 changes from 1 to 0 while detecting its state the output variable FALL DETECT will be 1 And 1 scan later the output variable FALL DETECT will be 0 8 189 8 Basic Function Function Block Librar RS Model GV8 Application e Reset Priority Bistable function block
171. lared as output variable WORK TIME will be T 2D2H30M Input 1 CURRENT DT DT DT 1995 12 15 14 30 00 SUB DATE IN2 START DT DT DT 1995 12 13 12 00 00 Output OUT WORK TIME TIME T 2D2H30M 8 88 8 Basic Function Function Block Library SUB TIME Time subtraction wa _ ar mlar as 4 ae av Amictim e e je je Input executes the function in case of 1 IN1 standard time of day IN2 the time to subtract Output ENO without an error it will be 1 OUT the subtracted result time or time of day OUT data type is the same as the input IN1 type That is if IN1 type is TIME OUT type should be TIME TIME TOD DT B Function gt is TIME it subtracts the time from the standard time and produces OUT time difference gt is TIME OF DAY it subtracts the time from the standard time of day and outputs the time of a day as OUT gt is DATE AND TIME it subtracts the time from the standard date and the time of day and produces the date and the time of day as OUT B Error If the output value is out of range of related data type ERR LER flags will be set If the result subtracting the time from the standard time is a negative number or the result subtracting the time from the time of day is a negative number an error occurs B Program Example 10 0 0 JMPN AAA LD TARGET TIME SUB TIME IN1 2 CURRENT RESULT 2 ELAPSED TIME ST TIM
172. le 11 1 0 LOAD 11 1 1 UNLOAD 11 1 15 RESET 11 1 0 LOAD INS FIF P LOAD FIFO_ REQ DON UNLOAD 5555 QUI OUTPUT 11 1 15 RESET P FIFO INDEX LOAD 1 LOAD FULLFFULL FLAG UNLOAD 5595 FIFO RESET 4RST LOAD FLAG UNLOAD UNLOAD RESET LOAD FULLFFFULL FLAG UNLD EMTYPEMTY FLAG FIFO function block is used as the above The two examples of the above execute the same operation The left one is a program which executes input and output functions at the same time to use only one function block while the right one is a program which executes input and output functions independently to use input function and output function respectively Note that the instance name should be the same on the right program 1 If the input conditions 11 1 0 11 1 1 9611 1 15 are on FIFO INT is executed 2 input contact 96l1 1 0 is on load function is executed 5555 is loaded to FIFO stack and INDEX increased by 1 3 If input contact 96l1 1 1 is on unload function is executed 1111 is unloaded from FIFO stack and PNT INDEX decreased by 1 4 If input contact 11 1 15 is on reset function is executed All the stack of FIFO is cleared as 0 INDEX is initialized as 0 and EMTY FLAG is on 8 209 8 Basic Function Function Block Library LOAD l1 1 0 is ON FIFO FIFO PNT 4 5 UNLOAD 11 1 1 is ON P
173. lication els els 5 Function Input EN executes the function in case of 1 IN1 IN2 Input2 MASK input data to mask Output ENO without an error it will be 1 OUT when equal it will be 1 gt It compares whether two input variables are equal after masking If it masks 8 bit variable with 23111111100 then lower 2 bits are excluded when it compares input values gt It s available to see whether or not specific bits are on in a variable For example in case of comparing 8 bit variables IN1 is an input variable IN2 is 16 FF and MASK for masking is a bit array 24200101100 If IN1 and IN2 after masking are equal then output OUT is 1 Function Input type Description MEQ BYTE BYTE MEQ WORD WORD It compares whether two variables are equal after making MEQ DWORD DWORD MEQ LWORD LWORD 8 156 8 Basic Function Function Block Library E Program example AMO 4Q1 3 20 INPUTI INPUT2 MASK 1 If the transition condition is on MEQ_BYTE function is executed 2 Input variable INPUT1 BYTE 2 01011100 INPUT2 BYTE 2 01110101 MASK BYTE 23111010110 Then the comparing bits of input variables after masking are as follows INPUT1 BYTE 2 01010100 INPUT2 BYTE 2 01010100 INPUT1 and INPUT2 are equal therefore output contact Q1 3 20 is on 8 157 8 Basic Function Funct
174. m the printer control right PRINTER SEMA END VAR Printer control program If print is conpl eted PRINT transfer printer control 8 193 8 Basic Function Function Block Library Linel Linel Line Line3 CLAIM PT Line4 Lines Line Line PRINTING Line Line Line 10 Line 11 Line 12 Line 13 Line 14 Linel3 Line 16 Line 17 Line 18 END Line 19 51 52 PRINT CLAIM PT gt 1 2 Ar 51 52 PRINTING _ gt END gt PRINTER SEMA END CLAI BUSY 0 RELE ASE 51 5 PRINT Printer Output User define Function Block or Program 52 5 51 52 PRINT 8 194 8 Basic Function Function Block Library SR Set Priority Bistable function block Model Aplicaion e Input S1 set condition R reset condition Output Q1 operation result B Function R Q If S1 is 1 output Q1 will be 1 regardless of the state of R The output variable Q1 is 0 and it maintains the previous state when S1 is 0 and R is 1 The initial state of Q1 is 0 Time Chart CAL SR INS S INS S j 1 SR i 31 oil RESULT R RESET1 LD INS 5 01 RESET1 JR ST RESULT
175. mapped out in the aspect of software The overall PLC system is defined as one project in GLOFA PLC In the project all composition elements necessary for the PLC system are defined hierarchically Project Configuration Resource Program Resource global variable Task Configuration global variable Access variable Parameter Basic parameter parameter Link parameter 2 2 Project gt For GLOFA PLC program the first priority should be given to project configuration To make one project means that all the elements necessary for a PLC system scan programs task definitions basic parameters I O parameters etc are programmed A project is divided into two groups configuration and parameter Configuration part is for several definitions of a PLC program such as global variable program task definition and their interrelation Parameter part is for setting parameters necessary for a PLC system operation In this book we deal with Configuration part For parameter part please refer to GMWIN User s Manual 2 3 Configuration gt Configuration means PLC system It consists of a base a CPU module modules and special modules and so on Generally one PLC system has one CPU module 4 CPU modules can be installed GM1 A PLC system has its own name called Configuration name This becomes its unique name during communicating between PLCs Configuration name is limited up to maximum 8 letters
176. n Function Block Librar TP Pulse timer function block Model GV8 Application e els e 2 IN timer operation condition PT preset time TP BOOL BOOL TIME PT TIME Q timer output ET elapsed Time E Function If IN 1 Q will be 1 only during the preset time PT if ET reaches PT will be 0 If IN 1 elapsed time ET starts to be measured and maintains its value after when it reaches PT if IN 2 0 after ET reaches PT 0 The state of IN doesn t matter while ET is measured increased Time Chart rogram Example CAL TP INS TP T TP T 10S LD INS_TP Q ST TIMER_OK LD INS_TP ET ST ET_TIME 8 200 8 Basic Function Function Block Library TIMER OK 105 bo Preset time 10s ET TIME 1 TIMER OK is 1 during 10 seconds after input T TP was asserted T TP 1 While ET TIME increases during 10 seconds the state of input T TP doesn t affect TIMER OK 2 ET TIME increases when it reaches T 10S and then it becomes 0 when T TP 0 8 201 8 Basic Function Function Block Library 8 4 Application Function Block Library 1 This chapter describes each application function block library MASTER K and others 2 Its much easier to apply function block library to your program after grasping the general of function blocks 8 202 8 Basic Function
177. n for CR and the value of D VALUES whose data type is DINT stores the result in CR After ADD operation for the current CR value and the moved CR value stored in other place stores the result in CR D VALUEA Stores the CR value in D VALUE4 whose data type is DINT D_VALUE4 lt D VALUE1 D VALUE2 D VALUE3 5 10 5 IL 9 SUB Meaning After subtraction operation for CR and the operand value stores the operation result in CR At this time a data type of both CR and the operand should be the same The operand value does not change Moves CR value in other place for a while and stores the operand value in CR deferred operation Operand Only SINT INT DINT LINT USINT UINT UDINT ULINT REAL LREAL data types are available Constant is also available Examples VALUE1 The value of VALUE1 whose data type is INT is loaded CR At this time a data type of CR is INT VALUE2 After SUB operation for CR and the value of VALUE2 whose data type is INT stores the result in CR VALUES Stores CR value in VALUES whose data type is INT VALUE lt VALUE1 VALUE2 D VALUE1 The value of D VALUE1 whose data type is DINT is loaded in CR At this time a data type of CR is DINT D VALUE2 Moves CR value in other place and stores the value of D VALUE2 whose data type is DINT CR D VALUES After MUL operation for CR and the value of D VALUES3 whose data type is DINT stores the result in CR After SUB oper
178. n the rung is TRUE the addressed memory bit marked with is set OFF That is if the state of left connection line is OFF the associated variable is ON and if the state of left connection line is ON the associated variable is OFF If the bit controls an output device that output device will be OFF Latched Coils Set coil It sets the associated variable marked with to ON when the left link is in the ON state or TRUE and remains set until reset by a Reset coil When the left link is OFF or FALSE the associated variable is not affected by the Set coil element Reset coil It sets the associated variable marked with to OFF when the left link is in the ON state or TRUE and remains reset until set by a Set coil When the left link is OFF or FALSE the associated variable is not affected by the Reset coil element State Transition sensing Coils Positive transition sensing coil If the state of its left connection that was OFF in the previous scan is ON in the current scan the associated variable marked with is ON during the current scan Negative transition sensing coil If the state of its left connection that was ON in the previous scan is OFF in the current scan the associated variable marked with is ON during the current scan gt Coils are placed in the rightmost side of LD of which right side is a right bus line 6 4 6 LD 6 6 Calling of Function and Function Block gt gt
179. nction will be 0 and SUB function will not be executed and the error ERR and will be on 3 ERR will be on and MOVE function will be executed Input IN1 VALUE1 SINT 100 164264 Output OUT OUT VAL SINT 100 162264 8 1 8 Basic Function Function Block Librar ABS Absolute value operation Model GM M Application 9 5 Function Description Input EN executes the function in case of 1 IN input value of absolute value operation ABS PODE Output ENO without an error it will be 1 ANY NUM IN OU ANY NUM OUT absolute value IN OUT should be the same data type m Function It converts input IN into its absolute value and produces output OUT X an absolute value of X is If X220 X X If lt 0 X OUT IN E Error _ERR _LER flags are set when input IN is a minimum value Ex If IN value is 128 and its data type is SINT an error occurs m Program Example E oe cuu gt D LEER ATA TUNE LD 0 0 0 JMPN AL TED LD VALUE ABS VALUE ST ABS VALUE AL 1 If the transition condition 9610 0 0 is on ABS function will be executed 2 If VALUE 7 ABS VALUE 7 If VALUE 200 ABS VALUE 200 200 VALUE INT 7 EHN 16 FFF9 ABS Output OUT ABS VALUE 7
180. nsion base of which input data are 2 0000 0000 1111 1111 1100 1100 0011 0011 LD IL LD 0 7 JMPN ABC j LD 3 2 RET j DIREC BASE CURRENT RESULT i SLOT 3 i MASK L 164FFFF0000 16 000000 09 MASK 16 FFFFFFFF 16 FFFFFF ST REF_OK FF 1 If input condition 0 is on function DIREC IN will be executed 2 The image scope to update will be ID3 3 0 but only IW3 3 0 will be updated with 241100 1100 0011 0011 during the scan because 16 contact module is installed and the lower 16 bit data update is allowed MASK L 164FFFF0000 8 23 8 Basic Function Function Block Library 3 This is the program that updates the lower 48 bit data of the 64 contact module installed in the 4th slot slot number is 3 of the 3rd extension base of which input data are 16540000 FFFF AAAA 7777 240000 0000 0000 0000 1111 1111 1111 1111 1010 1010 1010 1010 0111 0111 0111 0111 LD IL LD y JMPN ABC LD 3 2 REF DIREC 5 CURRENT RESULT SLOT 3 MASK L 164600000000 16 000000 09 MASK 164FFFF0000 16 ST REF OK 00 1 If the input condition 0 is on function DIREC_IN will be executed 2 The installed module is 64 contact module and the image scope to update will be IL3 3 0 ID3 3 0 and ID3 3 1 3 3 0 will be updated because the lower 32 bit data
181. nt Bit 1 If the transition condition is on BYTE BIT function is executed 2 If INPUT 16 230101100 it distributes INPUT from 001 to 008 in order The order is 2 0 0 1 1 0 1 0 1 8 139 8 Basic Function Function Block Library BYTE TO ASC Converts byte i nto ASA I G6 Description Input EN executes the function in case of 1 IN BYTE input BYTE TO ASC EN Output ENO without an error it will be 1 OUT ASCII output B Function gt It converts 2 digit hexadecimal into two ASCII data 1682 gt 3132 gt In case of 16 A F it produces ASCII data for character B Program example 1 If the transition condition is on BYTE 5 function is executed 2 If input BYTE VAL BYTE 16 output ASCII VAL WORD 1683341 2 3 A 8 140 8 Basic Function Function Block Library BYTE WORD mm mmm 75 O Input EN executes the function in case of 1 LOW lower BYTE Input HIGH upper BYTE Input Output ENO without an error it will be 1 OUT WORD output m Function It combines two bytes into one word LOW lower byte input HIGH upper byte input B Program example 1 If the transition condition M3 is on BYTE WORD function is executed 2 input BYTE IN1 16856 and BYTE IN2 16 AD output variable OUTPUT 16 AD56 8 141 8
182. o or 0 variables gt You can declare variable RETAIN that keeps its data in case of power failure Rules are 1 Retention Variable retains its data when the system is set as Warm Restart 2 In case of Cold Restart variables are initialized as the initial values set by users or the basic initial values as are shown in 3 2 3 Initial Value gt Variables which are not declared as RETAIN are to be initialized as the initial values set by a user or the basic initial values in case of Warm or Cold Restart Reference Variables which are assigned as or Q are not to be declared as VAR RETAIN or VAR CONSTANT gt Users can declare variables Array with Elementary Data Type When declaring the Array Variable users are supposed to set Data Type and Array Size String among Elementary Data Type is not allowed gt Effective scope of variable declaration the area which is available to use the variable is limited to the program where variables are declared And users can t use variables declared in other program in the above area On the contrary users can get an access to Global Variable from other program elements by declaring it as EXTERNAL Configuration Global Variable can be used in all program elements of all resources Resource Global Variable can be used in all program elements of the very resource 3 10 3 Elements Examples of Variable Declaration Vari
183. oaded If it s on the input mode output OUT is 0 8 211 8 Basic Function Function Block Library Function FIFO variable type Description LIFO Q BOOL It functions as LIFO for BOOL type data LIFO B BYTE It functions as LIFO for BYTE type data WORD It functions as LIFO for WORD type data LIFO DW DWORD It functions as LIFO for DWORD type data LW LWORD It functions as LIFO for LWORD type data LIFO SI SINT It functions as LIFO for SINT type data LIFO 1 INT It functions as LIFO for INT type data LIFO DI DINT It functions as LIFO for DINT type data LIFO LI LINT It functions as LIFO for LINT type data LIFO USI USINT It functions as LIFO for USINT type data LIFO UI UINT It functions as LIFO for UINT type data LIFO UDI UDINT It functions as LIFO for UDINT type data LIFO ULI ULINT It functions as LIFO for ULINT type data LIFO R REAL It functions as LIFO for REAL type data LIFO LR LREAL It functions as LIFO for LREAL type data LIFO TM TIME It functions as LIFO for TIME type data LIFO DAT DATE It functions as LIFO for DATE type data LIFO TOD TOD It functions as LIFO for TOD type data LIFO DT DT It functions as LIFO for DT type data 418 Before E After UNLOAD Before E After 8 212 8 Basic Function Function Block Library 81 1 1 UNLOAD P 11 1 15 ET INS LIF LOAD LIFO TM REQ DON 11 1 0 LOAD
184. of a function block are Timer and Counter On delay timer function block is TON and this is executed if IN is ON after users declare T1 as instance In order to use timer output contact and duration value it is required to place a period between the name of instance and the output name In case of a timer function block the output contact and the elapsed time value for the instance are T1 Q and T1 ET respectively because the output contact name is Q and the elapsed time contact name is ET The output value of a function is a return value by calling a function while the output value of a function block is fixed for the instance gt Users cannot declare a direct variable inside a function block However users can use a direct variable declared as Global Variable and allocated according to Assign AT after declaring it as VAR EXTERNAL gt A function block is inserted into a library for use gt Itis not available to call a program inside the function block 3 5 3 Program gt Users can use a program after declaring an instance like a function block gt It is available to use direct variables in the program gt A program does have input output variables The calling of a program is defined in the resource 3 20 4 5 4 SFC Sequential Function Chart 4 1 Overview gt SFC is a structured language that extends an application program in the form of flow chart according to the processing sequence using
185. omitted but don t skip the medium unit between duration units gt Not allowed to use the underline gt Duration data can overflow at the maximum unit if any and the data with a decimal point is available except ms It does not exceed T 49d17h2m47s295ms 32bits by ms unit gt data is limited to the third decimal place the second unit s gt Decimal point is not available at ms unit 3 2 3 Common Elements gt Capital and small letters are both available T 14ms T 14 7s T 14 7m T 14 7h t 14 7d t 25h15m t 5d14h12m18s356ms Duration no underline 3 1 2 3 2 Time of Day and Date gt There are three types expressing Time of Day and Date as follows Date Time of Day Date and Time Prefix as a reserved word Date prefix Time of Day prefix Date and Time prefix gt starting point of date is January 1st 1984 gt There s a limit on Time of Day and Date and Time which is up to the third decimal place in the ms unit gt overflow is not allowed for all the units when expressing Time of Day and Date and Time Content Examples Date D 1984 06 25 d 1984 06 25 oi Day TOD 15 36 55 36 tod 15 36 55 369 DT 1984 06 25 15 36 55 36 Date and Time dtit1984 06 25 15 36 55 369 3 3 3 Common Elements 3 2 Data Type Data has a data type to show its character 3 2 1 Basic Data Type GLOFA PLC supports th
186. onpari son lt INS amp 1 lt amp amp INF 1 IN 7 1 7 Character String Function m Function Find length of a character string 2 ur Take a left side of a string Rar Take a right side of a string Take a middle side of a string Concatenate the input character string in order NSERT Insert a string 7 Delete a sting REPLACE Replace a string Find a string 7 Function and Function Block 7 1 8 Time Time of Day Date and Time of Day Function m Furetion 0 Add tine Ti ne ti ne of day date and ti ne addi ti on SUB TI ME Subtract ti ne 2 SUB DNE SUB TCD Subtract TCD 3 Eur 5 amne Concatenatedatewith TOD o 7 1 9 System Control Function m ooo 1 D invalidates interrupt Not to permit task program starting 2 d Permits running for a task program 3 ste Stop runing by a task program o D REC IN Update input data available for GM 5 sj omo Updates output data available in M Initialize a ti ner of watchdog MS ste rtr fo Set MSAR Master Control ear 7 Function and Function Block 7 1 10 Data Manipulation Function m Function Oio O 4 BTBTE Gonbine 8 bits into one byte oo 6 BEW Combine two bytes into D vi de one WORD i nto tw bytes 8 wom two data into DARD L
187. ot shortened because the instructions between MCS and MCSCLR function are executed as the above gt Nesting is available in MCS That is to say Master Control is divided by Nesting NUM You set up Nesting NUM from 0 to 15 and if you set it more than 16 MCS is not executed normally Note if you use MSC without MCSCLR MCS function is executed till the end of the program 8 153 8 Basic Function Function Block Library E Program example 8 154 If Ais on it s executed If A and B are on it s execut ed If A B and C are on it s execut ed If Aand Bare on it s executed If Ais on it s executed If A B and C are on it s execut ed 8 Basic Function Function Block Library MCSCLR Master Control ear Model QR a4 Application e e Input EN executes the function in case of 1 NUM Nesting 0 15 Output ENO if MCSCLR is executed it will be 1 OUT if MCSCLR is executed it will be 1 E Function gt It clears Master Control instruction And it indicates the end of Master Control gt If MCSCLR function is executed it clears all the MCS instructions which are less than or equal to Nesting NUM There s no contact before MCSCLR function B Program example Refer to the MCS function example 8 155 8 Basic Function Function Block Library M EQ Masked Equal Model App
188. pe is BOOL at the first row And if the value is 0 at the second row it jumps to THERE label If IX0 0 0 value is 1 it does not execute JMP instruction but does the next row gt When calling a function block CAL is used as an operator and the instance name as operand that is previously declared gt CAL INSTANCE function block unconditionally CALN INSTANCE if CR is BOOL 0 call a function block CALC INSTANCE if CR is BOOL 1 call a function block Here INSTANCE should be previously declared as an instance of a function block gt CR is not loaded in a function block input So it is required to assign all the input values necessary for a function block Besides output value is not stored in CR Example On Delay Timer function block LD 961X0 0 0 CALC TON TIMERO 96IX0 1 2 PT 2005 LD TIMERO Q ST QX1 0 2 assume that TIMERO is declared as an instance of TON On delay timer has 2 inputs and calls it after assigning its input values respectively If users want to use the result values they can do it like the fifth row in the above program because the result values are stored in TIMERO Q and TIMERO ET respectively 5 25 6 10 6 LD Ladder Diagram 6 1 Overview gt LD program represents PLC program through graphic signs such as coil or contact used in relay logic diagram gt Configuration Line no Function block jf Rung comment Line0 This i
189. put is the highest on bit position among IN bit string Input data types are BYTE WORD DWORD and LWORD LWORD is available only for GM1 2 FUNCTION IN type Description ENCO BYTE BYTE ENCO WORD WORD ENCO DWORD DWORD ENCO LWORD LWORD You can select one of these functions according to the input data type B Error ERR and LER flags are set and OUT is 1 if no bit is 1 rogram example JMPN AAA i LD SWITCHS ON POSITI ENCO W ON ST ON_POSITION AAA 1 If the transition condition M0 is on ENCO_WORD function is executed 2 If SWITCHS WORD 2 0000 1000 0000 0010 then the highest on bit position is 11 Therefore output ON POSITON INT is 11 8 149 8 Basic Function Function Block Library GET CHAR Gets one character froma character string Model GR M GV6 GW Application e e Input EN executes the function in case of 1 IN STRING input N position in a character STRING Output ENO without an error it will be 1 OUT Byte Output E Function It extracts one byte from a character STRING starting from N B Error gt ERR LER flags are set if N exceeds the number of byte in STRING gt error occurs the output is 16 200 B Program example OUTPUT 1 If the transition condition is GET CHAT function is executed 2 When input INPUT STRING LG GLOFA
190. r the current CR value and the moved CR value stored in other place stores the result in CR As the stored CR current CR CR will be 1 Stores the CR value in VAL3 whose data type is BOOL B VAL3 TRUE 5 16 5 IL 15 NE Meaning After comparison operation for CR and the operand value stores the BOOL result in CR CR will be 1 only if CR is greater than operand A data type of both CR and the operand should be the same The operand value does not change After operation a data type of CR will be BOOL regardless of the operand data type deferred operation Constant is also available Examples In case that VAL1 50 VAL2 100 IVAL 50 The value of VAL1 whose data type is INT is loaded in CR After comparison operation for CR and the value of VAL2 whose data type is INT stores the result in CR As VAL1 1 VAL3 CR will be 0 Stores CR value in B VAL1 whose data type is BOOL B VAL1 lt FALSE The value of VAL2 whose data type is INT is loaded in CR After comparison operation for CR and the value of VAL1 whose data type is INT stores the result in CR As VAL1 lt gt VAL2 CR will be 1 Stores CR value in VAL2 whose data type is BOOL B VAL2 TRUE LD VAL 1 The value of VAL1 whose data type is INT is loaded in CR NE VAL2 Moves CR value in other place and stores the value of VAL2 whose data type is INT in CR SUB After SUB operation for CR and the value o
191. re Output 1 lt IN1 IN2 Val Val lt output where Val is an internal variable This cannot be a function as there is internal variable Val To have an internal variable means that an output will be different even if there is a same input Output 1 value is subject to change because of Val variable even if the value of IN1 and IN2 are constant as is shown on the above Compared with the above function A function A will have output 1 value 150 when IN1 is 20 and IN2 is 30 This shows that the output value will be constant if inputs are constant An internal variable of a function is not available to have an initial value Users can t declare a function as VAR EXTERNAL and use it It is not available to use direct variables inside the function A function will be called by program elements and used V VV Data transfer from program composition elements which call the function to the function will be executed through an input of a function 3 18 3 Elements Example EN SL Eno TEST IN QUT E QUTPUT NO N SHL function is a basic function that shifts input IN to the left as many as N bit number and produces it as an output Program composition elements call SHL function assigning a value of TEST variable to input IN and a value of NO variable to input N The result will be stored in OUTPUT variable gt A function is inserted into a library for use gt Itis not available to call a
192. re 0 B Timing Chart E 8 218 8 Basic Function Function Block Library E Program Example OK ET TIME T TM 1 1 12 10s ET 1 If 10 seconds passes after input variable T TMR is 1 output variable TIMER is 1 2 Elapsed time is produced at ET TIME after T is 1 3 ET TIME keeps its value even if T TMR is 0 before ET TIME reaches its preset time 10 seconds 4 If T TMR is 1 elapsed time is produced at ET TIME integrating its previous value 5 If input contact l1 1 12 is 1 elapsed time ET TIME and output variable TIMER OK are all cleared 8 219 8 Basic Function Function Block Library TMR FLK TMR with Flicker Model GM Application Input IN operation condition for Timer ON TON setting time OFF TOF setting time Output Q Timer output ET elapsed time E Function p IfINis 1 Qis 1 and maintains its value during TON setting time gt After TON setting time set by ON is 0 during TOF setting time gt If IN is 0 it stops its function of either on or off operation and keeps its time If IN is 1 again it is executed with its previous data gt Output is 0 while IN is 0 gt is 0 output is always 0 B Timing Chart CFF 8 220 8 Basic Function Function Block Library E Program Example T_TMR_FR
193. red time to work WORK TIME declared as output variable will be T 2H20M30S500MS Input 1 END_ TIME TOD TOD 14 20 30 5 SUB_TOD START TIME TOD TOD 12 00 00 Output OUT WORK TIME TIME T 2H20M30S500MS 8 90 8 Basic Function Function Block Library TAN Tangent Operation ar as ae Applicationle jo Applied only in GM4 CPUC among GM4 series Description Input EN executes the function in case of 1 IN tangent input value radian EN ENO BOOL Output ENO without an error it will be 1 IN OUTIF ANY REAL OUT the result value of Tangent operation IN OUT should be the same data type B Function It performs Tangent operation of IN and produces output OUT OUT TAN IN B Program Example 0 RESULT 1 If the transition condition is ON function TAN Tangent operation will be executed 2 If the value of input variable declared as INPUT is 0 7853 v4 45 RESULT declared as output variable will be 1 0000 TAN 24 1 Input IN1 INPUT REAL 0 7853 V Output IN2 RESULT REAL 9 99803722 01 8 91 8 Basic Function Function Block Library TIME TO TIME type conversion ar as ae Gv Apictim e jejejeje Input executes the function in case of 1 IN time data to be converted TIME TO Output ENO without an error
194. rent contact or memory variables It does not change the value of variable itself related to the contact Standard contact symbols are as follows Static contact Normally open contact When the addressed memory bit marked with is ON the instruction is TRUE which transmits the state of the left connection line to the right one Otherwise the state of the right connection line is OFF Normally closed contact When the addressed memory bit marked with is OFF the instruction is TRUE which transmits the state of the left connection line to the right one Otherwise the state of the right connection line is OFF State transition sensing contact Positive transition sensing contact When the addressed memory bit marked with that was OFF in the previous scan is ON it maintains ON state during one scan current scan Negative transition sensing contact When the addressed memory bit marked with that was ON in the previous scan is OFF it maintains ON state during just one scan current scan 6 3 6 LD 6 5 Coil gt Coil stores the state of the left connection line or the processing result of state transition in the associated BOOL variable Standard coil symbols are as follows Description Momentary Coils Coil When the rung is TRUE the addressed memory bit marked with is set ON If the bit controls an output device that output device will be ON Negated coil Whe
195. result in CR As the stored CR current CR CR will be 1 Stores the CR value in VAL3 whose data type is BOOL B VAL3 TRUE 5 14 5 IL 13 GE Meaning After comparison operation for CR and the operand value stores the BOOL result in CR CR will be 1 only if CR is greater than operand A data type of both CR and the operand should be the same The operand value does not change After operation a data type of CR will be BOOL regardless of the operand data type deferred operation Constant is also available Examples In case that VAL1 50 VAL2 100 IVAL 70 The value of VAL1 whose data type is INT is loaded in CR After comparison operation for CR and the value of VAL2 whose data type is INT stores the result in CR As VAL1 lt VAL2 CR will be 0 Stores CR value in B VAL1 whose data type is BOOL B VAL1 lt FALSE The value of VAL2 whose data type is INT is loaded in CR After comparison operation for CR and the value of VAL1 whose data type is INT stores the result in CR As VAL1 I VAL2 CR will be 1 Stores CR value in B VAL2 whose data type is BOOL B VAL2 TRUE The value of VAL1 whose data type is INT is loaded in CR Moves CR value in other place and stores the value of VAL2 whose data type is INT in CR After SUB operation for CR and the value of VAL3 whose data type is INT stores the result in CR After comparison operation for the current CR value and the moved C
196. ror it will be 1 OUT swapped data B Function It swaps upper data for lower data Function Input type Description SWAP BYTE BYTE Swaps upper nibble for lower nibble data SWAP WORD WORD Swaps upper byte for lower byte data SWAP DWORD DWORD Swaps upper word for lower word data SWAP LWORD LWORD __ Swaps upper double word for lower double word data RESULT 1 If the transition condition 0 is on SWAP BYTE function is executed 2 If INPUT BYTE 16 5F RESULT BYTE 16 F5 8 175 8 Basic Function Function Block Library UN Uni tes data Model Appl i cati on B Function Input EN executes the function in case of 1 IN input data array SEG bit number designate array to unite data Output ENO without an error it will be 1 OUT united data It unites an input data array from the lower bit to a designated bit set by SEG and produces an output Function Inputtype Output type Description UNI BYTE BYTE BYTE UNI WORD WORD WORD It cuts an input array into bit data set by SET and produces an UNI DWORD DWORD DWORD output united data with the same array type of input UNI LWORD LWORD LWORD b15 i SEG U 3 IN 15 SEGUTL4 wi IN 82 81180 b15 2 5 mam Tea es ez ei co b15 SEGG 4 320 YD 615
197. ry SHIFT A Shifts array el enents Model GR M a GV6 GW Application e e Input EN executes the function in case of 1 IN Input data to empty element after shifting N number to shift STRT starting position to shift in an array block END ending position to shift in an array block Output ENO without an error it will be 1 OUT overflowing data In Out SRC array block to shift m Function gt It shifts designated elements of an array block in the chosen direction gt Setting Scope STRT and END set a data array to rotate Shifting direction and time rotates times in the chosen direction set by STRT and END STRT END Input data setting fills an empty element after shifting with input data IN Output the result is written at ANY ARY designated by SRC and the overflowing data by shifting from END to STRT is written at OUT SRC SRC Before After 8 170 8 Basic Function Function Block Library Function In Out Array Type Description SHIFT A BOOL BOOL SHIFT A BYTE BYTE SHIFT A WORD WORD SHIFT A DWORD DWORD SHIFT A LWORD LWORD SHIFT A SINT SINT SHIFT A INT INT SHIFT A DINT DINT SHIET A USINT UENIT 2 elements of an array block the chosen SHIFT A UINT UINT SHIFT A UDINT UDINT SHIFT A ULINT ULINT SHIFT A REAL REAL SHIFT A LREAL LREAL SHIFT A TIME T
198. s decimal round off If integer number of input is 2 2 1 normal conversion LREAL TO DINT DINT Otherwise an error occurs decimal round off If integer number of input is 2 29 1 normal conversion LREAL TO LINT LINT Otherwise an error occurs decimal round off If integer number of input is 0 255 normal conversion LREAL TO USINT USINT Otherwise an error occurs decimal round off If integer number of input is 0 65 535 normal conversion LREAL TO UINT UINT Otherwise an error occurs decimal round off If integer number of input is 0 232 41 normal conversion LREAL TO UDINT UDINT Otherwise an error occurs decimal round off If integer number of input is 0 264 1 normal conversion Otherwise an error occurs decimal round off LREAL TO LWORD LWORD Converts into LWORD type without changing the internal bit array Converts LREAL into REAL type normally LREAL TO REAL REAL During the conversion an error caused by the precision may occur B Error LREAL TO ULINT ULINT If an overflow occurs because an input value is greater than the value available for the output type ERR and LER flags will be set If an error occurs an output will be 0 8 51 8 Basic Function Function Block Librar B Program Example E ID ma LD LREAL VAL LREAL TO REAL i ENO LREAL TO REAL ST REAL_VAL REAL VALjJINI OUT REAL VAL 1 If the inpu
199. s an example of LD program m T Function THERE START TON SIGN UP Label Linel f Line SET TIME JPT DATAL DATAS Line DATAZ Rung C ontact 210 0 0 Jump label Lined 4 DOUN Horizontal link Vertical link THERE gt Left bus line Right bus line 6 2 BusLine gt line as power line is placed vertically on both left and right sides on LD graphic diagram Description Left bus line Its value is always 1 BOOL Right bus line The value is not fixed 6 1 6 LD 6 3 Connection Line gt value BOOL 1 of left bus line is transmitted to the right side by the ladder diagram The line that has the transmitted value is called as power flow line or connection line which is connected to a contact or coil Power flow line has always a BOOL value and there s only one power flow line in one rung that is connected by lines gt There are two types of a connection line of LD horizontal connection line and vertical connection line Symbol Horizontal connection line It transmits the left side value to the right side Vertical connection line It s logical OR of horizontal connection lines of its left side 6 2 6 LD 6 4 Contact gt Contact transmits a value to the right horizontal connection line which is the result of logical AND operation of these the state of left horizontal connection line Boolean input output related to the cur
200. s out of range of related data type ERR and LER flags will be set B Program Example 0 JMPN AAA LD VALUE1 SUB QJRRENT RESULT 2 VALUE2 ST OUT_VAL 1 If the transition condition 96MO is ON function SUB will be executed 2 If input variables VALUE1 300 VALUE2 200 OUT VAL will be 100 after operation Input IN1 VALUE1 INT 300 16 012C af of a d q SUB 2 VALUE2 INT 200 16 00C8 Output OUT OUT_VAL INT 100 16 0064 8 86 8 Basic Function Function Block Library SUB DATE Date subtraction wa _ ar mlar as 4 ae av Amictim e je je Input EN executes the function in case of 1 IN1 standard date IN2 the date to subtract Output ENO without an error it will be 1 OUT produces the difference between two dates as time data B Function It subtracts IN2 specific date from IN1 standard date and outputs the difference between two dates as OUT B Error If output value is out of range TIME data type ERR and LER flags will be set An error occurs 1 when date difference exceeds the range of TIME data type T 49D17H2M47S295MS 2 the result of date operation is a negative number 10 0 0 JMPN PPP LD CURRENT DATE SUB DATE IN1 CURRENT RESULT 2 START DATE ST WORK DAY 1 If the transition condition 9610 0 0 is ON function SUB DATE will be executed 2 If input variable C
201. scan executing a scan program because a scan synchronized batch processing mode executes the batch processing to read input data and produce output data after a scan program gt It s available to update related output data if you use DIREC_O function during program execution gt If the base slot number is wrong or it is not available to write data normally in an output module ENO and OUT are 1 without an error it will be 1 B Program Example 1 This is the program that produces output data 240111 0111 0111 0111 in 16 contact relay output module installed in the 5th slot slot number is 4 of the 2nd extension base LD IL LD 9610 0 0 JMPN AAA DIR LD 2 DIREC CURRENT RESULT SLOT 4 MASK L 16 FFFF0000 MASK H 16 FFFFFFFF ST REF OK AAA 8 25 8 Basic Function Function Block Library 2 Set MASK L as 164FFFF0000 because the output data to produce are the lower 16 bits among the output contacts 3 If the transition condition 9610 0 0 is on DIREC_O will be executed and the data of the output module will be updated as 270111 0111 0111 0111 during the scan 2 This is the program that updates the lower 24 bits of the 32 contact transistor output module installed in the 5th slot slot number is 4 of the 2nd extension base with 241111 0000 1111 0000 1111 0000 DIA OK BASE CURRENT RESULT 4 j SLOT 4 MASK_L 16 FF000000 16 FF0000 E
202. steps are always divided by transitions without connecting directly gt Step always divides 2 transitions without connecting directly n Ls EN T T correct example wrong example gt For the transition between steps connected by serial the lower step will be activated if the upper step is active and the transition condition connected to the next is 1 4 3 2 Selection Branch gt When a processor executes a selection branch the processor finds the first path with a true transition in the order of the program scan and executes the steps and transitions in that path If more than one path in a selection branch goes true at the same time the processor chooses the left most path The following example shows a typical scan sequence Example In case that the transition condition of T1 is 1 the order of activation will be 1 gt S2 gt S3 In case that the transition condition of T4 is 1 the order of activation will be 1 gt S4 gt S3 In case that the transition condition of 5 is 1 the order of activation will be 1 gt 55 gt S3 If the transition conditions are 1 at the same time the processor chooses the left most path In case that the transition condition of T1 and T4 is 1 at the same time the order of activation will be 1 gt S2 gt S3 In case that the transition condition of T4 and T5 is 1 at the same time the order of activation will be 1 gt S4 gt S3 4 8 4 5
203. string to output STRING INT ENO without an error it will be 1 INT OUT output character string Function It produces a character string L of IN from the P character B Error If character number of variable IN lt P P lt 0 or lt 0 then ERR and flags will be set LD IN TEXT IN TEXT OUT TEXT MID IN CURRENT RESULT L LENGTH MENSEN P POSITION ST OUT_TEXT POSITION JP MM 1 If the transition condition 9610 0 0 is on MID function will be executed 2 If input character string IN TEXT ABCDEFG the length of character string LENGTH 3 and starting location of character starting POSITION 2 output variable OUT TEXT BCD Input IN IN TEXT1 STRING ABCDEFG L LENGTH INT 3 P POSITION INT MID Output OUT OUT_TEXT BCD 8 57 8 Basic Function Function Block Library MIN Minimum value Med ar aa Gs 94 a6 e e le le le Input EN executes the function in case of 1 IN1 value to be compared IN2 value to compare Input variable number can be extended up to 8 Output ENO without an error it will be 1
204. t condition 0 is on LREAL TO REAL function will be executed 2 If input variable LREAL_VAL LREAL 1 34E 12 output variable REAL VAL REAL 1 34E 12 Input 1 LREAL VAL LREAL 1 34 12 V LREAL TO REAL Output OUT REAL VAL REAL 1 34E 12 8 52 8 Basic Function Function Block Library LT Less than comparison Model M M M Application e e EN executes the function in case of 1 IN1 the value to be compared IN2 the value to compare Input variable number can be extended up to 8 IN1 IN2 should be the same data type ENO without an error it will be 1 OUT comparison result value B Function If IN1 IN2 IN3 INn n input number output value OUT will be 1 Otherwise output OUT will be 0 Program Example VALUE1 LT IN1 CURRENT RESULT UALUEl IN2 VALUE2 IN3 VALUES HEURE ST 00 0 1 VALUE 1 If the transition condition 0 is LT function will be executed 2 If input variable VALUE1 100 VALUE2 200 and VALUES 300 output Q0 0 1 1 Input IN1 VALUE1 INT 100 16 0064 IN2 VALUE INT 200 16 00C8 ETE VELO IN3 VALUES INT 300 1680120 1 o i 1 o o Output OUT 00 0 1 BOOL 1 164 lt 8 8 Basic Function Function Block Library LWORD TO LWOR
205. ted data E Function It converts input IN type and produces output OUT B Error If a conversion error occurs ERR LER flags will be set If an error occurs take as many lower bits as the bit number of the output type and produces an output without changing the internal bit array 8 41 8 Basic Function Function Block Librar B Program Example LD 3M0 INT TO WORD EN ENO LD IN VAL IN vaL 4 ovr ovr wor i INT TO WORD ST OUT WORD AAA 1 If the input condition 0 is on INT TO WORD function will be executed 2 If input variable IN VAL INT 512 164200 output variable OUT WORD WORD 162200 Input IN1 IN VAL INT 512 168200 oj of of of of of of o V INT TO WORD Output OUT OUT WORD WORD 165200 o o Jo o o o 1 o of of of of of of of o 8 42 8 Basic Function Function Block Library LE Less than or equal to comparison Model GML GJ Application e e EN executes the function in case of 1 IN1 the value to be compared IN2 the value to compare Input variable number can be extended up to 8 IN1 IN2 should be the same data type ENO without an error it will be 1 OUT comparison result value E Function If IN1 IN2 lt INS lt
206. tes 25 Hours Modify RTC data B Program example Its RTC data is 1999 01 17 11 53 24 Sunday OWENT then SET 3X9 E E RTC SET iunctio block renews or modifies the SET data HTC data SET 3 RTC SET REQ DUNE Row 2 aET LA ERROR Row 3 1 When SET_SW is on RTC_SET function block renews or modifies the SET_data RTC data 8 165 8 Basic Function Function Block Library 2 Variable setting is shown as below 3 You can set each TIME data using MOVE function 8 166 8 Basic Function Function Block Library 4 Use the following flags to read RTC data e g 1998 12 22 19 37 46 Tuesday Flag Type Description Data _RTC_TOD TOD Current time of RTC TOD 1 9 37 46 UINT Current day of RTC RTC WEEK 0 Mon 1 Tue 2 Wed 3 Thu 4 Fri 1 5 Sat 6 Sun DATE Current date of RTC en Pale 1984 01 01 2083 12 31 _ ERR BOOL When RTC data is wrong it is 1 0 BCD BCD data of current time of RTC _ _TIME 0 Last 2 digit number of years _ _TIME 1 Months _ _TIME 2 Dates _ _TIME 3 Hours _ _TIME 4 Minutes _ _TIME 5 Seconds _ TIME 6 Days _ _TIME 7 First 2 digit number of years Days 0 Mon 1 Tue 2 Wed 3 Thu 4 Fri 5 Sat 6 Sun _ TIMEQ O 16498 _ TIME 1 16412 TIME 2 16422 _ TIME 3 16419 _ TIME 4 16837
207. there is only one CR in IL it is available to execute the delayed operation CR is kept while other operations are executed and after that operation will be done with the stored CR value Type Characteristic Operation is delayed Evaluation deferred operation used with 5 2 5 IL Example AND lX1 0 0 OR IX2 0 0 CR lt CR AND IX1 0 0 OR IX2 0 0 This means that the execution of AND will be delayed until 9 appears After the operation inside the parentheses IX1 0 0 OR 961X2 0 0 is executed the operation with the result will be done gt Modifier indicates that the attached instruction must be executed only if the current result has the Boolean value 1 TRUE Example JMPC THERE If CR is BOOL 1 jump to THERE 5 3 3 Basic Operator Basic operators are as follows 1l iD N Daa current results equal to operand eper tae current results to operand BOOL If CR is BOOL 1 set Boolean Operand to 1 BOOL If CR is BOOL 1 set Boolean Operand to 0 Boolean AND operation Boolean OR operation Boolean XOR operation Addition operation Subtraction operation Multiplication operation Division operation Comparison operation gt greater than Comparison operation gt greater than or equal to Comparison operation equal to Comparison operation not equal Comparison operation less than or equal to Comparison operation less
208. ting per second 2 Task program increasing by executing second 1 P LDN 1 JMPN MM 19U0 0 0 JINI 9100 LD IW0 0 0 MOVE ST MW 100 MM 1 If REQ assigned as direct variable 9610 1 14 of DI is on DI function will be executed and output DI OK will be 1 2 If DI function is executed the task program to be executed per second stops 3 If REQ assigned as direct variable l0 1 15 of El is on El function will be executed and output El OK will be 1 4 If EI function is executed the task program stopped due to function DI will restart 8 19 8 Basic Function Function Block Library DINT TO Invalidates task program Not to permit task program Model GM 94 starting Aplication e e e Input executes the function in case of 1 IN double integer value to convert Output ENO without an error it will be 1 OUT type converted data B Function It converts Input IN type and produces output OUT
209. tion 9610 1 3 is on COS function will be executed 2 If input INPUT 0 5235 6 rad 30 output RESULT 0 8660 V 3 2 COS 6 3 2 0 866 Input IN1 INPUT REAL 0 5235 V COS Output OUT RESULT REAL 8 66074800E 01 8 15 8 Basic Function Function Block Library DATE TO Date type conversion Model GJ Application e e Input EN executes the function in case of 1 IN date data to convert DATE TO ENO Output ENO without an error it will be 1 OUT OUT type converted data m Function It converts an input IN type and produces output OUT Program Example T LD MO 2M0 DATE TO STRING JMPN LL EN ENO d LD IN VAL IN ovr var DATE TO STRING OUT VAL LL 1 If the transition condition is on DATE_TO_STRING function will be executed 2 If IN VAL DATE D 1995 12 01 OUT VAL STRING D 1995 12 01 Input IN1 IN VAL DATE D 1995 12 01 V DATE TO STRING Output OUT OUT VAL STRING D 1995 12 01 8 16 8 Basic Function Function Block Library DELETE Deletes a character string Model GM M M Application e EN executes the function in case of 1 DELETE IN input character string BOOL
210. tion It converts input IN type and produces output OUT Function Output type LINT TO SINT SINT If input is 128 127 normal conversion Otherwise an error occurs If input is 32 768 32 767 normal conversion LINT TO INT INT Otherwise an error occurs LINT TO DINT LINT TO USINT LINT TO UINT LINT TO UDINT LINT TO ULINT LINT TO BOOL LINT TO BYTE LINT TO DWORD DWORD Takes the lower 32 bits and converts into DWORD type LINT TO LWORD LWORD onverts into LWORD type without changing the internal bit array LINT TO BCD LWORD If input 0 9 999 999 999 999 999 normal conversion Otherwise an error occurs Converts LINT into REAL type LINT_TO_REAL REAL During the conversion error caused by the precision may occur Converts LINT into LREAL type LINT TO LREAL LREAL m During the conversion an error caused by the precision may occur B Error LINT TO WORD WORD Takes the lower 16 bits and converts into WORD type If a conversion error occurs ERR and LER flags will be set If an error occurs take as many lower bits as the bit number of the output type and produces an output without changing the Internal bit array 8 47 8 Basic Function Function Block Librar Program Example LD 9610 0 0 10 0 0LINT TO DINT EN ENO JMPN AAA LD IN_VAL IN VaL var LINT TO DINT 5 OUT VAL AAA 1 If the input condition 9610 0 0 is on LINT TO DINT function will be ex
211. tion Function Block Library WORD DWORD Conti nes two V RD data i nto DARD Model a4 GV6 GW e e Application e e Input EN executes the function in case of 1 LOW lower WORD input HIGH upper WORD input Output ENO without an error it will be 1 OUT DWORD output m Function It combines two WORD data into one DWORD LOW lower WORD input HIGH upper WORD input B Program example INPUTI 1LOW RESULT INPUT2 4 HIGH 1 If the transition condition 961X1 1 5 is on WORD DWORD function is executed 2 If input variable INPUT1 1620203040 and INPUT2 16 AOBOCODO output variable RESULT 16 A0BO0C0D010203040 8 179 8 Basic Function Function Block Library XCHG Exchanges two input data Model GM Aplicationn e e els 5 Input EN executes the function in case of 1 Output ENO Without an error it will be 1 OUT Dummy Output In Out IN1 In Output 1 IN2 In Output 2 B Function Exchanges input1 data with input2 data Function In Out type Description XCHG BOOL BOOL Exchanges two BOOL input data XCHG BYTE BYTE Exchanges two BYTE input data XCHG WORD WORD Exchanges two WORD input data XCHG DWORD DWORD Exchanges two DWORD input data XCHG LWORD LWORD Exchanges two LWORD inp
212. tion TRUNC will be executed 2 If input variable REAL VALUE REAL 1 6 output variable INT VALUE INT 1 If REAL VALUE REAL 1 6 INT VALUE INT 1 Input IN1 REAL VALUE REAL 1 6 V TRUNO Output OUT INT VALUE INT 1 8 94 8 Basic Function Function Block Library UDINT TO UDINT type conversion ar mja as ae ow Apictim e jejejeje Input executes the function in case of 1 DINT TOS IN Unsigned Double Integer value to be converted Output ENO without an error it will be 1 OUT type converted data B Function It converts the IN type and outputs it as OUT Output type UDINT TO SINT SINT If input is 0 127 normal conversion Otherwise an error occurs UDINT TO INT If input is 0732767 normal conversion Otherwise an error occurs UDINT TO DINT DINT If input is 0 2 147 483 64 normal conversion Otherwise an error occurs UDINT_TO_BCD DWORD If input is 0 99 999 999 normal conversion Otherwise an error occurs During the conversion an error caused by the precision may occur During the conversion an error caused by the precision may occur UDINT TO TOD Converts into TOD type without changing the internal bit array UDINT TO TIME TIME Converts into TIME type without changing the internal bit array B Error If a conversion error occurs ERR LER flags will be set If an error occurs take the lower bits as many as a bit number of an output data type
213. to the operand data type N If the operand is BOOL it negates its value and loads it in CR All the data types including constant are available LD TRUE LD INT VALUE LD THIS LDN B_VALUE 5 IL The value of BOOL 1 is loaded in CR The data type of CR is BOOL The value of INT_VALUE is loaded in CR The data type of CR is INT 15 time constant is loaded CR The data type of CR is TIME The value of B_VALUE is negated and is loaded in CR The data type of CR is BOOL It stores the current result CR in a variable operand The data type of both CR and operand should be the same The current result is not modified by this operation If CR is BOOL it negates its value and stores it in the operand At this time the value of CR does not change Operand All the data types except constant are available Its data type should be the same as that of CR LD FALSE ST B VALUF1 B VALUE2 LD INT VALUE ST VALUE1 LD D 1995 12 25 ST D VALUE1 The value of BOOL 0 is loaded in CR The data type of CR is BOOL Stores the value of CR in variable B VALUE1 of which data type is BOOL Negates the value of CR and stores it in B VALUE2 of which data type is BOOL The value of INT VALUE that is INT variable is loaded in CR The data type of CR is INT Stores the value of CR in variable VALUE1 of which data type is INT Date constant D 1995 12 25 is loaded in CR At this time a data typ
214. transition condition is on DWIRD TO TOD function will be executed 2 If output IN VAL DWORD 16 3E8 1000 output OUT VAL TOD TOD 1S Input IN1 IN VAL DWORD 16 3E8 1000 High 0 01 0 0 0 0 0 0 0 0 0 0 0 0 0 0 row Lofofofofofo sf if rf 1 if of 1 of ol o onverts a data type only without changing a data internal bit array state Output OUT OUT VALTOD TOD 1S High oTo o o o o o o o 0 oL o o L ow 1 1 1 1 of 1 of of o Calculates TIME TOD by converting decimal into MS unit That is 1000 is 1000ms 1s Refer to 3 2 4 Data Type Structure 8 31 8 Basic Function Function Block Librar Permits running for task program Model GM GVB Application e e e e 2 9 2 es Input executes the function in case of 1 REQ requires to permit running for task program BOOL ENO BOOL Output without an error it will be 1 BOOL 4REQ OU BOOL OUT If El is executed an output will be 1 B Function gt If EN is 1 and REQ input is 1 task program blocked by DI function starts normally gt Once El command is executed task program starts normally even if REQ input is 0 gt Task programs created when they are not permitted to operate will be executed after EI function or the current running task program execution B Program Example refer to DI
215. uNTORAL PAC UNTOLEA UN tL uNToDNE NE J oloJ o uuNTOSN SN O O uvTON ow uvTOUN UN um 0411 UINTOUSN UN UN O O uuNTOUN UN UN UINTOUNN UN UN UJ NE TO e UuNTOTD UN uiNTOmM UN mM O O uvToSN UINTOIN UN umwa oN pour Jaw uNTLuN uN umn urTOUN UN wnt o uirToUN o U NT ULI NT TOD 7 4 7 Function and Function Block fo t COT ae LOT GR 2 a 7 unon uw om ofl uNTORL UN O UINTOBT UN HE o J un rowo UN WD o wn To wn rowed UN DVD o un owe UN oO HIG He _ UL NT E 3 mps sm sw 6 o po gu TON a IN eo 1 Ba tmun po uN o J EL 1 0 B UN mETosN ee sw o o o EE IN 0O B rinn EE Lemrmum WE E woruw wo VD wnt o o we um o o 7 5
216. ue to be selected Output ENO without an error it will be 1 OUT the selected value IN1 IN2 OUT should be all the same type Function If G is 0 INO will be an output and if is 1 IN1 will be an output Program Example G CURRENT RESULT IN1 2 X VALUE1 IN2 VALUE2 96QWO0 0 0 1 If the transition condition 0 is ON function SEL will be executed 2 If S 1 and VALUE1 1641110 VALUE2 16 FFOO then output variable QW0 0 0 16 FFO Input S 1 INO VALUE1 WORD 1681110 IN1 VALUE2 WORD 16 FFOO V SEL Output OUT QW0 0 0 WORD 164 FFO00 8 75 8 Basic Function Function Block Library SHL Shift Left ar a Ge fas Aoolication jejeje jeje le Input EN If EN is 1 function is executed IN bit string to be shifted N bit number to be shifted ANY_BIT ANY_BIT Output ENO without an error it will be 1 OUT the shifted value Function It shifts input IN to the left as many as N bit number N number bit on the rightmost of input IN will be filled with O N will be filled with O Program Example This is the program that shifts input data value 1100 1100 1100 1100 164CCCO to the left by bits if input 10 0 0 is ON 10 0 0 VALUE CURRENT RESULT 3 OUT VALUE 1 Set the input variable IN VALUE 11001110 16 CE 2 Insert bit number 3 into N 3 If the transition condition Z0 0 0
217. update is allowed MASK L 165200000000 IW3 3 2 of ID3 3 1 will be updated because only the lower 16 bit data update among upper 32 bits is allowed H 164 FFFF0000 Accordingly the data update of the image scope is as follows IL3 3 0 103 3 0 IW 3 3 0 2 0111_0111_0111_0111 L 96IW 3 3 1 2441010 1010 1010 1010 103 3 1 IW 3 3 2 2 1111_1111_1111_1111 L IW 3 3 3 maintains the previous value 3 If the input update is completed output REF_OK will be 1 8 24 8 Basic Function Function Block Library DIREC O Update output data Model QR Gut G6 aw Application e e EN executes the function in case of 1 BASE base number of an input module installed SLOT slot number of an input module installed MASK designates bits not to be updated among lower 32 bit data of output MASK H designates bit not to update among upper 32 bit data of output ENO without an error it will be 1 OUT If update is completed output will be 1 DIREC O EN BASE OUTFBOOL SLOT MASK L MASK H B Function gt If EN is 1 during the scan DIREC_O function reads 64 bit data of an output module from the designated position of BASE and SLOT and updates the unmasked MASK 0 data gt DIREC O is available to use when you want to change the ON OFF state of output during the scan gt Generally it s impossible to update input data during 1
218. ure 8 3 8 Basic Function Function Block Library ADD Addition Model 94 a6 GW Application EN executes the function in case of 1 IN1 value to be added IN2 value to add Input variable number can be extended up to 8 ENO without an error it will be 1 OUT added value IN1 IN2 OUT should be the same data type m Function It adds input variables up IN1 IN2 and INn n input number and produces output OUT OUT IN1 2 E Error When the output value is out of its data type ERR LER flags are set Program Example LD VALUE1 ADD Nt CURRENT RESULT UALUEl IN2 VALUE IN3 VALUES VALUE j ST OUT VAL VALUE3 2 If input variable VALUE1 300 VALUE2 200 and VALUES 100 output variable OUT VAL 300 200 100 600 Input IN1 VALUE1 INT 300 16 012C lo o ol olo ojo 1 ol o 1 o 1 1 of oj ADD 2 VALUE2 INT 200 16 00C8 o o o o o o o o 1 1 of of 1 ADD IN2 VALUES INT 100 1620064 0 1 1 of of 1 of o OUT OUT VAL INT 600 16 0258 c To To o iT oT 1T 3L oL oT 0 8 4 8 Basic Function Function Block Library ADD TIME Time Addition Model W G6 GW Application e e Input
219. ut Output ENO without an error it will be 1 OUT Dummy Output In Out LOW lower DWORD Output HIGH upper DWORD Output Function gt It divides one LWORD into two DWORD data LOW lower DWORD Output HIGH upper DWORD Output INPUT 0 DUMMY DWO_OUT1 140W DWO_OUT2 4 H GH 1 If the transition condition M10 is on LWORD_DWORD function is executed 2 If the input variable INPUT 16 AAAABBBBCCCCDDDDABCDABCDABCDABCD then DWO OUT 16 ABCDABCDABCDABCD OUT2 16 AAAABBBBCCCCDDDD 8 152 8 Basic Function Function Block Library MCS Master Control Model aH GW Aplication e e Input EN executes the function in case of 1 NUM Nesting 0 15 Output ENO If MCS is executed it will be 1 OUT Dummy always 0 W Function gt If EN is on MCS function is executed and the program between MCS and MCSCLR function is normally executed gt If EN is off the program between MCS and MCSCLR function is executed as follows Instruction Description Timer Current value CV becomes 0 and the output Q becomes off Counter Output Q becomes off and CV retains its present state Coil All becomes off Negated coil All becomes off Set coil reset coil All retains its current value Function function block All retains its current value gt Even when EN is off scan time is n
220. ut data XCHG SINT SINT Exchanges two SINT input data XCHG INT Exchanges two INT input XCHG DINT DINT Exchanges two DINT input data XCHG LINT LINT Exchanges two LINT input data XCHG_USINT USINT Exchanges two USINT input data XCHG_UINT UINT Exchanges two UINT input data XCHG_UDINT UDINT Exchanges two UDINT input data XCHG_ULINT ULINT Exchanges two ULINT input data XCHG_REAL REAL Exchanges two REAL input data XCHG_LREAL LREAL Exchanges two LREAL input data XCHG_TIME TIME Exchanges two TIME input data XCHG_DATE DATE Exchanges two DATE input data XCHG_TOD TOD Exchanges two TOD input data XCHG_DT DT Exchanges two DT input data XCHG_STRING STRING Exchanges two STRING input data 8 180 8 Basic Function Function Block Library B Program example INPUT1 INPUT2 1 If the transition condition is on XCHG_BOOL function is executed 2 If INPUT1 0 and INPUT2 1 it will exchange two input data After the function execution INPUT1 1 and INPUT2 0 8 181 8 Basic Function Function Block Library 8 3 Basic Function Block Library 1 This chapter describes basic function blocks respectively 2 It s much easier to apply function block library to your program after grasping the general of function blocks 8 182 8 Basic Function Function Block Library CTD Down Counter function block Model H GW Application
221. utput variable COUNT CV 6 Set the Q value as the random output variable COUNT Q 7 Compile and write your program to the PLC after completing the program 8 After writing change the PLC mode Stop gt Run 9 If program runs PV 5 will be loaded into CV Count CV 10 The current value CV COUNT CV decreases by 1 when the pulse input enters the input contact 10 1 14 11 When the down counter pulse input enters the input contact 10 1 14 five times CV COUNT will be 0 and COUNT CV 1 12 If Q COUNT is 1 the output contact 00 3 0 will be set 8 184 8 Basic Function Function Block Library CTU Up Counter function block Model B aH G6 GW Application e CU up counter pulse input R reset input PV loads a preset value Output increase counter output CV current value Function gt Up counter function block CTU increases the current value CV by 1 with every rising pulse input gt CV increases only when CV is less than the maximum value of INT 32767 after reaching it CV does not change its value gt When the reset input is 1 CV is cleared 0 gt Output is 1 when CV is equal to or more than PV Time Chart R Reset input CU CTU input Max coefficient 32767 PV preset value CV current value Q CTU output Pro
222. xecutes the function in case of 1 IN Unsigned Long Integer value to be converted ULINT TO Output ENO without an error it will be 1 OUT type converted data B Function It converts the IN type and outputs it as OUT ULINT TO SINT If input is 0 9 999 999 999 999 999 normal conversion Otherwise ULINT TO BCD error occurs Converts ULINT into REAL type ULINT TO REAL REAL During the conversion an error caused by the precision may occur Converts ULINT into LREAL type ULINT TO LREAL LREAL 7 During the conversion an error caused by the precision may occur B Error If a conversion error occurs ERR and LER flags will be set If error occurs it takes as many lower bits as a bit number of output type and produces an output without changing its internal bit array 8 99 8 Basic Function Function Block Library E Program Example LD 0 3M0 ULINT TO LINT EN ENO JMPN PP LD IN VAL IN ovT vaL ULINT TO LINT ST OUT VAL PP 1 If the input condition is ON function ULINT TO LINT will be executed 2 If input variable IN VAL ULINT 123 567 899 then output variable OUT VAL LINT 123 567 899 Input IN1 IN VAL ULINT 123 567 899 ULINT TO LINT Output OUT OUT VAL LINT 123 567 899 8 100 8 Basic Function Function Block Library USINT TO USINT type conversion 96 av Application
223. ximum value Model Application e e EN executes the function in case of 1 IN1 the value to be compared IN2 the value to compare Input variable number can be extended up to 8 ENO without an error it will be 1 OUT maximum value among input IN1 IN2 OUT should be the same data type B Function It produces the maximum value among input IN1 IN2 INn n input number B Program Example JMPN GG LD VALUE1 VALUEl MAX IN1 CURRENT RESULT IN2 VALUE2 ST OUT VALUE GG 1 If the transition condition 0 is on MAX function will be executed 2 As the result of comparing input variable VALUE1 100 and VALUE2 200 maximum value is 200 Output OUT VAL will be 200 Input IN1 VALUE1 INT 100 1640064 1 1 o of if 0 0 MAX 2 VALUE2 INT 200 16 00C8 1 of o 1 of of o V 1 of 1 Output OUT OUT VAL INT 200 16 00C8 0 i 1 0 o 1 o o o 8 56 8 Basic Function Function Block Library MID Takes the middle part of a character string Model 9 46 Application EN executes the function in case of 1 IN input character string L the length of character string to output P starting location of character
224. ything to ENO output All the inputs of a function are assigned by entering its data The output of a function is stored at the output variable in the right side of it You can use a function block in LD as you do in IL Inputs of a function block are assigned much the same as a function A function block is called when the left link is TRUE and not called when the left link is FALSE The value of the left link IN is copied to the right link Q for further processing The name of the function block is the instance name which can be user defined and must be unique to LD in which the function block appears You don t have to assign output variables because they are in the instance If a function block is connected to the power flow line it is always executed because there is neither EN nor ENO in it Therefore it is required to use Jump gt gt to determine whether or not to execute a function block according to the logic result When connecting the power flow line to the function block it is required to connect it to the input output of which data type is BOOL Example Line INPE Ln WEM Line3 Line4 PLACE1 Lines Line amp Line PLACE Line8 6 6 6 LD gt You can place a function and function block in any place of LD It is available to make a program by connecting the power flow line to their output and then putting the contact to that Example RESET START VAL REGI EMERGE f
Download Pdf Manuals
Related Search
Related Contents
pDRIVE< MX eco Operating instructions CANopen Corrigé sept 2012- Épreuve E2 - BAC PRO SEN Electrodomestique Termozeta 74347V steam ironing station USER MANUAL ユーザーズガイド Élémentaire, mon cher Watson MANUAL DEL USUARIO - Icon Heath & Fitness Copyright © All rights reserved.
Failed to retrieve file