博文

AutomationStudio下自定义库的使用笔记

笔记

前言

正文

FUNCTION_BLOCK MotionParaCalc

	VAR_INPUT
		bEnable    : BOOL;
		MotionPara : MotionPara_typ;
	END_VAR
	VAR_OUTPUT
		bActivate    : BOOL;
		bError       : BOOL;
		wErrorID     : WORD;
		Acceleration : REAL;
		Deceleration : REAL;
		JogVelocity  : REAL;
	END_VAR 
 

    IF bEnable THEN
        bActivate := TRUE ;      
        IF (MotionPara.rMotorSpeed <> 0.0) AND (MotionPara.rInOfGear <> 0.0) AND (MotionPara.rOutOfGear <> 0.0) AND (MotionPara.rPuu <> 0.0) AND (MotionPara.rAcc <> 0.0) AND (MotionPara.rDec <> 0.0) AND (MotionPara.rJogSpeed <> 0.0)  THEN 
            bError       := FALSE ;
            wErrorID     := 16#00 ;
            Acceleration := MotionPara.rMotorSpeed / MotionPara.rInOfGear * MotionPara.rOutOfGear / 60.0 * MotionPara.rPuu / MotionPara.rAcc * 2.0 ;
            Deceleration := MotionPara.rMotorSpeed / MotionPara.rInOfGear * MotionPara.rOutOfGear / 60.0 * MotionPara.rPuu / MotionPara.rDec * 2.0 ;
            JogVelocity  := MotionPara.rMotorSpeed / MotionPara.rInOfGear * MotionPara.rOutOfGear / 60.0 * MotionPara.rPuu / 100.0 * MotionPara.rJogSpeed;
        ELSE
            bError := TRUE ;
            IF (MotionPara.rMotorSpeed = 0.0) THEN
                wErrorID := 16#01 ;
            ELSIF (MotionPara.rInOfGear = 0.0) THEN
                wErrorID := 16#02 ;
            ELSIF (MotionPara.rOutOfGear = 0.0) THEN
                wErrorID := 16#03 ;
            ELSIF (MotionPara.rPuu = 0.0) THEN
                wErrorID := 16#04 ;
            ELSIF (MotionPara.rAcc = 0.0) THEN
                wErrorID := 16#05 ;
            ELSIF (MotionPara.rDec = 0.0) THEN
                wErrorID := 16#06 ;                
            ELSE
                wErrorID := 16#07 ;
            END_IF ;
        END_IF ;  
    ELSE
        bActivate := FALSE ; 
        bError    := FALSE ;
        wErrorID  := 16#00 ;
    END_IF ;
    
END_FUNCTION_BLOCK

← 返回博文列表