Touch-off via MDI_COMMAND, and Axis confusion

More
22 Dec 2020 18:25 #192843 by pgf
Recently I realized that I was spending way too much of my "get ready to carve" time homing the axes of my 2.5D x/y/z mill. Using the Axis UI involves at least 6 keystrokes or mouse clicks to establish "home" relative to the workpiece, or a similar number (maybe more) to use "Touch-off" instead. So I've configured some buttons on my pyvcp panel which invoke MDI_COMMANDS:
  • home X and Y at the same time
  • home Z
  • auto-home Z

The last one invokes a G-code subroutine that uses my probe in (what I think is) the usual way: Z travels down slowly until the cutter hits my aluminum probe plate, and when it does, sets the Z location to the thickness of the plate, using:
(all dimensions inches and ipm)
o<probe> sub
#<plate> = .122 (plate thickness)
#<search> = .3  (maximum initial downward probe)
#<searchspd> = 1 (initial downward speed)
#<backoff> = .05 (distance to move up before slow retouch)
#<2ndsearch> = .06 (max retouch probe distance)
#<2ndsearchspd> = .4 (retouch downward speed)
#<finalup> = .5

G20 (inch units)
(xxxDEBUG, probing in Z direction)
G91					(relative moves)
G38.2 Z-#<search> F#<searchspd>		(1st probe move)
G0 Z#<backoff>				(move upward, before 2nd try)
G38.2 Z-#<2ndsearch> F#<2ndsearchspd>	(slow second touch)
G10 L20 P0 Z#<plate>			(Set Z0 offset plate thickness)
G0 Z#<finalup>				(rapid retreat)
G90
o<probe> endsub

The other two are similar, but without the probing:
(subroutine which manually homes Z)
o<home_z> sub
(xxxDEBUG, homing z)
G10 L20 P0 Z0.0
o<home_z> endsub
and
(subroutine which manually homes X and Y)
o<home_xy> sub
(xxxDEBUG, homing x and y)
G10 L20 P0 X0.0
G10 L20 P0 Y0.0
o<home_xy> endsub

In order to make all of the above work via MDI without first having to home the machine (which would somewhat defeat the purpose), I've had to set "NO_FORCE_HOMING = 1" in my .ini file. I have no physical homing switches, but I do have limit switches for safety.

This all works well, and I now have one-click manual, confirmationless, homing, as well as the probe feature. It's exactly what I want.

However: While the milling all works correctly, the Axis display is out of sync. When I use the Axis homing, or homing + touch-off commands, the red cutter path on the screen matches (and overlays) the predicted cutter path (in white) that is shown when I first load the file. But when I use my panel buttons, the cutting path is offset from the predicted path. It looks like it's off, on the screen, by approximately the values held in the G54 registers. You can see this in the screenshot.


Ignore the extra paths from a previous project in the upper right (I forgot to erase them), and just look at the spiral hole-boring cut. The white helix is the predicted path from the G-code, and the red-spiral is where the "cutting" occurred on-screen. (The cutting in real life did exactly the right thing.)

Any ideas on why this is happening, and how to fix it? Many thanks...

paul
Attachments:

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

More
22 Dec 2020 22:29 #192884 by chris@cnc
Hi Paul,
Try
G10 L2 P0 X0.0

G10 L20 is similar to G10 L2 except that instead of setting the offset/entry to the given value, it is set to a calculated value that makes the current coordinates become the given value.

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

More
22 Dec 2020 23:04 #192892 by pgf
Thanks. I did look at, and try, G10 L2 earlier. It doesn't reset the current position to 0.0 -- it leaves the current value. Nor does it seem to change the G54, so I'm not really sure what it's doing at all. :-/

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

More
22 Dec 2020 23:22 - 22 Dec 2020 23:49 #192897 by cmorley
You need to force AXIS to reload the graphics display.
We didn't make linuxcnc smart enough to tell the screen to update :(

