Hi, I am using grbl to control two different axes (X and Z) and want to run a piece of gcode after the X-homing cycle but before the Z-homing cycle. I understand how to set the order of homing cycle in config.h file, but unsure how to implement g-code execution in the middle. Any help would be much appreciated. Also, thanks in advance!
You can edit the .nc file using a text editor. Just open the file, insert the commands you want to execute in between the homing cycles and save. If you are using a windows app like notepad check your file extension after saving to make sure it didn't save as a .txt file, you might have to go back and re-change the file name extension back to .nc using the command line because windows explorer won't let you change extensions anymore.
Hi Brian, thanks for your help. However, I don't see any file with '.nc' extension in the grbl library (please see screenshot: Screenshot-2022-11-19-at-5-16-51-PM).
.nc is basically a text file that grbl reads and executes line by line. I am using Candle to execute my programs and it displays the file contents in a box below the operational display Candle also allows you to paste new codes into the the uploaded file but I don't think there is a way to save the changes.
That's a good approach but won't work for me because I want the changes to be saved in the firmware. Thanks anyway for the suggestion!
Homing is a fundamental stage of a machine 'coming alive' and there is no way to run Gcode between X homing and Z homing because the Gcode will not do safe, known, moves because homing is not yet finished. Therefore, the answer is "no, you cannot do this with GRBL" (but it might be possible with grblHAL)
David has a very valid point. Also, you'd need to be certain that Z is in a safe position before initiating your custom homing. Unless of course you're not actually wanting to "move" and want to do something else like trigger a relay. But if it is something you want to do, cant you just enable single axis homing in config.h? Then use a macro to home X, run code, then home Z? $HX some gcode $HZ I've never tried it, but it starts on line 120: grbl/config.h at bfb67f0c7963fe3ce4aaf8a97f9009ea5a8db36e · gnea/grbl
Hi Peter, I have assigned Z-axis to the stepper of a pump that I designed, and the X-axis is assigned to another stepper controlling a four-way valve. After homing the X-axis, I want the valve to be in a specific position (that I can control using position gcode) before I home the Z-axis.
then you only need to set the X homing pulloff distance to the correct value. Then it will home and pulloff to the settting you want, then home Z
Thanks for your reply David; this sounds promising! However, I don't see a way to define axis-specific homing pull-off distance. The only option I see in GRBL 1.1 is $27, which seems to affect all axes.
Wouldn't it be better to run native Arduino code so you have full control over all this? AccelStepper: AccelStepper library for Arduino
Thanks for the suggestion, Peter. I have built a gcode generator for my application and don't want to restart from ground zero. If I could figure out a way to define axis-specific pull-off distance, it'll save me a lot of trouble.
Custom firmware can still be made to respond to gcodes GitHub - tgolla/GCodeParser: The GCode parser is designed to parse GCode in order that it can then be processed. As it doesn't sound like its a CNC device you built, the limitations of a CNC firmware will always exist. CNC tools (firmwares, gcode, etc) are not ideally meant to control pumps and valves after all. A custom piece of simple firmware would actually be far less complicated