Touch Plate Z-Homing Routine - Possible?

Discussion about the arduino based g-code interpreter, grbl
Post Reply
Stephmon
Posts: 20
Joined: Sun Oct 05, 2014 6:13 am

Touch Plate Z-Homing Routine - Possible?

Post by Stephmon » Mon Nov 17, 2014 2:59 am

A little while back, I upgraded to grbl 0.9g and I'm working on setting up a homing sequence for my Z-axis, using a touchplate.

I would like to run a brief program, as follows (my annotations below, are not in my code)...

G20 G91 (Inches, Relative)
G38.2 Z-5 F2 (Move until interrupted by probe, Z-move down, Feed Rate 2in/min)
M0 (Pause for operator)
G92 z0.0605(After interrupt/pause/resume set current z work position to 0.0605 (the thickness of my plate, so z0 should be the top of my work))
G0 Z0.25 (Raise bit to safe height above work)
M30 (End program)

But, what ends up happening (UGC console output below) is that the work position gets updated, before the probe ever touches (so, the new z0 has nothing to do with the probe position). I have to 'pause" and then "resume" to execute the code after the M0 (seems that UGC should know it has been paused). Z moves up, after the "resume". But, then the program never finishes, because UGC thinks there is one more line to send (M30 shows as "Sent" but not "Done", in the command table). So, I have to cancel the file transfer with a soft reset and $X. Am I going about this all wrong? It seems the ideal way would be for UGC to allow me to write a macro "Home Z" button, but what do you want for nothing (has anyone else noticed that the Reset Zero button is 'broken' in 0.9g?)...

>>> G20G91
>>> G38.2Z-5F2
ok
>>> G92x0y0z0.0605
>>> G0Z0.125
>>> M30
ok
ok
ok
[PRB:0.000,0.000,-11.284]
ok
ok
ok
ok
Grbl 0.9g ['$' for help]
**** Canceling file transfer. ****
Grbl 0.9g ['$' for help]
>>> $X
**** Finished sending file. ****
ok

jarretl
Posts: 135
Joined: Mon Feb 24, 2014 2:50 pm
Location: Edmonton, AB

Re: Touch Plate Z-Homing Routine - Possible?

Post by jarretl » Mon Nov 17, 2014 3:39 pm

Hi,
What are your actual coordinates after running this, does it simply forget your G92 command and go back to match the machine coordinates?

You use the G92 command to set temporary zero, but if I recall, the M30 command will wipe any temp coordinates from GRBL, similar to a soft reset (CTRL+X)
To accomplish what you want, you may either need to leave out the M30 command or use the G54 work coordinate system instead of G92 temp coordinate system (using the G10L2 or G10L20 commands).

I wonder if UGS is getting confused by the extra ok responses in your code and not knowing when to end the file. Your 6 commands produce 8 'ok' responses, but if UGS is trying to match commands sent to OK's received in order to throttle the GRBL buffer, there may be a bug there when too many 'ok's are received it doesn't know how to end the file.

-J.
Shapeoko 2 #4043; DW660

Stephmon
Posts: 20
Joined: Sun Oct 05, 2014 6:13 am

Re: Touch Plate Z-Homing Routine - Possible?

Post by Stephmon » Mon Nov 17, 2014 7:33 pm

Hi J, thanks for the reply,

