Need help changing an X or Y coordinate into a variable
-
-
@fcwilt Yes, I send a "G38.2 X10 F100" command, the machine moves until the sensor is tripped and stops. I want that exact X coordinate where it stopped as a number to be used in in alignment calculations.
-
@Strider007 You can search "duet object model", it should be move.axes[0-1].machinePosittion -- You can also explore the object model list in DWC
-
See if this will work:
For the X:
move.axes[0].machinePosition or move.axes[0].userPosition
For the Y:
move.axes[1].machinePosition or move.axes[1].userPosition
Frederick
-
@fcwilt Thanks,
Ok, tried all combinations of your suggestions and only got error messages as follows:move.axes[0].machinePosition
Error: Bad command: move.axes[0].
Error: Bad command: machinePositionI had hoped that would work and had tried it already. What am I missing here?
I
-
@zuoyan
Its a long list, and I've looked through it multiple times. I probably should have mentioned that. That's when I found the two suggestions that fcwilt gave me but no success so far. Thanks -
@Strider007 Ok, now studying M409, and I think I got this working.
Thanks all
-
Those are not to be executed - they are merely variables holding those values.
To use such values, say, to move to a position, you would do something like
G1 X{move.axes[0].machinePosition} Y{move.axes[1].machinePosition}
The question is do those variables hold the values you desire. Compare them against what you see in the DWC, assuming the DWC is showing the values you seek.
Frederick
-
@fcwilt
Yes, when I echo, that is the number I want to store as a temp variable then use in calculations of tool offsets.echo "it is", move.axes[0].machinePosition
it is -118.088Thank you for your guidance. I believe I 've got it from here.
-
To save a value from the Object Model (OM) into a local variable you do something like:
var Xvalue = move.axes[0].machinePosition var Yvalue = move.axes[1].machinePosition
Or it you want it to be persistent so you can use it later or in other code:
global Xvalue = move.axes[0].machinePosition global Yvalue = move.axes[1].machinePosition
Good Luck.
Frederick
-
@fcwilt Exactly what I needed to get past my mental roadblock. Some small code blocks doing just what I need. Now to refine the hardware to go with it. Most appreciated Gilly