Babystepping by g-code macro?
-
Whilst I know this is on the list of firmware improvements, I wondered if we can come up with a workaround?
So I started messing about to see if I could effectively babystep up or down by 0.025mm using gccode macros, during printing.
What I tried at first was using M206 Z0.025 or M206 Z-0.025 but this doesn't seem to take effect during a print, though it could be used before/after, to make the new z offset permanent.
Then I tried
G91
G1 Z0.025 F2000
G90or
G91
G1 Z-0.025 F2000
G90Which (obvious now I think about it) doesn't work as the next line of gcode moves the nozzle back down/up to its absolute z coordinate and it carries on at the same height it was before, plus its not instant so if using it during printing a skirt/brim, the change in nozzle height would only occur after the lookahead buffer has executed the commands stored in it. To use this method would require a pre-print of some small lines/zig-zags during which to do the babystepping.
Is there a way to force a z offset change by gcode during printing, it need not be instant as we could use a small pre-print (or a raft or add a small object with lots of zigzags)? If so, a simple macro would give us effectively babystepping, saving the Duet team's time to implement other things? And it would make it a more customisable feature.
If babystepping is implemented in the firmware might we have a means of making the change persistent? I raised an issue on Marlin Github about babystepping in their RC firmwares, and Scott implemented a numerical readout in RC6 & 7 versions, which gives the amount of mm of change when babystepping, so that this be entered as a m851 or m206 offset for subsequent prints or used in your slicer, as long as the printer is setup to allow sufficient range of movement (especially in the negative z direction). What I was angling for was an option to save the babystep offset from the LCD, although changing the offset in the config.g file for the next print would not be too onerous.
-
I answered this yesterday or the day before in another thread, but as I can't find that thread I'll answer it again. If you only want to adjust the height while printing the first layer, and you always use the same first layer height, then you can do it. For example if the first layer height is 0.2mm and you want to drop the Z=0 plane by 0.05mm, just send G92 Z0.25. To raise the Z=0 plane by 0.05mm, send G92 Z0.15.
-
Thanks David, this will work for me, I did see your reply yesterday in passing, but I couldn't find it either to have a proper look. I use the same layer height each time for any given nozzle so I'll try this. If I send this gcode whilst printing a brim/skirt I presume the firmware executes whatever gcodes are ahead of this in the buffer before this one, so the effect will take a few moves to become apparent?
-
Yes, it will take a few moves before it executes, but in theory no more than 2 seconds worth of moves + 2 more moves.
-
If the last move in the lookahead queue is a z lift move, is there a danger that the g92 would cause a nozzle crash? I guess it would simply cause the nozzle to be printing much too high. No real danger. I shall use this next print! I've been cancelling and restarting prints forever, this will save time.
-
So a calibration object (or small second object included in the slicer printed sequentially) for this approach would have lots of small lines. We can count how many times we send the adjustment while printing it then apply this with m206 afterwards.
-
Had no luck with this - head crashes - but I think it's because I've set a z-offset in slicer of -0.28mm so any attempt to move down crashes the nozzle. I'll try again later without the z-offset in slicer.
-
@bot:
If the last move in the lookahead queue is a z lift move, is there a danger that the g92 would cause a nozzle crash? I guess it would simply cause the nozzle to be printing much too high. No real danger. I shall use this next print! I've been cancelling and restarting prints forever, this will save time.
If you have lift Z on travel moves enabled in your slicer then there is a risk that the G92 command will be executed when the nozzle is at the lifted height. That would cause the print to continue with the nozzle much too high.
-
So now this works for me I removed the slicer offset and remeasured the probe offset and entered it properly into the config.g.
Now using the G92 macros I can pseudo-babystep up/down as long as the first layer height is 0.4 in this case.
Thank you.
-
So now this works for me I removed the slicer offset and remeasured the probe offset and entered it properly into the config.g.
Now using the G92 macros I can pseudo-babystep up/down as long as the first layer height is 0.4 in this case.
Thank you.
Hello Dj,
Can you explain how you implemented this? And why does the first layer have to be 0.4?
Thanks! -
So all you are doing is sending (during printing the first layer) a G92 command to change the absolute Z coordinate. So if you are printing a 0.4mm first layer and you send G92 Z0.425 you've just told the printer that the current level is not 0.4 anymore its 0.425mm. You haven't physically moved anything. It takes the printer a few seconds to get to this command as there is a buffer, it lowers the nozzle by 0.025 on the next gcode command because this next command will ask it to be at Z0.4 and it thinks its now at z0.425.
Likewise if you send G92 Z0.375 the printer thinks its too low and at the next line of gcode it raises the nozzle 0.025.
I created two macros one for each command, so I can press lower or raise from the paneldue screen, but you can do it from the web interface instead. Or if using a host like pronterface create some buttons with these commands.
If you want to print 0.3 first layers, your lower nozzle macro would be G92 Z0.325 and raise would be G92 Z0.275
There are three reasons why this is a functional workaround but not very satisfying are that its not instant, the firmware has to process the commands in the buffer before it changes z level, so its hard to see if you need to press it once, twice etc… If you press to lower 10 times you might get a head crash. (A good reason to use 0.025 rather than 0.05). The other reason is that if you're printing a cube the brim or whatever you print first won't have that many moves in it, therefore you don't get a lot of time to make the adjustment unless you set your print speed to 10% as you begin. Also you have to use the same first layer height each time, or your need two macros for each first layer height you routinely print with.
My solution to this to make an object, one layer thick, with lots of short zigzags or similar, you place it next to the object you're printing in your slicer, make sure you've set plenty of skirt and brim to give you extra moves in which to have time (and moves) enough to adjust the z height and then leave it to print the object.
Marlin's babystepping which I helped (a little) to test with them just sends extra step pulses to the z motor as you turn the encoder wheel and does not alter the coordinate system. So on the plus side its instant, you can set it very quickly and you can do it with any layer height and at any point during the print (though why you would want to do it at any other point than the first layer I could not imagine). They eventually implemented a readout on the lcd which summed the extra steps and divided them by your z steps/mm and which shows how much in millimeters you moved, so at the next print you could enter a z-offset either in firmware or slicer, so provided your printer's reproducibility is good the next print just starts at the optimised Z height.
I've actually given up using this as its now so well calibrated if I measure the nozzle to zprobe trigger point accurately, then calibrate the nozzle is 0.1mm above the bed everywhere and I can just print. Possibly adding an offset in slic3r for the next print if it was fractionally too squashed or too high.