Welcome to Our Community

Some features disabled for guests. Register Today.

Resume job automatically?

Discussion in 'General Talk' started by francisco velazquez, May 5, 2020.

Tags:
  1. francisco velazquez

    Builder

    Joined:
    Jul 2, 2019
    Messages:
    7
    Likes Received:
    1
    Hi!

    I just want to know if is there a way to resume a job automatically?, once I close the door after opening it.
    I charged the firmware with N/C switches.
    Thanks.
     
  2. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    13,751
    Likes Received:
    4,070
    Did you remember to flash the DOOR firmware (from OpenBuildsCONTROL > Wizards and tools > Grbl Flashing , it resumes automatically when the door closes.

    Or if you were compiling manually, refer to gnea/grbl

    Without door being enabled in Grbl, the same input is just Feedhold
     
  3. francisco velazquez

    Builder

    Joined:
    Jul 2, 2019
    Messages:
    7
    Likes Received:
    1
    I did it from OpenBuildsCONTROL. as I show i the image.
     

    Attached Files:

  4. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    13,751
    Likes Received:
    4,070
    With that config, its supposed to resume when you close the door

    a) check on troubleshooting tab that door signal reacts on both opening, and closing the door
    b) take me a screenshot of the control window with the door open, and another right after closing the door (if it has not resumed yet) - on the Serial Console tab, but crop the whole window (want to see the bottom statusses, etc too)
     
  5. francisco velazquez

    Builder

    Joined:
    Jul 2, 2019
    Messages:
    7
    Likes Received:
    1
    I took this ones.
     

    Attached Files:

  6. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    13,751
    Likes Received:
    4,070
    OK, gimme a day or two to investigate, you might have found a new bug. :)
     
  7. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    13,751
    Likes Received:
    4,070
  8. francisco velazquez

    Builder

    Joined:
    Jul 2, 2019
    Messages:
    7
    Likes Received:
    1
    Thanks for your help, I can send the command "~" with a button but it would be great to do it automatically.
     
    Mark Carew likes this.
  9. Rob Taylor

    Rob Taylor Master
    Builder

    Joined:
    Dec 15, 2013
    Messages:
    1,470
    Likes Received:
    746
    What does the serial console say once you re-close the door?

    The config.h options that CONTROL should be flagging are these:

    upload_2020-5-7_17-30-19.png

    Makes me wonder if it doesn't like the NC door and expects an NO door?

    Unless BlackBox implements the pin differently, there may be something to this: [edit: this is the point at which my exhausted brain stopped looking at pictures properly, apparently]

    upload_2020-5-7_17-32-45.png

    If grbl is expecting high for active and low for feed hold (by the definition of the config option). Depends how the interrupt is set up...

    So, if you follow the rabbit hole of the surprisingly effective GitHub search function...

    Grbl has a specific door-safety subroutine in system.c:

    upload_2020-5-7_17-47-37.png

    It's a bitwise comparison of the pin state polling function's returned byte (ie. is one of those Analog In pins pressed?) with the byte address of the door switch pin (A1, feed hold, if you've set it in config.h as above). If both are 1, ie. the button that is currently pressed is also the door safety switch, it returns true to the main program and triggers a realtime feed hold.

    So what's the "system_control_get_state()" function actually looking for? That's right above it in system.c:

    upload_2020-5-7_17-55-10.png

    It just... Reads all the pins. A lot. Interesting point, though; it looks for the definition of a control pin invert mask. Where are the definitions? Back in config.h:

    upload_2020-5-7_17-56-47.png

    Ah. So... You wanna use an NC switch on your door, you have to... Tell the system you're using an NC switch. Shocking.

    Question is, does CONTROL manipulate the INVERT_CONTROL_PIN_MASK? Actually, looks like yes. So.. I'm stumped. That was an illuminating ride, though.
     
    #9 Rob Taylor, May 7, 2020
    Last edited: May 7, 2020
  10. francisco velazquez

    Builder

    Joined:
    Jul 2, 2019
    Messages:
    7
    Likes Received:
    1
    Hi.
    the serial console return nothing, I just close the door but nothing in the serial console appears, I´m actually using a blackbox4x I don't know if it's a problem of the firmware, as you could see I flashed the blackbox by checking the normally closed switches option.
     
  11. Rob Taylor

    Rob Taylor Master
    Builder

    Joined:
    Dec 15, 2013
    Messages:
    1,470
    Likes Received:
    746
    Yeah I thought I was onto something and then realized I wasn't. :ROFL:

    The options in the flashing image look correct, you see what variables they change in my post, but short of reflashing manually I'm not sure what would be wrong. Seems unlikely that CONTROL is manipulating the wrong bits short of a random typo in the code - "00001000" instead of "00000100" on a mask or something. Everything else looks like it should be right, so hopefully Peter finds something on his dive.
     
  12. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    13,751
    Likes Received:
    4,070
    We provide options for both cases - see https://openbuilds.com/attachments/config-png.45751/

    Pretty sure this is a bug, not a user error, haven't had time to dig in though (on firmware/hardware dev this week)
    Suspect we pause the queue (when we shouldn't)
     
  13. Rob Taylor

    Rob Taylor Master
    Builder

    Joined:
    Dec 15, 2013
    Messages:
    1,470
    Likes Received:
    746
    Yeah, I thought I had it in my evening exhaustion and clearly 'twas not to be. :ROFL:

    I just looked through grbl-flashing.js and I see you precompile your hexes anyway, which makes sense. Nothing obvious wrong that I can see (not being a JS programmer!), anyway, though the separate door and hold switch cases in websocket.js seem weird. I assume it's written that way for a reason though. Will be interesting to see what you come up with!
     
  14. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    13,751
    Likes Received:
    4,070
    That's the feedback from Grbl that makes it weird, if I look at Francisco's screenshot of the serial log, it looks like Grbl gives an H and a D on Door :D see gnea/grbl

    grbl wiki.PNG

    Looks like react to the H (Hold) that comes along with the D (Door) pin state, and it should change so we react on H only if D is not present. See OpenBuilds/OpenBuilds-CONTROL at Line 1865

    Code:
    if (pins.includes('H')) {
    should become

    Code:
    if (pins.includes('H') && !pins.includes('D')) {
     
  15. Rob Taylor

    Rob Taylor Master
    Builder

    Joined:
    Dec 15, 2013
    Messages:
    1,470
    Likes Received:
    746
    Ah, I see. I don't think I'd ever had cause to read that far down the Interface wiki page, actually. Some interesting stuff in there, I'll have to fully read it sometime.

    THAT'S the bit I was looking for, where you actually parse and react to the status reports, but GitHub wasn't showing that instance of "status.machine.inputs", which is mostly what I was searching for (to be fair to it, there are a lot!).

    Seems like adding an includes('D') if case directly above it (or just changing the whole thing to a switch as well) would circumvent that. If a machine isn't using a door hold .hex, it'll never send a D. If that's the first possible option, immediately followed by a standard H check, it'll always cause the right type of pause to the main loop. Like, literally just pasting in:

    Code:
    if (pins.includes('D')) {
            // pause
            pause();
            var output = {
              'command': '[external from hardware]',
              'response': "OpenBuilds CONTROL received a DOOR AJAR notification from Grbl: Check safety door. Operation will resume upon door close."
            }
            io.sockets.emit('data', output);
          } // end if DOOR
    ...Or something along those lines. Though actually, it looks like it would continue down the list of if-statements and also make H true as well, so maybe adding the Boolean to that one makes sense, since D will always include H, but H won't always include D. I'm guessing there's much less reason to avoid Booleans on an i86 machine than there is on Arduino, where you're more significantly penalized.

    So where does the unpause() come in? I see the socket (SocketIO?) listener for resume, but I don't see a socket.emit('resume', true) anywhere else in the repo other than where specifically requested by the user (in keyboards.js and index.html, unsurprisingly).

    Which I suppose, thinking about it, would lead to the OP's observed behaviour, right? If there isn't a listener- function, if-statement, whatever- with a flag for "D was true, now D is false because the door was closed on the switch", that either calls resume() directly or socket.emits a resume=true before resetting the "D used to be true" flag (so it's not spamming "resume" every time parseFeedback() runs and DOESN'T receive a 'D'), then the only way to restart the machine is, indeed, to press the button to make it do so.

    That seems like more of the issue than the order of the if statements, because all you'd get there is a double "pause" call/broadcast. So the above code should have a bit where you declare var doorFlag = false; or whatever up at the top in the global scope, and then check for it each time you don't receive a 'D':

    Code:
    if (pins.includes('D') && !doorFlag) {
            // pause
            pause();
            var output = {
              'command': '[external from hardware]',
             'response': "OpenBuilds CONTROL received a DOOR AJAR notification from Grbl: Check safety door. Operation will resume upon door close."
            }
            doorFlag = true;
            io.sockets.emit('data', output);
          } // end if DOOROPEN
    
    if (!pins.includes('D') && doorFlag) {
            // unpause
            unpause();
            var output = {
              'command': '[external from hardware]',
            'response': "OpenBuilds CONTROL received a DOOR CLOSED notification from Grbl: operation will now resume."
            }
            doorFlag = false;
            io.sockets.emit('data', output);
          } // end if DOORCLOSE
    
    ...Or something.
     
    #15 Rob Taylor, May 8, 2020
    Last edited: May 8, 2020
  16. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    13,751
    Likes Received:
    4,070
    Yip something like that :) will try and get to it on monday,
    - fix code
    - test with actual controller
    - compile
    - release :)


    That section was written probably two years ago or so (at the time the xPro v4 came out with the DriverMinder switch that randomly put Grbl into HOLD, so added a catch to deal with that) - it could use a cleanup for sure - will check that part too (though I think if you properly feedhold, you can run by clicking the Play button in CONTROL when ready) - which is fine the normal use case, but not for door.
    With door we don't want to pause the UI, then we'll just let Grbl do its own thing :) - we prefer to let Grbl run the show and we just relay info back and forth as far as possible
     
  17. Rob Taylor

    Rob Taylor Master
    Builder

    Joined:
    Dec 15, 2013
    Messages:
    1,470
    Likes Received:
    746
    Just a little more work left to do then. :ROFL:

    Yep- UI button and assigned keyboard shortcut:

    upload_2020-5-8_18-17-3.png

    I'm guessing the only way to allow this to happen is to assign a socket.emit to those events, since they're not directly in the index.js file and therefore can't call unpause() directly? Might explain why it's done that way. I have no idea what I was thinking when I wrote code even 6 months earlier though. :oops::D
     
    Peter Van Der Walt likes this.
  18. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    13,751
    Likes Received:
    4,070
    From How does the "Safety Door" features work? · Issue #713 · grbl/grbl

    So actually we don't need to look at D to pause or not.We pause "if (pins.includes('H'))" regardless

    The difference lies in how to resume... Play button used to be available whether door was open or closed after feedhold. But it should have only been an option once the door is closed again! That's what caused the issues. So in upcoming version 1.0.238 or later

    - Open the door, you get H, which Pauses the UI (pause button switches to a play button, statusses show paused etc)
    - We also get a D, so we Disable the RESUME button
    - Only once the D goes away from pin Status, do we enable Resume, allowing you to, as per above "only allow you to resume via '~' once the switch is closed"
    Otherwise the resume used to be ignored and then state thinks its playing, when it is still paused

    Be sure to test 1.0.238 when it arrives and let us know if that resolved it
     
  19. Smagavi

    Smagavi New
    Builder

    Joined:
    Jul 12, 2020
    Messages:
    4
    Likes Received:
    0
    Hi,
    I'm running 1.0.238 and hoping to have the job resume when the door is closed again. However, it just pauses and does not restart. I need to hit resume on the computer to make it restart. Are others having this problem as well, or is there another setting I need to check? My settings look like Francisco's up above.

    Best,
    Sanjay
     
  20. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    13,751
    Likes Received:
    4,070
    Did you flash the Door-enabled version of Grbl from Wizards and tools > Grbl Flashing tool yet. Same pin is used as Feedhold in stock Grbl config
     
  21. Smagavi

    Smagavi New
    Builder

    Joined:
    Jul 12, 2020
    Messages:
    4
    Likes Received:
    0
    Yes, I ran the wizard for the door enabled version.
    Thanks,
    Sanjay
     
  22. francisco velazquez

    Builder

    Joined:
    Jul 2, 2019
    Messages:
    7
    Likes Received:
    1
    I couldn't solve this by hardware, I send the resume command when i read a D in the status of the BlackBox, but I don't use the OpenBuildsControl, I have developed my own interface. And by flashing for first time I couldn't flash it anymore.
     
  23. Smagavi

    Smagavi New
    Builder

    Joined:
    Jul 12, 2020
    Messages:
    4
    Likes Received:
    0
    Hi Francisco,
    We came up with a similar workaround in a way. We wanted the system to wait for a trigger to make the next movement, so we put in a pause after every movement and a set up a USB button (USBbutton.com) to send a space bar to resume the program.
    Best,
    Sanjay
     
  24. Jason Walters

    Builder

    Joined:
    Mar 9, 2021
    Messages:
    1
    Likes Received:
    0
    Was there ever a solution to this? Control won’t resume as it should when the door is closed. I have to physically click play in control to resume.
     
  25. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    13,751
    Likes Received:
    4,070
    That is by design. If you refer the Grbl docs/source closing the door "allows you to resume" it does not automatically resume - safety reasons
     
    JustinTime likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice