Hello Guest it is December 09, 2019, 03:26:54 PM

Author Topic: MachTurn G31 problem  (Read 2679 times)

0 Members and 1 Guest are viewing this topic.

MachTurn G31 problem
« on: December 02, 2014, 02:06:51 PM »
Hi all,

I just got finished rebuild my Syil cnc lathe and now I would like to make some parts.

I'm trying to do a part/tool auto zero with no luck.

Here's the setup:

A piece of stock is chucked up, I want the z axes(probe) to move to the part, zero dro, continue running code(sizing,threading..... cut off)
open the chuck, pull out a bit of stock and *repeat*

I've tried running a macro using a G31 code, however I finding out that MachTurn doesn't recognize that command.

Is there a work around to this issue without having to pull the stock to a fixed stop. 

Any help would be greatly appreciated...

Thx MavStone
http://s862.photobucket.com/user/MaverickCustomAir/library/Lathe
MachTurn G31 problem
« Reply #1 on: December 02, 2014, 02:49:33 PM »
If you get the tool to a zero z position, pull out the stock until it is in contact with the tool, tighten the chuck, machine, cut off, reposition tool at zero z, repeat.  As you observe, probing command isn't supported in Turn.


Sent from my iPad using Tapatalk
Re: MachTurn G31 problem
« Reply #2 on: December 02, 2014, 03:07:49 PM »
I was hoping I wouldn't have to use a fixed stop. I use a 5c collet chuck and when the collet is tightened the stock moves back .010+ . Therefore, this action is not a precision, repeatable action. I might have to try running the lathe under MachMill in-order to run this part.
Re: MachTurn G31 problem
« Reply #3 on: December 04, 2014, 09:57:27 PM »
Hey Mav, 

What version of Mach are you running?

I have used G31 commands in turn via both MDI and in VB macros.  I am using Version R3.043.066.  What does a snippet of your code look like?

Regards,
Eric
Re: MachTurn G31 problem
« Reply #4 on: December 05, 2014, 09:08:33 AM »
Hi Eric,

I'm running this Hoss Probe Code which work well on my mill.

CurrentFeed = GetOemDRO(818) 'Get the current feedrate to return to later
PlateThickness = GetUserDRO(1151) '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 P2" ' two second delay
Code "G31 Z-1.0 F5" 'Z goes down a max of 1.0 at 5IPM
While IsMoving() 'wait while it happens
Wend
ZProbePos = GetVar(2002) 'get the axact 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.0" 'retract Z to 1.0 inch
Code "(Z axis is now zeroed)" 'puts this message in the status bar
Code "F" &CurrentFeed 'Returns to prior feed rate
Else
Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if aplicable
Exit Sub
End If

I am also using Version R3.043.066.

I have tried running the G31 command via both the MDI and in a VB macro. When it gets to the G31 command the z axes (kinda) (sometimes) moves a few .010, then retracts to "G0 Z1.0".  The DRO commands work fine.

I have also tried running a few other version of Auto Tool Zero macros. But all of the have the G31 command in them...... (this thing is driving me crazy!)

What does your code look like?

Thx, Mav
Re: MachTurn G31 problem
« Reply #5 on: December 05, 2014, 12:24:55 PM »
Eric,

I've install your addon and I'll give it a try after I go through the pdf.

From what I can see (without trying it out), I looks like you have spent some time on it...

Looks Good!

Mav
Re: MachTurn G31 problem
« Reply #6 on: December 05, 2014, 08:07:10 PM »


Hi Mav,

FYI, the wizard you downloaded is mill specific, and geared towards working in X/Y plane.  I'm working on a lathe specific version (X/Z plane).  What you have may not do what you want, and may have issues if you are in 'diameter mode' on lathe. 

I don't know why your code wouldn't work, do you have DRO 818 and 1151 in your lathe screenset somewhere for the macro to pull values?  that's all I can think of.  I can just MDI G31 commands, and they work for me.

Here is some rough code that I've used before to set the XDRO to a value based on a measured part (ie, if put a 2.0" bar in, I have to touch off and set X=2.0).  Note this is some rough code based on cutting/pasting a portion out of a larger script, and I've replaced some references to DROs with just numbers so it should run if you just paste it into a button.  I don't guarantee it is error free :)  test with care.

Not sure if it helps, but hope it does.

regards,
Eric

Code: [Select]
'set some variable, these are hard code for paste to button, but you could load DRO values...
frate1=1 ' feedrate
Xstart=GetoemDRO(800) 'current position
Probemax=1.0
Xset=2.0    ' this is the diameter of the stock to touch off on
Xend=Xstart-probemax
xretract=.1 ' how far to pull back after touch
hittol=.002 ' this is a small amount to see if hit or missed


' here is probing
Code "G31 x" & xend  & "F" & FRate1
While IsMoving()
wend

'================
xhit = GetVar(2000)
yhit = GetVar(2001)
ZHit = GetVar(2002)

if xhit=0 and yhit=0 and zhit=0 then
sleep(15)
xhit = getoemdro(800)
yhit = getoemdro(801)
zhit = getoemdro(802)
else
end if
'=================

if abs(xHit-xend)<HitTol then
message "missed target"
code "G01 x" & xstart
while ismoving()
wend
exit sub
end if

 
'xset = xset + (ProbeD/2) ' Adjust up  by Probe Radius to set Z at ball center (you may not want this, as I do this when using a probe with ball tip)
SetoemDRO(800, xset) ' Set XDRO to center of ball, bottom of ball as surface variable.
sleep(1000)


xclear= xset+Abs(xretract) ' retract away after touch.
Code "G0 x"&xclear
While IsMoving()
Wend


And a similar snippet for probing from right to left in Z

Code: [Select]

'set some variable, these are hard code for paste to button, but you could load DRO values...
frate1=1 ' feedrate
Zstart=GetoemDRO(802)
Probemax=1.0
Zset=2
Zend=Zstart-probemax
zretract=.1
hittol=.002 ' this is a small amount to see if hit or missed



Code "G31 z" & zend  & "F" & FRate1
While IsMoving()
wend

'================
xhit = GetVar(2000)
yhit = GetVar(2001)
ZHit = GetVar(2002)

if xhit=0 and yhit=0 and zhit=0 then
sleep(15)
xhit = getoemdro(800)
yhit = getoemdro(801)
zhit = getoemdro(802)
else
end if
'=================

if abs(ZHit-zend)<HitTol then
message "missed target"
code "G01 z" & zstart
while ismoving()
wend
exit sub
end if


'zset = zset + (ProbeD/2) ' Adjust up  by Probe Radius to set Z at ball center (you may not want this)
SetoemDRO(802, zset) ' Set ZDRO to center of ball, bottom of ball as surface variable.
sleep(1000)


Zclear= zset+Abs(zretract)
Code "G0 z"&zclear
While IsMoving()
Wend