Syringes printer, adjust different offset
-
@jay_s_uk I have updated to 3.4.4, but it still ignores the Z parameter. Put 5, 20 or 40 it always stays at the same height
:::::::EDIT::::
Fixed, I had repeated the command at the end of config.g
-
Hello.
I was wondering how to assign an endstop to act as a leveler for each tool.
I have a tool with syringes, which have to be changed often and the sizes are different, sometimes shorter and sometimes longer. As initial configuration, I have assigned offset for each tool with EXAMPLEG10 P0 X-9 Y39 Z-17.5
Well, if now I want to change the needle in that tool and calculate the z offset so that I know and save that value? Is there any way to do it, creating a macro or similar?
-
Yes, you can create a macro to do it. Here is a potential procedure, and probably not the only, or best way to do it.
This is mostly from memory so it will need tweaking.
Also be sure to update to the latest stable firmware version first, if possible. In the gcode examples below, i'm assuming at least RRF v3.0
-
Mount a switch somewhere on the build plate where every tool can reach.
-
Define an additional Z-endstop in the console. Add this line to the beginning of your macro, later on, as well.
(e.g.M574 Z0 P"pin_name" S1
)
- Before proceeding, you need to measure the height at which your z-offset probing switch actuates (e.g. "z_switch_actuation_height")
- Pickup any tool with a syringe tip and clear the existing Z-offset
- move the tip above the switch
Tx ; Pick up a tool with syringe tip G10 Px Z0 ; clear z-offset for active tool G1 Xx Yx ; move syringe tip over z-offset switch
-
manually jog the bed upward until the switch actuates (use M119 in the console to determine the endstop state and note at which height it changes. Always use M114 in the console to check axes positions, the positions in the DWC dashboard are rounded numbers)
-
write down the current z-position (for instance 40mm)
-
move off the switch and manually jog the buildplate up to the syringe tip (use a sheet of paper, if needed, to feel when the tip is close to touching the build plate).
-
write down the current z-position (for instance, 25mm)
-
Initiate a global variable for the actuation height. This will always be the same unless you change something about your z-switch mount.
global z_switch_actuation_height = 40 - 25 ; minus the thickness of the sheet of paper, too , if needed
- Put this global variable at the end of your config.g
The Automatic offset macro:
- Write some gcode to pick up a tool (with newly installed syringe tip), move the syringe tip over the switch and probe the switch
Tx ; pick up a tool G1 Z10 ; Move the bed down (probably taken care of by your tpostx.g macros already, just need to more the bed to a safe position to prevent crashes) G10 Px Z0 ; clear the previous Z-offset for the active tool G1 Xx Yx ; move over the switch G91 ; set to relative positioning G1 Z-10 H4 ; Syringe tip probes the switch and stops when the switch actuates (that's what the H4 does) G90 ; set to absolute positioning
Query the object model for the current position of the Z-axis and initiate a variable. An if statement checks if the variable already exists, and will overwrite it if so, or initiate it if not. This is useful if you are running the macro multiple times; otherwise RRF will give you an error that a variable already exists.
if exists (var.current_z_pos) set var.current_z_pos = move.axes[2].machinePosition else var current_z_pos = move.axes[2].machinePosition
- Take the measured z-position and subtract your pre-determined z-switch 'actuation height'
var Tx_z_offset = var.current_z_pos - global.z_switch_actuation_height
- The difference calculated in step 4 should be your new z-offset for the active tool. Add this to the active tool's G10 command, ENSURE IS IT NEGATIVE, and save with M500 to the config-override.g
G10 Px Z{var.Tx_z_offset} ; set new z-offset M500 ; save the offset (will appear in config-override.g) T-x ; return the tool to the dock
-
-
Wow!! It is brilliant, i'll try next week.
-
@hebigt said in Syringes printer, adjust different offset:
{1}
Hello.
I have been this afternoon testing and understanding a little the operation.
I have followed all the steps, the macro works but when it reaches the limit switch and activates it, this message appears:
M98 P"0:/macros/Prueba Z TOOL CALIBRACION" Error: Bad command: {1} Error: in file macro line 16 column 37: meta command: unknown variable 'current_z_pos'
My Macro:
T0 ; pick up a tool G1 Z30 ; Move the bed down (probably taken care of by your tpostx.g macros already, just need to more the bed to a safe position to prevent crashes) G10 P0 Z0 ; clear the previous Z-offset for the active tool G1 X-12.5 ; move X over the switch G1 Y-2 ; move X over the switch G91 ; set to relative positioning G1 Z-10 H4 ; Syringe tip probes the switch and stops when the switch actuates (that's what the H4 does) G90 ; set to absolute positioning {1} if exists (var.current_z_pos) set var.current_z_pos = move.axes[2].machinePosition else var current_z_pos = move.axes[2].machinePosition var T0_z_altura = var.current_z_pos - global.z_switch_actuation_height
I have added at the end of my config.g the following:
global z_switch_actuation_height = 38 - 19 ; minus the thickness of the sheet of paper, too , if needed
And in the config.g:
;OFFSET TOOLS G10 P0 X-9 Y39 Z-18.5 ; T0 ;PARA OFFSET HERRAMIENTA G10 P0 Z{var.T0_z_altura} ; set new z-offset M500 ; save the offset (will appear in config-override.g) T-1 ; return the tool to the dock
-
@fj3d If you haven't already, you can safely delete the {1} from your macro.
I don't know why it showed up in the formatting for my last message but it popped in there.
-
@hebigt I think that's the forum software adding the {1}
I haven't seen that happen in a while. -
@hebigt
The error must be something else, I keep getting the same error:I am reviewing the macro, and it may be that what I highlight is the error? it seems that the var.current_z_pos is in parentheses and makes it a comment, I think that's the error!
-
@fj3d you're missing a dot after var on line 14
-
@jay_s_uk
It is true!! changing that now these appear:Error: Bad command: var.current_z_pos = move.axes[2].machinePosition Error: in file macro line 15 column 37: meta command: unknown variable 'current_z_pos'
CODE
T0 ; pick up a tool G1 Z30 ; Move the bed down (probably taken care of by your tpostx.g macros already, just need to more the bed to a safe position to prevent crashes) G10 P0 Z0 ; clear the previous Z-offset for the active tool G1 X-12.5 ; move X over the switch G1 Y-2 ; move X over the switch G91 ; set to relative positioning G1 Z-10 H4 ; Syringe tip probes the switch and stops when the switch actuates (that's what the H4 does) G90 ; set to absolute positioning if exists (var.current_z_pos) set var.current_z_pos = move.axes[2].machinePosition else var.current_z_pos = move.axes[2].machinePosition var T0_z_altura = var.current_z_pos - global.z_switch_actuation_height
-
@fj3d actually, it was right the first time without the dot as thats setting the variable up, so i was wrong on that one.
Just thinking about it, you don't need to run an exists on a variable in a macro as you're only using it in that macro.
The one that may be causing you the issue is the global. does that one exist?best to change your macro to
var current_z_pos = 0 T0 ; pick up a tool G1 Z30 ; Move the bed down (probably taken care of by your tpostx.g macros already, just need to more the bed to a safe position to prevent crashes) G10 P0 Z0 ; clear the previous Z-offset for the active tool G1 X-12.5 ; move X over the switch G1 Y-2 ; move X over the switch G91 ; set to relative positioning G1 Z-10 H4 ; Syringe tip probes the switch and stops when the switch actuates (that's what the H4 does) G90 ; set to absolute positioning set var.current_z_pos = move.axes[2].machinePosition var T0_z_altura = var.current_z_pos - global.z_switch_actuation_height
I suppose the next question is what are you going to do with the variable T0_z_altura as after the macro finishes its gone
-
With this code I no longer get an error.
- Picks up the tool, positions itself at the endstop
- Activates it and here the maro is over, it does nothing else
Inside config I have the following:
;OFFSET TOOLS G10 P0 X-9 Y39 Z-18.5 ; T0 ;PARA OFFSET HERRAMIENTA G10 P0 Z{var.T0_z_altura} ; set new z-offset M500 ; save the offset (will appear in config-override.g) T-1 ; return the tool to the dock global z_switch_actuation_height = 38 - 19 ; minus the thickness of the sheet of paper, too , if needed
-
@fj3d you can't reference a variable like that as its only present during the macro its ran so you'd have to make it a global instead.
and what do you mean you have that inside config.g? and changes to a G10 tool offset won't get saved in config.g unless
M500 P10
is used -
Ok, I misunderstood the explanation @HebigT
What I have inside config.g goes inside the macro, of course, it's logical now thought. Sorry but I don't understand programming of this type...
I have executed the macro and it seems that now it does everything.
- Picks up the tool, positions itself at the endstop
- Activate endstop and return execute T-1
Now my question is, am I supposed to save myself with M500 the value in config-override.g right?
But I go in and this is what I see and I have:
; config-override.g file generated in response to M500 at 2022-09-28 10:15 ; This is a system-generated file - do not edit ; Heater model parameters M307 H4 R2.430 K0.560:0.000 D5.50 E1.35 S1.00 B0 V0.0 ; Workplace coordinates G10 L2 P1 X0.00 Y0.00 Z0.00 C0.00 G10 L2 P2 X0.00 Y0.00 Z0.00 C0.00 G10 L2 P3 X0.00 Y0.00 Z0.00 C0.00 G10 L2 P4 X0.00 Y0.00 Z0.00 C0.00 G10 L2 P5 X0.00 Y0.00 Z0.00 C0.00 G10 L2 P6 X0.00 Y0.00 Z0.00 C0.00 G10 L2 P7 X0.00 Y0.00 Z0.00 C0.00 G10 L2 P8 X0.00 Y0.00 Z0.00 C0.00 G10 L2 P9 X0.00 Y0.00 Z0.00 C0.00
My macro looks like this:
var current_z_pos = 0 T0 ; pick up a tool G1 Z30 ; Move the bed down (probably taken care of by your tpostx.g macros already, just need to more the bed to a safe position to prevent crashes) G10 P0 Z0 ; clear the previous Z-offset for the active tool G1 X-12.5 ; move X over the switch G1 Y-2 ; move X over the switch G91 ; set to relative positioning G1 Z-10 H4 ; Syringe tip probes the switch and stops when the switch actuates (that's what the H4 does) G90 ; set to absolute positioning set var.current_z_pos = move.axes[2].machinePosition var T0_z_altura = var.current_z_pos - global.z_switch_actuation_height ;PARA OFFSET HERRAMIENTA G10 P0 Z{var.T0_z_altura} ; set new z-offset M500 ; save the offset (will appear in config-override.g) T-1 ; return the tool to the dock
** Ingnore {1}, is added in the forum...**
-
@fj3d you need to use
M500 P10
notM500
-
Yes!!!! I already see added in config-override.g!!!
With this it would be enough if I configure it for each tool, right? In other words, if I change the needle right now by executing this macro, my tool would already be calibrated, right?; config-override.g file generated in response to M500 at 2022-09-28 10:28 ; This is a system-generated file - do not edit ; Heater model parameters M307 H4 R2.430 K0.560:0.000 D5.50 E1.35 S1.00 B0 V0.0 ; Probed tool offsets G10 P0 X-9.00 Y39.00 Z21.10 C0.00 0.00 0.00 0.00 0.00 0.00 0.00 G10 P1 X-9.00 Y39.00 Z-18.50 C0.00 0.00 0.00 0.00 0.00 0.00 0.00 G10 P2 X-9.00 Y39.00 Z-18.50 C0.00 0.00 0.00 0.00 0.00 0.00 0.00 G10 P3 X-9.00 Y39.00 Z-10.00 C0.00 0.00 0.00 0.00 0.00 0.00 0.00 ; Workplace coordinates G10 L2 P1 X0.00 Y0.00 Z0.00 C0.00 G10 L2 P2 X0.00 Y0.00 Z0.00 C0.00 G10 L2 P3 X0.00 Y0.00 Z0.00 C0.00 G10 L2 P4 X0.00 Y0.00 Z0.00 C0.00 G10 L2 P5 X0.00 Y0.00 Z0.00 C0.00 G10 L2 P6 X0.00 Y0.00 Z0.00 C0.00 G10 L2 P7 X0.00 Y0.00 Z0.00 C0.00 G10 L2 P8 X0.00 Y0.00 Z0.00 C0.00 G10 L2 P9 X0.00 Y0.00 Z0.00 C0.00
-
@fj3d assuming your endstop position is calibrated, yes, it should be.
but best jog down to the bed and check etc -
Another question, should I remove this line from config.g ?
;OFFSET TOOLS G10 P0 X-9 Y39 Z-18.5 ; T0
-
@fj3d shouldn't hurt having them as they get overwritten by config-override.g
-
@fj3d Ah, sorry you ran into issues! Thanks, @jay_s_uk for your insight.
I think that's exactly right - you won't need to check whether that variable exists because I believe that variable (var.curr_z_pos) is lost when the macro ends. But I might be wrong.
You would need an 'if' statement if you set up a macro to probe multiple tools in the same macro, or maybe better, just define variables specific to each tool (curr_z_pos_T0). There may be better ways to do this, though!