{"id":78,"date":"2021-08-08T05:48:44","date_gmt":"2021-08-07T21:48:44","guid":{"rendered":"http:\/\/139.224.63.49\/?p=78"},"modified":"2021-08-08T05:48:44","modified_gmt":"2021-08-07T21:48:44","slug":"%e6%a0%91%e8%8e%93%e6%b4%be%e7%9a%84%e7%a1%ac%e4%bb%b6pwm","status":"publish","type":"post","link":"http:\/\/iamnear.top\/?p=78","title":{"rendered":"\u6811\u8393\u6d3e\u7684\u786c\u4ef6pwm"},"content":{"rendered":"\n<p>\u597d\u4e45\u6ca1\u5199\u535a\u5ba2\u4e86\uff0c\u6765\u6c34\u4e00\u7bc7<\/p>\n\n\n\n<p>\u6700\u8fd1\u6709\u4e2a\u9879\u76ee\u9700\u8981\u7528\u6811\u8393\u6d3e\u6765\u4ea7\u751fpwm\u4fe1\u53f7\u6765\u63a7\u5236\u4e00\u4e2a\u8235\u673a\u3002<\/p>\n\n\n\n<p>\u539f\u672c\u4f7f\u7528\u7684\u662fRpi.GPIO\u4e2d\u63d0\u4f9b\u7684\u8f6f\u4ef6pwm\u7684\u65b9\u5f0f\u6765\u4ea7\u751f\u4fe1\u53f7\uff0c\u4f46\u662f\u9047\u5230\u4e24\u4e2a\u95ee\u9898<\/p>\n\n\n\n<p>\u95ee\u9898\u4e00\u662f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import PRi.GPIO as GPIO\nGPIO.setmode(GPIO.BOARD)\nGPIO.setup(7,GPIO.OUT)\np = GPIO.PWM(7,330)\np.start(50)\n<\/code><\/pre>\n\n\n\n<p>\u6267\u884c\u5230\u4ee5\u4e0a\u8fd8\u4e00\u5207\u6b63\u5e38\uff0c\u867d\u7136\u7531\u4e8e\u662f\u8f6f\u4ef6pwm\uff0c\u6240\u4ee5\u9891\u7387\u548c\u5360\u7a7a\u6bd4\u5728\u793a\u6ce2\u5668\u4e0a\u53ef\u4ee5\u770b\u5230\u5e76\u4e0d\u662f\u7279\u522b\u7cbe\u51c6\uff0c\u4e0d\u8fc7\u95ee\u9898\u4e0d\u5927\u3002\u4f46\u662f\uff0c\u5982\u679c\u60f3\u505c\u6b62\u53d1\u9001pwm\u4fe1\u53f7\uff0c\u518d\u91cd\u65b0\u53d1\u9001<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>p.stop()\np.start(50)\n<\/code><\/pre>\n\n\n\n<p>\u6b64\u65f6\uff0c\u5c31\u4f1a\u53d1\u73b0\u4fe1\u53f7\u5b8c\u5168\u4e71\u6389\u4e86\uff0c\u867d\u7136\u8fd8\u662fpwm\u6ce2\uff0c\u4f46\u662f\u9891\u7387\u53d8\u6210\u4e86800k-900k\u7684\u6837\u5b50\uff0c\u975e\u5e38\u5947\u602a\u3002<\/p>\n\n\n\n<p>\u6211\u53c8\u8bd5\u9a8c\u4e86\u4e0b\uff0c\u53d1\u73b0\u5728start\u4ee5\u540e\uff0c\u9700\u8981<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>del p\np = GPIO.PWM(7,330)\np.start(50)<\/code><\/pre>\n\n\n\n<p>\u8fd9\u6837\u624d\u80fd\u6b63\u5e38\u7684\u53d1\u9001\u4fe1\u53f7\u3002\u6211\u8bb0\u5f97\u4ee5\u524d\u7528\u7684\u65f6\u5019\u662f\u53ef\u4ee5\u76f4\u63a5stop\u7136\u540e\u518dstart\u7684\u3002\u4e0d\u77e5\u9053\u662f\u73b0\u5728GPIO\u7684\u7248\u672c\u6539\u4e86\u8fd8\u662f\u56e0\u4e3a\u54ea\u91cc\u7684\u95ee\u9898\uff1f<\/p>\n\n\n\n<p>\u9047\u5230\u7684\u7b2c\u4e8c\u4e2a\u95ee\u9898\u5c31\u662f\u8f6f\u4ef6pwm\u4e0d\u591f\u7cbe\u51c6\u7684\u95ee\u9898\u3002\u56e0\u4e3a\u63a7\u5236\u7684\u662f360\u5ea6\u8235\u673a\uff0c\u800c\u4e14\u6ca1\u6709\u7f16\u7801\u76d8\uff0c\u5bf9\u5360\u7a7a\u6bd4\u975e\u5e38\u654f\u611f\u3002\u7406\u8bba\u4e0a\u7ed949.5%\u7684\u5360\u7a7a\u6bd4\u5c31\u5e94\u8be5\u9759\u6b62\u4e0d\u8f6c\u52a8\uff0c\u4f46\u5b9e\u9645\u4e0a\u53d1\u73b0\u7ed947.5%\u5360\u7a7a\u6bd4\u7684\u65f6\u5019\u624d\u4f1a\u6bd4\u8f83\u9759\u6b62\uff0c\u4f46\u4e0d\u662f\u5f88\u7a33\u5b9a\uff0c\u8fd8\u662f\u4f1a\u5f88\u7f13\u6162\u7684\u6b63\u4f20\u6216\u8005\u53cd\u8f6c\u3002\u8003\u8651\u5230\u9879\u76ee\u9700\u8981\u8235\u673a\u957f\u65f6\u95f4\uff087\u5929\uff09\u4fdd\u6301\u56fa\u5b9a\u4f4d\u7f6e\uff0c\u56e0\u6b64\u8f6f\u4ef6pwm\u662f\u5fc5\u7136\u65e0\u6cd5\u4f7f\u7528\u7684\u4e86\u3002<\/p>\n\n\n\n<p>\u6211\u4ee5\u524d\u63a7\u5236\u6811\u8393\u60153B+\u7684\u65f6\u5019\u6709\u7528wiringPi\u6765\u7528\u6811\u8393\u6d3e\u4ea7\u751fpwm\u6ce2\uff0c\u4e3b\u8981\u662f\u63a7\u5236gpio pwmc xxx, gpio pwmr xxx, gpio pwm 1 xxx\u8fd9\u4e09\u6761\u6307\u4ee4\u3002\u4f46\u662f\u6211\u5728\u6811\u8393\u6d3e4B\u4e0a\u6d4b\u8bd5\u53d1\u73b0\u4f3c\u4e4e\u8d70\u4e0d\u901a\uff0c\u4e0d\u77e5\u9053\u662f\u4e0d\u662f\u56e0\u4e3awiringPi\u5df2\u7ecf\u4e0d\u518d\u7ef4\u62a4\u4e86\u7684\u539f\u56e0\u3002<\/p>\n\n\n\n<p>\u7ecf\u8fc7\u5bfb\u627e\uff0c\u7ec8\u4e8e\u627e\u5230\u4e86\u4e2a\u6bd4\u8f83\u65b9\u4fbf\u7684\u7528\u6811\u8393\u6d3e4B\u4ea7\u751f\u786c\u4ef6pwm\u7684\u65b9\u6cd5\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/jdimpson\/syspwm\/blob\/master\/syspwm.py\">https:\/\/github.com\/jdimpson\/syspwm\/blob\/master\/syspwm.py<\/a><\/p>\n\n\n\n<p>\u867d\u7136\u662fpython2\u5199\u7684\uff0c\u4f46\u662f\u628aprint\u8bed\u53e5\u6539\u4e00\u4e0b\u5c31\u548cpython3\u6ca1\u533a\u522b\u3002<\/p>\n\n\n\n<p>\u7528\u8fd9\u4e2a\u4ee3\u7801\uff0c\u8bbe\u7f6e\u4e0b\u9891\u7387\u548c\u5360\u7a7a\u6bd4\u5c31\u597d\u4e86\uff0c\u8fd8\u7701\u53bb\u4e86\u4e4b\u524d\u5176\u5bf9\u65f6\u949f\u9891\u7387\u7684\u5947\u5947\u602a\u602a\u7684\u8ba1\u7b97\u3002\u8981\u6ce8\u610f\u7684\u662f\u8fd9\u4e2a\u4ee3\u7801\u91cc\u9762\u7684\u5360\u7a7a\u6bd4\u4e0d\u662f\u767e\u5206\u6bd4\uff0c\u800c\u662f\u6307\u6b63\u8109\u5bbd\u7684\u6beb\u79d2\u6570\u3002<\/p>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230\u8fd9\u4e2a\u4ee3\u7801\u57fa\u672c\u5c31\u662f\u5bf9&#8221;\/sys\/class\/pwm\/pwmchip0&#8243;\u4e0b\u6587\u4ef6\u7684\u4e00\u4e9b\u8bfb\u5199\u64cd\u4f5c\uff0c\u548c\/proc\u7684\u903b\u8f91\u5dee\u4e0d\u591a\uff0c\u901a\u8fc7\u6587\u4ef6\u7c7b\u578b\u7684\u63a5\u53e3\u6765\u63a7\u5236\u5916\u8bbe\uff08\u786c\u4ef6\uff09<\/p>\n\n\n\n<p>\u66f4\u591a\u7684\u53c2\u8003\u8d44\u6599\u89c1\uff1a<\/p>\n\n\n\n<p><a href=\"https:\/\/jumpnowtek.com\/rpi\/Using-the-Raspberry-Pi-Hardware-PWM-timers.html\">https:\/\/jumpnowtek.com\/rpi\/Using-the-Raspberry-Pi-Hardware-PWM-timers.html<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/raspberrypi\/linux\/blob\/rpi-4.4.y\/arch\/arm\/boot\/dts\/overlays\/README\">https:\/\/github.com\/raspberrypi\/linux\/blob\/rpi-4.4.y\/arch\/arm\/boot\/dts\/overlays\/README<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u597d\u4e45\u6ca1\u5199\u535a\u5ba2\u4e86\uff0c\u6765\u6c34\u4e00\u7bc7 \u6700\u8fd1\u6709\u4e2a\u9879\u76ee\u9700\u8981\u7528\u6811\u8393\u6d3e\u6765\u4ea7\u751fpwm\u4fe1\u53f7\u6765\u63a7\u5236\u4e00\u4e2a\u8235\u673a\u3002 \u539f\u672c\u4f7f\u7528\u7684\u662fRp&hellip; <a href=\"http:\/\/iamnear.top\/?p=78\" class=\"more-link read-more\" rel=\"bookmark\">\u7ee7\u7eed\u9605\u8bfb <span class=\"screen-reader-text\">\u6811\u8393\u6d3e\u7684\u786c\u4ef6pwm<\/span><i class=\"fa fa-arrow-right\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":{"0":"post-78","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-uncategorized","7":"h-entry","9":"h-as-article"},"_links":{"self":[{"href":"http:\/\/iamnear.top\/index.php?rest_route=\/wp\/v2\/posts\/78","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/iamnear.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/iamnear.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/iamnear.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/iamnear.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=78"}],"version-history":[{"count":1,"href":"http:\/\/iamnear.top\/index.php?rest_route=\/wp\/v2\/posts\/78\/revisions"}],"predecessor-version":[{"id":79,"href":"http:\/\/iamnear.top\/index.php?rest_route=\/wp\/v2\/posts\/78\/revisions\/79"}],"wp:attachment":[{"href":"http:\/\/iamnear.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=78"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/iamnear.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=78"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/iamnear.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=78"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}