1、 TwinCAT PLC 2005 5 1 1 TwinCAT PLC Control .1 1.1 1 1.2 .3 1.3 10 1.3.1 10 1.3.2 (IL)10 1.3.3 ST 12 1.3.4 SFC 17 1.3.5 FBD .21 1.3.6 CFC .21 1.3.6 LD .22 1.4 24 1.5 IEC 61131-3 .26 2 27 2.1 .27 3 36 3.1 36 3.2 38 3.3 .53 3.4 74 3.5 .87 3.6 .92 3.7 101 3.8 .102 3.9 103 4 .105 4.1 105 4.2 .107 4.3 .1
2、18 4.4 122 4.5 124 4.6 .125 4.7 127 2 4.8 132 4.9 137 4.10 .150 5 .159 5.1 159 5.2 .160 5.3 PLC .163 5.4 .164 5.5 .167 5.6 172 6 .175 6.1 .175 7 ENI .177 7.1 177 8 .180 8.1 .180 8.1.1 .180 8.1.2 181 8.1.2.1 BOOL181 8.1.2.2 BYTE.181 8.1.2.3 WORD.182 8.1.2.4 DWORD 182 8.1.2.5 SINT182 8.1.2.6 USINT .18
3、2 8.1.2.7 INT182 8.1.2.8 UINT182 8.1.2.9 DINT183 8.1.2.10 UDINT183 8.1.2.11 REAL183 8.1.2.12 LREAL .183 8.1.2.13 STRING .183 8.1.2.14 TIME 184 8.1.2.15 TIME_OF_DAY 184 8.1.2.16 DATE .184 8.1.2.17 DATE_AND_TIME .184 8.1.3. 185 8.1.3.1 185 8.1.3.2 186 8.1.3.3 ENUM 186 3 8.1.3.4 STRUCT 187 8.1.3.5 188
4、8.1.3.6 .189 8.2 190 8.2.1 .190 8.2.2 IEC 190 8.2.3 193 8.2.3.1 ABS193 8.2.3.2 ACOS.193 8.2.3.3 ASIN 194 8.2.3.4 ATAN194 8.2.3.5 COS.194 8.2.3.6 EXP194 8.2.3.7 EXPT.194 8.2.3.8 LN195 8.2.3.9 LOG .195 8.2.3.10 SIN 195 8.2.3.11 SQRT 195 8.2.3.12 TAN .195 8.2.4 197 8.2.4.1 ADD .197 8.2.4.2 MUL .197 8.2
5、.4.3 SUB .197 8.2.4.4 DIV.198 8.2.4.5 MOD 198 8.2.5 199 8.2.5.1 AND .199 8.2.5.2 OR.199 8.2.5.3 XOR.199 8.2.5.4 NOT .200 8.2.6 200 8.2.6.1 SHL200 8.2.6.2 SHR .201 8.2.6.3 ROL .202 8.2.6.4 ROR.202 8.2.7 204 8.2.7.1 SEL204 8.2.7.2 MAX.204 8.2.7.3 MIN 205 8.2.7.4 LIMIT205 8.2.7.5 MUX.205 8.2.8 207 8.2.
6、8.1 GT207 8.2.8.2 LT.207 4 8.2.8.3 LE207 8.2.8.4 GE.208 8.2.8.5 EQ.208 8.2.8.6 NE209 8.2.9 .210 8.2.9.1 INDEXOF.210 8.2.9.2 SIZEOF210 8.2.9.3 ADR 210 8.2.9.4 210 8.2.9.5 CAL .210 8.2.9.6 BITADR211 8.2.10 .212 8.2.10.1 BOOL_TO .212 8.2.10.2 TO_BOOL .212 8.2.10.3 STRING_TO .212 8.2.10.4 TO_STRING .212
7、 8.2.10.5 TIME_TO 213 8.2.10.6 DATE_TO 213 8.2.10.7 TOD_TO .213 8.2.10.8 “DT_TO .213 8.2.10.9 REAL_TO-/LREAL_TO .214 8.2.10.10 .214 8.2.10.11 TRUNC214 8.3 215 8.3.1 .215 8.3.1.1 BOOL 215 8.3.1.2 TIME .215 8.3.1.3 DATE 215 8.3.1.4 TIME_OF_DAY .215 8.3.1.5 DATE_AND_TIME 216 8.3.1.6 216 8.3.1.7 REAL/LR
8、EAL 216 8.3.1.8 STRING 216 8.3.1.9 .217 8.3.2 .218 8.3.2.1 218 8.3.2.2 218 8.3.2.3 POU 219 8.3.2.4 .219 8.3.2.5 219 8.3.2.6 219 8.3.2.6.1 219 8.3.2.6.2 SYSTEMINFO220 8.3.2.6.3 SYSTEMTASKINFOARR .220 5 8.4 .221 8.4.1 CheckBounds 221 8.4.2 CheckDivByte 222 8.4.3 CheckDivReal 222 8.4.4 CheckDivWord 223
9、 8.4.5 CheckDivDWord 223 8.4.6 CheckRangeSigned 224 8.4.7 CheckRangeUnsigned .225 8.5 .227 8.6 .231 8.7 .246TwinCAT PLC Control 1 249 1 TwinCAT PLC Control 1.1 TwinCAT PLC Control TwinCAT PLC Control PLC TwinCAT PLC Control PLC IEC TwinCAT PLC Control Task Configuration Standard POU MAIN POU TwinCAT
10、 PLC Control POU Object Organizer POU POU PLC PLC TwinCAT PLC Control POU Watch and Receipt Manager TwinCAT PLC Control Sampling Trace Log ENI ENI TwinCAT PLC Control 2 249 TwinCAT PLC Control PLC TwinCAT PLC Control 3 249 1.2 PLC POU POU POU Action POU IEC IL ST SFC FBD LD CFC TwinCAT PLC Control I
11、EC POU POU standard.lib POU POU POU FUNCTION Fct:INT IL ST IL LD 7 Fct 2,4 ST Result TwinCAT PLC Control 4 249 ST Result := Fct(7, 2, 4); FBD SFC CheckBounds CheckBounds CheckBounds TRUE A10 A7 A7 Check Bounds CheckDivByte CheckDivWord CheckDivDWord CheckDivReal DIV 0 CheckRangeSigned CheckRangeUnsi
12、gned POU IL TwinCAT PLC Control 5 249 INSTANCE FUB INSTANCE:FUB; FB INT in1 PROGRAM prog VARinst1:fb; END_VARLD 17 ST inst1.in1 CAL inst1 END_PROGRAM POU TwinCAT PLC Control 6 249 POU . IL ST := POU / (VAR_IN_OUT) ST POU fubo VAR_IN_OUT inout1 VARinst:fubo; var1:int; END_VAR var1:=2; inst(inout1:=va
13、r1); inst(inout1:=2); inst.inout1:=2; FUB ERG QUAD FUB INSTANCE IL TwinCAT PLC Control 7 249 ST IL FBD IL SFC POU POU POU PROGRAM END_PROGRAM IL TwinCAT PLC Control 8 249 CAL PRG Example LD PRGexample.PAR ST ERG ST PRGExample; Erg := PRGexample.PAR; FBD PRGexample PAR 0 ERG 1 2 3 Action normal / Cou
14、nter in Reset 0 Out . . PROGRAM PLC_PRG VAR Inst : Counter; END_VARTwinCAT PLC Control 9 249 IL CAL Inst.Reset(In := FALSE) LD Inst.out ST ERG ST Inst.Reset(In := FALSE); Erg := Inst.out; FBD SFC SFC IEC 61131-3 SFC Global Variable PLC PLC Configuration Task Configuration Sampling Trace Watch and Re
15、ceipt Manager POU “standard.lib“ TwinCAT PLC Control 10 249 1.3 1.3.1 TwinCAT PLC Control IEC61131-3 (IL) ST FBD (LD) CFC SFC 1.3.2 (IL) IL LD 17 ST lint (* *) GE 5 JMPC next LD idword EQ istruct.sdword STN test next: IL IL JMP CAL RET C TRUE JMPC CALC RETC N FALSE N IL LD N TwinCAT PLC Control 11 249 ST N S TRUE TRUE R TRUE FALSE AND N, ( OR N, ( XOR ( ADD ( SUB ( MUL ( DIV ( GT ( EQ ( = NE ( LE ( = LT ( JMP CN CAL CN RET CN ) IEC IL LD TRUE