Syringes printer, adjust different offset
-
@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!