Hey all,
I've implemented a macro for my auto-tool zero script, based upon information I found on this wonderful site, however, I would like to improve on the code somewhat if possible. (And, of course, not being a programmer, I do not know how to do so!) My current code will lower the z-axis slowly, until it registers the touch plate I built, and then will take the thickness of the plate into effect, zero the z-axis and return to 1" above the stock. This is the code I am presently using for my z-axis zeroing:
Code "(Now attempting to Zero the Z-Axis.)"
PlateThickness = 0.11811 'Z-plate thickness DRO
If GetOemLed (825)=0 Then 'Check to see if the probe is already grounded or faulty
DoOEMButton (1010) 'zero the Z axis so the probe move will start from here
Code "G4 P5" 'this delay gives me time to get from computer to hold probe in place
Code "G31Z-40 F500" 'probing move, can set the feed rate here as well as how far to move
While IsMoving() 'wait while it happens
Wend
ZProbePos = GetVar(2002) 'get the exact point the probe was hit
Code "G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun
While IsMoving ()
Wend
Call SetDro (2, PlateThickness) 'set the Z axis DRO to whatever is set as plate thickness
Code "G4 P0.25" 'Pause for Dro to update.
Code "G0 Z1" 'put the Z retract height you want here
Code "(Z axis is now zeroed)" 'puts this message in the status bar
Else
Code "(Z-Plate is grounded, check connection and try again)"'this goes in the status bar if applicable
Exit Sub
End If
What I would like to do is similar, with the x-axis and y-axis limit switches. I would like to manually bring the x-axis and y-axis within 6" of the zero values (no code required here - I'll move the machine myself) and then have it slowly approach the x-axis, and then once it touches it, it should move 1/4" in the positive, and set the x-axis zero for the machine to this value. Then, I would like it to have it do the same for the y-axis. (Have it slowly approach the y-axis, and then once it touches it, it should move 1/4" in the positive, and set the y-axis zero for the machine to this value.)
I have had a number of issues in the past whereby my machine has gotten caught up on stock, and then losing it's location values because of it. (The machine would get jammed up, and the software would still think it was moving.) As such, I've then had to reposition the router and manually reset the x-axis and y-axis. I figure if I can implement this code properly, it will improve everything significantly. First, I won't have to perform the manual process any longer, and second, I should be able to perform cuts on the same sheet once the system is re-aligned properly. (On occasion, I've had to recut into the same parts, but after the manual process, it can be out by 1/8" or more, which as you can imagine, is not good enough for anything. So, toss that part away.)
My other questions are these:
- Can the limit switches do this, if they are already assigned in Mach3 as "limit switches"?
- If the machine gets jammed up, and accidentally click a limit switch, will it run this code or just stop?
- If they don't run the code when the limit switch is hit, is there an opportunity to have the machine run (perhaps different) code that will automatically try to re-align to zero on the x-axis and y-axis, and restart the cut at the point at which it failed?
I would like to say that I appreciate all of the help I've received over the years here. While I haven't posted too much, I've read and learned a lot here. I would really, really appreciate any help you guys are prepared to give.
Thanks!
Rick