codesys 涔 SFC鎺㈢储-CODESYS璧勬簮涓嬭浇鍖-閰峰痉缃 - CoDeSys杞欢鏁欑▼涓嬭浇,CoDeSys宸ユ帶璧勮闂ㄦ埛
HSC6490-cn涓浗鍒堕狅紝涓浗鑺瘇
鏌ョ湅: 1438|鍥炲: 0

codesys 涔 SFC鎺㈢储

[澶嶅埗閾炬帴]

璇ョ敤鎴蜂粠鏈鍒

鍙戣〃浜 2023-4-12 22:47:12 | 鏄剧ず鍏ㄩ儴妤煎眰 |闃呰妯″紡
1 娴嬭瘯

鍦╥niting鐘舵佷腑娴嬭瘯(entry)杩涘叆鍔ㄤ綔锛(exit)鍑哄幓鍔ㄤ綔锛屽唴閮ㄥ姩浣滐紝澶栭儴鍔ㄤ綔 鍥涚绫诲瀷鐨勬墽琛屽仛浜嗗鍥炬墍绀虹殑娴嬭瘯锛
鑾峰緱缁撹锛
1锛氬嵆浣縤niting鐨勮烦杞潯浠朵竴鐩存槸true锛屼篃浼氭墽琛宨niting鐨勫叆鍙e姩浣滐紝鍐呴儴鍔ㄤ綔锛屽閮ㄥ姩浣滐紱
2锛氱涓娆℃壂鎻忓緱鐭niting鐨勮烦杞潯浠朵负true,绗簩娆℃壂鎻忕殑鏃跺欏彧浼氭墽琛屽閮ㄥ姩浣滐紝鍑哄幓鍔ㄤ綔锛
3锛歩niting鐨勫姩浣滄墽琛岄『搴忔槸锛屽厛鎵ц鍐呴儴鍔ㄤ綔锛屽悗鎵ц澶栭儴鍔ㄤ綔锛
4: 濡傛灉鍦╥niting 鍐呴儴鍔ㄤ綔涓湪宓屽瀛愮姸鎬乻fc锛岀埗鐘舵佽浆绉讳細鎵ц鐖剁殑exit鍔ㄤ綔锛屽瓙鐘舵佸鏋滄槸鍥犱负鐖剁姸鎬佽浆绉昏屼笉鎵ц锛屽瓙鐘舵佺殑exit鍔ㄤ綔涓嶄細鎵ц锛岀被浼糷istory鍘嗗彶鐘舵侊紝涓嬫杩涘叆瀛愮姸鎬佷細缁х画绱ф帴鐫鎵ц锛
codesys 涔 SFC鎺㈢储-1.jpg


2 闅愬紡鐨勫彉閲

鍦ㄥ垱寤簊fc涓殑姝ュ拰鍔ㄤ綔锛堝唴閮ㄥ姩浣滐紝涓嶆槸鍏宠仈鍔ㄤ綔锛夌殑鏃跺欙紝闅愬紡鐨勫垱寤哄涓嬬被鍨嬶紝鍦ㄥ搴旂殑搴撲腑鍙互鏌ョ湅绫诲瀷锛
甯哥敤鐨勬槸 ._x锛氬己鍒朵笅涓涓懆鏈熺殑婵娲荤姸鎬侊紙娴嬭瘯鍙戠幇鏄敼鍙樺綋鍓嶅懆鏈熺殑婵娲荤姸鎬侊級銆傜敤鏉ュ畾涔夊巻鍙茬姸鎬佸拰鍒濆鐘舵侊紱
闅愬紡鍙橀噺澹版槑鐨勮娉曪細
:SFCStepType;
_:SFCActionType;

codesys 涔 SFC鎺㈢储-2.jpg

codesys 涔 SFC鎺㈢储-3.jpg


3 妯℃嫙

