CODESYS 瀹炴垬锛氭煡鎵 鈥 瀹岀編鏁 鈥-CODESYS璧勬簮涓嬭浇鍖-閰峰痉缃 - CoDeSys杞欢鏁欑▼涓嬭浇,CoDeSys宸ユ帶璧勮闂ㄦ埛
HSC6490-cn涓浗鍒堕狅紝涓浗鑺瘇
鏌ョ湅: 102|鍥炲: 0

CODESYS 瀹炴垬锛氭煡鎵 鈥 瀹岀編鏁 鈥

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

    [LV.1]鍒濇潵涔嶅埌

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

    寮曡█

    鍦ㄥ伐涓氳嚜鍔ㄥ寲涓紝PLC锛堝彲缂栫▼閫昏緫鎺у埗鍣級閫氳繃浣跨敤缂栫▼璇█鏉ュ疄鐜板鏉傜殑閫昏緫鎺у埗銆傚叾涓紝ST锛堢粨鏋勫寲鏂囨湰锛夎瑷鍥犲叾鎺ヨ繎楂樼骇璇█鐨勮娉曡岃骞挎硾浣跨敤銆傛湰绡囨枃绔犲皢灞曠ず濡備綍浣跨敤 ST 璇█鍦 CoDeSys 骞冲彴涓婄紪鍐欎竴涓▼搴忥紝璁$畻骞跺鎵剧粰瀹氳寖鍥村唴鐨勫畬鏁般傞氳繃瑙e喅涓涓粡鍏哥殑鏁板闂锛屽府鍔╂偍鍦ㄥ疄璺典腑鎻愰珮 ST 璇█缂栫▼鑳藉姏銆
    1  闂鎻忚堪
    瀹屾暟鏄寚杩欐牱涓绉嶆暟锛屽畠绛変簬闄よ嚜韬鎵鏈夋鍥犲瓙鐨勫拰銆備緥濡傦紝6 鏄竴涓畬鏁帮紝鍥犱负鍏跺洜瀛 1銆2 鍜 3 鐨勫拰绛変簬 6銆傛湰鏂囩殑鐩爣鏄紪鍐欎竴涓▼搴忥紝鎵惧嚭缁欏畾鑼冨洿鍐呯殑鎵鏈夊畬鏁般
    2  绋嬪簭璁捐鎬濊矾
    • 杈撳叆杈撳嚭鍙橀噺锛氬畾涔夎緭鍏ュ彉閲忔寚瀹氳寖鍥达紝杈撳嚭鍙橀噺瀛樺偍瀹屾暟鍙婂叾璁℃暟銆
    • 鍒濆鍖栵細鍒濆鍖栧畬鏁拌鏁板櫒鍜屽瓨鍌ㄦ暟缁勩
    • 涓诲惊鐜細閬嶅巻鑼冨洿鍐呯殑姣忎釜鏁板瓧锛岃绠楀叾鍥犲瓙鍜岋紝鍒ゆ柇鏄惁涓哄畬鏁般
    • 瀛樺偍缁撴灉锛氬鏋滄壘鍒板畬鏁帮紝瀛樺偍鍦ㄦ暟缁勪腑骞舵洿鏂拌鏁板櫒銆

    3  绋嬪簭浠g爜
    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    PROGRAM FindPerfectNumbers
    VAR_INPUT
        MinValue: INT := 1;        // 鑼冨洿涓嬮檺
        MaxValue: INT := 10000;    // 鑼冨洿涓婇檺
    END_VAR
    
    VAR_OUTPUT
        PerfectCount: INT := 0;     // 瀹屾暟璁℃暟鍣
        PerfectNumbers: ARRAY[1..100] OF INT; // 瀛樺偍瀹屾暟鐨勬暟缁  
    END_VAR
    
    VAR
        CurrentNumber: INT;         // 褰撳墠妫鏌ョ殑鏁板瓧
        DivisorSum: INT;            // 褰撳墠鏁板瓧鐨勫洜瀛愬拰
        Divisor: INT;               // 褰撳墠鍥犲瓙
        I: INT;                     // 寰幆璁℃暟鍣
        J: INT;                     // 鍒濆鍖栬鏁板櫒
    END_VAR
    
    (*
    鐗堟湰璁板綍锛
    鐗堟湰          鏃ユ湡           浣滆
     V1         2024-10-3       宸ユ帶鑰佺帇
    *)
    
    
    // 鍒濆鍖栧畬鏁拌鏁板櫒鍜屾暟缁
    PerfectCount := 0;
    FOR J := 1 TO 100 BY 1 DO
        PerfectNumbers[J] := 0;
    END_FOR;
    
    // 涓诲惊鐜
    FOR CurrentNumber := MinValue TO MaxValue DO
        DivisorSum := 0; // 閲嶇疆鍥犲瓙鍜
    
        // 璁$畻鍥犲瓙鍜
        FOR Divisor := 1 TO CurrentNumber / 2 DO
            IF CurrentNumber MOD Divisor = 0 THEN
                DivisorSum := DivisorSum + Divisor; // 鍔犲叆鍥犲瓙
            END_IF;
        END_FOR;
    
        // 妫鏌ユ槸鍚︿负瀹屾暟
        IF DivisorSum = CurrentNumber THEN
            PerfectCount := PerfectCount + 1; // 澧炲姞瀹屾暟璁℃暟
            // 瀛樺偍瀹屾暟
            IF PerfectCount <= 100 THEN
                PerfectNumbers[PerfectCount] := CurrentNumber;
            END_IF;
        END_IF;
    END_FOR;
    4  浠g爜瑙i噴
    杈撳叆杈撳嚭鍙橀噺锛
    • 浣跨敤 VAR_INPUT 澹版槑杈撳叆鍙橀噺 MinValue 鍜 MaxValue銆
    • 浣跨敤 VAR_OUTPUT 澹版槑杈撳嚭鍙橀噺 PerfectCount 鍜 PerfectNumbers銆
    鍙橀噺鍒濆鍖栵細
    • 鍦ㄤ富绋嬪簭寮濮嬫椂锛屽皢 PerfectCount 鍒濆鍖栦负 0锛屽苟灏 PerfectNumbers 鏁扮粍鐨勬墍鏈夊厓绱犺缃负 0銆
    璁$畻瀹屾暟锛
    • 浣跨敤涓や釜宓屽鐨勫惊鐜紝澶栧眰閬嶅巻褰撳墠鏁板瓧锛屽唴灞傝绠楀洜瀛愬拰锛屽苟妫鏌ュ畬鏁版潯浠躲
    娉ㄦ剰浜嬮」锛
    • 鏁扮粍澶у皬闄愬埗涓 100锛屽闇瀛樺偍鏇村瀹屾暟锛岃鐩稿簲璋冩暣鏁扮粍鐨勫ぇ灏忋
    • 杈撳叆鑼冨洿涓婇檺鐨勬暟鎹被鍨嬩负 INT锛屾渶澶у间负锛32767锛屽鏋滈渶瑕佹祴璇曟洿澶х殑鏁帮紝闇瑕佽皟鏁存暟鎹被鍨嬨
    • 纭繚杈撳叆鑼冨洿閫傚悎浣犵殑瀹為檯闇姹傘
    5  杩愯缁撴灉
    杩愯绋嬪簭鍚庯紝PerfectNumbers 鏁扮粍灏嗗瓨鍌ㄥ湪鎸囧畾鑼冨洿鍐呮壘鍒扮殑鎵鏈夊畬鏁帮紝鑰 PerfectCount 灏嗚〃绀烘壘鍒扮殑瀹屾暟鏁伴噺銆傚浜 MinValue 涓 1锛孧axValue 涓 10000锛岀▼搴忓皢鍙戠幇瀹屾暟涓猴細 6銆28銆496銆8128 銆


    640?wx_fmt=png&from=appmsg.jpg

    640?wx_fmt=png&from=appmsg.jpg
    6  寮婧愮増鏈鏄
    璇ョ▼搴忛伒寰紑婧愬師鍒欙紝浠讳綍浜洪兘鍙互浣跨敤銆佷慨鏀瑰拰鍒嗗彂姝や唬鐮併傚湪浣跨敤鍓嶅簲杩涜鍏呭垎鐨勬祴璇曪紝淇敼浠g爜鏃讹紝璇风鎸佸垎浜簿绁烇紝灏嗘偍鐨勬敼杩涘拰鎴愭灉杩涜鍒嗕韩锛屼互渚挎洿澶氫汉鍙楃泭銆

    鎬荤粨

    鏈枃灞曠ず浜嗗浣曚娇鐢 CoDeSys 骞冲彴涓婄殑 ST 璇█缂栧啓涓涓畝鍗曠殑瀹屾暟鏌ユ壘绋嬪簭銆傞氳繃瀹氫箟杈撳叆杈撳嚭鍙橀噺锛屽垵濮嬪寲绋嬪簭锛屼娇鐢ㄥ惊鐜拰鏉′欢鍒ゆ柇锛屾垜浠兘澶熸湁鏁堝湴璁$畻鍑虹粰瀹氳寖鍥村唴鐨勫畬鏁般傞氳繃杩欎竴缁冧範锛屾偍涓嶄粎鐔熸倝浜嗗浣曞湪 CODESYS 涓娇鐢 ST 璇█杩涜鏉′欢鍒ゆ柇鍜屽惊鐜帶鍒讹紝杩樺湪瀹炶返涓彁鍗囦簡閫昏緫鎬濈淮鍜岄棶棰樿В鍐宠兘鍔涖


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

    浣跨敤閬撳叿 涓炬姤

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

    鏈増绉垎瑙勫垯

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

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

    GMT+8, 2025-4-3 16:07 , Processed in 0.154025 second(s), 62 queries .

    閰峰痉缃

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

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