{"action":"created","issue":{"url":"https://api.github.com/repos/Smoothieware/Smoothieware/issues/834","labels_url":"https://api.github.com/repos/Smoothieware/Smoothieware/issues/834/labels{/name}","comments_url":"https://api.github.com/repos/Smoothieware/Smoothieware/issues/834/comments","events_url":"https://api.github.com/repos/Smoothieware/Smoothieware/issues/834/events","html_url":"https://github.com/Smoothieware/Smoothieware/issues/834","id":129955083,"number":834,"title":"false endstops trigger while moving: debounced_get(n)","user":{"login":"PaoloBi","id":3226926,"avatar_url":"https://avatars.githubusercontent.com/u/3226926?v=3","gravatar_id":"","url":"https://api.github.com/users/PaoloBi","html_url":"https://github.com/PaoloBi","followers_url":"https://api.github.com/users/PaoloBi/followers","following_url":"https://api.github.com/users/PaoloBi/following{/other_user}","gists_url":"https://api.github.com/users/PaoloBi/gists{/gist_id}","starred_url":"https://api.github.com/users/PaoloBi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PaoloBi/subscriptions","organizations_url":"https://api.github.com/users/PaoloBi/orgs","repos_url":"https://api.github.com/users/PaoloBi/repos","events_url":"https://api.github.com/users/PaoloBi/events{/privacy}","received_events_url":"https://api.github.com/users/PaoloBi/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-01-30T07:50:57Z","updated_at":"2016-01-30T18:09:28Z","closed_at":"2016-01-30T07:59:25Z","body":"Hi, I sometimes get an \"endstop triggered error\" while moving (and obviously NOT triggering endstops).\r\n\r\nI checked endstops.cpp, Endstops::on_idle:\r\n\r\n........\r\n    for( int c = X_AXIS; c <= Z_AXIS; c++ ) {\r\n        if(this->limit_enable[c] && STEPPER[c]->is_moving()) {\r\n            std::array<int, 2> minmax{{0, 3}};\r\n            // check min and max endstops\r\n            for (int i : minmax) {\r\n                int n= c+i;\r\n                if(debounced_get(n)) {\r\n                    // endstop triggered\r\n                    ...\r\n                    this->status= LIMIT_TRIGGERED;\r\n                    // disables heaters and motors, ignores incoming Gcode and flushes block queue\r\n                    THEKERNEL->call_event(ON_HALT, nullptr);\r\n                    return;\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\ndebounced_get(n) is a simple loop, and returns true if pin X[Y,Z] is ON endstop_debounce_count times.\r\n\r\nIn my opinion this is a) a waste of time b) not correct. In my experience a correct debounce time is between 1 and 10ms; i guess debounced_get(n) takes less than 1ms to complete.\r\nWouldn't be better to change debounced_get and call it periodically (every 100us...1ms) ?\r\n\r\nThanks"},"comment":{"url":"https://api.github.com/repos/Smoothieware/Smoothieware/issues/comments/177265088","html_url":"https://github.com/Smoothieware/Smoothieware/issues/834#issuecomment-177265088","issue_url":"https://api.github.com/repos/Smoothieware/Smoothieware/issues/834","id":177265088,"user":{"login":"wolfmanjm","id":22263,"avatar_url":"https://avatars.githubusercontent.com/u/22263?v=3","gravatar_id":"","url":"https://api.github.com/users/wolfmanjm","html_url":"https://github.com/wolfmanjm","followers_url":"https://api.github.com/users/wolfmanjm/followers","following_url":"https://api.github.com/users/wolfmanjm/following{/other_user}","gists_url":"https://api.github.com/users/wolfmanjm/gists{/gist_id}","starred_url":"https://api.github.com/users/wolfmanjm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wolfmanjm/subscriptions","organizations_url":"https://api.github.com/users/wolfmanjm/orgs","repos_url":"https://api.github.com/users/wolfmanjm/repos","events_url":"https://api.github.com/users/wolfmanjm/events{/privacy}","received_events_url":"https://api.github.com/users/wolfmanjm/received_events","type":"User","site_admin":false},"created_at":"2016-01-30T18:09:28Z","updated_at":"2016-01-30T18:09:28Z","body":"Yes we are sure it is noise, if you get it triggered when it is not hit then it has absolutely nothing to do with debounce. the debounce is only needed for the homing cycle not the limit switches. I am not even sure why there is even a debounce in there for the limit switches. If a limit switch triggers it should stop immediately there is no need to debounce a limit switch. If your limit switch gets triggered before it is even touched then it is a H/W issue, probably noise. How on earth could that be S/W?"}}