鐢╟odesys 妯℃嫙 sfc鐨勫叆鍙 鍑哄彛 鍐呴儴鍔ㄤ綔锛屽苟琛岄夋嫨鍒嗘敮锛岀敤sfc涔熸槸涓轰簡婊¤冻鐘舵佹満鐨勮璁¢渶姹傦紱鐞嗚В浜嗕负浠涔圲ML璁╅夋嫨锛屼俊鍙峰悓姝ョ瓑鍙仛铏氭嫙鐘舵侊紱
鑰冭檻鍒板苟琛岀殑鎯呭喌锛氭湁鏃跺悓鏃跺浜庡涓姸鎬侊紝鎵鏈夌敤瀛楃殑姣忎竴涓〃绀轰竴涓姸鎬併傚湪璺冲嚭鐘舵佺殑鏃跺欙紝瑕佹妸褰撳墠鐘舵佷綅缃负0锛
  1. 锛*鐘舵佺殑鏋氫妇绫诲瀷*锛
  2. TYPE StetaMachine :(
  3. eMainStateInit:=16#00000001,
  4. eMainState1  :=16#00000001,
  5. eMainState2  :=16#00000002);
  6. END_TYPE
澶嶅埗浠g爜
  1. 锛*鍙橀噺瀹氫箟*锛
  2. iMainState       : StetaMachine := eMainState1 ;
  3. iMainStateFollow : StetaMachine := eMainStateInit;
  4. bMainStateExit   : BOOL:= FALSE;
澶嶅埗浠g爜
  1. {涓銆佺姸鎬佸悕绉皚IF(iMainState OR eMainState1)<>0 THEN
  2.    {1 entry 鍏ュ彛鍑芥暟---------------------------------------}IF(iMainStateFollow AND  eMainState1)=0THEN(*do1*)(*do2*)(*do3*)
  3.        iMainStateFollow :=(iMainStateFollow OR eMainState1);
  4.        bMainStateExit := FALSE;
  5.    END_IF
  6.    {2 鍐呴儴澶勭悊鍔ㄤ綔-----------------------------------------}
  7.    IF bMainStateExit = FALSE THEN(*do1:澶勭悊鍔ㄤ綔   :*)(*do2:骞跺彂瀛愮姸鎬1:*)(*do3:骞跺彂瀛愮姸鎬2:*)
  8.    END_IF
  9.    {3 exit  鍑哄彛鍑芥暟-----------------------------------------}
  10.    IF bMainStateExit = TRUE THEN
  11.        bMainStateExit := FALSE;(*do1*)(*do2*)(*do3*)(* jump to state2:*){IF condition1 = TRUE THEN
  12.             iMainState :=((iMainState XOR eMainState1) OR eMainState2);
  13.             iMainStateFollow :=(iMainStateFollow XOR eMainState1);        
  14.             RETURN;
  15.          END_IF}(* jump to state3:*){IF condition2 = TRUE THEN
  16.             iMainState :=((iMainState XOR eMainState1) OR eMainState3);
  17.             iMainStateFollow :=(iMainStateFollow XOR eMainState1);        
  18.             RETURN;
  19.         END_IF}
  20.    END_IF
  21.    
  22.    {4 璺宠浆鏉′欢鍒ゆ柇-------------------------------------------}(*鏉′欢閫夋嫨鍒嗘敮1: judge_jump_to_state1 :*){IF condition1 = TRUE THEN
  23.          bMainStateExit := TRUE;
  24.          RETURN;
  25.       END_IF}(*鏉′欢閫夋嫨鍒嗘敮2: judge_jump_to_state2 :*){IF condition2 = TRUE THEN
  26.           bMainStateExit := TRUE;
  27.           RETURN;
  28.       END_IF}
  29. END_IF
  30. {閫夋嫨鍒嗘敮锛岄夋嫨鏄竴涓櫄鎷熺姸鎬,鏄竴涓灛闂寸姸鎬亇
  31. IF iMainState =2THEN(*IF condition THEN
  32.         jump to state3
  33.         iMainState :=((iMainState XOR eMainState2) OR eMainState3);      
  34.      ELSE      
  35.         jump to state4
  36.         iMainState :=((iMainState XOR eMainState2) OR eMainState4);   
  37.      END_IF*)
  38. END_IF
  39. {3.1 骞惰寮濮,骞惰鏄竴涓櫄鎷熺姸鎬,鏄竴涓灛闂寸姸鎬亇
  40. IF iMainState =3 THEN
  41.    {JUMP TO STATE4}{JUMP TO STATE5}
  42.    iMainState :=((iMainState XOR eMainState3) OR eMainState4 OR eMainState5 );
  43. END_IF
  44. {3.2 骞惰寮濮,骞惰鏄竴涓櫄鎷熺姸鎬,鏄竴涓灛闂寸姸鎬亇
  45. IF iMainState =4THEN(*IF condition1 AND condition2 AND condition3 AND conditionN THEN
  46.      {jump to state5}
  47.      iMainState :=((iMainState XOR eMainState4) OR eMainState5
  48. END_IF*)
  49. END_IF
澶嶅埗浠g爜
codesys 涔 SFC鎺㈢储-4.jpg

codesys 涔 SFC鎺㈢储-5.jpg


4 璁″垝锛氱悊瑙e叧鑱斿姩浣滃苟鐢ㄤ唬鐮佹ā鎷

codesys 涔 SFC鎺㈢储-6.jpg


5 璁″垝锛氱悊瑙FC鐨勬爣蹇

codesys 涔 SFC鎺㈢储-7.jpg


6 璁″垝锛氬畬鍠刢odesys鐘舵佹満妯℃澘浠g爜
+10
涓嶈禐涓涓紵
鎵撹祻榧撳姳涓涓嬶紒
鍥炲

浣跨敤閬撳叿 涓炬姤

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

鏈増绉垎瑙勫垯

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

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

GMT+8, 2024-11-23 20:52 , Processed in 0.149520 second(s), 60 queries .

閰峰痉缃

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

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