Problems with meta comments
-
Hello everyone,
First off, I'm new into the Object Model Game, but see the potential and want to use it.
I want to write a simple macro which allow me to set the actual z offset (at height 10 mm over the bed) of the current tool1 to the actual machine position. I have tried different approaches but couldn't achieve it yet. Furthermore, I'm get all sort of error messages.The code:
if move.axes[2].machinePosition != 10 tools[1].offsets[2] = tools[1].offsets[2] + 10 - move.axes[2].machinePosition M500 P10
Error Message:
M98 P"0:/macros/1"
Error: in file macro line 2 column 20: expected number after 't'
Error: Bad command: move.axes[2].
Error: Bad command: machinePositionDoes anyone know what's wrong?
Board: Duet 2 Ethernet (2Ethernet)
Firmware: RepRapFirmware for Duet 2 WiFi/Ethernet 3.3 (2021-06-15) -
@philipp-r Stupid question I know do you have a tool number 1 ?
AND move.axes[2].machinePosition isn't that move.axes[2].drivers.machinePosition ?
-
@philipp-r you can't directly assign values in the object model, so your second line is not valid. Use G10 to set the tool offset instead.
-
@philipp-r
...what dc42 said, but for other variables you can use "set variablename" = bla bla -
@peter247 thanks for the answer. Yes, I have Tool1
I also double checked it, and it should be move.axes[2].machinePosition -
@philipp-r said in Problems with meta comments:
I also double checked it, and it should be move.axes[2].machinePosition
You are right I didn't understand the object model viewer , BUT set variablename = whatever , you still need the var or global in it so it should be
set var.variablename = whatever , that I have learned. -
@dc42 maybe I should clarify my problem in more detail. Currently, I'm working with a tool changer with 4 Tools with different Z-offsets, my Tool1 has an offset in Z = -12. When I change the nozzle, I'm searching for the new offset. For this, I use a 10 mm gauge lock on the Heated Bed to get the new Z-offset. For example, on the DWC movement section, the value 9.95 mm is displayed.
So now I'm calculating (-12)+(10-9.95) = -11.95--> new Z-Offset which I should change in the config.g file.Now I want a macro for this procedure. But I don't see how it will be done with G10 as far as I know, I can only set the Z-offset value but can't put in a function like above. Please correct me if I'm wrong.
-
@philipp-r Eventually something like this:
if move.axes[2].machinePosition != 10 G10 P{ tools[1].offsets[2] + 10 - move.axes[2].machinePosition } M500 P10
I don't know the exact G10 command for setting offsets... so there could be a fault!
-
@cosmowave said in Problems with meta comments:
I don't know the exact G10 command for setting offsets... so there could be a fault!
Looks like you want to set the Z offset of tool 1, so:
G10 P1 Z{tools[1].offsets[2] + 10 - move.axes[2].machinePosition}
-
Here is the code for a macro to set your Nozzle height with a Gauge block of 10 mm of your selected Tool:
G10 L1 P{state.currentTool} Z{ tools[1].offsets[2] + 10 - move.axes[2].userPosition } M500 P10 ;save values into config-override.g
-
Had to change from move.axes[2].machinePosition to move.axes[2].userPosition. Because my machine coordinates and tool coordinates are different. But thank you guys for your help
-
@dc42 one more question came also to my mind. Is it possible to check whether a Pin input is true or false in a if or while condition?
I have defined a Trigger1.g at my machine and now i want to check the pin status, like:
if e0stop = true ... elif...
i tried also:
if M582 T1 = true ... elif...
But i got a error message for M582 is not known.
-
@philipp-r yes, you can configure the pin as a GpIn port using M950 with J parameter (which you probably do already to use it as a trigger), and then test sensors.gpIn[n].value.
-
@dc42 thank you for your help David it worked.