2.0 浣犵殑绗竴涓狢ODESYS绋嬪簭-CODESYS璧勬簮涓嬭浇鍖-閰峰痉缃 - CoDeSys杞欢鏁欑▼涓嬭浇,CoDeSys宸ユ帶璧勮闂ㄦ埛
HSC6490-cn涓浗鍒堕狅紝涓浗鑺瘇
鏌ョ湅: 2286|鍥炲: 0

2.0 浣犵殑绗竴涓狢ODESYS绋嬪簭

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

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

    鍙戣〃浜 2020-12-28 09:51:12 | 鏄剧ず鍏ㄩ儴妤煎眰 |闃呰妯″紡
    銆銆寮濮嬩箣鍓

    銆銆鏁版嵁瀹夊叏锛 涓轰簡灏介噺鍑忓皯鏁版嵁瀹夊叏婕忔礊鐨勯闄╋紝鎴戜滑寤鸿閲囧彇浠ヤ笅缁勭粐鍜屾妧鏈帾鏂斤細  * 閬垮厤浠庡紑鏀剧綉缁滃拰浜掕仈缃戣闂甈LC鍜屾帶鍒剁綉缁溿

    銆銆* 浣跨敤VPN杩涜杩滅▼璁块棶銆

    銆銆* 瀹夎闃茬伀澧欍

    銆銆* 濡傛灉瑕佸湪缃戠粶涓婂彂甯冨彲瑙嗗寲鏂囦欢锛岃璁剧疆瀵嗙爜浠ラ槻姝㈡湭缁忔巿鏉冪殑璁块棶銆

    銆銆* 浣跨敤鏈鏂扮増鏈殑缃戝叧鏈嶅姟鍣ㄥ拰Web鏈嶅姟鍣ㄣ

    銆銆瀹夎CODESYS锛

    銆銆娉ㄦ剰

    銆銆瀹夎鍖呮嫭寮鍙戠郴缁燂紝CODESYS缃戝叧鍜孋ODESYS Control Win V3锛屽叾鏈嶅姟鍙氳繃Windows浠诲姟鏍忚闂

    銆銆杩欎笁涓▼搴忔槸妯℃嫙璁$畻鏈轰笂鐨勬帶鍒跺櫒鎵蹇呴渶鐨勩

    銆銆鍏充簬浣犵殑绗竴涓」鐩殑鍐呭

    銆銆鍦ㄦ湰鏁欑▼涓紝鎮ㄥ皢缂栧啓涓涓畝鍗曠殑鍐扮鎺у埗鍣ㄣ

    銆銆宸插畬鎴愮殑椤圭洰RefrigeratorControl.project_archive鍙互鍦ㄢProjects鈥濈洰褰曚笅鐨凜ODESYS瀹夎鐩綍涓壘鍒般

    銆銆闄や簡鎮ㄥ皢閫愭鍒涘缓鐨勭ず渚嬮」鐩箣澶栵紝宸插畬鎴愮殑椤圭洰杩樺寘鍚畬鏁寸殑鍙鍖栨搷浣滃拰璇婃柇銆

    銆銆涓庝紶缁熺殑鍐扮涓鏍凤紝娓╁害鐢辩敤鎴烽氳繃鏃嬭浆鎺у埗鍣ㄦ潵鎸囧畾銆

    銆銆鍐扮閫氳繃浼犳劅鍣ㄧ‘瀹氬疄闄呮俯搴︺

    銆銆濡傛灉澶珮锛屽啺绠变細閫氳繃鍙皟鑺傜殑寤舵椂鍚姩鍘嬬缉鏈恒

    銆銆鍘嬬缉鏈哄喎鍗寸洿鑷宠揪鍒版墍闇鐨勬俯搴︼紝鍑忓幓1搴︾殑婊炲悗銆

    銆銆婊炲悗鏄负浜嗛槻姝㈠疄闄呮俯搴﹀湪娓╁害璁惧畾鐐归檮杩戞尝鍔ㄥお澶э紝杩欏皢瀵艰嚧鍘嬬缉鏈轰笉鏂湴鑷鍏抽棴鍜屾墦寮銆

    銆銆濡傛灉闂ㄦ墦寮锛屽啺绠卞唴閮ㄧ殑鐏細浜捣銆

    銆銆濡傛灉闂ㄦ墦寮鏃堕棿杩囬暱锛屽垯杈撳嚭闂存瓏鎬х殑澹伴煶淇″彿銆

    銆銆濡傛灉鍘嬬缉鏈哄湪鐢垫満闀挎椂闂村伐浣滅殑鎯呭喌涓嬩粛鏈揪鍒版俯搴﹁瀹氬硷紝铚傞福鍣ㄥ皢鍙戝嚭涓涓亽瀹氱殑澹伴煶淇″彿銆

    銆銆椤圭洰璁″垝锛  鍐峰嵈娲诲姩鍦ㄥ簲鐢ㄧ▼搴忕殑涓荤▼搴忎腑杩涜鎺у埗锛屼俊鍙风鐞嗗湪鍙︿竴涓▼搴忓潡涓繘琛屻

    銆銆Standard搴撲腑鎻愪緵浜嗘墍闇鐨勬爣鍑嗗姛鑳藉潡銆

    銆銆鐢变簬鍦ㄦ绀轰緥椤圭洰涓病鏈夎繛鎺ョ湡姝g殑娓╁害浼犳劅鍣ㄥ拰瀹為檯鐨勬墽琛屽櫒锛屾偍杩橀渶瑕佺紪鍐欎竴涓▼搴忔潵妯℃嫙娓╁害鐨勪笂鍗囧拰涓嬮檷銆

    銆銆杩欏皢鍏佽鎮ㄥ湪鍦ㄧ嚎妯″紡涓嬬洃鎺у啺绠辨帶鍒跺櫒鐨勬搷浣溿

    銆銆蹇呴』鍦ㄥ叏灞鍙橀噺鍒楄〃涓畾涔夎鐢辨墍鏈夊姛鑳藉潡浣跨敤鐨勫彉閲忋

    銆銆鍑嗗

    銆銆鎮ㄥ凡缁忓畨瑁呬簡CODESYS寮鍙戠郴缁熷苟浣跨敤榛樿閰嶇疆鏂囦欢鈥淐ODESYS V鈥濆惎鍔ㄥ畠銆

    銆銆寮鍙戠郴缁熺殑妗嗘灦绐楀彛鐢ㄦ爣鍑嗚彍鍗曟爮鎵撳紑; 鐩墠杩樻病鏈夋墦寮鐨勯」鐩

    銆銆鍒涘缓椤圭洰骞堕夋嫨PLC璁惧

    銆銆1. 閫夋嫨鍛戒护File 鈥 New Project銆

    銆銆2. 鍦═emplates绐楀彛涓紝閫夋嫨Standard Project妯℃澘銆

    銆銆3. 杈撳叆椤圭洰鐨勫悕绉板拰瀛樺偍浣嶇疆锛岀劧鍚庡崟鍑籓K鎸夐挳銆

    銆銆   鈬掓墦寮Standard Project瀵硅瘽妗嗭紝杈撳叆璁惧绫诲瀷鍜屼富绋嬪簭鐨勫疄鐜拌瑷銆

    銆銆4. 鍦―evice鍒楄〃涓紝閫夋嫨鏉$洰CODESYS Control Win V3銆

    銆銆5. 鍦≒LC_PRG鍒楄〃涓夋嫨鏉$洰Continuous Function Chart (CFC)  ,鐒跺悗鍗曞嚮OK鎸夐挳銆

    銆銆鈬掗」鐩湪CODESYS妗嗘灦绐楀彛涓墦寮銆

    銆銆鍦ㄦ鏋剁獥鍙g殑宸︿晶鐨凞evices瑙嗗浘涓紝鎮ㄥ皢鐪嬪埌鈥滆澶囨爲鈥濄備箣鍓嶉夋嫨鐨凱LC璁惧浠ラ粯璁ゅ悕绉癉evice鏄剧ず銆

    銆銆鐢辨偍鏉ョ紪绋嬬殑PLC搴旂敤绋嬪簭鐨凙pplication瀵硅薄宸茬粡鎸傝浇鍦≒LC Logic瀵硅薄涓嬨侫pplication宸茬粡鍖呭惈PLC_PRG涓荤▼搴忓拰Library manager瀵硅薄銆侺ibrary manager宸茬粡鍖呭惈浜咺oStandard鍜孲tandard搴撱

    銆銆IoStandard鏄疘/O閰嶇疆鎵蹇呴渶鐨勩

    銆銆Standard搴撳寘鍚獻EC 61131-3鏍囧噯鎻忚堪鐨勬墍鏈夊姛鑳藉拰鍔熻兘鍧椼俆ask Configuration瀵硅薄鎸傝浇鍦ㄨ澶囨暟搴曢儴锛屽寘鍚玀ain task锛孧ain task鎺у埗PLC_PRG鐨勫鐞嗐

    銆銆渚嬪锛岀敤浜庡彲瑙嗗寲鐨勫璞″彲浠ョ◢鍚庢彃鍏ュ埌Task Configuration涓嬫柟銆

    銆銆闄や簡IoStandard鍜孲tandard搴撲箣澶栵紝姝ょず渚嬮」鐩繕闇瑕乁til搴擄細

    銆銆1. 鍙屽嚮璁惧鏍戜腑鐨凩ibrary manager瀵硅薄銆

    銆銆    鈬掓墦寮Library manager缂栬緫鍣ㄣ

    銆銆2. 鍦ㄧ紪杈戝櫒鐨勬爣棰樻爮涓紝鍗曞嚮Add library锛岀劧鍚庡湪Add library瀵硅瘽妗嗕腑閫夋嫨Util搴撱

    銆銆鍗曞嚮OK鎸夐挳纭閫夋嫨 鈬扷til搴撹娣诲姞鍒癓ibrary manager涓紝搴撲腑鐨勫姛鑳藉潡鍙緵鎮ㄥ湪椤圭洰涓娇鐢ㄣ

    銆銆鍦ㄩ」鐩腑缂栧啓鎺у埗搴旂敤绋嬪簭锛氳鎵ц姝ゆ搷浣滐紝璇峰弬闃呬互涓嬮儴鍒嗭細
    銆銆澹版槑鍏ㄥ眬鍙橀噺

    銆銆棣栧厛锛屽0鏄庝綘甯屾湜鍦ㄦ暣涓簲鐢ㄧ▼搴忎腑浣跨敤鐨勫彉閲忋

    銆銆涓烘锛岃鍦ˋpplication涓嬪垱寤轰竴涓叏灞鍙橀噺鍒楄〃锛  1. 閫夊畾Application骞跺湪涓婁笅鏂囪彍鍗曚腑閫夋嫨鍛戒护Add Object 鈥 Global Variables List銆傚皢鑷姩杈撳叆鐨勫悕绉癎VL鏇存敼涓篏lob_Var骞跺崟鍑籄dd纭銆

    銆銆鈬掑璞 https__3A__2F__2Fhelp___codesys___com__2Fapi-content__2F2__2Fcodesys__2F3___5___12___0__2Fen__2F_images__2F_cds_icon_gvl___png.jpg Glob_Var鍑虹幇鍦 https__3A__2F__2Fhelp___codesys___com__2Fapi-content__2F2__2Fcodesys__2F3___5___12___0__2Fen__2F_images__2F_cds_icon_application___png.jpg 銆銆Application涓嬨

    銆銆GVL缂栬緫鍣ㄥ湪璁惧鏍戠殑鍙充晶鎵撳紑銆

    銆銆1. 鍑虹幇鏂囨湰瑙嗗浘鏃讹紝瀹冨凡缁忓寘鍚叧閿瓧VAR_GLOBALEND_VAR銆傚湪鎴戜滑鐨勪緥瀛愪腑锛岄氳繃鐐瑰嚮缂栬緫鍣ㄥ彸渚ц竟鐨 https__3A__2F__2Fhelp___codesys___com__2Fapi-content__2F2__2Fcodesys__2F3___5___12___0__2Fen__2F_images__2F_cds_img_button_decl_editor_tabular___png.jpg 銆銆鎸夐挳婵娲昏〃鏍艰鍥俱

    銆銆    鈬掑嚭鐜颁竴涓┖琛屻傚厜鏍囧湪Name鍒椾腑銆

    銆銆2. 鍦ㄤ笂涓嬫枃鑿滃崟涓夋嫨鍛戒护Insert銆

    銆銆    鈬掓墦寮杈撳叆鏍忋傚悓鏃禨cope VAR_GLOBALData type BOOL鑷姩濉叆璇ヨ銆

    銆銆3. 鍦ㄥ瓧娈礜ame涓敭鍏rTempActual

    銆銆4. 鍙屽嚮Data type鍒椾腑鐨勫瓧娈点

    銆銆    鈬掕瀛楁鐜板湪鏄彲缂栬緫鐨勶紝骞跺嚭鐜版寜閽 https__3A__2F__2Fhelp___codesys___com__2Fapi-content__2F2__2Fcodesys__2F3___5___12___0__2Fen__2F_images__2Fcds_icon_open_input_asisstant___png.jpg 銆銆銆

    銆銆5. 鍗曞嚮鎸夐挳锛岀劧鍚庨夋嫨Input assistant銆

    銆銆    鈬掓墦寮Input assistant瀵硅瘽妗嗐

    銆銆6. 閫夋嫨鏁版嵁绫诲瀷REAL锛岀劧鍚庡崟鍑籓K鎸夐挳銆

    銆銆7. 鍦↖nitialization鍒椾腑杈撳叆涓涓暟鍊硷紝渚嬪8.0銆

    銆銆浠ョ浉鍚岀殑鏂瑰紡澹版槑浠ヤ笅鍙橀噺銆

    [td]
    鍚嶇О鏁版嵁绫诲瀷鍒濆鍊
    rTempActualREAL鏁板瓧锛屼緥濡8.0
    rTempSetREAL鏁板瓧锛屼緥濡8.0
    rDoorOpenBOOLFALSE
    timAlarmThresholdTIMET#30S鍘嬬缉鏈鸿繍琛岃鏃堕棿鍚庯紝淇″彿鍝嶈捣
    rDoorOpenThresholdTIMET#10S寮闂ㄥ悗鐨勬椂闂达紝鐒跺悗鍙戝嚭涓涓俊鍙
    bCompressorBOOLFALSE
    bSignalBOOLFALSE
    bLampBOOLFALSE


    銆銆鍦–FC缂栬緫鍣ㄤ腑鍒涘缓鍐峰嵈鎺у埗鐨勪富绋嬪簭

    銆銆鎮ㄧ幇鍦ㄥ皢鍦ㄩ粯璁ゅ垱寤虹殑涓荤▼搴忓潡PLC_PRG涓弿杩板簲鐢ㄧ▼搴忕殑涓昏鍔熻兘锛氬鏋滃疄闄呮俯搴﹂珮浜庢俯搴﹁瀹氬煎姞涓婃粸鍚庯紝鍘嬬缉鏈哄皢琚縺娲诲苟寮濮嬪喎鍗淬

    銆銆濡傛灉瀹為檯娓╁害浣庝簬璁惧畾鍊煎噺鍘绘粸鍚庯紝鍒欏叧闂帇缂╂満銆

    銆銆涓轰簡鍦ㄥ疄鐜拌瑷CFC涓弿杩版鍔熻兘锛岃鎵ц浠ヤ笅姝ラ锛  1. 鍦ㄨ澶囨爲涓弻鍑籔LC_PRG銆

    銆銆    鈬扖FC缂栬緫鍣ㄥ皢鎵撳紑PLC_PRG閫夐」鍗°傚0鏄庣紪杈戝櫒浠ユ枃鏈垨琛ㄦ牸褰㈠紡鍑虹幇鍦ㄥ浘褰㈢紪杈戝櫒鐨勪笂鏂广傚彸杈规槸Tools绐楀彛銆

    銆銆1. 鍦═ools绐楀彛涓崟鍑籌nput锛岀劧鍚庣敤榧犳爣灏嗗叾鎷栧姩鍒癈FC缂栬緫鍣ㄤ腑鎻掑叆瀹冦

    銆銆2. 鍗曞嚮CFC缂栬緫鍣ㄤ腑鐨勫厓绱狅紝鐒跺悗鍗曞嚮 https__3A__2F__2Fhelp___codesys___com__2Fapi-content__2F2__2Fcodesys__2F3___5___12___0__2Fen__2F_images__2F_cds_icon_input_assistent___png.jpg 銆銆鎵撳紑杈撳叆鍔╂墜銆備粠Variables绫诲埆涓紝閫夋嫨Application 鈥 Glob_Var涓嬬殑鍙橀噺rTempActual銆傜敤杩欑鏂规硶浣犲彲浠ュ湪杩欓噷寮曠敤鍏ㄥ眬鍙橀噺rTempActual

    銆銆3. 涓3.涓鏍凤紝浣跨敤鍏ㄥ眬鍙橀噺rTempSet鍒涘缓鍙︿竴涓緭鍏ャ

    銆銆4. 鍐嶅垱寤轰竴涓緭鍏ワ紝鐒跺悗鐐瑰嚮涓変釜闂彿???骞跺皢鍏舵浛鎹负鍚嶇ОrHysteresis銆

    銆銆    鈬掑洜涓鸿繖涓嶆槸宸茬煡鍙橀噺鐨勫悕绉帮紝鎵浠ュ嚭鐜癆uto Declare瀵硅瘽妗嗐傝鍚嶇О宸茶濉叆鍒板璇濇涓

    銆銆5. 浣跨敤Data typeREAL鍜孖nitialization鍊1濉厖Declare鍙橀噺瀵硅瘽妗嗕腑鐨勫瓧娈点傚崟鍑籓K鎸夐挳銆

    銆銆    鈬掑彉閲rHysteresis鍑虹幇鍦ㄥ0鏄庣紪杈戝櫒涓

    銆銆6. 鐜板湪鍐嶆彃鍏ヤ竴涓姛鑳藉潡锛氬崟鍑诲伐鍏风獥鍙d腑鐨凚ox鍏冪礌锛屽苟鐢ㄩ紶鏍囧皢鍏舵嫋鍔ㄥ埌CFC缂栬緫鍣ㄤ腑銆

    銆銆    鈬掑姛鑳藉潡鍑虹幇鍦–FC缂栬緫鍣ㄤ腑銆

    銆銆7. 浣跨敤ADD鏇挎崲???銆

    銆銆    鈬( )ADD鍔熻兘鍧楃敱鏍囧噯搴撴彁渚涖傚畠灏嗚繛鎺ュ埌瀹冪殑鎵鏈夎緭鍏ヨ繘琛岀浉鍔犮

    銆銆8. 灏Glob_Var.rTempSet杈撳叆杩炴帴鍒癆DD鍔熻兘鍧椼備负姝わ紝璇峰崟鍑昏緭鍏ョ殑杈撳嚭杩炴帴鍣紝骞跺皢鍏舵嫋鍔ㄥ埌ADD鍔熻兘鍧楃殑涓婇儴杈撳叆銆

    銆銆9. 鍚屾牱锛屽皢杈撳叆rHysteresis杩炴帴鍒癆DD鍔熻兘鍧楃殑涓嬮儴杈撳叆銆

    銆銆    鈬掍袱涓緭鍏Hysteresis鍜宺TempSet鐜板湪鐢盇DD娣诲姞銆

    銆銆10. 濡傛灉鎮ㄥ笇鏈涘湪缂栬緫鍣ㄤ腑绉诲姩鍏冪礌锛岃鍗曞嚮鍏冪礌涓垨妗嗘灦涓婄殑绌虹櫧鍖哄煙锛屼互渚块夋嫨璇ュ厓绱狅紙绾㈣壊杈规锛岀孩鑹查槾褰憋級銆傛寜浣忛紶鏍囧苟灏嗗厓绱犳嫋鍔ㄥ埌鎵闇鐨勪綅缃

    銆銆11. 鍦ˋDD鍔熻兘鍧楃殑鍙充晶鍒涘缓鍙︿竴涓姛鑳藉潡銆傚畠鐨勫姛鑳芥槸姣旇緝Glob_Var.rTempActual鍜孏lob_Var.rTempSet + rHysteresis涔嬪拰銆傝祴浜堝姛鑳藉潡GT锛堝ぇ浜庯級鐨勫姛鑳姐

    銆銆    鈬扜T鍔熻兘鍧椾篃鏉ヨ嚜Standard搴擄紝宸ヤ綔鍘熺悊濡備笅锛IF (upper input > lower input) THEN output

    銆銆12. 灏嗚緭鍏lob_Var_rTempActual杩炴帴鍒癎T鍔熻兘鍧楃殑涓婇儴杈撳叆绔

    銆銆13. 灏咥DD鍔熻兘鍧楃殑杈撳嚭杩炴帴鍒癎T鍔熻兘鍧楃殑涓嬮儴杈撳叆銆

    銆銆14. 鐜板湪鏍规嵁杈撳叆鏉′欢锛圫et - Reset锛夊湪GT鍔熻兘鍧楃殑鍙充晶鍒涘缓涓涓姛鑳藉潡锛屼互鍚姩鎴栧仠姝㈠喎鍗村帇缂╂満銆傚湪瀛楁???涓緭鍏ュ悕绉SR銆備娇鐢‥nter閿叧闂姛鑳藉潡锛SR_0锛変笂鏂规墦寮鐨勮緭鍏ュ瓧娈点

    銆銆    鈬掓墦寮Declare variables瀵硅瘽妗嗐

    銆銆15. 澹版槑鍚嶇О涓SR_0鍜屾暟鎹被鍨嬩负SR鐨勫彉閲忋傚崟鍑籓K鎸夐挳銆

    銆銆    鈬Standard搴撲腑瀹氫箟鐨凷R鍔熻兘鍧楃敤浜庡湪GT鍔熻兘鍧楃殑杈撳嚭绔畾涔THEN銆傚嚭鐜拌緭鍏SET1RESET

    銆銆16. 灏咷T鍔熻兘鍧楀彸渚х殑杈撳嚭杩炴帴鍣ㄨ繛鎺ュ埌SR_0鍔熻兘鍧楃殑SET1杈撳叆銆

    銆銆鈬SR鍙互灏嗕竴涓竷灏斿彉閲忎粠FALSE璁剧疆涓TRUE锛岀劧鍚庡啀杩斿洖銆傚鏋滆緭鍏ET1鐨勬潯浠舵弧瓒筹紝鍒欏竷灏斿彉閲忚缃负TRUE銆傚鏋滄弧瓒RESET鏉′欢锛屽彉閲忓皢閲嶆柊澶嶄綅銆傛垜浠緥瀛愪腑鐨勫竷灏旓紙鍏ㄥ眬锛夊彉閲忔槸bCompressor

    銆銆17. 鍒涘缓涓涓厓绱燨utput骞跺皢鍏跺垎閰嶇粰鍏ㄥ眬鍙橀噺Glob_Var.Compressor銆傚湪Glob_Var.Compressor鍜孲R鐨勮緭鍑鸿繛鎺ュ櫒Q1涔嬮棿鐢讳竴鏉¤繛绾裤

    銆銆鐜板湪鎸囧畾鍘嬬缉鏈哄簲璇ュ啀娆″叧闂殑鐘舵侊紝鍗砈R鍔熻兘鍧楃殑RESET杈撳叆鎺ユ敹鍒颁竴涓猅RUE淇″彿銆

    銆銆瑕佸仛鍒拌繖涓鐐癸紝浣犺鍒跺畾涓庝笂杩扮浉鍙嶇殑鏉′欢銆備娇鐢ㄥ姛鑳藉潡SUB锛堝噺锛夊拰LT锛堝皬浜庯級鏉ュ仛鍒拌繖涓鐐广

    銆銆鏈鍚庡垱寤轰笅闈㈢殑CFC鍥捐〃锛
    https__3A__2F__2Fhelp___codesys___com__2Fapi-content__2F2__2Fcodesys__2F3___5___12___0__2Fen__2F_images__2F_cds_img_tutorial_refrigerator_plcprg_cfc_diagram___png.jpg
    銆銆鍦ㄦ褰㈠浘缂栬緫鍣ㄤ腑鍒涘缓淇″彿绠$悊鐨勭▼搴忓潡

    銆銆鍦ㄥ彟涓涓▼搴忓潡涓紝鎮ㄧ幇鍦ㄥ皢鎵ц璀︽姤铚傞福鍣ㄧ殑淇″彿绠$悊涓庢墦寮鍜屽叧闂伅娉°傞傚悎鐢ㄦ褰㈠浘锛圠D锛夎瑷瀹炵幇銆

    銆銆鍦ㄥ崟鐙綉缁滀腑澶勭悊浠ヤ笅淇″彿锛  * 濡傛灉鍘嬬缉鏈虹敱浜庢俯搴﹁繃楂樿岃繍琛屾椂闂磋繃闀匡紝鍒欓氳繃杩炵画鐨勫0闊充俊鍙峰紩璧锋敞鎰忋

    銆銆* 濡傛灉闂ㄦ墦寮鏃堕棿杩囬暱锛屽垯閫氳繃闂存瓏淇″彿寮曡捣娉ㄦ剰銆

    銆銆* 鍙闂ㄦ墦寮锛岀伅灏变寒銆

    銆銆鍦ㄨ澶囨爲鐨凙pplication涓嬫柟锛屼娇鐢↙adder Diagram (LD)瀹炵幇璇█鍒涘缓涓涓被鍨嬩负Program鐨凱OU瀵硅薄銆傚悕绉颁负Signals銆

    銆銆鈬扴ignals瀵硅薄鍑虹幇鍦≒LC_PRG涓嬮潰鐨勮澶囨爲涓傚湪姊舰鍥剧紪杈戝櫒鎵撳紑Signals閫夐」鍗°傚0鏄庣紪杈戝櫒鍑虹幇鍦ㄤ笂閮紝Tools绐楀彛鍑虹幇鍦ㄥ彸渚с侺D鍖呭惈涓涓┖缃戠粶銆

    銆銆鍦ㄧ綉缁滀腑鍒涘缓涓涓▼搴忥紝褰撳帇缂╂満杩愯鏃堕棿杩囬暱鑰屾病鏈夎揪鍒版俯搴﹁瀹氬兼椂锛屼細鍙戝嚭澹伴煶淇″彿銆備负姝わ紝鎻掑叆涓涓畾鏃跺櫒鍔熻兘鍧桾ON銆傚畠鍦ㄦ寚瀹氱殑鏃堕棿涔嬪悗鎵嶅皢甯冨皵TRUE淇″彿鍒囨崲涓篢RUE锛氬湪Tools绐楀彛涓殑Function blocks涓嬮夋嫨涓涓猅ON锛屽苟鐢ㄩ紶鏍囧皢鍏舵嫋鍏ョ┖缃戠粶锛岀劧鍚庢嫋鍒板嚭鐜扮殑鐭╁舰Start here澶勩傚綋瀛楁鍙樹负缁胯壊鏃堕噴鏀鹃紶鏍囨寜閽

    銆銆鈬掑姛鑳藉潡鏄剧ず涓哄甫鏈夎緭鍏ュ拰杈撳嚭鐨勭煩褰紝骞惰嚜鍔ㄧ粰鍑哄疄渚嬪悕绉癟ON_0銆備笂闈㈢殑杈撳叆榛樿宸茬粡鏄剧ず涓哄姛鑳藉潡涓婃父鐨勮Е鐐广

    銆銆娉ㄦ剰 濡傛灉瑕侀槄璇诲姛鑳藉潡鐨勫湪绾垮府鍔╋紝璇峰皢鍏夋爣鏀惧湪鍔熻兘鍧楃殑鈥淭ON鈥濆瓧绗︿覆涓紝鐒跺悗鎸塅1閿

    銆銆缂栫▼鏃讹紝鍙鍐峰嵈鍘嬬缉鏈哄紑濮嬭繍琛岋紝鍔熻兘鍧楀氨浼氳婵娲伙細涓烘锛岃鍦ㄥ姛鑳藉潡Glob_Var.Compressor鐨勪笂閮ㄨ緭鍏ュ鍛藉悕瑙︾偣銆傛偍宸茬粡鍦℅VL Glob_Var涓畾涔変簡杩欎釜甯冨皵鍙橀噺銆

    銆銆娉ㄦ剰  褰撴偍寮濮嬪湪杈撳叆浣嶇疆杈撳叆涓涓彉閲忓悕鏃讹紝鎮ㄥ皢鑷姩鑾峰緱鍚嶇О浠ヨ緭鍏ュ瓧绗﹀紑澶寸殑鎵鏈夊彉閲忕殑鍒楄〃锛屽苟涓斿彲浠ュ湪姝ゅ浣跨敤銆傝繖绉嶅府鍔╂槸CODESYS閫夐」涓敤浜庢櫤鑳界紪绋嬬殑鏍囧噯璁剧疆銆

    銆銆鎻掑叆瑕佹縺娲荤殑淇″彿銆備负姝わ紝浠庡伐鍏风被鍒獿adder elements鎷栧姩涓涓狢oil鍒癟ON鍔熻兘鍧楃殑杈撳嚭绔疩. 灏嗙嚎鍦堝懡鍚嶄负Glob_Var.bSignal銆

    銆銆瀹氫箟浠嶵ON鍔熻兘鍧楁縺娲荤洿鍒颁俊鍙峰彂鍑虹殑鏃堕棿娈碉細璇ュ畾涔夐氳繃鍙橀噺Glob_Var.timAlarmThreshold杩涜锛岃鍙橀噺涓篢ON_0鐨勮緭鍏T銆備负姝わ紝璇峰崟鍑昏緭鍏ヨ繛鎺ュ彸渚х殑缁嗚竟鐭╁舰锛岀劧鍚庤緭鍏ュ彉閲忓悕绉般

    銆銆鐐瑰嚮TON鍔熻兘鍧楀苟鍦ㄤ笂涓嬫枃鑿滃崟涓夋嫨Remove unused FB call parameters鍛戒护銆

    銆銆鈬掓湭浣跨敤鐨勮緭鍑篍T琚垹闄ゃ

    銆銆鍦↙D鐨勭浜屼釜缃戠粶涓紝缂栫▼浣垮緱濡傛灉闂ㄦ墦寮鏃堕棿杩囬暱锛屼細闂存瓏鍙戝嚭淇″彿銆

    銆銆鍦ㄢ滅紪杈戝櫒鈥濈獥鍙d腑鍗曞嚮绗竴涓綉缁滀笅闈㈢殑鍦版柟锛岀劧鍚庡湪涓婁笅鏂囪彍鍗曚腑閫夋嫨Insert network鍛戒护銆

    銆銆鈬掓樉绀虹紪鍙蜂负2鐨勭┖鐧界綉缁溿

    銆銆涓庡湪绗竴涓綉缁滀腑涓鏍凤紝瀹炵幇涓涓猅ON鍔熻兘鍧楋紝鐢ㄤ簬鏃堕棿鎺у埗婵娲讳俊鍙凤紝杩欐鐢辫緭鍏N鐨勫叏灞鍙橀噺Glob_Var.rDoorOpen瑙﹀彂銆傚湪杈撳叆PT锛屾坊鍔犲叏灞鍙橀噺GlobVar.timDoorOpenThreshold銆

    銆銆鍙﹀锛屽湪璇ョ綉缁滅殑TON鍔熻兘鍧楃殑杈撳嚭绔疩涓婏紝浠嶶til搴撲腑娣诲姞涓涓狟LINK鍔熻兘鍧楋紝骞跺懡鍚嶄负Blink_0銆

    銆銆BLINK瀵硅浆鍙慟鐨勪俊鍙疯繘琛岃鏃讹紝骞跺洜姝ゅGlobVar.bSignal杩涜璁℃椂銆

    銆銆鍦ㄤ袱涓Е鐐瑰悗闈㈡彃鍏ヤ竴涓猚oil鍏冪礌锛屽苟涓哄叾鍒嗛厤鍏ㄥ眬鍙橀噺lob_Var.bSignal銆

    銆銆涓烘锛屽0鏄庡眬閮ㄥ彉閲弔imSignalTime锛歍IME锛= T#1S;,骞跺湪杈撳叆TIMELOW鍜孴IMEHIGH澶勬彃鍏ユ鍙橀噺;鍥犳寰幆鏃堕棿瀵逛簬TRUE涓1绉掞紝瀵逛簬FALSE涓1绉掋

    銆銆鍗曞嚮TON鍔熻兘鍧楀苟鍦ㄤ笂涓嬫枃鑿滃崟涓夋嫨Remove unused FB call parameters鍛戒护銆

    銆銆鈬掓湭浣跨敤鐨勮緭鍑篍T琚垹闄ゃ

    銆銆鍦↙D鐨勭涓変釜缃戠粶涓紝鍙闂ㄦ墦寮锛岀伅灏变細浜捣鏉ャ

    銆銆瑕佸仛鍒拌繖涓鐐癸紝鎻掑叆鍙︿竴涓綉缁滐紝鍦ㄥ畠鐨勫乏杈癸紝GlobVar.rDoorOpen锛岀洿鎺ヨ繛鎺ュ埌绾垮湀Glob_Var.bLamp銆

    銆銆CODESYS杩炵画澶勭悊LD鐨勭綉缁溿傜幇鍦紝鍦ㄧ綉缁1鐨勬湯绔彃鍏ヨ烦杞埌缃戠粶3锛屼互纭繚鍙墽琛岀綉缁1鎴栧彧鎵ц缃戠粶2锛 閫氳繃榧犳爣鍦ㄧ綉缁滀腑鍗曞嚮鎴栭氳繃缃戠粶鍙风爜瀛楁閫夋嫨缃戠粶3銆傚湪涓婁笅鏂囪彍鍗曚腑閫夋嫨鍛戒护Insert label銆傜敤DoorIsOpen鏇挎崲缃戠粶宸︿笂瑙掓爣绛剧殑鏂囧瓧Label锛 閫夋嫨缃戠粶1銆侸ump鍏冪礌浠嶵ools绐楀彛鐨凣eneral绫诲埆鎷栧埌缃戠粶涓

    銆銆鎶婂畠鏀惧湪鍑虹幇鐨勭煩褰dd output or jump here杩欓噷銆

    銆銆鈬掑嚭鐜拌烦杞厓绱犮

    銆銆璺宠浆鐩爣浠嶇劧琚寚瀹氫负???銆

    銆銆閫夋嫨???骞剁偣鍑绘寜閽 https__3A__2F__2Fhelp___codesys___com__2Fapi-content__2F2__2Fcodesys__2F3___5___12___0__2Fen__2F_images__2F_cds_icon_button_threedots___png.jpg 銆銆銆

    銆銆浠庡彲鑳界殑鏍囩鏍囪瘑涓夋嫨DoorIsOpen锛岀劧鍚庡崟鍑籓K纭銆

    銆銆鈬掔綉缁3鐨勬爣绛捐鎵ц銆

    銆銆LD绋嬪簭鐜板湪鐪嬭捣鏉ュ儚杩欐牱锛
    https__3A__2F__2Fhelp___codesys___com__2Fapi-content__2F2__2Fcodesys__2F3___5___12___0__2Fen__2F_images__2F_cds_img_main_tutorial_ld_signals___png.jpg
    銆銆鍦ㄤ富绋嬪簭涓皟鐢ㄤ俊鍙风▼搴

    銆銆鍦ㄦ垜浠殑绋嬪簭绀轰緥涓紝涓荤▼搴廝LC_PRG搴旇璋冪敤Signals绋嬪簭杩涜淇″彿澶勭悊銆

    銆銆鍦ㄨ澶囨爲涓弻鍑籔LC_PRG銆

    銆銆鈬掑湪缂栬緫鍣ㄤ腑鎵撳紑PLC_PRG绋嬪簭銆

    銆銆灏嗕竴涓猣unction block鍏冪礌浠嶵ools瑙嗗浘鎷栧埌PLC_PRG鐨勭紪杈戝櫒涓

    銆銆浣跨敤杈撳叆鍔╂墜锛屼粠Function block calls绫诲埆涓坊鍔犲姛鑳藉潡璋冪敤Signals绋嬪簭銆

    銆銆鍒涘缓涓涓敤浜庢ā鎷熺殑ST绋嬪簭鍧

    銆銆鐢变簬鏈ず渚嬮」鐩腑鐨勫簲鐢ㄧ▼搴忎笌瀹為檯鐨勪紶鎰熷櫒鍜屾墽琛屽櫒娌℃湁鍏宠仈锛岀幇鍦ㄦ偍杩樺繀椤荤紪鍐欎竴涓敤浜庢ā鎷熸俯搴︿笂鍗囧拰涓嬮檷鐨勭▼搴忋傝繖灏嗗厑璁告偍鍦ㄧ嚎妯″紡涓嬬洃鎺у啺绠辨帶鍒跺櫒鐨勬搷浣溿

    銆銆鎮ㄥ彲浠ヤ娇鐢ㄧ粨鏋勫寲鏂囨湰鍒涘缓妯℃嫙绋嬪簭銆

    銆銆绋嬪簭鍗囬珮娓╁害锛岀洿鍒颁富绋嬪簭PLC_PRG纭畾宸茬粡瓒呰繃娓╁害璁惧畾鍊煎苟婵娲诲喎鍗村帇缂╂満銆

    銆銆鐒跺悗妯℃嫙绋嬪簭鍐嶆闄嶄綆娓╁害锛岀洿鍒颁富绋嬪簭鍐嶆鍋滅敤鍘嬬缉鏈恒

    銆銆鍦ˋpplication涓嬶紝鎻掑叆涓涓狿rogram绫诲瀷鍜屽疄鐜拌瑷ST鐨凱OU锛屽苟鍛藉悕涓篠imulation銆

    銆銆鍦⊿T缂栬緫鍣ㄤ腑瀹炵幇浠ヤ笅浠g爜锛
    [C] 绾枃鏈煡鐪 澶嶅埗浠g爜
    銆銆PROGRAM Simulation
    
    銆銆VAR
    
    銆銆T1: TON; //The temperature is decreased on a time delay, when the comepressor has been activated
    
    銆銆P_Cooling: TIME:=T#500MS;
    
    銆銆xReduceTemp: BOOL; //Signal for dereasing the temperature
    
    銆銆T2: TON; //The temperature is increased on a time delay, when the compressor has been activated
    
    銆銆P_Environment: TIME:=T#2S; //Delay time when the door is closed
    
    銆銆P_EnvironmentDoorOpen: TIME:=T#1S; //Delay time when the door is open
    
    銆銆xRaiseTemp: BOOL; //Signal for increasing the temperature
    
    銆銆timTemp: TIME; //Delay time
    
    銆銆iCounter: INT;
    
    銆銆END_VAR
    
    銆銆iCounter := iCounter+1; // No function, just for demonstration purposes.
    
    銆銆// After the compressor has been activated due to TempActual being too high, the temperature decreases.
    
    銆銆// The temperature is decremented by 0.1掳C per cycle after a delay of P_Cooling
    
    銆銆IF Glob_VAR.bCompressor THEN
    
    銆銆T1(IN:= Glob_Var.bCompressor, PT:= P_Cooling, Q=>xReduceTemp);
    
    銆銆IF xReduceTemp THEN
    
    銆銆Glob_Var.rTempActual := Glob_Var.rTempActual-0.1;
    
    銆銆T1(IN:=FALSE);
    
    銆銆END_IF
    
    銆銆END_IF
    
    銆銆//If the door is open, the warming occurs faster; SEL selects P_EnvironmentDoorOpen
    
    銆銆timTemp:=SEL(Glob_Var.rDoorOpen, P_Environment, P_EnvironmentDoorOpen);
    
    銆銆//If the compressor is not in operation, then the cooling chamber becomes warmer.
    
    銆銆//The temperature is incremented by 0.1掳C per cycle after a delay of tTemp
    
    銆銆T2(IN:= TRUE, PT:= timTemp, Q=>xRaiseTemp);
    
    銆銆IF xRaiseTemp THEN
    
    銆銆Glob_Var.rTempActual := Glob_Var.rTempActual + 0.1;
    
    銆銆T2(IN:=FALSE);
    
    銆銆END_IF


    銆銆娉ㄦ剰

    銆銆涓轰簡鏂逛究鎿嶄綔鍜岀洃鎺ф暣涓帶鍒剁▼搴忥紝鎺ㄨ崘浣跨敤鍙鍖栥備娇鐢–ODESYS Visualization鍒涘缓鐨勫彲瑙嗗寲鏂囦欢瀹夎鍦ㄦ湰鏁欑▼鐨勫凡瀹屾垚绀轰緥椤圭洰涓紝璇ョず渚嬮」鐩殢鏍囧噯CODESYS瀹夎锛圥rojects鐩綍锛変竴璧锋彁渚涖傛偍鍙互灏嗘椤圭洰鍔犺浇鍒版帶鍒跺櫒锛屽苟鍚姩瀹冧互鏌ョ湅瀹冧笌鍙鍖栦竴璧峰伐浣溿傚湪鍚姩鏃讹紝Live_Visu鍚姩浼氭樉绀哄啺绠辩殑鍥剧ず锛岃鍐扮鍙互鍦ㄤ笉闇瑕佽繘琛屼换浣曡緭鍏ョ殑鎯呭喌涓嬪啀鐜版ā鎷熺▼搴忕殑鎿嶄綔銆備絾鏄紝鍙鐢ㄩ紶鏍囩偣鍑籵n/off寮鍏筹紝灏卞彲浠ュ疄鐜伴棬鐨勬墦寮鍜屽叧闂紝骞朵笖鍙互璋冭妭鏃嬭浆鎺у埗鍣ㄩ拡涓婇璁剧殑娓╁害銆傛垜浠笉浼氬湪鏈暀绋嬩腑瀹炵幇鍙鍖栫殑鍒涘缓銆傝鍒掑湪CODESYS Visualization鑱旀満甯姪鐨勪笂涓嬫枃涓彁渚涗竴涓悎閫傜殑鏁欑▼銆

    銆銆浠诲姟閰嶇疆涓皢瑕佹墽琛岀殑绋嬪簭鐨勮鑼

    銆銆棰勮鐨勪换鍔¢厤缃寘鍚富绋嬪簭PLC_PRG鐨勮皟鐢ㄣ傚浜庢垜浠殑绀轰緥椤圭洰锛屾偍杩樺繀椤绘坊鍔犲Simulation绋嬪簭鐨勮皟鐢ㄣ

    銆銆鍦ㄨ澶囨爲涓紝浣跨敤榧犳爣灏哠imulation鏉$洰鎷栧埌Task Configuration涓嬬殑MainTask涓娿

    銆銆鈬掍豢鐪熷姛鑳藉潡鎻掑叆鍒颁换鍔¢厤缃腑銆

    銆銆濡傛灉鎮ㄥ笇鏈涙煡鐪嬩换鍔¢厤缃紝璇峰弻鍑籑ainTask鏉$洰鎵撳紑缂栬緫鍣ㄣ

    銆銆鈬掑湪缂栬緫鍣ㄧ殑涓嬪崐閮ㄥ垎鐨勮〃鏍间腑锛屾偍灏嗙湅鍒扮敱浠诲姟璋冪敤鐨凱OU锛歅LC_PRG锛堥粯璁ゆ彃鍏ワ級鍜孲imulation銆備换鍔$殑璋冪敤绫诲瀷鏄互20姣涓洪棿闅旂殑Cyclic銆傚湪鍦ㄧ嚎妯″紡涓嬶紝浠诲姟姣忎釜鍛ㄦ湡鎵ц涓娆¤繖涓や釜鍔熻兘鍧椼

    銆銆瀹氫箟涓嶱LC閫氳鐨勨滄椿鍔ㄥ簲鐢ㄧ▼搴忊

    銆銆搴旂敤绋嬪簭Application鐨勫悕绉板湪Devices绐楀彛涓互绮椾綋鏄剧ず銆傝繖鎰忓懗鐫杩欎釜搴旂敤绋嬪簭琚缃负鈥滄椿鍔ㄥ簲鐢ㄧ▼搴忊濄備笌鎺у埗鍣ㄧ殑閫氫俊鎸囧悜杩欎釜搴旂敤绋嬪簭銆

    銆銆鍦ˋpplication涓婂崟鍑婚紶鏍囧彸閿紝鐒跺悗鍦ㄤ笂涓嬫枃鑿滃崟涓夋嫨Set Active Application鍛戒护銆

    銆銆鈬掑簲鐢ㄧ▼搴忓簲鐢ㄧ▼搴忕幇鍦ㄥ湪鈥滆澶団濊鍥句腑浠ョ矖浣撴樉绀恒

    銆銆璋冭瘯搴旂敤绋嬪簭

    銆銆鍦ㄨ緭鍏ヤ唬鐮佺殑杩囩▼涓紝CODESYS浼氱珛鍗抽氳繃鐩稿叧鏂囨湰涓嬫柟鐨勭孩鑹叉尝娴嚎璀﹀憡鎮ㄦ湁璇硶閿欒銆傛寜F11妫鏌ユ暣涓簲鐢ㄧ▼搴忕殑璇硶锛屾鏌ョ粨鏋滄樉绀哄湪娑堟伅绐楀彛涓傚鏈夊繀瑕侊紝浣跨敤View 鈥 Messages鍛戒护鎵撳紑娑堟伅绐楀彛銆傜劧鍚庯紝鎮ㄥ彲浠ラ夋嫨涓鏉℃秷鎭苟浣跨敤F4閿烦杞埌浠g爜涓殑鐩稿簲浣嶇疆銆

    銆銆涔嬪悗鎮ㄥ彧鑳藉皢涓涓棤閿欑殑搴旂敤绋嬪簭鍔犺浇鍒版帶鍒跺櫒銆

    銆銆寤虹珛涓嶱LC鐨勮繛鎺ワ細涓烘锛岃鍙傞槄浠ヤ笅閮ㄥ垎锛

    銆銆鍚姩缃戝叧鏈嶅姟鍣ㄥ拰PLC

    銆銆鍚姩缃戝叧鏈嶅姟鍣細

    銆銆绋嬪簭GatewaySysTray涓嶤ODESYS涓璧锋爣鍑嗗畨瑁呫傛偍鍙互閫氳繃姝ょ▼搴忎笌缃戝叧鏈嶅姟鍣ㄨ繘琛岄氫俊銆

    銆銆缃戝叧鏈嶅姟鍣ㄥ湪绯荤粺鍚姩鏃朵綔涓烘湇鍔¤嚜鍔ㄥ惎鍔ㄣ傛鏌indows浠诲姟鏍忔槸鍚﹀寘鍚▼搴忓浘鏍 https__3A__2F__2Fhelp___codesys___com__2Fapi-content__2F2__2Fcodesys__2F3___5___12___0__2Fen__2F_images__2Ficon_gateway_running___png.jpg 銆銆銆傚鏋滅綉鍏虫湇鍔″櫒娌℃湁杩愯锛屽浘鏍囧涓嬫墍绀猴細 https__3A__2F__2Fhelp___codesys___com__2Fapi-content__2F2__2Fcodesys__2F3___5___12___0__2Fen__2F_images__2Ficon_gateway_stopped___png.jpg 銆銆銆傚湪杩欑鎯呭喌涓嬶紝鎮ㄥ彲浠ラ氳繃鍗曞嚮鍥炬爣鎵撳紑鈥滅綉鍏斥濊彍鍗曪紝鐒跺悗閫夋嫨Start Gateway鍛戒护銆

    銆銆鍚姩PLC锛

    銆銆绋嬪簭CODESYSControlSysTray涔熶綔涓篊ODESYS鏍囧噯瀹夎鐨勪竴閮ㄥ垎銆傛偍鍙互閫氳繃姝ょ▼搴忎笌CODESYS鎺у埗鏈嶅姟杩涜閫氫俊銆備粠CODESYS V3.5 SP2寮濮嬶紝鎺у埗鏈嶅姟涓嶅啀鑷姩鍚姩銆傝繖鏄负浜嗛槻姝㈡湭缁忔巿鏉冪殑璁块棶銆傛寜濡備笅鏂瑰紡鍚姩PLC锛氬湪Windows浠诲姟鏍忎腑鍗曞嚮 https__3A__2F__2Fhelp___codesys___com__2Fapi-content__2F2__2Fcodesys__2F3___5___12___0__2Fen__2F_images__2F_cds_icon_plc_stopped___png.jpg 銆銆锛屾墦寮PLC鑿滃崟锛岀劧鍚庨夋嫨鍛戒护Start PLC銆

    銆銆濡傛灉PLC姝e湪杩愯锛屽浘鏍囧彉涓 https__3A__2F__2Fhelp___codesys___com__2Fapi-content__2F2__2Fcodesys__2F3___5___12___0__2Fen__2F_images__2F_cds_icon_plc_running___png.jpg 銆銆銆傚惎鍔ㄦ椂鍑虹幇鐨勫璇濇琛ㄧず宸插惎鍔ㄧ殑PLC鍏佽缂栫▼璁块棶銆傝鍔″繀閬靛畧涓婅堪瀹夊叏璇存槑锛

    銆銆鍦ㄧ涓娆¢氫俊閰嶇疆鏈熼棿锛氭坊鍔犵綉鍏

    銆銆鍙屽嚮璁惧瑙嗗浘涓殑Device鏉$洰 锛圕ODESYS Control Win V3锛夈

    銆銆鈬掑嚭鐜癉evice瀵硅瘽妗嗙殑Communication Settings閫夐」鍗°

    銆銆娉ㄦ剰

    銆銆濡傛灉杩欐槸鎮ㄩ娆′娇鐢–ODESYSV3杩涜鐨勯氫俊閰嶇疆锛屽垯鐜板湪蹇呴』瀹氫箟鏈湴缃戝叧鏈嶅姟鍣ㄣ傚鏋滄偍宸茬粡瀹氫箟浜嗙綉鍏虫湇鍔″櫒锛屽畠灏嗘樉绀哄湪Communication閫夐」鍗′笂銆傚湪杩欑鎯呭喌涓嬶紝鎮ㄧ幇鍦ㄥ彲浠ョ户缁缃氫俊閫氶亾鐨勬楠ゃ

    銆銆缃戝叧鏈嶅姟鍣ㄩ殢CODESYS瀹夎鎻愪緵銆

    銆銆閫夋嫨鍛戒护Gateway 鈥 Add Gateway銆

    銆銆鈬掑嚭鐜癎ateway瀵硅瘽妗嗐
    https__3A__2F__2Fhelp___codesys___com__2Fapi-content__2F2__2Fcodesys__2F3___5___12___0__2Fen__2F_images__2F_cds_img_main_tutorial_gateway_added___png.jpg
    銆銆鍦ㄨ緭鍏ュ瓧娈礜ame涓緭鍏ョ綉鍏崇殑symbolic name銆

    銆銆鍦―rivers鍒楄〃涓夋嫨TCP/IP鏉$洰銆

    銆銆鍙屽嚮IP-Address琛岀殑鍙冲垪骞跺湪杈撳叆瀛楁涓緭鍏ocalhost銆

    銆銆鍗曞嚮OK鎸夐挳銆

    銆銆鈬掕澶囩紪杈戝櫒鐨凜ommunication Settings閫夐」鍗★紙1锛夊皢濉叆缃戝叧銆傚鏋滅綉鍏宠繍琛屾甯革紝鍒欑綉鍏冲浘褰笂浼氬嚭鐜颁竴涓豢鑹插渾鍦堬細
    https__3A__2F__2Fhelp___codesys___com__2Fapi-content__2F2__2Fcodesys__2F3___5___12___0__2Fen__2F_images__2F_cds_img_main_tutorial_select_device___png.jpg
    銆銆璁剧疆閫氳閫氶亾

    銆銆鐜板湪瀹氫箟璁惧鐨勯氫俊閫氶亾锛岀劧鍚庨氳繃鎮ㄨ缃殑缃戝叧浣跨敤璇ラ氶亾銆備负姝わ紝鍙屽嚮璁惧鏍戜腑鐨凞evice鏉$洰锛屾墦寮璁惧缂栬緫鍣ㄧ殑Communication Settings閫夐」鍗°

    銆銆鍗曞嚮Scan network鎸夐挳锛屽湪鏈湴缃戠粶涓悳绱㈡墍鏈夊彲鐢ㄧ殑璁惧銆

    銆銆鈬掑嚭鐜癝elect device瀵硅瘽妗嗭紙1锛夛紝骞跺垪鍑哄彲浠ヤ笌涔嬪缓绔嬭繛鎺ョ殑鎵鏈夎澶囥 https__3A__2F__2Fhelp___codesys___com__2Fapi-content__2F2__2Fcodesys__2F3___5___12___0__2Fen__2F_images__2F_cds_icon_stop_in_status_bar___png.jpg 銆銆閫夋嫨鎮ㄧ殑璁$畻鏈哄悕绉扮殑鏍戞潯鐩

    銆銆鍗曞嚮OK銆

    銆銆鈬掗氶亾鐜板湪澶勪簬婵娲荤姸鎬侊紝鐩稿叧淇℃伅鍑虹幇鍦–ommunication Settings閫夐」鍗′笂鐨勮澶囧浘褰笅鏂广

    銆銆娉ㄦ剰

    銆銆鐜板湪鎵鏈夌殑閫氫俊琛屼负閮戒笌杩欎釜閫氶亾瀹屽叏鐩稿叧銆傚鏋滄偍鍦ㄩ」鐩腑鏈夊涓氫俊閫氶亾锛岃璁颁綇杩欎竴鐐广

    銆銆鍦≒LC涓婄殑搴旂敤锛氳鍙傝冧互涓嬬珷鑺

    銆銆灏嗗簲鐢ㄧ▼搴忓姞杞藉埌PLC

    銆銆瑕佹眰锛氬簲鐢ㄧ▼搴忓凡缁忕紪璇戞病鏈夐敊璇傝鍙傞槄璋冭瘯搴旂敤绋嬪簭銆

    銆銆1. 閫夋嫨Online 鈥 Login鍛戒护銆

    銆銆鈬掑嚭鐜颁竴涓璇濇锛岃闂簲鐢ㄧ▼搴忔槸鍚﹀簲璇ュ姞杞藉埌鎺у埗鍣ㄣ

    銆銆2. 鍗曞嚮Yes鎸夐挳銆

    銆銆鈬掑簲鐢ㄧ▼搴忚鍔犺浇鍒版帶鍒跺櫒銆侱evices绐楀彛涓帶鍒跺櫒鍜屽簲鐢ㄧ▼搴忕殑鏉$洰鍏锋湁缁胯壊鑳屾櫙銆係top鍑虹幇鍦ㄥ簲鐢ㄧ▼搴忓璞″悗闈€傛帶鍒跺櫒鐨勫綋鍓嶇姸鎬佸嚭鐜板湪浠诲姟鏍忎腑锛 https__3A__2F__2Fhelp___codesys___com__2Fapi-content__2F2__2Fcodesys__2F3___5___12___0__2Fen__2F_images__2F_cds_icon_run_in_status_bar___png.jpg 銆銆銆

    銆銆鍚姩搴旂敤绋嬪簭

    銆銆濡傛灉鎮ㄥ凡缁忔寜鐓ф湰鏁欑▼鐨勮姹傛搷浣滐紝鐜板湪鍙互浣跨敤PLC Device锛圕ODESYS Control Win V3锛変笂鐨凙pplication銆

    銆銆鍦―evices绐楀彛涓彸閿崟鍑籄pplication瀵硅薄锛岀劧鍚庡湪涓婁笅鏂囪彍鍗曚腑閫夋嫨Start鍛戒护銆

    銆銆鈬掔▼搴忚繍琛屻侱evices绐楀彛涓帶鍒跺櫒鍜屽簲鐢ㄧ▼搴忕殑鏉$洰鍏锋湁缁胯壊鑳屾櫙銆侱evices鍑虹幇鍦ˋpplication瀵硅薄鐨勫悗闈€傛帶鍒跺櫒鐨勫綋鍓嶇姸鎬佸嚭鐜板湪浠诲姟鏍忎腑锛
    https__3A__2F__2Fhelp___codesys___com__2Fapi-content__2F2__2Fcodesys__2F3___5___12___0__2Fen__2F_images__2F_cds_img_tutorial_refrigerator_monitoring___png.jpg 銆銆銆

    銆銆鍦ㄨ繍琛屾椂鐩戣鍜屼竴娆℃у啓鍏ュ彉閲忓

    銆銆鎺ヤ笅鏉ワ紝鎮ㄥ彲浠ョ湅鍒板悇绉嶇▼搴忓姛鑳藉潡涓彉閲忓肩殑鈥滅洃瑙嗏濓紝鎮ㄥ彲浠ュ湪CODESYS涓婅缃竴涓壒瀹氱殑鍙橀噺鍊笺

    銆銆鎮ㄥ彲浠ュ湪鍔熻兘鍧楃紪杈戝櫒鐨勫湪绾胯鍥炬垨鐩戞帶鍒楄〃涓煡鐪嬪簲鐢ㄧ▼搴忓彉閲忕殑瀹為檯鍊笺傚湪杩欎釜渚嬪瓙涓紝鎴戜滑灏嗗眬闄愬湪鍔熻兘鍧楃紪杈戝櫒涓繘琛岀洃鎺с

    銆銆瑕佹眰锛氬簲鐢ㄧ▼搴忔鍦ㄦ帶鍒跺櫒涓婅繍琛屻

    銆銆鍙屽嚮璁惧鏍戜腑鐨凱LC_PRG锛孲ignals锛孲imulation鍜孏lob_Var瀵硅薄锛屾墦寮缂栬緫鍣ㄧ殑鍦ㄧ嚎瑙嗗浘銆

    銆銆鈬掑湪姣忎釜瑙嗗浘鐨勫0鏄庨儴鍒嗭紝鎺у埗鍣ㄤ笂鍙橀噺锛1锛夌殑瀹為檯鍊煎嚭鐜板湪Value鍒楋紙3锛夌殑琛ㄨ揪寮忚〃鏍间腑锛堝弬瑙佸浘绀猴級銆
    https__3A__2F__2Fhelp___codesys___com__2Fapi-content__2F2__2Fcodesys__2F3___5___12___0__2Fen__2F_images__2F_cds_img_main_tutorial_booleans_in_cfc___png.jpg
    銆銆瀹炵幇閮ㄥ垎涓殑鐩戣鍙栧喅浜庡疄鐜拌瑷锛氬浜庨潪甯冨皵鍙橀噺锛屽煎缁堜綅浜庢爣璇嗙鍙充晶鐨勭煩褰㈠瓧娈典腑銆傚湪ST缂栬緫鍣ㄤ腑锛岃繖涔熼傜敤浜庡竷灏斿彉閲忋傛垜浠О涔嬩负鈥滃唴鑱旂洃瑙嗏濄傚湪鍥惧舰缂栬緫鍣ㄤ腑锛屽竷灏斿彉閲忕殑鍊肩敱杈撳嚭杩炴帴绾跨殑棰滆壊鏄剧ず锛氶粦鑹茶〃绀篎ALSE锛岃摑鑹茶〃绀篢RUE锛 https__3A__2F__2Fhelp___codesys___com__2Fapi-content__2F2__2Fcodesys__2F3___5___12___0__2Fen__2F_images__2F_cds_icon_breakpoint_activated___png.jpg 銆銆瑙傚療鍚勪釜鍔熻兘鍧椾腑鍙橀噺鍊肩殑鍙樺寲銆備緥濡傦紝鎮ㄥ彲浠ュ湪GVL Glob_Var涓湅鍒皉TempActual鍜孋ompressor鐨勫兼槸濡備綍鐢变簬妯℃嫙绋嬪簭鐨勫鐞嗚屾敼鍙樼殑銆

    銆銆鎺у埗鍣ㄤ笂涓娆℃ц缃彉閲忓硷細

    銆銆鍏夋爣鏀惧湪鍦℅VL Glob_Var鐨勫湪绾胯鍥句腑銆

    銆銆瑕佽缃柊鐨勮瀹氬硷紝璇峰弻鍑昏〃杈惧紡rTempSet鏃佽竟鐨凱repared value锛2锛夊垪銆

    銆銆鈬掕緭鍏ユ爮鎵撳紑銆

    銆銆杈撳叆鍊9骞剁寮杈撳叆鏍忋

    銆銆瑕侀夊畾鎵撳紑鐨勯棬锛岃鍦ㄨ〃杈惧紡rDoorOpen鏃佽竟鐨凱repared value瀛楁涓崟鍑讳竴娆°傚皢杈撳叆鍊糡RUE銆傚啀娆″崟鍑3娆″皢鍐嶆鐪嬪埌鍑嗗濂界殑鍊煎垏鎹㈠埌FALSE锛岀劧鍚庤繑鍥炲埌绌猴紝鐒跺悗杩斿洖TRUE銆

    銆銆瑕佸皢鍑嗗濂界殑鍊糡RUE鍙啓鍏ヤ竴娆★紝璇锋寜Ctrl + F7銆

    銆銆鈬掕繖涓や釜鍊煎垎鍒浼犻佸埌Value鏍忥紙3锛夈傚彉閲弐DoorOpen鐜板湪涓嶅啀鏀瑰彉瀹冪殑鍊硷紝娓╁害璁惧畾鍊肩幇鍦ㄦ槸9搴︺傚彉閲弔imTemp鍙樹负1s锛屽洜涓哄啺绠遍棬鐜板湪澶勪簬鈥滄墦寮鈥濈姸鎬侊紝Simulation鍔犵儹搴旇姣斾箣鍓嶏紙2s锛夊揩銆

    銆銆璁剧疆鏂偣骞跺湪杩愯鏃跺崟姝ユ墽琛

    銆銆鈥滆皟璇曗濓細鍑轰簬鏁呴殰鎺掗櫎鐨勭洰鐨勶紝鎮ㄥ笇鏈涙鏌ヤ唬鐮佷腑鏌愪簺鐐圭殑鍙橀噺鍊笺傛偍鍙互涓烘墽琛屽畾涔夋柇鐐瑰苟鍗曟鎵ц鎸囦护銆

    銆銆瑕佹眰锛氬簲鐢ㄧ▼搴忓凡缁忓姞杞藉埌鎺у埗鍣ㄥ苟姝e湪杩愯銆

    銆銆鍙屽嚮Simulation鎵撳紑缂栬緫鍣ㄤ腑鐨勭▼搴忋

    銆銆灏嗗厜鏍囩疆浜庝唬鐮佽iCounter锛= iCounter + 1;骞舵寜F9 鈬 https__3A__2F__2Fhelp___codesys___com__2Fapi-content__2F2__2Fcodesys__2F3___5___12___0__2Fen__2F_images__2F_cds_icon_breakpoint_halt___png.jpg 銆銆鍥炬爣鍑虹幇鍦ㄤ唬鐮佽鐨勫墠闈€傚畠琛ㄧず鍦ㄨ繖涓琛屼笂璁剧疆浜嗕竴涓柇鐐广傚浘鏍囩珛鍗冲彉涓 https__3A__2F__2Fhelp___codesys___com__2Fapi-content__2F2__2Fcodesys__2F3___5___12___0__2Fen__2F_images__2F_cds_icon_halt_on_bp_iin_status_bar___png.jpg 銆銆銆傞粍鑹茬澶存绘槸鎸囧悜涓嬩竴鏉¤澶勭悊鐨勬寚浠ゃ https__3A__2F__2Fhelp___codesys___com__2Fapi-content__2F2__2Fcodesys__2F3___5___11___0__2Fen__2F_images__2F_cds_icon_run_in_status_bar___png.jpg 銆銆鏇挎崲

    銆銆鍑虹幇鍦ㄤ换鍔℃爮銆

    銆銆瑙傚療鍦ㄧ嚎鐩戞祴鎴杝imulation绋嬪簭鐨勫0鏄庨儴鍒嗕腑鍙橀噺iCounter鐨勫笺

    銆銆鈬掑彉閲忕殑鍊间笉鍐嶆敼鍙樸傚鐞嗗湪鏂偣澶勫仠姝€

    銆銆鎸塅5閲嶆柊寮濮嬪鐞嗐

    銆銆鈬掍竴涓惊鐜悗绋嬪簭鍐嶆鍋滃湪鏂偣澶勩俰Counter澧炲姞浜1銆

    銆銆鎸塅8鎵ц涓嬩竴涓鐞嗘楠ゃ

    銆銆鈬扲ETURN鍦╥Counter锛= iCounter + 1;鎸囦护琛岀殑鏈鍚庝互榛勮壊绐佸嚭鏄剧ず銆

    銆銆鍐嶆鎸塅8鎵ц涓嬩竴涓鐞嗘楠ゃ

    銆銆鈬掑鐞嗚烦杞埌PLC_PRG鐨勭紪杈戝櫒銆傚弽澶嶆寜F8鏄剧ず绋嬪簭鏄浣曞崟姝ユ墽琛岀殑銆

    銆銆姣忔鐢ㄩ粍鑹茬澶存爣璁拌鎵ц鐨勬寚浠ゃ

    銆銆涓轰簡鍋滅敤鏂偣骞惰繑鍥炲埌姝e父鐨勫鐞嗭紝鍐嶆鍦ㄤ唬鐮佽涓缃厜鏍囧苟鎸変笅F9銆傜劧鍚庢寜F5鍐嶆灏嗚搴旂敤绋嬪簭缃簬

    銆銆妯″紡涓嬨

    銆銆鍦ㄨ繍琛屾椂鎵ц鍗曚釜寰幆

    銆銆瑕佹眰锛氬簲鐢ㄧ▼搴忓凡缁忓姞杞藉埌鎺у埗鍣ㄥ苟姝e湪杩愯銆

    銆銆濡備笂鎵杩帮紝鍗曟鎵ц浠跨湡绋嬪簭涓殑iCounter锛= iCounter + 1琛屻

    銆銆鎸塁trl + F5鎴栭夋嫨Debug 鈥 Single Cycle浠ユ墽琛屽崟涓惊鐜

    銆銆鈬掑鐞嗚繍琛屼竴涓惊鐜紝鐒跺悗鍐嶆鍋滃湪鏂偣澶勩

    銆銆iCounter澧炲姞浜1銆

    銆銆鍐嶆寜鍑犳Ctrl + F5鍙煡鐪嬪崟涓懆鏈熴傜劧鍚庢寜F5  鈬掔▼搴忓啀娆¤繍琛岋紝娌℃湁鍋滄锛屾病鏈夊己鍒跺笺傚彉閲弔emp鍐嶆鍏锋湁鍊1s銆
    銆銆鍐嶆鍑虹幇鍦ㄧ姸鎬佹爮涓
    +10
    涓嶈禐涓涓紵
    鎵撹祻榧撳姳涓涓嬶紒

    鐩稿叧甯栧瓙

    鍥炲

    浣跨敤閬撳叿 涓炬姤

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

    鏈増绉垎瑙勫垯

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

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

    GMT+8, 2024-11-24 02:14 , Processed in 0.171460 second(s), 64 queries .

    閰峰痉缃

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

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