Hello Guest it is April 28, 2024, 06:37:36 PM

Author Topic: Touch script not working, Help?  (Read 1366 times)

0 Members and 1 Guest are viewing this topic.

Touch script not working, Help?
« on: March 31, 2022, 06:22:45 PM »
Hey guys. I've setup for Z zero touch plate. The Digitize DRO in Mach3 and the Data Monitor for the ESS are both indicating the "Touch".
But the script I found is not working. The Z axis starts it's move but has no reaction when the probe (Bit) hits the plate. Below is the script I found. Can someone point me to a better one or suggest a fix for the one I have?

CurrentFeed = GetOemDRO(818) 'Get the current feed rate to return to later
CurrentAbsinc = GetOemLED(48) 'Get current G90/G91 state
CurrentGmode = GetOemDRO(819) 'Get the current G0/G1 state

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 "G90 G31Z-2. F5" '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 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, .192) 'set the Z axis DRO to whatever is set as plate thickness
sleep 200 'pause for Dro update.
Code "G1 Z1,F50" '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 aplicable
Exit Sub
End If


Thanks.........dt


Mach3
CNC4PC bob
ESS
Win10

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: Touch script not working, Help?
« Reply #1 on: April 01, 2022, 03:27:37 AM »
your code should basicly work, but it is for imperial units, so if you are in metric all speeds and distances are to
smal. mado two simple version's one for imperial and one fpr metric

imperial:
Code: [Select]
'imperial
CurrentFeed = GetOemDRO(818) 'Get the current feed rate to return to later
CurrentAbsinc = GetOemLED(48) 'Get current G90/G91 state
CurrentGmode = GetOemDRO(819) 'Get the current G0/G1 state

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 "G90 G31 Z-2 F5" '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 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, .192) 'set the Z axis DRO to whatever is set as plate thickness
sleep 200 'pause for Dro update.
Code "G1 Z1 F50" '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 aplicable
Exit Sub
End If

metric:
Code: [Select]
'metric
CurrentFeed = GetOemDRO(818) 'Get the current feed rate to return to later
CurrentAbsinc = GetOemLED(48) 'Get current G90/G91 state
CurrentGmode = GetOemDRO(819) 'Get the current G0/G1 state

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 "G90 G31 Z-50 F50" '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 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, 5) 'set the Z axis DRO to whatever is set as plate thickness
sleep 200 'pause for Dro update.
Code "G1 Z10 F500" '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 aplicable
Exit Sub
End If
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Touch script not working, Help?
« Reply #2 on: April 01, 2022, 07:45:57 AM »
Thanks TPS! I'll give that a try today.

Thanks.......dt
Re: Touch script not working, Help?
« Reply #3 on: April 01, 2022, 11:57:54 AM »
It works!....But when told to go to Z 0, it comes up short by ~1.5 inch off the material. Do you have any suggestions for that? I'm trying to parse the code but my brain came up short too.

Thanks.........dt

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: Touch script not working, Help?
« Reply #4 on: April 02, 2022, 02:54:19 AM »
have you adjusted this line:

Code: [Select]
Call SetDro (2, .192) 'set the Z axis DRO to whatever is set as plate thickness

to the correct height of your touchplate?
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Touch script not working, Help?
« Reply #5 on: April 02, 2022, 06:16:12 PM »
No. The .192 is the thickness of my plate.

Procedure:
1. Run Auto tool Zero
    Result...Z axis changed to 0000

2.  Hit Go to Zero
     Result...Z axis above material surface

3.  Hit Zero Z and Jog to material surface
    Result...1.525

4.  Hit Zero Z again and Jog to 1.192 (1 plus plate thickness)

5.   Hit Go To Zero
       Result...Z hits surface exactly!

 SO distance error is 1.525 less 1.192 = .333. I've run this series several times and come up with a different difference error each time. I'm thinking this eliminates machine error and suggests the script. Are there any hints as to the problem here?

Thanks.........dt

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: Touch script not working, Help?
« Reply #6 on: April 03, 2022, 04:41:17 AM »
OK, i have two ideas.
1st we need some updatetime for the Var's after touch
2nd your controller will not support update of var's 2000-2002

code for 1st idea with Sleep to update:
Code: [Select]
'imperial
CurrentFeed = GetOemDRO(818) 'Get the current feed rate to return to later
CurrentAbsinc = GetOemLED(48) 'Get current G90/G91 state
CurrentGmode = GetOemDRO(819) 'Get the current G0/G1 state

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 "G90 G31 Z-2 F5" 'probing move, can set the feed rate here as well as how far to move
While IsMoving() 'wait while it happens
Wend
Sleep(200) 'give the dro's time to update
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, .192) 'set the Z axis DRO to whatever is set as plate thickness
sleep 200 'pause for Dro update.
Code "G1 Z1 F50" '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 aplicable
Exit Sub
End If

code for 2nd idea without using var 2002:
Code: [Select]
'imperial
CurrentFeed = GetOemDRO(818) 'Get the current feed rate to return to later
CurrentAbsinc = GetOemLED(48) 'Get current G90/G91 state
CurrentGmode = GetOemDRO(819) 'Get the current G0/G1 state

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 "G90 G31 Z-2 F5" 'probing move, can set the feed rate here as well as how far to move
While IsMoving() 'wait while it happens
Wend
Sleep(200) 'give the dro's time to update
'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, .192) 'set the Z axis DRO to whatever is set as plate thickness
sleep 200 'pause for Dro update.
Code "G1 Z1 F50" '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 aplicable
Exit Sub
End If

let's see witch solution will help
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Touch script not working, Help?
« Reply #7 on: April 03, 2022, 01:22:08 PM »
TPS, the second solution worked great! Thanks again for your help!

Thanks........dt