Code for wireless toolsetter broken

More
12 Jan 2020 06:03 - 12 Jan 2020 17:23 #154664 by dannym
I have a wireless toolsetter cycle G38.3 set up on my wireless MPG's "Probe Z" button to set the Z offset in the current work coordinates. The simple G38.3 didn't do quite what I needed, so I wrote my own. Which worked for years then suddenly it's probing up instead of down, and I'm baffled. There are many other users on this machine but no one would be changing the config. I went to debug it and got more confused.

o100 sub
#1 = #[5203 + [20 * #5220] ]
M50 P0 (all Feedrate Override off)
G38.3 F50 Z[-6.5-#1]
...

The initial reason for this complexity was that, IIRC, G38.3 F50 Z... targets a Z in the work coordinate system. That's not what I'm looking for, I want to go from current position down to a probe lower z-limit in *machine* coords.

It was awkward but seemed correct and always worked before:
#1 = #[5203 + [20 * #5220] ]
That's using #5220 to get the current coord system number (we're always using 1 though), and use it as in index to get the z offset. The coord systems are all 20 addresses apart. They start at #5221 and #5223 would be the z offset. But since the first coord system number is 1, not zero, I use #5203 as the base address and add [20*1]= #5223

G38.3 F50 Z[-6.5-#1] OK now come up with a work coord using the offset that will take us to -6.5" below the upper Z-homing point in machine coords. Like I say, now this is probing upward, and I don't have any idea what changed.

Simple debug started with:
(debug, sys=#5220 x0=#5221 y=#5222 z0=#5223)
Sys=1. With the X,Y,Z axes homed close to their respective homing switches, I get X and Y close to zero as expected. The #5221-#5223 numbers don't change when the axes are jogged but do change when you do a manual touch-off entry for that axis, so that's looking right.

But z0=-6.232220. Now the system is such that Z+ = go up, the homing switch is up high, and there's a 0.75" offset because the homing switch was placed that far from the axis's physical stop point. And a lower limit of -7.5" (the point 6.75" below where the homing switch trips).

So I expected when I jogged the Z axis up to its soft limit, zero the work coord there, and I expect a "z0=0".

What is this "z0=-6.23220"?? I dropped Z down and touched that off as z-zero. Then I get z0~=-12". So it did move the offset. I just don't understand why the #5223 offset is this arbitrary -6.23220 number from where it should be in machine coords. This puts my Z-probe target in the wrong spot.

Any insight?
Last edit: 12 Jan 2020 17:23 by dannym.

Please Log in or Create an account to join the conversation.

More
12 Jan 2020 17:09 #154691 by MaHa
In Axis, in Menu 'View', select 'show offsets', you can see the offsets and G92 of the active coordinate system, to confirm correctness.
Also, if G43 used check tooldata.
G10 L2 P1 Z0   then Z0 is similar G53 Z0.
G10 L20 P1 Z0  sets actual Position to Z0.

If you want to travel and lift off a incremental distance from current point, use G91 Z-6.5. Don't forget to switch back to G90.
Or if you want the probing result in machinecoordinates (G53),use also G28.1, when probe trigered, before retract.
G38.3 F50 Z [-6.5- # 1]
G28.1         ;Get triggerposition in machinecoordinates
G91 G1 Z2     ;Lift off 2mm
G90

#5163 contains the actual Z position in machinecoordinates.
Then G10 L2 P(coordinatesystem used) Z(your desired value in machinecoordinates G53)

Please Log in or Create an account to join the conversation.

More
12 Jan 2020 17:29 #154696 by dannym
I'm trying to avoid incremental distance probes, OR erasing the current offset prior to a successful probing cycle.

Can I preface G38.3 with G53 so it's a machine coord op? I don't think that one's possible. (not at the shop right now to try)

Any idea why my #1 calc is so wacky? Well, it's because #5223 isn't what I expect it to be. Am I misunderstanding what #5223 is supposed to be?

Please Log in or Create an account to join the conversation.

More
15 Jan 2020 06:09 #154891 by dannym
AH. Someone somehow set G92 and offset ALL the coord systems, in addition to the zeroed #5223 P1 z-offset. I did not do math expecting that.

I will add G92.1 to my startup code to clobber this sort of shenanigans

Please Log in or Create an account to join the conversation.

Time to create page: 0.069 seconds
Powered by Kunena Forum