{"action":"created","issue":{"url":"https://api.github.com/repos/intel-iot-devkit/mraa/issues/585","repository_url":"https://api.github.com/repos/intel-iot-devkit/mraa","labels_url":"https://api.github.com/repos/intel-iot-devkit/mraa/issues/585/labels{/name}","comments_url":"https://api.github.com/repos/intel-iot-devkit/mraa/issues/585/comments","events_url":"https://api.github.com/repos/intel-iot-devkit/mraa/issues/585/events","html_url":"https://github.com/intel-iot-devkit/mraa/issues/585","id":179916512,"number":585,"title":"Setting PWMs on Edison to zero duty is weird and unreliable","user":{"login":"RiccardoMaffei","id":15818918,"avatar_url":"https://avatars.githubusercontent.com/u/15818918?v=3","gravatar_id":"","url":"https://api.github.com/users/RiccardoMaffei","html_url":"https://github.com/RiccardoMaffei","followers_url":"https://api.github.com/users/RiccardoMaffei/followers","following_url":"https://api.github.com/users/RiccardoMaffei/following{/other_user}","gists_url":"https://api.github.com/users/RiccardoMaffei/gists{/gist_id}","starred_url":"https://api.github.com/users/RiccardoMaffei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RiccardoMaffei/subscriptions","organizations_url":"https://api.github.com/users/RiccardoMaffei/orgs","repos_url":"https://api.github.com/users/RiccardoMaffei/repos","events_url":"https://api.github.com/users/RiccardoMaffei/events{/privacy}","received_events_url":"https://api.github.com/users/RiccardoMaffei/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-09-28T23:25:39Z","updated_at":"2016-09-29T17:30:25Z","closed_at":null,"body":"I'm currently using mraa v1.3.0 with Java bindings on an Intel Edison and sometimes the PWM pins are not set to zero.\r\n\r\nIn this version the #515 fix should be already implemented.\r\nThis bug may be similar and related to the #91 but I think it's not the same.\r\n\r\nPWM pins sometimes (**not always**) fail to go to 0% duty but the failure rate seem related to the difference between the zero and the previous duty value. \r\nI've made some tests including the three examples provided below.\r\n\r\n## Example 1:\r\nThe following code has a failure rate of ~100%. A led connected to the pin is almost never turned off.\r\n```java\r\nfor(int i = 0; i < 100; i++) {\t//a hundred times\r\n\tThread.sleep(500);\t\t\t//wait half a second\r\n\tpwmPin.write(1);\t\t\t//write 100%\r\n\tThread.sleep(500);\t\t\t//wait half a second\r\n\tpwmPin.write(0.0f);\t\t\t//write 0%\r\n}\r\n```\r\n\r\n## Example 2:\r\nThe following code has a failure rate of ~60%:\r\n- ~40% of the time the led works as expected: 100%->50%->0% (each loop)\r\n- ~60% of the time the led is not turned off and goes to 100%: 100%->50%->100% (each loop)\r\n```java\r\nfor(int i = 0; i < 100; i++) {\t//a hundred times\r\n\tThread.sleep(500);\t\t\t//wait half a second\r\n\tpwmPin.write(1);\t\t\t//write 100%\r\n\tThread.sleep(500);\t\t\t//wait half a second\r\n\tpwmPin.write(0.5f);\t\t\t//write 50%\r\n\tThread.sleep(500);\t\t\t//wait half a second\r\n\tpwmPin.write(0.0f);\t\t\t//write 0%\r\n}\r\n```\r\n\r\n## Example 3:\r\nIn the following code the two pins fail but not necessarily at the same time:\r\n- sometimes the first pin fails\r\n- sometimes the second pin fails\r\n- sometimes they both fail\r\n- sometimes they both work as expected\r\n```java\r\nfor(int i = 0; i < 100; i++) {\t//a hundred times\r\n\tThread.sleep(500);\t\t\t//wait half a second\r\n\tpwmPinOne.write(1);\t\t\t//write 100%\r\n\tpwmPinTwo.write(1);\t\t\t//write 100%\r\n\tThread.sleep(500);\t\t\t//wait half a second\r\n\tpwmPinOne.write(0.5f);\t\t//write 50%\r\n\tpwmPinTwo.write(0.5f);\t\t//write 50%\r\n\tThread.sleep(500);\t\t\t//wait half a second\r\n\tpwmPinOne.write(0.0f);\t\t//write 0%\r\n\tpwmPinTwo.write(0.0f);\t\t//write 0%\r\n}\r\n```\r\n\r\nI've tried using `pwmPin.enable(false)` but the bug is still there and the failure rate is the same."},"comment":{"url":"https://api.github.com/repos/intel-iot-devkit/mraa/issues/comments/250535630","html_url":"https://github.com/intel-iot-devkit/mraa/issues/585#issuecomment-250535630","issue_url":"https://api.github.com/repos/intel-iot-devkit/mraa/issues/585","id":250535630,"user":{"login":"Propanu","id":5123898,"avatar_url":"https://avatars.githubusercontent.com/u/5123898?v=3","gravatar_id":"","url":"https://api.github.com/users/Propanu","html_url":"https://github.com/Propanu","followers_url":"https://api.github.com/users/Propanu/followers","following_url":"https://api.github.com/users/Propanu/following{/other_user}","gists_url":"https://api.github.com/users/Propanu/gists{/gist_id}","starred_url":"https://api.github.com/users/Propanu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Propanu/subscriptions","organizations_url":"https://api.github.com/users/Propanu/orgs","repos_url":"https://api.github.com/users/Propanu/repos","events_url":"https://api.github.com/users/Propanu/events{/privacy}","received_events_url":"https://api.github.com/users/Propanu/received_events","type":"User","site_admin":false},"created_at":"2016-09-29T17:30:25Z","updated_at":"2016-09-29T17:30:25Z","body":"This was a big deal with our UPM Buzzer driver too so I did the following:\r\n```\r\nmraa_pwm_period_us(m_pwm_context, 1);\r\nmraa_pwm_write(m_pwm_context, 0);\r\n```\r\nIt works well for the Buzzer since it's not audible, but I have doubts it's a flat 0 and you might still see it with an LED. However, since the issue seems to appear only when writing a pulse_width of 0, you can also try the other extreme and set the maximum possible value for the period and 1 us for the width. That might be the closest you could get to a flat 0 reliably.\r\n"}}
{"actor":{"display_login":"Propanu"}}