So, turns out someone is a filthy liar. I never created a macro for the 4th, just ran it hand-entered via the MDI.
What I DO have is a macro I wrote for finding the centre of a hole:
Code:
'Simon's Hole Centre Finder
'NB - this doesn't move Z so triple check for obstacles.
' Keeping these around in case I want to extend this later
'XCurrent = GetOemDro(800)
'YCurrent = GetOemDro(801)
'ZCurrent = GetOemDro(802)
'GageH = GetOEMDRO(1001) 'OEMDRO(1001)=Gage Block Height
' Speeds
fast = 1000
slow = 50
' Get the current feed rate so we can restore it at the end
FeedCurrent = GetOemDRO(818)
' Find north and south edges
north = Approach(1,300, fast, slow)
south = Approach(1, -300, fast, slow)
' The north/south centre is between those two.
ymid =(north+south)/2.0
' Go to the middle.
Code "G00Y"&ymid
' Find east and west, go to the middle again
east = Approach(0,300, fast,slow)
west = Approach(0,-300, fast,slow)
xmid = (east+west)/2.0
Code "G00X"&xmid
' We're now in the centre of the hole!
' Restore feedrate and we're done
SetOemDRO(818,FeedCurrent)
' Function approaches a probe point quickly, backs off and comes in again slower (for better accuracy)
' nAxis: 0 for X axis, 1 for Y axis, anything else for Z
' nMaxAndDir: maximum distance to travel looking for probe trigger.
' Sign of this parameter determines direction
' nFast: Fast feed rate
' nSlow: Slow approach feed rate
' return value: The ordinate along the axis at which the probe triggered.
Function Approach (nAxis As Integer, nMaxAndDir As Double, ByVal nFast As Integer, ByVal nSlow As Integer) As Double
' Work out the axis and target ordinate of maximum searching travel
Select Case nAxis
Case 0
sAxis = "X"
t = GetOemDro(800) + nMaxAndDir
Case 1
sAxis = "Y"
t = GetOemDro(801) + nMaxAndDir
case Else
sAxis = "Z"
t = GetOemDro(802) + nMaxAndDir
End Select
' Work out the direction
nDir = (nMaxAndDir/Abs(nMaxAndDir))
' Make fast approach
' Send the move command
Code "G31 F" & nFast &" " & sAxis &t
' Wait to get there
While IsMoving()
Sleep(10)
Wend
' The DRO gives us the position at which we stopped
rVal = GetOemDro(800 + nAxis)
t = rVal - nDir
' back off
Code "G00 " &sAxis &t
t = rVal + nDir
' slow approach now
Code "G31 F" & nSlow & " " & sAxis & t ' slow approach
While IsMoving()
Sleep(10)
Wend
rVal = GetOemDro(800 + nAxis)
' back off the overshoot
t = rVal - nDir
Code "G00 " &sAxis &t ' back off
' return the new position
Approach = rVal
End function
Now, if you replaced everything from ' Find north and south edges to ' We're now in the centre of the hole!" with calls to Approach following the logic in my first post, I reckon you'd be in about the right place. Untested but this should be close to it assuming the rotary axis runs along X:
Code:
YCurrent = GetOemDro(801)
ZCurrent = GetOemDro(802)
' Hit the front (-ve Y) side
south = Approach(1, 200, fast, slow)
' Hop up and over the rod
Code "G00 Z" & (zCurrent + 25)
Code "G00 Y" & (yCurrent + 50)
Code "G00 Z" & zCurrent
' Come back to find the north side
north = Approach(1, -200, fast, slow)
' our Y centre is between north and south
radius = (north + south) / 2.0
' set the Y position, we're currently at +ve radius
SetOemDRO(801,radius)
' Now hop up and over the centre
Code "G00 Z" & (zCurrent + 25)
Code "G00 Y0"
' Find the top of the bar
Approach (2, -25, fast / 10, slow)
' And set Z based on us being one radius above the centreline
SetOemDRO(802, radius)
' Back off and we're done
Code "G00 Z" (radius + 5)
Note this will need you to be working low enough on the rod mounted in the 4th that your probe triggers at the widest point.
Hope it helps.