There is no easy direct way.
You can use HAL and Axis remote:
linuxcnc.org/docs/2.8/html/gui/axis.html#_axis_remote
(I'm pretty sure there is a forum post somewhere about this)
Surely you could use custom python code to do it -if you know that sort of thing.

I just realized AXIS looks for magic comments for some display controls.
I should add reload as a magic comment control to make this easier.
Can't be done by AXIS, it only reads the file when loaded not running.

Chris
Last edit: 22 Dec 2020 23:49 by cmorley.

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

More
22 Dec 2020 23:34 #192899 by tommylight

You need to force AXIS to reload the graphics display.
We didn't make linuxcnc smart enough to tell the screen to update :(

I am pretty sure Phill did something about this for PlasmaC in master, not sure if it was backported to 2.8.
Found it:
linuxcnc.org/docs/devel/html/plasma/plasmac-user-guide.html
Touch Off X & Y section, about 2/3 down:


%halcmd setp axisui.refresh 1

works in Axis GUI only.

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

More
23 Dec 2020 02:06 #192911 by pgf
Okay. A fair amount to process here. :-)

Chris -- Are you really saying that HAL can call out to the shell?? Even given that (somewhat surprising!) possibility, I've looked at axis-remote, and the "tell AXIS to reread all the internal registers" command isn't jumping out at me from the usage message. And I know just enough python to shoot my foot off, so I'm game. But I didn't think pyvcp could invoke python directly -- has that changed? Is there anything at all I can do via MDI that would cause axis to refresh? Some mode I could set, then unset, perhaps?

And tommylight -- can you expand on "%halcmd setp axisui.refresh 1"? I get
$ halcmd setp axisui.refresh 1
<commandline>:0: parameter or pin 'axisui.refresh' not found
in linuxcnc 2.7.15. Should I expect otherwise?

paul

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

More
23 Dec 2020 02:51 #192914 by cmorley
No HAL can't send to the shell directly/ You would use an Mcode to call an external program (shell python etc)

axis-remote - you would use the --reload command.
I think this would work . you could try it manually first before spending lots of time on the code.

calling a python program like this might do it (untested):
#!/usr/bin/env python
from subprocess import call
call(['axis-remote','--reload'])


Tom's idea would use the python modification-to-AXIS technique that apparently Plasmac uses - I don't see the actual code in the link he posted.
the code must add the pin to AXIS.

This guy was using gladevcp which gives more options.
In his case he wanted to load a program via a button - but it's the same principal.
forum.linuxcnc.org/48-gladevcp/38063-com...p-button-call-python
Chris

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

More
23 Dec 2020 04:05 #192924 by pgf
Excellent. Thanks -- that helps a lot. Yes, "axis-remote --reload" seems to fix things. I hadn't thought through that reloading the file would also reset the UI in other ways.

I'll look into your other suggestions. I wasn't familiar with M-Codes before. Looks useful, to say the least!

paul

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

More
23 Dec 2020 10:38 #192946 by tommylight
I did mention above that it does work on master/2.9, not sure it works on 2.8 but it should on 2.81.
There is a whole topic about it but i could not find it last night.

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

More
23 Dec 2020 13:50 #192958 by pgf
Okay, this seems to work:
$ cat linuxcnc/nc_files/M100 
#!/bin/sh

echo "Reloading AXIS via 'axis-remote --reload'"
( axis-remote --reload ) &

I had to put the reload into the background. Before doing so, I was getting this error:
can't do that (EMC_TASK_PLAN_OPEN:506) in manual mode

I'm still a little confused about all this, though. As I think back, I've been using my probe routine for auto-homing Z for a couple of weeks, and it hasn't exhibited the "stale display" problem that my newer manual buttons have shown. Why wouldn't my probe routine show the same problem that they do? (I'm afraid I'll be away from my mill for several days, so won't be able to retest for a while.)

paul

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

Time to create page: 0.179 seconds
Powered by Kunena Forum