{"action":"created","issue":{"url":"https://api.github.com/repos/MarlinFirmware/Marlin/issues/5102","repository_url":"https://api.github.com/repos/MarlinFirmware/Marlin","labels_url":"https://api.github.com/repos/MarlinFirmware/Marlin/issues/5102/labels{/name}","comments_url":"https://api.github.com/repos/MarlinFirmware/Marlin/issues/5102/comments","events_url":"https://api.github.com/repos/MarlinFirmware/Marlin/issues/5102/events","html_url":"https://github.com/MarlinFirmware/Marlin/issues/5102","id":185892932,"number":5102,"title":"End-stop ISR","user":{"login":"tracklogic","id":18684074,"avatar_url":"https://avatars.githubusercontent.com/u/18684074?v=3","gravatar_id":"","url":"https://api.github.com/users/tracklogic","html_url":"https://github.com/tracklogic","followers_url":"https://api.github.com/users/tracklogic/followers","following_url":"https://api.github.com/users/tracklogic/following{/other_user}","gists_url":"https://api.github.com/users/tracklogic/gists{/gist_id}","starred_url":"https://api.github.com/users/tracklogic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tracklogic/subscriptions","organizations_url":"https://api.github.com/users/tracklogic/orgs","repos_url":"https://api.github.com/users/tracklogic/repos","events_url":"https://api.github.com/users/tracklogic/events{/privacy}","received_events_url":"https://api.github.com/users/tracklogic/received_events","type":"User","site_admin":false},"labels":[{"id":338043867,"url":"https://api.github.com/repos/MarlinFirmware/Marlin/labels/Support:%20Configuration","name":"Support: Configuration","color":"006b75","default":false},{"id":179009757,"url":"https://api.github.com/repos/MarlinFirmware/Marlin/labels/Support:%20Documentation","name":"Support: Documentation","color":"006b75","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2016-10-28T10:43:23Z","updated_at":"2016-11-02T23:19:24Z","closed_at":null,"body":"I'm slightly surprised the end-stops aren't checked all the time, what happens if the firmware gets itself into a knot or the motors lose steps and the firmware thinks the head is somewhere that is not and drives the head into the side of the printer/cnc-mill etc.. - its potentially going to do damage.\n\nIs there a reason the end-stops are only checked during homing? \n\nI've got marlin running on a couple of 3d printers and i've ported it to running a larger cnc machine, to get the larger machine running for development purposes, but the motors (220v 5-phase jobs) have got that much torque that its likely to do some damage if something goes wrong, hence my question.\n\nI am thinking of adding an additional pinOnChange ISR() to my copy of marlin so if any of the end-stops get triggered then it can just stall, not sure what the general thoughts on this would be though.\n\nThanks in advance\n\nMatt\n"},"comment":{"url":"https://api.github.com/repos/MarlinFirmware/Marlin/issues/comments/258028792","html_url":"https://github.com/MarlinFirmware/Marlin/issues/5102#issuecomment-258028792","issue_url":"https://api.github.com/repos/MarlinFirmware/Marlin/issues/5102","id":258028792,"user":{"login":"Blue-Marlin","id":17075493,"avatar_url":"https://avatars.githubusercontent.com/u/17075493?v=3","gravatar_id":"","url":"https://api.github.com/users/Blue-Marlin","html_url":"https://github.com/Blue-Marlin","followers_url":"https://api.github.com/users/Blue-Marlin/followers","following_url":"https://api.github.com/users/Blue-Marlin/following{/other_user}","gists_url":"https://api.github.com/users/Blue-Marlin/gists{/gist_id}","starred_url":"https://api.github.com/users/Blue-Marlin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Blue-Marlin/subscriptions","organizations_url":"https://api.github.com/users/Blue-Marlin/orgs","repos_url":"https://api.github.com/users/Blue-Marlin/repos","events_url":"https://api.github.com/users/Blue-Marlin/events{/privacy}","received_events_url":"https://api.github.com/users/Blue-Marlin/received_events","type":"User","site_admin":false},"created_at":"2016-11-02T23:19:24Z","updated_at":"2016-11-02T23:19:24Z","body":"Indeed.\r\nFor the EXT-interrupts it's easy. pins_arduino.h provides a macro (digitalPinToInterrupt(p)) we can check with the preprocessor.\r\nBut with the PCIs i'm struggling a bit. \r\nFrom:\r\n```\r\n#if digitalPinToPCICR(2) == NULL\r\n  #error \"Not a PCI-pin\"\r\n#endif\r\n```\r\ni get\r\n```\r\nerror: operator '&' has no left operand\r\n                                   (((p) >= 62) && ((p) <= 69)) ? (&PCICR) : ((uint8_t *)0) )\r\n\r\n                                                                   ^\r\n```\r\nLikely the preprocessor can't handle adresses - or at least I can't handle adresses in the preprocessor.\r\n@thinkyhead \r\nHas the 'Macro Master' an idea?\r\n\r\nI could handle that in C at runtime. But that would produce a lot of unused code.\r\n\r\nCutout from `pins_Arduino.h` for the MEGA\r\n```\r\n// A majority of the pins are NOT PCINTs, SO BE WARNED (i.e. you cannot use them as receive pins)\r\n// Only pins available for RECEIVE (TRANSMIT can be on any pin):\r\n// (I've deliberately left out pin mapping to the Hardware USARTs - seems senseless to me)\r\n// Pins: 10, 11, 12, 13,  50, 51, 52, 53,  62, 63, 64, 65, 66, 67, 68, 69\r\n\r\n#define digitalPinToPCICR(p)    ( (((p) >= 10) && ((p) <= 13)) || \\\r\n                                  (((p) >= 50) && ((p) <= 53)) || \\\r\n                                  (((p) >= 62) && ((p) <= 69)) ? (&PCICR) : ((uint8_t *)0) )\r\n\r\n#define digitalPinToPCICRbit(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? 0 : \\\r\n                                ( (((p) >= 62) && ((p) <= 69)) ? 2 : \\\r\n                                0 ) )\r\n\r\n#define digitalPinToPCMSK(p)    ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? (&PCMSK0) : \\\r\n                                ( (((p) >= 62) && ((p) <= 69)) ? (&PCMSK2) : \\\r\n                                ((uint8_t *)0) ) )\r\n\r\n#define digitalPinToPCMSKbit(p) ( (((p) >= 10) && ((p) <= 13)) ? ((p) - 6) : \\\r\n                                ( ((p) == 50) ? 3 : \\\r\n                                ( ((p) == 51) ? 2 : \\\r\n                                ( ((p) == 52) ? 1 : \\\r\n                                ( ((p) == 53) ? 0 : \\\r\n                                ( (((p) >= 62) && ((p) <= 69)) ? ((p) - 62) : \\\r\n                                0 ) ) ) ) ) )\r\n\r\n#define digitalPinToInterrupt(p) ((p) == 2 ? 0 : ((p) == 3 ? 1 : ((p) >= 18 && (p) <= 21 ? 23 - (p) : NOT_AN_INTERRUPT)))\r\n```\r\n`digitalPinToPCICRbit(p)` and `digitalPinToPCMSKbit(p)` don't work as a check because 0 is in legal results. `digitalPinToPCMSK(p)` has the same pointer problem."}}
{"actor":{"display_login":"Blue-Marlin"}}