Codesys鈥斺旇緭鍑篜WM娉㈠舰锛團B鍧楋級-CODESYS璧勬簮涓嬭浇鍖-閰峰痉缃 - CoDeSys杞欢鏁欑▼涓嬭浇,CoDeSys宸ユ帶璧勮闂ㄦ埛
HSC6490-cn涓浗鍒堕狅紝涓浗鑺瘇
鏌ョ湅: 1581|鍥炲: 2

Codesys鈥斺旇緭鍑篜WM娉㈠舰锛團B鍧楋級

[澶嶅埗閾炬帴]

璇ョ敤鎴蜂粠鏈鍒

鍙戣〃浜 2023-11-22 16:06:51 | 鏄剧ず鍏ㄩ儴妤煎眰 |闃呰妯″紡
浠ヤ笅鍐呭绾睘涓汉鐞嗚В锛屽鏈夐敊璇杩庢寚姝c
鏈瘒涓昏璁茶堪濡備綍鍒涘缓骞惰皟鐢‵B鍧楋紝骞朵功鍐欏嚭鍗犵┖姣斿彲璋冪殑FB鍧楋紝骞舵彃鍏race杩涜鐩戞帶杈撳嚭娉㈠舰銆
棣栧厛鍒涘缓涓涓狥B鍧銆傚彸閿產pplication-娣诲姞瀵硅薄-绋嬪簭缁勭粐鍗曞厓锛屽垱寤哄苟鎵撳紑銆
Codesys鈥斺旇緭鍑篜WM娉㈠舰锛團B鍧楋級-1.png


鍒涘缓FB涔嬪悗锛岀紪鍐欑▼搴銆傞鍏堝畾涔夎緭鍏ユ帴鍙o紙鍚姩銆佸仠姝€佸崰绌烘瘮锛夛紝杈撳嚭锛坥ut锛夈傚崰绌烘瘮灏辨槸楂樼數骞冲崰鏁翠釜鍛ㄦ湡鐨勬瘮渚嬨傚湪杩欎釜绋嬪簭閲岄潰锛屾病鏈夊畾涔夊懆鏈熺殑杈撳叆鎺ュ彛锛屽浐瀹氬懆鏈熶负1S锛屾牴鏈崰绌烘瘮璁$畻楂樼數骞冲拰浣庣數骞崇殑鏃堕棿銆傚苟鐢ㄤ袱涓畾鏃跺櫒杩涜缂栧啓銆
Codesys鈥斺旇緭鍑篜WM娉㈠舰锛團B鍧楋級-2.png


瀹氫箟瀹屾垚涔嬪悗锛屼功鍐欎富鍑芥暟锛屾湰绋嬪簭鍘熺悊绫讳技浜庢尟鑽$數璺備唬鐮佸涓嬨
  1. /********************鍙橀噺澹版槑************************/
  2. FUNCTION_BLOCK POU
  3. VAR_INPUT
  4.         START: BOOL;
  5.         STOP: BOOL;
  6.         DUTY: REAL;
  7. END_VAR
  8. VAR_OUTPUT
  9.         OUT:BOOL;
  10. END_VAR
  11. VAR
  12.         START_UP: BOOL;
  13.         STOP_UP: BOOL;
  14.         TON0_PT: TIME;
  15.         TON1_PT: TIME;
  16.         TON0_ET: TIME;
  17.         TON1_ET: TIME;
  18.         TON0_Q: BOOL;
  19.         TON1_Q: BOOL;
  20.         //TON0_Q_NOT: BOOL;
  21.         PLUS_UP: DINT;
  22.         PLUS_DOWN: DINT;
  23.         R_TRIG_0: R_TRIG;
  24.         R_TRIG_1: R_TRIG;
  25.         TON_0: TON;
  26.         TON_1: TON;
  27. END_VAR
  28. /********************绋嬪簭涔﹀啓************************/
  29. //R_TRIG_0(CLK:=START , Q=>START_UP );
  30. //R_TRIG_1(CLK:=STOP , Q=>STOP_UP );
  31. START_UP := START_UP AND (NOT STOP_UP);
  32. PLUS_UP := REAL_TO_DINT(1000*DUTY);
  33. PLUS_DOWN := 1000 - PLUS_UP;
  34. TON0_PT := DINT_TO_TIME(PLUS_UP);
  35. TON1_PT := DINT_TO_TIME(PLUS_DOWN);
  36. IF START THEN
  37.        
  38.         TON_0(IN:=NOT TON1_Q , PT:=TON0_PT , Q=>TON0_Q , ET=>TON0_ET );
  39.     TON_1(IN:= TON0_Q , PT:=TON1_PT , Q=>TON1_Q , ET=>TON1_ET );
  40.        
  41.         OUT :=TON1_Q OR (NOT TON0_Q);
  42. END_IF
