Hello Guest it is March 05, 2021, 09:16:38 PM

Author Topic: Touch Off Macro Half Works  (Read 4648 times)

0 Members and 1 Guest are viewing this topic.

Touch Off Macro Half Works
« on: August 19, 2012, 01:44:53 PM »
I've got a touch off plate, but the software only half works.  By this I mean the tool comes down and stops when it touches the plate, but it does not then retract and it does not set the Z height.  Also, after running this macro I cannot manually jog the machine until I reset it.  Can someone point out what I'm doing wrong?  I "borrowed" this macro code from these forums (thanks to whomever wrote it).  The code seems OK to me.

Thanks.
Greg

Code: [Select]
'Tool Zero Setting Macro

' Change the following three lines to suit your machine
PlateThickness = GetOEMDRO(1001) ' Thickness of touch plate
RetractClearance = 0.100 ' Clearance above touch plate to retract to
ProbeFeed = 5      ' Feedrate to use for probing

' Define some constants
ZDRO = 2      ' Z Axis DRO
AbsoluteModeLED = 48   ' Absolute Coordinate Mode LED
IncrementalModeLED = 49   ' Incremental Coordinate Mode LED
FeedrateDRO = 818   ' OEM code for feedrate DRO
ProbeLED = 825      ' OEM code for probe input LED
ZTouchDRO = 2002   ' OEM code for DRO that holds Z touch position

' Do nothing if probe is already grounded
If GetOemLed(ProbeLED) = 0 Then

   ' Wait a few seconds for user to get touchplate in place
   Code "G4 P2"
   
   ' Save current feedrate
   CurrentFeed = GetOemDRO(FeedrateDRO)
   
   ' Save current coordinate mode
   AbsMode = GetOemLED(AbsoluteModeLED)

   ' Set absolute coordinate mode
   Code "G90"

   ' Zero Z DRO
   Call SetDro (ZDRO, 0.0000)

   ' Pause for DRO to update
   Code "G4 P0.5"

   ' Do the touch move
   Code "G31 Z-0.5 F" & ProbeFeed

   ' Wait for it to complete
   While IsMoving()
   Wend

   ' Delay a bit for Huh
   Code "G4 P0.25"

   ' Get the Z position where probe input triggered
   ZProbePos = GetVar(ZTouchDRO)

   ' Go back to touch position (G31 backs off after touch)
   Code "G0 Z" & ZProbePos

   ' Wait for it to complete
   While IsMoving ()
   Wend

   ' Set Z DRO to touch plate thickness
   Call SetDro (ZDRO, PlateThickness)

   ' Pause for DRO to update
   'Code "G4 P0.5"

   ' Retract Z to SafeZ, if enabled, else to RetractClearance above plate
   If(IsSafeZ() = 1) Then
      SafeZ = GetSafeZ
      If  SafeZ  > PlateThickness Then
         GotoSafeZ()
      End If
   Else
      RetractHeight = PlateThickness + RetractClearance
      Code "G0 Z" & RetractHeight
   End If
   
   ' Tell user we're done
   Code "(Z axis is now zeroed)"

   ' Reset feedrate to original value
   Code "F" & CurrentFeed
   
   ' Reset coordinate mode to original value
   If AbsMode = 0 Then
      Code "G91"
   End If
Else
   Code "(Z-Plate is grounded, check connection and try again)"
End If

Exit Sub

Offline Hood

*
  •  25,838 25,838
  • Carnoustie, Scotland
    • View Profile
Re: Touch Off Macro Half Works
« Reply #1 on: August 19, 2012, 05:04:54 PM »
Is your probe seen correctly by Mach, could you have its active state the wrong way?
Hood
Re: Touch Off Macro Half Works
« Reply #2 on: August 19, 2012, 06:02:08 PM »
Hood,

Yes, I believe the probe is being seen correctly by Mach.  On the diagnostics screen, the digitize LED lights up when the bit touches the plate.  Also, when executing the macro, the Z axis stops as soon as it touches the plate.  The code is also checking to see if the probe is already active when the macro starts, so I should have received a message to that effect if this were the case.

