您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 管理学资料 > SCL-典型功能的写法
典型功能的设计思路和实现方式BYTE(TB)TOINT(TI)TI:=WORD_TO_INT(BYTE_TO_WORD(TB))INT(in2)TODINT(in1)in1:=INT_TO_DINT(in2)DINT(in2)TOREAL(in1)in1:=DINT_TO_REAL(in2)WORD(in2)TOINT(in1)in1:=WORD_TO_INT(in2)WORD(in2)TODINT(in1)in1:=WORD_TO_DINT(in2)WORD(in2)TOREAL(in1)in1:=INT_TO_REAL(WORD_TO_INT(in2))BOOL_TO_BYTEWORD_TO_INTWORD_TO_BOOLBOOL_TO_WORDINT_TO_REALWORD_TO_INTBO_BYW_IW_BOBO_WI_RW_IANDNANDNORNOTORXORINPUT:IN1,IN2,IN3,IN4,IN5,IN6,IN7,IN8,IN9,IN10,IN11(BOOL)(WORD,DWORD)OUTPUT:OUT1,OUT2,OUT3,OUT4,OUT5,OUT6(BOOL)(WORD,DWORD)IFIN1=TRUEANDIN2=TRUETHENOUT1:=TRUE;ELSEOUT1:=FALSE;END_IF;//ANDIFIN3=TRUEANDIN4=TRUETHENOUT2:=FALSE;ELSEOUT2:=TRUE;END_IF;//NANDIFIN5=FALSEANDIN6=FALSETHENOUT3:=TRUE;ELSEOUT3:=FALSE;END_IF;//NORIFIN7=FALSETHENOUT4:=TRUE;ELSEOUT4:=FALSE;END_IF;//NOTIFIN8=TRUEORIN9=TRUETHENOUT5:=TRUE;ELSEOUT5:=FALSE;END_IF;//ORIF(IN10=TRUEANDIN11=TRUE)OR(IN10=FALSEANDIN11=FALSE)THENOUT6:=FALSE;ELSEOUT6:=TRUE;END_IF;//XOROUT1:=IN1ANDIN2;OUT4:=NOTIN7;OUT5:=IN8ANDIN9;OUT6:=IN10XORIN11;CMP_DICMP_ICMP_RCMP_TINPUT:IN1,IN2(DINT,INT,REAL,TIME)OUTPUT:GT,GE,EQ,LT,LE(BOOL)IFIN1IN2THENGT:=1;END_IF;IFIN1=IN2THENGE:=1;END_IF;IFIN1=IN2THENEQ:=1;END_IF;IFIN1IN2THENLT:=1;END_IF;IFIN1=IN2THENLE:=1;END_IF;JK_FFRS_FFSR_FFRS:IFH2_PV_Q=TRUEANDReset=FALSETHENH2_Reset_Q:=TRUE;END_IF;IFReset=TRUETHENH2_Reset_Q:=FALSE;END_IF;TOFTONINPUT:IN1(BOOL),IN2(TIME)OUTPUT:OUT(BOOL)F_TRIGR_TRIGTIMER_PINPUT:IN1(BOOL)OUTPUT:OUT(BOOL)ADDSUBMULDIVMAXMINSQRTABSNEGEPSMODLIMINPUT:IN1,IN2,IN3,IN4,IN5,IN6,IN7,IN8,IN9,IN10,IN11,IN12,IN13,IN14,IN15(REAL,INT,DINT)OUTPUT:OUT1,OUT2,OUT3,OUT4,OUT5,OUT6,OUT7,OUT8,OUT9(REAL)OUT1:=IN1+IN2;//ADDOUT2:=IN3-IN4;//SUBOUT3:=IN5*IN6;//MULOUT4:=IN7/IN8;//DIVIFIN9IN10THENOUT5:=IN9;END_IF;//MAXIFIN9IN10THENOUT5:=IN10;END_IF;IFIN9=IN10THENOUT5:=IN9;END_IF;IFIN11IN12THENOUT6:=IN12;END_IF;//MINIFIN11IN12THENOUT6:=IN11;END_IF;IFIN11=IN12THENOUT6:=IN11;END_IF;OUT7:=SQRT(IN13);//SQRTOUT8:=ABS(IN14);//ABSIFIN150THENOUT9:=-IN15;END_IF;//NEGIFIN150THENOUT9:=-IN15;END_IF;IFIN15=0THENOUT9:=0;END_IF;INPUT:IN1,IN2(INT,DINT)OUTPUT:OUT(BOOL)IFIN1=IN2TNENOUT:=FALSE;//EPSELSEOUT:=TRUE;END_IF;INPUT:IN1,IN2(INT,DINT)OUTPUT:OUT(INT,DINT)OUT:=IN1MODIN2;//MODOUT:=IN1DIVIN2;//DIVINPUT:IN,MAX,MIN(REAL,INT)OUTPUT:OUT,OUTH,OUTL(REAL,INT,BOOL)IFINMINTHENOUT:=MIN;OUTL:=TRUE;END_IF;//LIMIFINMAXTHENOUT:=MAX;OUTH:=TRUE;END_IF;IFINMAXANDINMINTHENOUT:=IN;OUTL:=FALSE;OUTH:=FALSE;END_IF;MUXSELOP_AOP_DOP_TRIGROLRORSHLSHRINPUT:KIN1IN2IN3IN4(INT,DINT,BOOL,REAL)OUTPUT:OUT(BOOL,REAL)IFK=1THENOUT:=IN1;END_IF;//MUXIFK=2THENOUT:=IN2;END_IF;IFK=3THENOUT:=IN3;END_IF;IFK=4THENOUT:=IN4;ELSEOUT:=FALSE;END_IF;IFK=1THENOUT:=IN1;//SELELSEOUT:=IN2;END_IF;INPUT:KIN1IN2(BOOL)OUTPUT:OUT(BOOL)IFK=0THENOUT:=IN1;END_IF;//OP_DIFK=1THENOUT:=IN2;IN1:=IN2;END_IF;INPUT:KIN1IN2(BOOL,REAL)OUTPUT:OUT(REAL)IFK=0THENOUT:=IN1;END_IF;//OP_AIFK=1THENOUT:=IN2;IN1:=IN2;END_IF;INPUT:KIN1IN2IN3IN4(BOOL,REAL)OUTPUT:OUT(REAL)IFK=0THENOUT:=IN1;END_IF;//OP_A_LIMIFK=1THENOUT:=IN2;IN1:=IN2;END_IF;IFIN2IN3THENOUT:=IN3;END_IF;IFIN2IN4THENOUT:=IN4;END_IF;IFuIN3THENOUT:=IN3;u:=IN3;END_IF;IFuIN4THENOUT:=IN4;u:=IN4;END_IF;INPUT:IN1IN2(BOOL)OUTPUT:OUT(BOOL)//OP_TRIG函数类型,如三角函数(正弦,余弦,指数函数,对数函数。。。。。。。。)INPUT:IN1,IN2,IN3,IN4(REAL,INT)OUTPUT:OUT1,OUT2,OUT3,OUT4(REAL)OUT1:=SIN(IN1);//sinOUT2:=COS(IN2);//cosOUT3:=EXP(IN3);//EXPOUT4:=LN(IN4);//ln加减计数器IF….THEN….ELSE….END_IF;CASEModeOF………END_CASE;FOR….TO…..BY…..DO…END_FOR;WHILEa=bDO……END_WHILE;REPEATCONTINUEEXITGOTORETURNINPUT:KIN1IN2(BOOL,REAL)OUTPUT:OUT(BOOL,REAL)IFK=1THENOUT:=IN1;//IF…..THEN….ELSE…….END_IF;ELSEOUT:=IN2;END_IF;INPUT:IN1,IN2,IN3(REAL,INT)OUTPUT:OUT1(BOOL,REAL)CASEIN1OF//CASE0:v:=IN2*IN3;1:v:=IN2+IN3;2:v:=IN2-IN3;3:v:=IN2/IN3;END_CASE;CASEModeOF0:IF(LMNSet_position)THENQopen:=1;Qclose:=0;ELSEQopen:=0;Qclose:=1;END_IF;1:IF(LMNSet_position)THENQclose:=1;ELSEQclose:=0;END_IF;Qopen:=open;2:IF(LMNSet_position)THENQopen:=1;ELSEQopen:=0;END_IF;Qclose:=close;3:Qopen:=open;Qclose:=close;ELSEQopen:=0;Qclose:=0;END_CASE;CNTDIG_MONILOKINTERLOKMEASMOTOPDPIDVALRAMP
本文标题:SCL-典型功能的写法
链接地址:https://www.777doc.com/doc-5170415 .html