澶嶅埗浠g爜
瀹炰緥鍖栥FB鍧楃紪鍐欏畬鎴愪箣鍚庯紝鍦≒LC_PRG鍑芥暟涓FB鍧楄繘琛屽疄渚嬪寲銆傜劧鍚庡湪浠g爜鍖鸿皟鐢≒WM_FB杩欎釜FB鍧楀氨鍙互浜嗭紝鍙互杩涜澶氭璋冪敤璁剧疆涓嶅悓鐨勫崰绌烘瘮銆
Codesys鈥斺旇緭鍑篜WM娉㈠舰锛團B鍧楋級-3.png

  1. /********************鍙橀噺澹版槑************************/
  2. PROGRAM PLC_PRG
  3. VAR
  4.        
  5.         PWM_FB: POU;
  6.         DUTY0: REAL := 0.2;
  7.         START0: BOOL;
  8.         STOP0: BOOL;
  9.         OUT0: BOOL;
  10.        
  11. END_VAR
  12. /********************绋嬪簭涔﹀啓************************/
  13. PWM_FB(
  14.         START := START0,
  15.         STOP := STOP0,
  16.         DUTY := DUTY0,
  17.         OUT => OUT0
  18.         );
  19.        
澶嶅埗浠g爜
娣诲姞trace銆鍙抽敭application-娣诲姞瀵硅薄-璺熻釜銆
Codesys鈥斺旇緭鍑篜WM娉㈠舰锛團B鍧楋級-4.png


閰嶇疆鎵閫夎窡韪璺熻釜閰嶇疆涓渶瑕佽窡韪殑鍙橀噺鎵鍦ㄧ殑浠诲姟銆
Codesys鈥斺旇緭鍑篜WM娉㈠舰锛團B鍧楋級-5.png


Codesys鈥斺旇緭鍑篜WM娉㈠舰锛團B鍧楋級-6.png


娣诲姞闇瑕佽窡韪殑鍙橀噺銆鍗曞嚮鐪佺暐鍙烽夋嫨闇瑕佽窡韪殑鍙橀噺銆
Codesys鈥斺旇緭鍑篜WM娉㈠舰锛團B鍧楋級-7.png


Codesys鈥斺旇緭鍑篜WM娉㈠舰锛團B鍧楋級-8.png


鍦ㄤ豢鐪熻繍琛岀殑鏃跺欓渶瑕佷笅杞借窡韪傚彸閿-涓嬭浇璺熻釜銆
鍗犵┖姣斾负0.5鐨勬柟娉俊鍙枫
Codesys鈥斺旇緭鍑篜WM娉㈠舰锛團B鍧楋級-9.png


鍗犵┖姣斾负0.2鐨勬柟娉俊鍙枫
Codesys鈥斺旇緭鍑篜WM娉㈠舰锛團B鍧楋級-10.png


璋㈣阿澶у~
+10
涓嶈禐涓涓紵
鎵撹祻榧撳姳涓涓嬶紒
鍥炲

浣跨敤閬撳叿 涓炬姤

  • TA鐨勬瘡鏃ュ績鎯
    闅捐繃
    2024-9-28 20:00
  • 绛惧埌澶╂暟: 53 澶

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

    鍙戣〃浜 2024-3-17 20:19:00 | 鏄剧ず鍏ㄩ儴妤煎眰
    濂戒笢瑗垮涔犲涔
    +10
    涓嶈禐涓涓紵
    鎵撹祻榧撳姳涓涓嬶紒
    鎮ㄩ渶瑕佺櫥褰曞悗鎵嶅彲浠ュ洖甯 鐧诲綍 | 绔嬪嵆娉ㄥ唽 鏂版氮寰崥鐧婚檰

    鏈増绉垎瑙勫垯

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

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

    GMT+8, 2024-11-23 20:15 , Processed in 0.159485 second(s), 68 queries .

    閰峰痉缃

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

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