CODESYS 缂栫▼杞欢鍩烘湰璇硶鍜岃繍绠楃浠嬬粛-CODESYS璧勬簮涓嬭浇鍖-閰峰痉缃 - CoDeSys杞欢鏁欑▼涓嬭浇,CoDeSys宸ユ帶璧勮闂ㄦ埛
HSC6490-cn涓浗鍒堕狅紝涓浗鑺瘇
鏌ョ湅: 142|鍥炲: 0

CODESYS 缂栫▼杞欢鍩烘湰璇硶鍜岃繍绠楃浠嬬粛

[澶嶅埗閾炬帴]
  • TA鐨勬瘡鏃ュ績鎯
    寮蹇
    2017-11-20 22:07
  • 绛惧埌澶╂暟: 2 澶

    [LV.1]鍒濇潵涔嶅埌

    鍙戣〃浜 2024-9-6 09:01:10 | 鏄剧ず鍏ㄩ儴妤煎眰 |闃呰妯″紡

    寮曡█

    CODESYS锛圕ontroller Development System锛夋槸涓涓泦鎴愬紑鍙戠幆澧冿紝鏄竴绉嶅箍娉涘簲鐢ㄤ簬宸ヤ笟鑷姩鍖栭鍩熺殑缂栫▼杞欢銆傛敮鎸 IEC 61131-3 鏍囧噯鐨勫绉嶇紪绋嬭瑷锛屽缁撴瀯鍖栨枃鏈紙ST锛夈佹褰㈠浘锛圠D锛夈佹寚浠ゅ垪琛紙IL锛夌瓑銆傚畠鐨勫己澶у姛鑳藉拰鐏垫椿鎬т娇鍏舵垚涓鸿澶 PLC锛堝彲缂栫▼閫昏緫鎺у埗鍣級宸ョ▼甯堢殑棣栭夊伐鍏枫傛湰鏂囧皢涓昏鑱氱劍浜 CODESYS 涓殑缁撴瀯鍖栨枃鏈紙ST锛夎瑷锛屼粙缁嶅叾鍩烘湰璇硶鍜岃繍绠楃銆
    1
    璇硶浠嬬粛
    1.1
    璧嬪艰娉
    鍦 CODESYS 涓紝璧嬪兼搷浣滄槸灏嗕竴涓艰祴缁欎竴涓彉閲忋傝祴鍊艰鍙ヤ娇鐢 := 杩愮畻绗︺備互涓嬫槸涓涓畝鍗曠殑璧嬪艰鍙ョず渚嬶細

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    VAR
        iValue1 : INT; // 瀹氫箟涓涓暣鏁板彉閲
        iValue2 : INT; // 瀹氫箟鍙︿竴涓暣鏁板彉閲
    END_VAR
    
    iValue1 := 10; // 灏嗗 10 璧嬬粰鍙橀噺 iValue1
    iValue2 := iValue1; // 灏 iValue1 鐨勫艰祴缁 iValue2

    1.2
    閫夋嫨璇硶
    閫夋嫨璇彞鐢ㄤ簬鏍规嵁涓嶅悓鏉′欢鎵ц涓嶅悓鐨勪唬鐮併傛渶甯哥敤鐨勯夋嫨璇彞鏄 IF 璇彞鍜 CASE 璇彞銆
    IF 璇彞
    IF 璇彞鐢ㄤ簬鍦ㄦ潯浠朵负鐪熸椂鎵ц鐗瑰畾浠g爜鍧椼

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    IF iValue1 > 5 THEN
        iValue2 := iValue1 * 2;
    ELSE
        iValue2 := iValue1 / 2;
    END_IF
    CASE 璇彞
    CASE 璇彞鐢ㄤ簬鏍规嵁鍙橀噺鐨勪笉鍚屽兼墽琛屼笉鍚岀殑浠g爜鍧椼

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    CASE iValue1 OF
        1: iValue2 := 10;
        2: iValue2 := 20;
        3: iValue2 := 30;
    ELSE
        iValue2 := 0;
    END_CASE

    1.3
    寰幆璇硶
    寰幆璇彞鐢ㄤ簬閲嶅鎵ц浠g爜鍧椼侰ODESYS 鏀寔 FOR 寰幆鍜 WHILE 寰幆銆
    FOR 寰幆
    FOR 寰幆鐢ㄤ簬鍦ㄥ凡鐭ユ鏁板唴閲嶅鎵ц浠g爜銆

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    FOR i := 1 TO 10 DO
        iValue2 := iValue2 + i;
    END_FOR
    WHILE 寰幆
    WHILE 寰幆鐢ㄤ簬鍦ㄦ潯浠朵负鐪熸椂閲嶅鎵ц浠g爜銆

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    WHILE iValue1 < 50 DO
        iValue1 := iValue1 + 5;
    END_WHILE

    1.4
    鍏朵粬璇硶
    REPEAT 寰幆
    REPEAT 寰幆绫讳技浜 WHILE 寰幆锛屼絾瀹冧細鍏堟墽琛屼竴娆′唬鐮佸潡锛岀劧鍚庡啀妫鏌ユ潯浠躲

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    REPEAT
        iValue1 := iValue1 - 1;
    UNTIL iValue1 = 0
    END_REPEAT
    EXIT 璇彞
    EXIT 璇彞鐢ㄤ簬鎻愬墠閫鍑哄惊鐜

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    FOR i := 1 TO 10 DO
        IF i = 5 THEN
            EXIT;
        END_IF
        iValue2 := iValue2 + i;
    END_FOR

    2
    杩愮畻绗︿粙缁
    CODESYS 涓殑杩愮畻绗﹀垎涓虹畻鏈繍绠楃銆佹瘮杈冭繍绠楃銆侀昏緫杩愮畻绗﹀拰浣嶈繍绠楃銆
    2.1
    绠楁湳杩愮畻绗
    绠楁湳杩愮畻绗︾敤浜庢暟瀛﹁绠椼
    • +锛氬姞娉
    • -锛氬噺娉
    • *锛氫箻娉
    • /锛氶櫎娉
    • MOD锛氬彇妯

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    iValue1 := 10 + 5; // iValue1 涓 15
    iValue2 := 10 - 5; // iValue2 涓 5
    iValue1 := 10 * 2; // iValue1 涓 20
    iValue2 := 10 / 2; // iValue2 涓 5
    iValue1 := 10 MOD 3; // iValue1 涓 1

    2.2
    姣旇緝杩愮畻绗
    姣旇緝杩愮畻绗︾敤浜庢瘮杈冧袱涓笺
    • =锛氱瓑浜
    • <>锛氫笉绛変簬
    • >锛氬ぇ浜
    • <锛氬皬浜
    • >=锛氬ぇ浜庣瓑浜
    • <=锛氬皬浜庣瓑浜

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    IF iValue1 = 10 THEN
        iValue2 := 1;
    END_IF
    
    IF iValue1 <> 5 THEN
        iValue2 := 2;
    END_IF

    2.3
    閫昏緫杩愮畻绗
    閫昏緫杩愮畻绗︾敤浜庨昏緫鎿嶄綔銆
    • AND锛氶昏緫涓
    • OR锛氶昏緫鎴
    • NOT锛氶昏緫闈

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    IF (iValue1 > 5) AND (iValue2 < 10) THEN
        iValue1 := iValue1 + 1;
    END_IF
    
    IF (iValue1 > 5) OR (iValue2 < 10) THEN
        iValue2 := iValue2 + 1;
    END_IF
    
    IF NOT (iValue1 = 10) THEN
        iValue1 := 10;
    END_IF

    2.4
    浣嶈繍绠楃
    浣嶈繍绠楃鐢ㄤ簬浣嶇骇鎿嶄綔銆
    • &锛氭寜浣嶄笌
    • |锛氭寜浣嶆垨
    • ^锛氭寜浣嶅紓鎴
    • NOT锛氭寜浣嶉潪

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    iValue1 := 5; // 浜岃繘鍒 0101
    iValue2 := 3; // 浜岃繘鍒 0011
    
    iValue3 := iValue1 & iValue2; // 缁撴灉涓 1 (浜岃繘鍒 0001)
    iValue4 := iValue1 | iValue2; // 缁撴灉涓 7 (浜岃繘鍒 0111)
    iValue5 := iValue1 ^ iValue2; // 缁撴灉涓 6 (浜岃繘鍒 0110)
    iValue6 := NOT iValue1; // 缁撴灉涓 -6 (浜岃繘鍒 1010)

    鎬荤粨

    鏈枃浠嬬粛浜 CODESYS 缂栫▼杞欢涓殑鍩烘湰璇硶鍜岃繍绠楃锛屽寘鎷祴鍊艰娉曘侀夋嫨璇硶銆佸惊鐜娉曞拰鍏朵粬璇硶銆傚悓鏃讹紝涔熻缁嗕粙缁嶄簡绠楁湳杩愮畻绗︺佹瘮杈冭繍绠楃銆侀昏緫杩愮畻绗﹀拰浣嶈繍绠楃鐨勪娇鐢ㄦ柟娉曘傞氳繃杩欎簺鍩虹鐭ヨ瘑鐨勫涔狅紝璇昏呭彲浠ュ紑濮嬬紪鍐欏拰璋冭瘯绠鍗曠殑 PLC 绋嬪簭锛屼负杩涗竴姝ョ殑楂樼骇缂栫▼濂犲畾鍩虹銆
    甯屾湜鏈瘒鏂囩珷鑳藉浣犳湁鎵甯姪锛屽湪瀛︿範CoDeSys鐨勯亾璺笂鏈夋墍杩涙銆

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

    浣跨敤閬撳叿 涓炬姤

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

    鏈増绉垎瑙勫垯

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

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

    GMT+8, 2024-11-27 12:20 , Processed in 0.135148 second(s), 53 queries .

    閰峰痉缃

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

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