閫氳繃涓涓畝鏄撶殑鍔熻兘鍧楁潵瀛︿範Codesys涓嬪姩浣溿佹柟娉曘佸睘鎬-CODESYS璧勬簮涓嬭浇鍖-閰峰痉缃 - CoDeSys杞欢鏁欑▼涓嬭浇,CoDeSys宸ユ帶璧勮闂ㄦ埛
HSC6490-cn涓浗鍒堕狅紝涓浗鑺瘇
鏌ョ湅: 25|鍥炲: 0

閫氳繃涓涓畝鏄撶殑鍔熻兘鍧楁潵瀛︿範Codesys涓嬪姩浣溿佹柟娉曘佸睘鎬

[澶嶅埗閾炬帴]
  • TA鐨勬瘡鏃ュ績鎯
    鎿︽睏
    2019-8-13 14:13
  • 绛惧埌澶╂暟: 32 澶

    [LV.5]甯镐綇灞呮皯I

    鍙戣〃浜 5 澶╁墠 | 鏄剧ず鍏ㄩ儴妤煎眰 |闃呰妯″紡
    鍓嶈█
    Codesys 鍔ㄤ綔銆佹柟娉曘佸睘鎬 鐨勪娇鐢紝鑷绗旇澶囧繕

    鍓嶈█    鏈夋湅鍙嬪湪鎴戝垎浜竴浜涘叧浜嶤odesys涓嬬殑闈㈠瀵硅薄鐨凮OP浣跨敤銆備粖澶╁垰濂戒紤鎭紝灏卞埄鐢ㄧ┖浣欑殑鏃跺欙紝鎶婁箣鍓嶇殑瀛︿範鍒扮殑杩涜姊崇悊銆

    姝f枃
    1.Code Show1.1 Fb_MotorCtrl 鏅氱數鏈哄甫缂栫爜鍣ㄥ弽棣堟帶鍒剁殑姝e弽杞姛鑳藉潡

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    FUNCTION_BLOCK Fb_MotorCtrl
    VAR_INPUT
        xEnabel     : BOOL ; //浣胯兘
        xFault      : BOOL ; //鏁呴殰
        xFwd        : BOOL ; //姝h浆
        xRev        : BOOL ; //鍙嶈浆
        xAuto       : BOOL ; //鑷姩
        xReset      : BOOL ; //澶嶄綅鏁呴殰
        rActPos     : REAL ; //褰撳墠鍊
        rLimitP     : REAL ; //姝i檺浣
        rLimitN     : REAL ; //鍙嶉檺浣
        rAutoPos    : REAL ; //鑷姩浣嶇疆
        rOffset     : REAL ; //鍋忓樊
        UdiOverTime : UDINT ; //瓒呮椂鏃堕棿
    END_VAR
    VAR_OUTPUT
        bFault    : BOOL ; //澶栭儴鏁呴殰
        bOverTime : BOOL ; //缂栫爜鍣ㄨ秴鏃
        yFwd      : BOOL ; //姝h浆杩愯
        yRev      : BOOL ; //鍙嶈浆杩愯
        bDone     : BOOL ; //鑷姩瀹屾垚
        iState    : INT ;  //-1>>> 鍙嶈浆 0>>>鍋滄 1>>>姝h浆 100>>绂佺敤 1000>>>鏁呴殰 2000>>>缂栫爜鍣ㄨ秴鏃
    END_VAR
    VAR
        iAutoStep    : INT  ;         //鑷姩娴佺▼姝
        iRecordsStep : INT  ;         //璁板綍娴佺▼姝
        rTempPos     : REAL ;         //閿佷綅缃
        tOverTime    : Standard.TON ; //璁℃椂
    END_VAR
    ACT_OverTime();
    IF NOT xEnabel THEN
        METH_Disable();
    ELSE
        IF NOT xFault OR bOverTime THEN
            METH_Error();
        ELSE
            IF xFwd THEN
                METH_FwdOut();
            ELSIF xRev THEN
                METH_RevOut();
            ELSIF NOT bDone AND xAuto THEN
                METH_Auto();
            ELSE    
                METH_Stop();
            END_IF ;
        END_IF ;
    END_IF ;
    (*ACT_OverTime 鍐呭*)
    CASE iRecordsStep OF
        0:
            IF yFwd OR yRev THEN
                rTempPos     := rActPos ;
                iRecordsStep := 10 ;
            END_IF ;
        10:
            tOverTime.PT := UDINT_TO_TIME(UdiOverTime);
            tOverTime.IN := TRUE ;
            IF tOverTime.Q THEN
                IF rTempPos <> rActPos THEN
                    tOverTime.IN := FALSE ;
                    iRecordsStep := 0 ;
                ELSE
                    bOverTime    := TRUE ;
                    iRecordsStep := 100 ;
                END_IF ;
            ELSIF NOT tOverTime.Q AND NOT yFwd AND NOT yRev THEN
                tOverTime.IN := FALSE ;
                iRecordsStep := 0 ;         
            END_IF ;
        100:
            IF xReset THEN
                bOverTime    := FALSE ;
                tOverTime.IN := FALSE ;
                iRecordsStep := 0 ;
            END_IF ;    
    ELSE
        ;
    END_CASE ;
    tOverTime();
    (*METH_Disable 鍐呭*)
    METHOD PUBLIC METH_Disable : BOOL
    VAR_INPUT
    END_VAR
    bFault       := FALSE ;
    bOverTime    := FALSE ;
    yFwd         := FALSE ;
    yRev         := FALSE ;
    iAutoStep    := 0 ;
    iRecordsStep := 0 ;
    iState       := 100 ;
    (*METH_Error 鍐呭*)
    METHOD PUBLIC METH_Error : BOOL
    VAR_INPUT
    END_VAR
    yFwd      := FALSE ;
    yRev      := FALSE ;
    iAutoStep := 0 ;
    IF NOT bOverTime THEN
        bFault := xFault ;
        iState := 1000 ;
    ELSE
        iState := 2000 ;
    END_IF ;
    (*METH_FwdOut 鍐呭*)
    METHOD PUBLIC METH_FwdOut : BOOL
    VAR_INPUT
    END_VAR
    yRev   := FALSE ;
    yFwd   := xEnabel AND xFault AND NOT yRev AND (rActPos < rLimitP) AND xFwd ;
    iState := 1 ;
    (*METH_RevOut 鍐呭*)
    METHOD PUBLIC METH_RevOut : BOOL
    VAR_INPUT
    END_VAR
    yFwd   := FALSE ;
    yRev   := xEnabel AND xFault AND NOT yFwd AND (rActPos > rLimitN) AND xRev;
    iState := -1 ;
    (*METH_Auto 鍐呭*)
    METHOD PUBLIC METH_Auto : BOOL
    VAR_INPUT
    END_VAR
    CASE iAutoStep OF
        0 :
            IF (rActPos >= (rAutoPos - rOffset)) AND (rActPos <= (rAutoPos + rOffset)) THEN
                yFwd   := FALSE ;
                yRev   := FALSE ;
                iState := 0 ;
                bDone  := TRUE ;
            END_IF ;
            IF rActPos < rAutoPos THEN
                iAutoStep := 10 ;
            ELSIF rActPos > rAutoPos THEN
                iAutoStep := 20 ;
            END_IF ;
        10:
            bDone     := FALSE ;
            yRev      := FALSE ;
            yFwd      := TRUE ;
            iState    := 1 ;
            iAutoStep := 30 ;
        20:
            bDone     := FALSE ;
            yFwd      := FALSE ;
            yRev      := TRUE ;
            iState    := -1 ;       
            iAutoStep := 30 ;
        30:
            IF (rActPos >= (rAutoPos - rOffset)) AND (rActPos <= (rAutoPos + rOffset)) THEN
                yFwd      := FALSE ;
                yRev      := FALSE ;
                iState    := 0 ;
                bDone     := TRUE ;
                iAutoStep := 0 ;
            END_IF ;
    END_CASE ;
    (*METH_Stop 鍐呭*)
    METHOD PUBLIC METH_Stop : BOOL
    VAR_INPUT
    END_VAR
    yFwd      := FALSE ;
    yRev      := FALSE ;
    bDone     := FALSE ;
    iAutoStep := 0 ;
    iState    := 0 ;
    PROPERTY PUBLIC Prop_AutoStep : INT
    Prop_AutoStep := iAutoStep ;
    PROPERTY PUBLIC Prop_RecordStep : INT
    Prop_RecordStep := iRecordStep ;



    1.2 Pro_Main

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    PROGRAM Pro_Main
    VAR
        MotorCtrl      : Fb_MotorCtrl ;
        rCount         : REAL ;
        iActAutoStep   : INT ;
        iActRecordStep : INT ;
    END_VAR
    MotorCtrl.rActPos := rCount ;
    MotorCtrl();
    IF MotorCtrl.yFwd THEN
        rCount := rCount + 0.1 ;
    ELSIF MotorCtrl.yRev THEN
        rCount := rCount - 0.1 ;
    END_IF ;
    IF MotorCtrl.bDone THEN
        MotorCtrl.xAuto := FALSE ;
    END_IF ;
    iActAutoStep   := MotorCtrl.Prop_AutoStep;
    iActRecordStep := MotorCtrl.Prop_RecordStep ;
    IF MotorCtrl.xReset THEN
        IF (iActRecordStep = 0) THEN
            MotorCtrl.xReset := FALSE ;
        END_IF ;
    END_IF ;
       



    閫氳繃涓婇潰鐨勭▼搴忔鍙互鐪嬪嚭鍦–odesys涓嬬殑鍔ㄤ綔銆佹柟娉曘佸睘鎬х殑浣跨敤銆傚悗缁細鏇村鐨勫垎浜湁鍏充簬OOP鐨勫疄闄呴」鐩娇鐢ㄣ傜粨灏    閫氳繃涓涓畝鏄撶殑鍔熻兘鍧楀幓鐞嗚В锛屽湪鍔熻兘鍧椾笅鍔ㄤ綔鐢ㄦ潵鍋氬父瑙勪竴鐩撮渶瑕佺殑鍔ㄤ綔銆傝屾柟娉曠敤鏉ュ綋浣滆繃绋嬪拰缁撴灉銆傝屽睘鎬х敤鏉ョ敤浜庡彉閲忓湪涓嶄綔涓鸿緭鍏ヨ緭鍑虹殑鎯呭喌涓嬶紝閫氳繃灞炴ф潵瀹炵幇浼犻掋傦紙褰撶劧鏈枃鍐呭浠呮槸绗旇呬釜浜虹殑鐞嗚В銆傦級


    +10
    涓嶈禐涓涓紵
    鎵撹祻榧撳姳涓涓嬶紒
    鍥炲

    浣跨敤閬撳叿 涓炬姤

    鎮ㄩ渶瑕佺櫥褰曞悗鎵嶅彲浠ュ洖甯 鐧诲綍 | 绔嬪嵆娉ㄥ唽 鏂版氮寰崥鐧婚檰

    鏈増绉垎瑙勫垯

    椤堕儴qrcode搴曢儴
    鍏虫敞閰峰痉缃戣闃呭彿锛岃幏鍙栨洿澶氳祫璁紒

    QQ|灏忛粦灞|鎵嬫満鐗|Archiver|閰峰痉璁哄潧 ( 鑻廔CP澶16065247鍙-1 )|缃戠珯鍦板浘

    GMT+8, 2025-1-22 22:06 , Processed in 0.165957 second(s), 54 queries .

    閰峰痉缃

    © 2001-2013 Hicodesys. 鎶鏈敮鎸 by 閰峰痉缃

    蹇熷洖澶 杩斿洖椤堕儴 杩斿洖鍒楄〃