Welcome to Our Community

Some features disabled for guests. Register Today.

NickEng's Sawstop Grbl interface / coding

Discussion in 'Other Software' started by NickEng, Feb 5, 2022.

  1. NickEng

    NickEng Well-Known
    Builder

    Joined:
    Sep 10, 2020
    Messages:
    152
    Likes Received:
    18
    I tried that as well. If I type in to the serial console G0 X10 n/ M8 I get this error:
    I will give runJob a try tomorrow.
    I did get it to work by changing $J to G0 in the moveTo ()!! It worked! But, I have no way of using the jog buttons in the macro unless the suggestion of runJob will allow me to add the m8/m9 commands to the end of a $J move.
    I am also having some crazy homing issues that just came up. If I home through my macro or if I type $H in the serial console, the saw stop homes just as it always has. Hits switch moves forward, goes back slow, and forward slow and is at “home”. However, if I click on the “home all” button in the main control ui, the saw stop continuously homes… hits switch, backs off, hits switch backs off…. Over and over… some times it does it 2 or 3 times, but sometimes it does it 9 or 10 times before it sets at “home”. It’s weird it only does it with the home icon on the main control interface. It doesn’t seem to be as accurate when it does it either.

    A quick video if interested: (don’t watch if you’re looking for eye candy!! ) :(:(:p
    https://youtube.com/shorts/XexrWv8DRKU?feature=share

    Thanks!
     
  2. Peter Van Der Walt

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

    Joined:
    Mar 1, 2017
    Messages:
    14,917
    Likes Received:
    4,290
    Compare the position of your backslash to the advice I gave....
    Well not just the position, but also the type. Forwards vs back.

    Operator error. Further reading Creating Line Breaks In JavaScript Strings

    Did you add any button listeners in your code that now also fires when the main UI buttons are clicked? Important to give your buttons unique IDs and even sometimes own classes as we have listeners for IDs and Classes to reuse code
     
  3. NickEng

    NickEng Well-Known
    Builder

    Joined:
    Sep 10, 2020
    Messages:
    152
    Likes Received:
    18
    Yes, I am guilty of many of those….

    I have an old iPad laying around, I see control has Mac support, does that include iPad?

    thanks!
     
  4. Peter Van Der Walt

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

    Joined:
    Mar 1, 2017
    Messages:
    14,917
    Likes Received:
    4,290
    Nope, iPadOS is not MacOS
     
  5. NickEng

    NickEng Well-Known
    Builder

    Joined:
    Sep 10, 2020
    Messages:
    152
    Likes Received:
    18
    I am checking on this in my code. I think this is the problem with my homing issue on the main control interface. I am a little confused about how I should be handling the coding of the macro. As I am "borrowing" some functions from the
    OpenBuilds-CONTROL/jog.js at master · OpenBuilds/OpenBuilds-CONTROL.

    If I add buttons/functions from here and add them to my macro, will they run twice (or possibly more) when they are clicked on the main control screen? I still want to be able to utilize the main control UI.

    Also, do I have access to edit what happens when the buttons are clicked on the main Control UI? For example, now that I have the m8/m9 commands working with my macro; I will need them to work as well if I click a move button on the main UI. So if I click 'home all' on the main UI, I would need a m9 command to be executed prior to sending the $H to GRBL. Is that something I can change?

    Thanks!
     
  6. Peter Van Der Walt

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

    Joined:
    Mar 1, 2017
    Messages:
    14,917
    Likes Received:
    4,290
    Depends how you define the listener / id / classnames


    You can redefine global functions, though this is getting much more complicated than you want to do. The operator will only forget to unlock once (;
     
  7. NickEng

    NickEng Well-Known
    Builder

    Joined:
    Sep 10, 2020
    Messages:
    152
    Likes Received:
    18
    Honestly, I would really like to make the macro able to open on startup, but you said this macro wasn't created to do this. I'm not sure what you meant, but it will open correctly if I check the box. The problem is, I have no way of "connecting" to the arduino. This is really the only thing I would need for the saw stop application, and the macro itself would be sufficient (I think). I would then only need to use what was on the macro itself.

    I still would like to be able to display the digital readout that shows where my 'x' value is located. Where would I find these functions / code to display these on the macro?

    Thanks!
     
  8. Peter Van Der Walt

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

    Joined:
    Mar 1, 2017
    Messages:
    14,917
    Likes Received:
    4,290
  9. NickEng

    NickEng Well-Known
    Builder

    Joined:
    Sep 10, 2020
    Messages:
    152
    Likes Received:
    18
    @Peter Van Der Walt , I know you are probably tired of explaining things to me, but I am lost. I can't even find where the screen shot you provided that has the laststatus tab is. I press the Control shift I buttons and I get the screen up, but I have no idea where to look for that screen shot you provided. I also don't know how you would edit the html directly. I assume you would do it here?

    I am sure I have been going about it wrong, but I have been just editing the code and repasting it to create a "new" macro. I open the macro back up to see what changes have been made. That is how I have done all of my changes.

    Thanks!
     
  10. Peter Van Der Walt

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

    Joined:
    Mar 1, 2017
    Messages:
    14,917
    Likes Received:
    4,290
    #130 Peter Van Der Walt, Feb 21, 2022
    Last edited: Feb 21, 2022
  11. NickEng

    NickEng Well-Known
    Builder

    Joined:
    Sep 10, 2020
    Messages:
    152
    Likes Received:
    18
    When I press control shift I, the window that pops up to the side, is that dev tools?

    What folder should I look in to find the screen shot above that has the bit with laststatus.machine.position? Element, console, etc. ? What sub folder is it? Main.js? Jog.js etc?

    I pressed control f and type in laststatus, but I don’t see it used like is in your screen shot.

    Thanks!
     
  12. Peter Van Der Walt

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

    Joined:
    Mar 1, 2017
    Messages:
    14,917
    Likes Received:
    4,290
    Ctrl+shift+i and yes. Google "chrome devtools" to learn more about it

    In devtools > console tab > enter "laststatus" and press enter. It spits out what the variable holds. Laststatus is a variable holding JSON formatted data of most of the important status info. Google for "JSON" to learn more. Devtools is just a visual way to execute code, view variables, explore things, DOM elements etc etc.

    You then use the variable you discovered while exploring using devtools, in a normal jquery html call to update a DOM element.
     
  13. Peter Van Der Walt

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

    Joined:
    Mar 1, 2017
    Messages:
    14,917
    Likes Received:
    4,290
    Provide the code for your most current one and I'll add it for you :)
     
  14. NickEng

    NickEng Well-Known
    Builder

    Joined:
    Sep 10, 2020
    Messages:
    152
    Likes Received:
    18
    This is what I couldn't figure out. I have now found what you screen shot above. I had no idea how to access this. Again, I am completely new to all things java, jquery, html, css, devtools, pretty much all of this .... I apologize. It is like reading a foreign language to me (I guess it kind of is). I do know that google is my friend, and I am trying to use it as much as possible, but sometimes I don't even know what to google. The information above was very helpful and appreciated.

    Yes, I was trying to "find" the "laststatus" variable with the control F command. I do realize it was not explicitly told in the link you provided. I was trying to find a way to find the info.

    Yes, I have read the entire thread multiple times. It didn't have the detail that you provided in the last post that allowed me to find what you were describing. I probably should have known this, but I did not. ... Sorry,.

    Thanks!
     
  15. NickEng

    NickEng Well-Known
    Builder

    Joined:
    Sep 10, 2020
    Messages:
    152
    Likes Received:
    18
    Just saw this. I am kind of cringing as I paste the code, as it is really hacked together. I am going to paste two different ones. The first basically works:
    It will execute the m8/m9 commands as it should with the macro functions (home, far left, move to (any input value), and jog (as long as "continuous" is selected on the main UI. If incremental is selected in the main UI the m8/m9 commands do not execute. I also get and error if I do a quick click on the jog button even if it is "continuous" mode: Here it is:


    The second: As you will see, I am trying to add the DRO for the x value and a way to connect the arduino from the macro screen.
    I know you said not to do this and scrap the macro if I wanted it, but I had already gotten that far, and I have no idea how to begin editing the .html for a new UI... It does not work anything like it shoule.... Here is the second Code

     
  16. Peter Van Der Walt

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

    Joined:
    Mar 1, 2017
    Messages:
    14,917
    Likes Received:
    4,290
    Will get to it later in the week - lot of cleanup needed, you are redefining existing functions like mmMode, and global vars like allowContinuousJog and jogDist - that all already exists and you can just call it from the main code, most of it doesn't need to be redefined
     
  17. NickEng

    NickEng Well-Known
    Builder

    Joined:
    Sep 10, 2020
    Messages:
    152
    Likes Received:
    18
    Well, I appreciate it!! I am not sure if this will be helpful or not, but I have gone through and stripped down some more of the first code above. I took small sections out one at a time (including the ones you suggested above) and tested the code to make sure it was still functioning as expected. There is probably still more though. I am going to paste it here: I am still getting the issue of the jog button giving an error if I click it quickly in the macro, and I am not sure what is causing it. If I hold the click down it works as expected.

    Here is the "cleaner" code:

    Thanks!
     
  18. Peter Van Der Walt

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

    Joined:
    Mar 1, 2017
    Messages:
    14,917
    Likes Received:
    4,290
    Looking at what you are trying to do there are sure other more efficient ways to do it. Like I wouldn't re-implement the whole jog code - just let the code prior to Metro.dialog.create also force Continuous mode, and then let your buttons just jquery.click the buttons behind the wizard for you (event propogation), etc
     
  19. NickEng

    NickEng Well-Known
    Builder

    Joined:
    Sep 10, 2020
    Messages:
    152
    Likes Received:
    18
    Ok, I will work on it. I assume this is what I need to force continuous mode all the time:

    localStorage.setItem('continuousJog', true);
    allowContinuousJog = true;
    $('.distbtn').hide();

    and use these to click the button behind?
    $('.xM').click();
    $('.xP').click();

    Can I add my m8/m9 commands to run when those "clicks" are executed?

    edit: Won't I need to use the mousedown and mouseup functions for continous jog?

    Thanks!
     
    Peter Van Der Walt likes this.
  20. Peter Van Der Walt

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

    Joined:
    Mar 1, 2017
    Messages:
    14,917
    Likes Received:
    4,290
    I'll look into it and let you know. I can't remember of the top of my head how we handled it on the probe wizard, I think the listener is setup for the class (not the ID) so any button with the class just works already... sorry if I sometimes contradict myself - on a fire task at the moment, couldn't go check the code to see what we did

    See OpenBuilds-CONTROL/probev2.js at master · OpenBuilds/OpenBuilds-CONTROL - that's all it takes to put it in Continuous

    We don't force store it to Localstore - as it may have been in Incremental before. What we do is when we exit the Wizard, we restore what it should be OpenBuilds-CONTROL/probev2.js at master · OpenBuilds/OpenBuilds-CONTROL by running OpenBuilds-CONTROL/probev2.js at master · OpenBuilds/OpenBuilds-CONTROL

    In your case you can call resetJogModeAfterProbe() in the Close actions of the Metro.dialog to clean up nicely

    Try sending it before propogating the click event
     
    #140 Peter Van Der Walt, Feb 23, 2022
    Last edited: Feb 23, 2022
  21. NickEng

    NickEng Well-Known
    Builder

    Joined:
    Sep 10, 2020
    Messages:
    152
    Likes Received:
    18
    Trust me, no worries, I am just thankful for the help. Curious, fire task, are we talking literal fire? Or, some more code that I don’t understand?o_O:D
     
  22. Peter Van Der Walt

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

    Joined:
    Mar 1, 2017
    Messages:
    14,917
    Likes Received:
    4,290
    :) no just a task at work that is a "fire" to attend to with highest speed and priority
     
  23. NickEng

    NickEng Well-Known
    Builder

    Joined:
    Sep 10, 2020
    Messages:
    152
    Likes Received:
    18
    I am trying....But still can't get the jog commands to execute without having the whole jog code in my macro.

    If I create my button with this and the id=myX:

    <td><button class="button alert x large rounded m-0 xP" id="myX" style="width: 160px;" data-role="ripple" data-ripple-color="#5de21b"><i class="fas fa-arrow-left "></i>JOG LEFT</button></td>
    <span class="fa-layers fa-fw">

    and I create a jquery function for a click on my button like this:

    $('#myX').on('click', function(){
    $('.xP').click();
    })

    I don't understand why the click on my button does not execute the xP click and cause the jog button on my macro to "click" the wizard button?

    I added the code to force continous mode prior to the .metro dialogue portion of my macro:

    $('#jogTypeContinuous').prop('checked', true)
    allowContinuousJog = true;

    and I put the resetJogFunctionAfterProbe() in the Exit macro: portion:

    `,
    actions: [{
    caption: "Exit Macro",
    cls: "js-dialog-close alert",
    onclick: function() {
    resetJogModeAfterProbe()
    printLog("Saw Stop Macro Exited")
    }
    }]
    });

    Along with adding the resetJogModeAfterProbe() function itself to my macro (not sure if needed).

    I have been doing some studying on jquery, so I have a little bit better understanding of it, but obviously not enough.....

    Thanks!
     
  24. Peter Van Der Walt

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

    Joined:
    Mar 1, 2017
    Messages:
    14,917
    Likes Received:
    4,290
    Your button:
    Has the class of .xP as well. So when you click your button, you are sending an event down to also go click on all .xP buttons, which includes this button that may trigger a loop.
    Take the .xP class out of your button's class parameter. Not sure Click's enough, as we look for both mousedown/touchdown (start jogging) and mouseup/touchup (stop the jog) to handle the "jog while the button is being held down". See OpenBuilds-CONTROL/jog.js at master · OpenBuilds/OpenBuilds-CONTROL - so you may need to propogate those events instead

    Almost done on my other urgent tasks - might get to this soon. Hard to give advice without digging in and testing couple things myself.
     
  25. NickEng

    NickEng Well-Known
    Builder

    Joined:
    Sep 10, 2020
    Messages:
    152
    Likes Received:
    18
    No rush. I am still slowly trudging my way through, hopefully learning a little as I go.

    I think I got my buttons to work as you described sorta. I haven't tried on the machine, but in simulation it seems to work. I am getting an error " Please wait for machine to be Idle, before jogging" when I click my jog buttons, but it doesn't seem to effect the result of the button click.

    I am also using the .mousedown() and .mouseup() functions to be executed when my ('touchstart mouseup', function() and ('touchstart mousedown', function() are pressed. I am not sure if touchstart is for touchscreens as I am using, but it may not function correctly on a touchscreen device. I will have to test later.

    Here is the basic functions I am using:

    Here is the entire code:

    I guess the DRO is next on my list.

    THANKS!
     
  26. Peter Van Der Walt

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

    Joined:
    Mar 1, 2017
    Messages:
    14,917
    Likes Received:
    4,290
    We check for Idle/Door status before starting to jog: See OpenBuilds-CONTROL/jog.js at master · OpenBuilds/OpenBuilds-CONTROL for example

    Some devices sends Mouse events for the touchscreen, some sends Touch events. That's we listen for both in our listener, you should too
     
  27. NickEng

    NickEng Well-Known
    Builder

    Joined:
    Sep 10, 2020
    Messages:
    152
    Likes Received:
    18
    So, should I add this to my code too?

    In devtools, this seems to be the address to the location of my saw stops (machine.position.work.x). In order to display it on my macro, could I save it to a variable and or string and have it updated with the main UI of the macro?

    @Peter Van Der Walt I haven't been able to figure out how to save this to a variable. I see in the main jog.js that $("#xPos").show() is used, but does this have to be a global variable for me to be able to use it in the macro?

    Thanks!
     
    #147 NickEng, Feb 27, 2022
    Last edited: Feb 28, 2022
  28. NickEng

    NickEng Well-Known
    Builder

    Joined:
    Sep 10, 2020
    Messages:
    152
    Likes Received:
    18
    Ok, I guess I need to ask some simple questions. When I look to add something to the macro, and I want to add a jquery () most of what I find on the internet starts with something like $(document).ready() and they have a script src = “some jquery library.com

    I am assuming this is all being taken care of somewhere in the openbuild main code and the document.ready is not needed for the macro because of the display of the ui that is in the macro code you provided. However, how do I add jquery functions such as $(“#xPos”).show() to my macro?

    Is it not a global variable that I can use in my macro?

    Or, should I be trying to use the path
    Machine.position.work.x and create a variable to store this location to in order to display on the macro the position of the sawstop?

    Thanks!
     
  29. Peter Van Der Walt

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

    Joined:
    Mar 1, 2017
    Messages:
    14,917
    Likes Received:
    4,290
    Macros are loaded after "the document is ready" so no need.

    Up to you. In a setInterval if its something that happens on a loop. After a button press? On a Listener. When you you want the thing that has the ID of "xPos" to be "shown" (aka Unhidden, so its to be assumed it was hidden earlier?)

    laststatus.machine.position.work.x is already a variable, just use it as is. It always contains the last reported x work position
     
  30. NickEng

    NickEng Well-Known
    Builder

    Joined:
    Sep 10, 2020
    Messages:
    152
    Likes Received:
    18

    Ok, I can get it display fine in mm like this:

    // Update the UI <span> fields to display value
    window.updateSawStopValueUI = setInterval(function() {
    $("#sawStopValue").html(sawStopValue.toFixed(0));
    $("#currentPosition").html(laststatus.machine.position.work.x);
    if(currentFractionValue.length > 1){
    $("#currentFraction").html("&nbsp;and&nbsp;" + currentFractionValue);
    } else {
    $("#currentFraction").html("");
    }

    However, if I try to convert it to inches by / 25.4, it flickers between the metric value and the converted inch value.

    // Update the UI <span> fields to display value
    window.updateSawStopValueUI = setInterval(function() {
    $("#sawStopValue").html(sawStopValue.toFixed(0));
    $("#currentPosition").html((laststatus.machine.position.work.x / 25.4 ));
    if(currentFractionValue.length > 1){
    $("#currentFraction").html("&nbsp;and&nbsp;" + currentFractionValue);
    } else {
    $("#currentFraction").html("");
    }

    I have tried doing the conversion in a set interval function and then displaying the value of the new variable when the UI is updated, but it doesn't seem to work either.

    Thanks!
     

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