It appears that the Z coordinate is updated to a new value and persists (likely because the M30 is sent, but never actually executes). I did a lot of experimentation and actually only added the M30, after I noticed that UGS was 'stuck' in my program (I was trying to force it out). You may also notice that the console output I C&P'd below doesn't exactly match the rev of my program that I pasted (there is an extra x0y0) which was another attempt to see what was going on (x and y started at non-zero values and were successfully zeroed by the code, but the Z still didn't end up where I expected).

I'm not sure what you mean by OK's in my code. Those OK's are generated by UGS, I assumed it is one OK for each executed command. The last one never comes and the program continues to run, until I do a soft restart.

I'll play with G92 tonight and see what happens.

It would be great if UGS would offer a user definable button and/or the ability to edit the underlying code of one of the machine control buttons (like "Reset Zero" which results in an invalid command error, in 0.9g).

ALuomala
Posts: 136
Joined: Mon Feb 17, 2014 7:30 pm
Location: Alberta, Canada

Re: Touch Plate Z-Homing Routine - Possible?

Post by ALuomala » Mon Nov 17, 2014 7:36 pm

I have zero coding skills, and since I couldn't find another way, I have used the latest beta build of UGS (the one with macro abilities) and put in one command per line, and then manually select each (after I have ensured that each step is done completely (i.e the "probe" (endmill) has actually made contact with my touchplate). I would prefer something more elegant, but it works quite well (I just have to ensure I remove the alligator clip from the endmill before starting the spindle/router......)).

I'm away from my SO2/computer, but the workaround broken Reset Zero [in latest release of UGS] is accomplished by setting "G92 X0 Y0 Z0" manually (I assume you know that but I wanted to point it out to anybody who might not know how to overcome that issue).

Allan
ShapeOko2, serial ??
DW660 spindle;
Upgrades: 900mm X axis and 1000mm Y axis; ACME Z Axis; modified MDF wasteboard with t-slot
Primary usage: wood crafting (signs, plaques, and ultimately a CNC-made electric guitar)

Stephmon
Posts: 20
Joined: Sun Oct 05, 2014 6:13 am

Re: Touch Plate Z-Homing Routine - Possible?

Post by Stephmon » Mon Nov 17, 2014 8:59 pm

I've been to the UGS Beta page, but haven't seen mention of macros... It figures they would be working on a macro, as that would be top of my wishlist (close second would be the ability to read XYZ coordinates off of the visualizer, by hovering. This would allow me to better register parts that are partially machined.

Manually typing the G92 (zero reset workaround) is why it was top of mind, when I started trying my little program.

Stephmon
Posts: 20
Joined: Sun Oct 05, 2014 6:13 am

Re: Touch Plate Z-Homing Routine - Possible?

Post by Stephmon » Tue Jun 30, 2015 3:54 am

Sorry to bring up an old post, but I have a working solution, so I thought I would put it here...

I just downloaded UGS 1.08 (which allows you to save up to 5 macros). One of my macros is:

G20 G38.2 Z-1 F2; G10 L20 P1 Z0.030; G0 Z0.125

Which is:
G20 = Inches
G38.2 = Move until interrupted by the probe
Z-1 = Z-axis travels 1 inch (I always manually jog, to within 1" of my desired height, because...)
F2 = 2"/minute (dead slow)

Then (the macros allow more than one command, separated by ';'
G10 L20 P1 = Set G54 workspace coordinates
Z0.030 = The thickness of my touch plate (inches)

Then
G0 Z0.125 = Rapid move to 0.125" to release the probe.

RobCee
Posts: 587
Joined: Wed Jan 08, 2014 11:33 am
Location: Birmingham, UK

Re: Touch Plate Z-Homing Routine - Possible?

Post by RobCee » Wed Jul 01, 2015 6:31 pm

I use almost exactly this method, with UGS and macros.

My metric based macro code line is as follows:

G56; G38.3 Z-5 F25; G38.5 Z1 F5; G10 P3 L20 Z20; G0 Z40

I manually get to within 5mm of my touch plate, which is springy, then run this macro and it touches the plate, moves back up slowly until it is no longer touching, then sets zero at the plate thickness and withdraws from the area.
This works very nicely for me.

I use the G56 set of coordinates as they are held in the memory if the power is cycled or an M30 command is issued (just remember to re-select them).

Macro explained:
G56 - Switch to the P3 set of position coordinates
G38.3 Z-5 F25 - Probe (stop on probe touch) in the Z direction negative 5mm at a speed of 25mm/min
G38.5 Z1 F5 - Probe (stop on probe release) in the Z direction positive 1mm at a speed of 5mm/min
G10 P3 L20 Z20 - Set the P3 position coordinates Z-height to equal the height of my probe
G0 Z40 - Move out of the way
ShapeOko2 #3400 - Chinese 800W AC Spindle - Stiffened X-Axis - TR10 Z-Axis - Inverted Z Motor - Hall Effect Limits - Drag Chains & Custom Brackets

jvabob
Posts: 5
Joined: Mon Dec 30, 2013 7:52 pm

Re: Touch Plate Z-Homing Routine - Possible?

Post by jvabob » Thu Jul 09, 2015 12:25 pm

Sounds like you guys have a solution... Been waiting for someone to come up with one.... Can you tell me how you are connecting the touch plate to the controller?

RobCee
Posts: 587
Joined: Wed Jan 08, 2014 11:33 am
Location: Birmingham, UK

Re: Touch Plate Z-Homing Routine - Possible?

Post by RobCee » Thu Jul 09, 2015 3:36 pm

Connection is made to 0V and pin A5.
I cheated and built a custom shield to control my limits, leds and spindle control, so I am not exactly typical!
ShapeOko2 #3400 - Chinese 800W AC Spindle - Stiffened X-Axis - TR10 Z-Axis - Inverted Z Motor - Hall Effect Limits - Drag Chains & Custom Brackets

Post Reply