鍦 Codesys 涓娇鐢 ST 璇█鐨 FOR 璇彞-CODESYS璧勬簮涓嬭浇鍖-閰峰痉缃 - CoDeSys杞欢鏁欑▼涓嬭浇,CoDeSys宸ユ帶璧勮闂ㄦ埛
HSC6490-cn涓浗鍒堕狅紝涓浗鑺瘇
鏌ョ湅: 148|鍥炲: 0

鍦 Codesys 涓娇鐢 ST 璇█鐨 FOR 璇彞

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

    [LV.1]鍒濇潵涔嶅埌

    鍙戣〃浜 2025-3-14 09:07:15 | 鏄剧ず鍏ㄩ儴妤煎眰 |闃呰妯″紡

    寮曡█

    鍦ㄥ伐涓氳嚜鍔ㄥ寲涓紝PLC锛堝彲缂栫▼閫昏緫鎺у埗鍣級琚箍娉涚敤浜庢帶鍒跺拰鐩戞祴杩囩▼銆侰odesys 鏄竴绉嶅父鐢ㄧ殑 PLC 缂栫▼鐜锛屾敮鎸佺粨鏋勫寲鏂囨湰锛圫T锛夎瑷銆係T 璇█鎻愪緵浜嗗绉嶆帶鍒剁粨鏋勶紝FOR 璇彞鏄叾涓箣涓锛屽父鐢ㄤ簬閲嶅鎵ц鐗瑰畾娆℃暟鐨勬搷浣溿傛湰鏂囧皢浠嬬粛 FOR 璇彞鐨勪娇鐢紝甯姪澶у鏇村ソ鍦扮悊瑙e拰搴旂敤杩欎竴缁撴瀯銆
    1  璇彞浠嬬粛
    FOR 璇彞鏄竴绉嶅惊鐜帶鍒剁粨鏋勶紝鐢ㄤ簬鍦ㄦ寚瀹氭鏁板唴閲嶅鎵ц浠g爜鍧椼傚叾鍩烘湰璇硶濡備笅锛

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    FOR variable := start TO end BY step DO
        (* Statements to execute in loop *)
    END_FOR

    • variable锛氬惊鐜彉閲忋
    • start锛氬惊鐜捣濮嬪笺
    • end锛氬惊鐜粨鏉熷笺
    • step锛氭瘡娆″惊鐜彉閲忓鍔犵殑姝ラ暱锛堝彲閫夛紝榛樿 1锛夈
    2  FOR 缂栫▼鎬濊矾
    浣跨敤 FOR 璇彞鏃讹紝闇瑕佺簿蹇冭璁″惊鐜殑璧峰鏉′欢鍜屾闀裤備互涓嬫槸缂栫▼鎬濊矾鐨勫嚑涓鐐癸細
    • 纭畾寰幆鑼冨洿锛氭槑纭捣濮嬪笺佺粨鏉熷煎拰姝ラ暱銆
    • 閬垮厤鏃犻檺寰幆锛氱‘淇濇闀挎柟鍚戜笌璧锋鍊煎叧绯讳竴鑷达紝闃叉姝诲惊鐜
    • 浼樺寲寰幆浣擄細灏介噺鍑忓皯寰幆浣撳唴鐨勫鏉傛搷浣滐紝鎻愰珮鎵ц鏁堢巼銆
    • 娉ㄦ剰鍙橀噺浣滅敤鍩燂細寰幆鍙橀噺鍦ㄥ惊鐜閫氬父鏃犳晥銆
    3  浣跨敤灏忔妧宸
    • 閫嗗悜寰幆锛氶氳繃璐熸闀垮疄鐜伴嗗悜寰幆锛屼緥濡 FOR i := 10 TO 1 BY -1 DO銆
    • 宓屽寰幆锛氭敮鎸佸灞傚祵濂楋紝浣嗗簲娉ㄦ剰鎺у埗澶嶆潅搴︺
    • 鎻愬墠閫鍑猴細浣跨敤 EXIT 璇彞鍦ㄦ弧瓒崇壒瀹氭潯浠舵椂璺冲嚭寰幆銆
    4  鍏稿瀷妗堜緥浠嬬粛
    鍋囪鎴戜滑闇瑕佽绠椾竴涓暟缁勪腑鎵鏈夊厓绱犵殑鍜屻備互涓嬫槸浣跨敤 FOR 璇彞鐨勫疄鐜扮ず渚嬶細
    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    VAR
        i : INT;
        sum : REAL := 0;
        numbers : ARRAY[1..5] OF REAL := [1.2, 2.3, 3.4, 4.5, 5.6];
    END_VAR
    
    FOR i := 1 TO 5 DO
        sum := sum + numbers[i];
    END_FOR
    鍦ㄨ繖涓緥瀛愪腑锛孎OR 璇彞鐢ㄤ簬閬嶅巻鏁扮粍锛岃绠楁墍鏈夊厓绱犵殑鍜屻

    鎬荤粨

    FOR 璇彞鏄 ST 璇█涓殑閲嶈寰幆缁撴瀯锛岄傜敤浜庨渶瑕侀噸澶嶆墽琛岀殑鍦烘櫙銆傞氳繃鍚堢悊浣跨敤 FOR 璇彞锛屽伐绋嬪笀鍙互鎻愰珮浠g爜鐨勬晥鐜囧拰鍙鎬с傚湪鏃ュ父寮鍙戜腑锛屾帉鎻 FOR 璇彞鐨勪娇鐢ㄦ妧宸у皢鏈夊姪浜庢洿楂樻晥鍦板疄鐜板鏉傜殑鎺у埗閫昏緫銆傚笇鏈涙湰鏂囪兘甯姪鎮ㄦ洿濂藉湴鐞嗚В鍜屽簲鐢 FOR 璇彞銆
    +10
    涓嶈禐涓涓紵
    鎵撹祻榧撳姳涓涓嬶紒
    鍥炲

    浣跨敤閬撳叿 涓炬姤

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

    鏈増绉垎瑙勫垯

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

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

    GMT+8, 2025-4-5 03:57 , Processed in 0.150164 second(s), 54 queries .

    閰峰痉缃

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

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