Thanks for your help.
Greg

Offline Hood

*
  •  25,838 25,838
  • Carnoustie, Scotland
    • View Profile
Re: Touch Off Macro Half Works
« Reply #3 on: August 19, 2012, 06:16:54 PM »
Oh well only other thing I can think of, assuming the macro is correct, that you have some noise on the probe.
Presume you are using the parallel port and not some external controller?
Hood
Re: Touch Off Macro Half Works
« Reply #4 on: August 19, 2012, 06:40:51 PM »
Hood,

That is correct, I'm using the parallel port.

Thanks.
Greg

Offline ger21

*
  • *
  •  6,289 6,289
    • View Profile
    • The CNC Woodworker
Re: Touch Off Macro Half Works
« Reply #5 on: August 19, 2012, 07:57:36 PM »
Do you have a DRO 1001 on your screen for the plate thickness?

If not, change

PlateThickness = GetOEMDRO(1001) ' Thickness of touch plate

to

PlateThickness = .125 ' Thickness of touch plate

with the .125 being the thickness of your plate.
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: Touch Off Macro Half Works
« Reply #6 on: August 20, 2012, 10:08:41 AM »
Gerry,

I modified the macro as you suggested and there was no change in behavior.  So I removed some of the complexity to try and locate the offending line.  It seems that the machine is just ignoring the retract move and I still get the message saying "Z Axis is now zeroed".  The Z axis DRO is being set properly, just no retraction move is done.

Any suggestions are welcome, below is the current version that I'm using that has been stripped down to the bare minimum.

Greg

Code: [Select]
'Tool Zero Setting Macro

' Change the following three lines to suit your machine
PlateThickness = 0.060 ' Thickness of touch plate
RetractClearance = 1.000 ' Clearance above touch plate to retract to
ProbeFeed = 5      ' Feedrate to use for probing

' Define some constants
ZDRO = 2      ' Z Axis DRO
' Wait a few seconds for user to get touchplate in place
Code "G4 P2"
   
' Do the touch move
Code "G31 Z-0.5 F" & ProbeFeed

' Wait for it to complete
While IsMoving()
Wend

' Delay a bit
Code "G4 P0.25"

' Set Z DRO to touch plate thickness
Call SetDro (ZDRO, PlateThickness)

Code "G0 Z0.250"
   
' Tell user we're done
Code "(Z axis is now zeroed)"

Exit Sub

Offline Hood

*
  •  25,838 25,838
  • Carnoustie, Scotland
    • View Profile
Re: Touch Off Macro Half Works
« Reply #7 on: August 20, 2012, 10:25:40 AM »
Do you have a licence? I am not sure if it is required or not for probing.
Hood

Offline ger21

*
  • *
  •  6,289 6,289
    • View Profile
    • The CNC Woodworker
Re: Touch Off Macro Half Works
« Reply #8 on: August 20, 2012, 10:35:03 AM »

Try changing this:

   If(IsSafeZ() = 1) Then
      SafeZ = GetSafeZ
      If  SafeZ  > PlateThickness Then
         GotoSafeZ()
      End If
   Else
      RetractHeight = PlateThickness + RetractClearance
      Code "G0 Z" & RetractHeight
   End If

to this:

RetractHeight = PlateThickness + RetractClearance
Code "G0 Z" & RetractHeight


Retracting to SafeZ in a macro is dangerous, because the macro doesn't know if Safe Z is in work coordinates or machine coordinates.
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html

Offline Tweakie.CNC

*
  • *
  •  8,664 8,664
  • Super Kitty
    • View Profile
    • Tweakie.CNC
Re: Touch Off Macro Half Works
« Reply #9 on: August 20, 2012, 11:15:16 AM »
Hi Greg,

This is a shot in the dark but try adding the following line to your script, just before the Code "G0 Z0.250" line and see if that cures the problem.

DoOemButton (1003)

Tweakie.

KEEP SAFE !