I've got a total newbie question on G Code so my apologies if this is a really stupid question. I'm installing an XYZ Touch probe on my Ooznest Workbee using the information from the Ooznest YouTube video, Touch Probe Commands Guide pdf. and Touch Probe Offset Calculator xls and rather than just copy and paste I thought I should try and understand the G Code. The first command in the pdf for a Z Probe is: G38.2 Z-25 F100; G10 P0 L20 Z5; G21 G91 G0 Z3 I understand what is happening until G21 (use millimeters for length units) because that code isn't used in the subsequent command in the pdf: XYZ Probe 1/4 bit G38.2 Z-25 F100; G91 G0 Z3; G91 G0 X-50; G91 G0 Z-8.2; G38.2 X30 F100; G91 G0 X-3; G91 G0 Z8.2; G91 G0 Y-50; G91 G0 X50; G91 G0 Z-8.2; G38.2 Y30 F100; G91 G0 Y-3; G91 G0 Z8.2; G10 P0 L20 X34.355 Y-17.255 Z8 Is it necessary to set G21? Or should I add it into the XYZ Probe 1/4 bit command where it is missing? Thanks Adam
Hi @Award, I can't answer most of your questions, but which version of the workbee have you got (ie what controller are you using). The answers you (and I - I'm about to try to fit an X/Y/Z probe to my workbee) need may be different for the Xpro and Duet controllers. I suspect the Y and X macros use inches because they use an 1/8th or 1/4" bit as the probe. Alex
Its not inches. G21 is a modal command which means it stays in effect until it is changed with a G20.
Yes, but @Award is referring to two different macros - G21 is only in the Z probe macro. It is not included in the X/Y/Z probe macro. Alex
Unless he runs another program that changes it to G20, then its still in G21. As a safety measure, I always make sure to call out either G21 or G20 in a program, but its not necessary.
Good point, the X/Y/Z probe macro should probably declare inches or mm as at that stage it is likely nothing else has been run. Alex
Thank you very much for the replies guys - this forum is great! Alex, I'm using the xPro v3 controller and the OpenBuilds Control v1.0.144 for the probe macro Sharmstr, I'll follow your safety first tactic and and put the G21 code into the XYZ probe command as well. Cheers
I went off and did a little bit of investigation about grbl and g code as the G21 thing was annoying me even though it is a very minor thing. As Sharmstr said G21 (and G20) is a modal setting for units. I looked into how grbl deals with g code and G21 is the default mode so it doesn't need to be set unless G20 has previously been issued in the program (or the startup block). As this is just a simple Z Probe macro and I'm always going to be working in metric (and haven't messed with the startup block) it just confuses newbies like me. Here's a link to the grbl wiki if like me you are newbie to g code and grbl. gnea/grbl G21 is also the default for the Duet controller as well: Gcode You've probably already found it but the guys at Ooznest have written some instructions for the XYZ Probe for the Duet controller: Setup a XYZ Touch Probe With a Duet Controller Now I have some serious studying of G code and grbl to do - as an actual builder this is all a bit out of my comfort zone! Thanks again for the help
Hiya Since G20/21 is modal, ie it gets remembered, the right thing to do is always set it to what you want. This means always setting it in the probe macros, and also always setting it in all your gcode programs, and even in jog moves internal to the GUI. The reason is that you get used to it all just working and then one day you run some inch Gcode which leaves the machine in inch mode. then you click a jog button to move Z 5mm up but instead it moves 5 inches up. CRASH. Thus all jog buttons, all macros,all probe macros, and all part programs etc, must specify G21 so they know what the mode is for safety (GRBL specific jog commands may not require it but only GUI's will use those). Also, some GUI's will display in inches, GRBL knows how to report in inches, but this does not mean that the mode is inches, the mode is still set by the last G21 or G20 received. Another really dangerous modal command is G90/G91. Issuing a G90 at the start of every program and macro is a good safety habit.
Thank you very much for the clarification. This is a great example of why this forum is so useful to beginners like me because your real world experience trumps just reading the documents! If I go back to the XYZ 1/4 Bit Probe macro from Ooznest: G38.2 Z-25 F100; G91 G0 Z3; G91 G0 X-50; G91 G0 Z-8.2; G38.2 X30 F100; G91 G0 X-3; G91 G0 Z8.2; G91 G0 Y-50; G91 G0 X50; G91 G0 Z-8.2; G38.2 Y30 F100; G91 G0 Y-3; G91 G0 Z8.2; G10 P0 L20 X34.355 Y-17.255 Z8 Should I just set G21 and G91 at the beginning of the macro?: G21 G91; G38.2 Z-25 F100; G91 G0 Z3; G91 G0 X-50; G91 G0 Z-8.2; G38.2 X30 F100; G91 G0 X-3; G91 G0 Z8.2; G91 G0 Y-50; G91 G0 X50; G91 G0 Z-8.2; G38.2 Y30 F100; G91 G0 Y-3; G91 G0 Z8.2; G10 P0 L20 X34.355 Y-17.255 Z8 Cheers Adam
G21 yes, G91 no The way G91 is used in the macro in lines like G91 G0 Z3 makes it only apply to that line, and that is correct within the macro. It means that the macro will not set G91 permanently so that after the macro, if it was off, it remains off, if it was on, it remains on. so: G21; G38.2 Z-25 F100; G91 G0 Z3; G91 G0 X-50; G91 G0 Z-8.2; G38.2 X30 F100; G91 G0 X-3; G91 G0 Z8.2; G91 G0 Y-50; G91 G0 X50; G91 G0 Z-8.2; G38.2 Y30 F100; G91 G0 Y-3; G91 G0 Z8.2; G10 P0 L20 X34.355 Y-17.255 Z8
Hello again, I've run into a problem running the Z Probe macro: G38.2 Z-25 F100; G10 P0 L20 Z6.3; G21 G91 G0 Z3 When I run the macro in the Open Builds Control it successfully probes downwards and then a dialogue box appears asking if I would like to retract the probe. When I click on Yes I get the error message below: Error: 2 Numeric value format is not valid or missing an expected value [$J=G91Z5FNaN ] The output from the Open Builds Control serial console is below: [16:22:14] [ [ PROBE ] ] Probe Completed. Setting Z to 0mm [16:22:14] [ G38.2 Z-25 F100 ] [PRB:-633.000,-350.000,-33.710:1] [16:22:14] [ G38.2 Z-25 F100 ] ok [16:22:14] [ G10 P1 L20 Z0 ] ok [16:23:13] [ ] error: 2 - Numeric value format is not valid or missing an expected value. [ $J=G91Z5FNaN ] [16:23:13] [ $J=G91Z5FNaN ] error:2 Any help/advice would be greatly appreciated. For completeness I'm using an xPro v3 card, grbl 1.1f and the latest Open Builds Control. Update: I've just run the same code as a macro in Universal G Code Sender and it runs without a hitch. Could it be the Open Builds Control Software?
As we have a built-in probe tool, it already catches certain messages from grbl, so when you manually probe, the [PRB:] is intercepted as an expected result to our Z-probe module. Thats not entirely correct, so I will gladly open an issue for you and work on getting that fixed so we only intercept after sending the Z probe from the wizard. (And as it wasnt sent using the wizard, the feedrate isnt stored in the backend, thus NaN (Not a Number) Interesting find thanks! It may take a couple days before I get it fixed for you though, for now, dont click Retract (as you didnt send it with the wizard, you shouldn't retract either) so at least you can continue - just don't click Yes. If you want to probe Z use the Wizard (dropdown next to Z DRO -> Z0 Probe) - no need for a Macro Click here to view a GIF of the Built in one: View attachment 37368
Z Probe: [PRB: responses should only be caught if send from our wizard, as users may want to probe in custom macros or from the console · Issue #54 · OpenBuilds/SW-Machine-Drivers = the issue tracker for this problem - will be updated there when addressed [edit: Fixed in 1.0.146 or later]
Thank you very much for the response Peter. I hadn't realised that there was a wizard in the Open Builds Control. I will use that and stop messing around with macros and breaking things! Cheers Adam
Heads up, CONTROL v1.0.146 will be out in a day or two. In that I stopped catching the [prb: responses unless it came in response to our wizard. That means its OK to use G38 commands in Macros again. Thanks for your patience.
Hello Peter, I downloaded the new version of the Open Builds Control v1.0.147 and thought I would give the pesky probing macros a try. Unfortunately if I try to run my first test ZProbe Macro then it only runs the first line (G38.2) of the G code and ignores the rest. Here's the code from the the macro and the output from the serial console: G38.2 Z-25 F100; G10 P0 L20 Z3.3; G21 G91 G0 Z10 [15:02:23] [ G38.2 Z-25 F100 ] [PRB:-530.000,-480.000,-32.690:1] [15:02:23] [ G38.2 Z-25 F100 ] ok If I create a separate macro with only one line it runs fine and retracts: G21 G91 G0 Z10 [15:03:51] [ G21 G91 G0 Z10 ] ok However if I run the macro below it only runs the first part (G10) and ignores the rest G10 P0 L20 Z3.3; G21 G91 G0 Z10 [15:15:32] [ G10 P0 L20 Z3.3 ] ok I'm guessing (probably incorrectly!) that the OpenBuilds control is just passing the first part of the G code to grbl and ignoring the rest of the string? Cheers Adam
I updated to the newest version and I still cannot use this gcode as a macro. Now that it is updated I cannot even run it as a job. G21 G92 X0 G92 Y0 G92 Z0 G38.2 X-12.7 F25 G91 G0 X3.175 F125 G91 G0 Y25 F10 G91 G0 X-15.875 F125 G38.2 Y-25 F25 G91 G0 Y3.175 F125 G91 G0 X15.875 F125 G91 G0 Y-15.875 F125 G38.2 X-12.7 F25 G92 X49.6725 G91 G0 X3.175 F125 G91 G0 Y15.875 F125 G91 G0 X-15.875 F125 G38.2 Y-25 F25 G92 Y49.7725 G91 G0 Y3.175 F125 G91 G0 Z20.32 F125 G91 G0 Y-15.875 F125 G38.2 Z-20.32 F75 G91 G0 Z1.27 F75 G38.2 Z-5.08 F25 G92 Z5.7400 G91 G0 Z3.175 F125 G91 G0 X25 F700 G91 G0 Y25 F700 M02
I just tried out the \n in my Z Probe macro and it worked a treat. So instead of this: G38.2 Z-25 F100; G10 P0 L20 Z3.3; G21 G91 G0 Z10 It should look like this: G38.2 Z-25 F100\n G10 P0 L20 Z3.3\n G21 G91 G0 Z10 Thank you very much for all your help and time on this Peter it is really appreciated. Cheers Adam
Just a heads up here. I suggest adding a G90 to the end of your macros. I ran into an issue over the weekend where issuing a G0X0Y0 via serial console would not move the machine after a probing routine. The problem is that the macros use G91 (incremental move) which is modal so after the probing is done, a G0X0Y0 command essentially tells the machine to not move.
agree, a macro should leave the machine in a consistent state, something you can count on. One thing you can count on is that you don't know the state when the macro starts, so the macro must always set what it wants (and so must all Gcode files, never assume G90/91 and G20/21 and so on, set what you want).
Hi Peter, I've been following this thread to figure out XYZ Probing using Macro's. I Just upgraded to v1.0.148 and noticed that the Macro function is not working. I would setup a new macro and apply whereafter the macro would lose the G-code content. Apart from this glitch the software is great! Dankie.
I've reported the issue in the ob control thread so that Peter gets eyes on it. Its here: OpenBuilds CONTROL Software EDIT: I just stalked Peters activity and it doesnt look like he's been around the last day or so. If you need this fixed ASAP, you can download the previous version here: OpenBuilds/SW-Machine-Drivers
actually I found the macro's are working, you just cant see the content. Try entering a macro, then zero out the machine and execute the macro, It still goes where you told it to. Just cant see the contents. It is scary though.
Hmmmm. I thought of that, but it didnt work in my case. Let me go try again. EDIT: No, it didnt work for me at all. Maybe you never clicked "apply" which I did.
I think I figured out what the problem is. The macro contents is indeed being saved to the button value. Its a simple fix, but I cant fix it since the app is an electron package. I havent played with Electron yet, so gonna have to wait for Peter. Now, as far as the macro not working. Single line macros work, but multi-line macros dont. So if I have a macro that has the following, it works fine. Code: G0X0 However, if I have a macro that looks has this, it doesnt. Code: G0X0 G0Y0 I throws the following error: "Uncaught SyntaxError: Invalid or unexpected token: (index):1" The button code looks like this: Code: <button id="macro0" onclick="sendGcode('G0X0 G0Y0');" class="shortcut outline rounded no-caption m-1 "> If I edit the html using chrome inspector and add "\n", the buttons works. Code: <button id="macro0" onclick="sendGcode('G0X0\nG0Y0');" class="shortcut outline rounded no-caption m-1 ">