Hello Guest it is September 21, 2019, 12:07:06 PM

Author Topic: Bridgeport Knee Mill Conversion?  (Read 159166 times)

0 Members and 1 Guest are viewing this topic.

Offline Davek0974

*
  •  2,577 2,577
    • View Profile
    • DD Metal Products Ltd
Re: Bridgeport Knee Mill Conversion?
« Reply #640 on: January 24, 2018, 10:42:43 AM »
Something like this maybe, I think I have it all working in Machine Coords for the C axis(knee) - it needs a hidden user DRO adding to the screen, unless we go down the variable route;)
Its not that long, I just like adding LOTS of text descriptors :)
Note - this code is UNTESTED


Code: [Select]
Sub Main()

If GetSelectedTool() = GetCurrentTool() Then Exit Sub ‘***Do nothing if current tool is called again

If GetOEMLED(1866) Then Exit Sub ***Ignore M6 calls LED

‘***Get the current G90/G91 state
CurrentAbsInc = GetOemLED(48)

‘***Get Axis Scale factors in use
XScale = GetOEMDRO(59)
YScale = GetOEMDRO(60)
ZScale = GetOEMDRO(61)
AScale = GetOEMDRO(62)

‘***Set All Axis Scales to 1
Call SetOEMDRO(59,1)
Call SetOEMDRO(60,1)
Call SetOEMDRO(61,1)
Call SetOEMDRO(62,1)
Sleep(250)

‘***Set the requested tool to be the current tool
tool = GetSelectedTool()
SetCurrentTool( tool )

‘***Switch to absolute distance mode
Code "G90"

‘***Move Z axis to machine zero - fully retracted for tool change
Code "G53 G0 Z0”
While IsMoving()
  Sleep 100
Wend

'========================================================================================
' Start of Knee Positioning Code
'========================================================================================
‘Get the knee reference position - set when pressing “Z Zero” at probing stage of setup
KneeRefPosition = roun(GetOEMDRO(1012)) ‘***This is a hidden DRO

‘***Get the respective backlash clearance allowance for downwards knee moves
If GetOEMLED(801) Then ‘***On  = English Measure INCH
    ClearAllow = 0.125  
Else                   ‘***Off = Metric Measure MM
    ClearAllow = 3.0    
End If

‘***Get the tool length whose offset number we are to use
‘***Tool has already been set to “currenttool” above
ToolOffsetNum = GetCurrentTool()

‘***Lookup the offset in the tool table, round it to 4 places, T100 is our 3d Haimer Probe
ToolOffset = roun(GetToolParam(ToolOffsetNum, 2))
ProbeOffset = roun(GetToolParam(100, 2))

‘***Calculate the difference between the probe and the new tool - can be negative or positive
OffSetDifference = ProbeOffset-ToolOffset

‘***See where the knee is now in machine coordinates
CurrentKneePos = roun(GetOEMDRO(88))’***Mach C Axis DRO
  ‘Message "CurrentKneePos=" & CurrentKneePos & " OffsetDifference=" & OffsetDifference ‘***Use this line for debugging

‘***Calculate the new knee machine coordinate value based on tool length difference
TargetKneePosition = KneeRefPosition - OffsetDifference

  ‘Message “Target Knee Pos = " & TargetKneePos ‘***Use this line for debugging

‘***If the knee is currently higher than it needs to be, we first
‘***move it down, to ensure the final move is always UP.  This ensures
‘***backlash is taken out, and provides more consistent positioning.
If TargetKneePosition > CurrentKneePosition Then
  Code “G53 G0 C“ & (TargetKneePosition + ClearAllow)
  While IsMoving ()
    Sleep 100
  Wend
End If

‘***Now move the knee UP to its final position
Code “G53 G0 C“ & TargetKneePosition
While IsMoving ()
  Sleep 100
Wend

'========================================================================================
' End of Knee Positioning Code
'========================================================================================

‘***If G91 was in effect before then return to it
If CurrentAbsInc = 0 Then
  Code "G91"
End If

‘***Put previous Axis Scale factors back
Call SetOEMDRO(59,XScale)
Call SetOEMDRO(60,YScale)
Call SetOEMDRO(61,ZScale)
Call SetOEMDRO(62,AScale)
Sleep(250)

End Sub
  
« Last Edit: January 24, 2018, 10:44:44 AM by Davek0974 »
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives

Offline Davek0974

*
  •  2,577 2,577
    • View Profile
    • DD Metal Products Ltd
Re: Bridgeport Knee Mill Conversion?
« Reply #641 on: January 24, 2018, 04:20:49 PM »
Couple of small errors in that code, fixed now - i'm calling axis scale factor DRO for A axis but i'm using C axis  and i called my hidden DRO an OEMDRO where it should be UserDRO I think.


So, presuming this code mostly works, if i check OEMLED(812) (C Ref Led) a value of 1 would indicate if the knee has been homed yes?
My reason is so that i can abort the tool change macro somewhere as it could be dangerous unless the knee is homed and its exact position known.

Is it worth also zeroing my UserDRO when the knee is homed - a latent value in this DRO could be dodgy if it was from a previous job, I can check for a zero value in the macro and abort.
Maybe also zero the UserDRO when the LoadFile button is pressed?

I'm just trying to look for pitfalls before they happen and possibly building the fix in - seems there can be quite a lot can go wrong when you have mixed length tools and the knee going up and down along with the Z axis etc :)
« Last Edit: January 24, 2018, 04:23:58 PM by Davek0974 »
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives

Offline Davek0974

*
  •  2,577 2,577
    • View Profile
    • DD Metal Products Ltd
Re: Bridgeport Knee Mill Conversion?
« Reply #642 on: January 25, 2018, 05:09:49 AM »
Ok, major changes below, my learned friend and mentor has enlightened me to a simple way by just comparing old and new tools, seems to make more sense now and needs no DRO's adding etc.

I have also made the last 3mm of move at F100 rather than G0 all the way so it gives the best chance of hitting the spot.


Code: [Select]
Sub Main()

If GetSelectedTool() = GetCurrentTool() Then Exit Sub ‘***Do nothing if current tool is called again

If GetOEMLED(1866) Then Exit Sub ***Ignore M6 calls LED

‘***Get the current G90/G91 state
CurrentAbsInc = GetOemLED(48)

‘***Get Axis Scale factors in use
XScale = GetOEMDRO(59)
YScale = GetOEMDRO(60)
ZScale = GetOEMDRO(61)
CScale = GetOEMDRO(64)

‘***Set All Axis Scales to 1
Call SetOEMDRO(59,1)
Call SetOEMDRO(60,1)
Call SetOEMDRO(61,1)
Call SetOEMDRO(64,1)
Sleep(250)

‘***Get old tool length
OldToolLength = roun(ToolLengthOffset)

‘***Set the requested tool to be the current tool
SetCurrentTool(GetSelectedTool())

‘***Get new tool length
NewToolLength = roun(ToolLengthOffset)

‘***Switch to absolute distance mode
Code "G90"

‘***Move Z axis to machine zero - fully retracted for tool change
Code "G53 G0 Z0”
While IsMoving()
  Sleep(100)
Wend

'========================================================================================
' Start of Knee Positioning Code
'========================================================================================
‘Get the knee position in machine coordinates
CurrentKneePosition = roun(GetOEMDRO(88))

‘***Get the respective backlash clearance allowance for downwards knee moves
If GetOEMLED(801) Then ‘***On  = English Measure INCH
    ClearAllow = 0.125 
Else                   ‘***Off = Metric Measure MM
    ClearAllow = 3.0   
End If

‘***Calculate the knee machine move value based on tool length difference
If OldToolLength > NewToolLength then ‘***We need to RAISE the knee
    Message “Knee Will Lift ” & OldToolLength - NewToolLength ‘***Use this line for debugging
    Code “G53 G0 C” & (CurrentKneePosition - (OldToolLength - NewToolLength)) + ClearAllow
    While IsMoving ()
      Sleep(100)
    Wend
    Code “G53 G1 C” & (CurrentKneePosition - (OldToolLength - NewToolLength)) & “ F100”
    While IsMoving ()
      Sleep(100)
    Wend
End If

‘***If the knee is currently higher than it needs to be, we first
‘***move it down, to ensure the final move is always UP.  This ensures
‘***backlash is taken out and provides more consistent positioning.

If OldToolLength < NewToolLength then ‘***We need to LOWER the knee
    Message “Knee Will Lower ” & NewToolLength - OldToolLength ‘***Use this line for debugging
    Code “G53 G0 C” & ((CurrentKneePosition + (NewToolLength - OldToolLength)) + ClearAllow
    While IsMoving ()
      Sleep(100)
    Wend
    Code “G53 G1 C” & (CurrentKneePosition + (NewToolLength - OldToolLength)) & “ F100”
    While IsMoving ()
      Sleep(100)
    Wend
End If

If OldToolLength = NewToolLength then
    Message “Knee Will Not Move” ‘***Use this line for debugging
End If

'========================================================================================
' End of Knee Positioning Code
'========================================================================================

‘***If G91 was in effect before then return to it
If CurrentAbsInc = 0 Then
  Code "G91"
End If

‘***Put previous Axis Scale factors back
Call SetOEMDRO(59,XScale)
Call SetOEMDRO(60,YScale)
Call SetOEMDRO(61,ZScale)
Call SetOEMDRO(64,CScale)
Sleep(250)

End Sub
   
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives
Re: Bridgeport Knee Mill Conversion?
« Reply #643 on: January 25, 2018, 06:39:32 AM »
Looking good.
Keep up the good work.


Mike
We never have the time or money to do it right the first time, but we somehow manage to do it twice and then spend the money to get it right.

Offline Davek0974

*
  •  2,577 2,577
    • View Profile
    • DD Metal Products Ltd
Re: Bridgeport Knee Mill Conversion?
« Reply #644 on: January 25, 2018, 01:19:30 PM »
Hmm, after spending an hour trying to figure out why it does nothing, i filled it with msgbox calls to examine why

"ToolLengthOffset" seems to do nothing at all and returns zero, this is why the macro failed.

what is the correct way to get tool length offset???

Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives
Re: Bridgeport Knee Mill Conversion?
« Reply #645 on: January 25, 2018, 01:37:58 PM »
 ???
page 28-29

GetTooParam

Offline Davek0974

*
  •  2,577 2,577
    • View Profile
    • DD Metal Products Ltd
Re: Bridgeport Knee Mill Conversion?
« Reply #646 on: January 25, 2018, 01:49:51 PM »
Just found it, thanks.

Was reworking it with this method as you replied...

NewToolLength = roun(GetToolParam(GetCurrentTool, 2))
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives

Offline Davek0974

*
  •  2,577 2,577
    • View Profile
    • DD Metal Products Ltd
Re: Bridgeport Knee Mill Conversion?
« Reply #647 on: January 25, 2018, 02:41:43 PM »
 :D ;D :D ;D

This code version works perfectly, it's one impressive addition to the mill, just increased it's usability 200% I think, she's now got 350mm of Z clearance under code control  8)

Of course, with every new feature there are new ways to mess things up of course -
do not enter a new tool manually in the "Current tool" DRO,
do not jog the knee manually once you have ref'd the Z axis and set the first tool or probe,
always enter the 1st tool/probe manually in the current tool DRO
probably a million other ways to make balls-up :)

I think a good addition will be to add some code to check that the new knee position is still a negative number as the axis runs out of travel at zero :)

One thing that did fail is the Index Homing on the knee - keeps throwing "Index not within allowed distance" error which means the index pulse is out of range, will have read the manual on this one.


Code: [Select]
Sub Main()

If GetSelectedTool() = GetCurrentTool() Then Exit Sub ‘***Do nothing if current tool is called again

If GetOEMLED(1866) Then Exit Sub ***Ignore M6 calls LED

‘***Get the current G90/G91 state
CurrentAbsInc = GetOemLED(48)

‘***Get Axis Scale factors in use
XScale = GetOEMDRO(59)
YScale = GetOEMDRO(60)
ZScale = GetOEMDRO(61)
CScale = GetOEMDRO(64)

‘***Set All Axis Scales to 1
Call SetOEMDRO(59,1)
Call SetOEMDRO(60,1)
Call SetOEMDRO(61,1)
Call SetOEMDRO(64,1)
Sleep(250)

‘***Get old tool length
OldToolLength = roun(GetToolParam(GetCurrentTool, 2))

‘***Set the requested tool to be the current tool
SetCurrentTool(GetSelectedTool())

‘***Get new tool length
NewToolLength = roun(GetToolParam(GetCurrentTool, 2))

‘***Switch to absolute distance mode
Code "G90"

‘***Move Z axis to machine zero - fully retracted for tool change
Code "G53 G0 Z0”
While IsMoving()
  Sleep(100)
Wend

'========================================================================================
' Start of Knee Positioning Code
'========================================================================================
‘***Get the knee position in machine coordinates
CurrentKneePosition = roun(GetOEMDRO(88))

‘***Get the respective backlash clearance allowance for downwards knee moves
If GetOEMLED(801) Then ‘***On  = English Measure INCH
    ClearAllow = 0.125 
Else                   ‘***Off = Metric Measure MM
    ClearAllow = 3.0   
End If

‘***Calculate the knee machine move value based on tool length difference
If OldToolLength > NewToolLength then ‘***We need to RAISE the knee
    Code “G53 G0 C” & (CurrentKneePosition - (OldToolLength - NewToolLength)) + ClearAllow
    While IsMoving ()
      Sleep(100)
    Wend
    Code “G53 G1 C” & (CurrentKneePosition - (OldToolLength - NewToolLength)) & “ F100”
    While IsMoving ()
      Sleep(100)
    Wend
End If

‘***If the knee is currently higher than it needs to be, we first
‘***move it down, to ensure the final move is always UP.  This ensures
‘***backlash is taken out and provides more consistent positioning.

If OldToolLength < NewToolLength then ‘***We need to LOWER the knee
    Code “G53 G0 C” & (CurrentKneePosition + (NewToolLength - OldToolLength)) + ClearAllow
    While IsMoving ()
      Sleep(100)
    Wend
    Code “G53 G1 C” & (CurrentKneePosition + (NewToolLength - OldToolLength)) & “ F100”
    While IsMoving ()
      Sleep(100)
    Wend
End If

If OldToolLength = NewToolLength then
    ‘Message “Knee Will Not Move” ‘***Use this line for debugging
End If

'========================================================================================
' End of Knee Positioning Code
'========================================================================================

‘***If G91 was in effect before then return to it
If CurrentAbsInc = 0 Then
  Code "G91"
End If

‘***Put previous Axis Scale factors back
Call SetOEMDRO(59,XScale)
Call SetOEMDRO(60,YScale)
Call SetOEMDRO(61,ZScale)
Call SetOEMDRO(64,CScale)
Sleep(250)

End Sub
   
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives

Offline Davek0974

*
  •  2,577 2,577
    • View Profile
    • DD Metal Products Ltd
Re: Bridgeport Knee Mill Conversion?
« Reply #648 on: January 25, 2018, 04:54:47 PM »
One more - make sure you don't have any G43 active - i modified the post processor to always output G43 H0 for any tool, having TL comp active as well as knee comp could be good fun :)
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives

Offline Davek0974

*
  •  2,577 2,577
    • View Profile
    • DD Metal Products Ltd
Re: Bridgeport Knee Mill Conversion?
« Reply #649 on: January 26, 2018, 04:33:01 AM »
Ok, lets try this flavour - it uses a hidden DRO or a #Var to store the position of the knee when the Z axis is referenced to work zero.

Its a much safer version i think as i can then move the knee anywhere i want anytime and it still knows where to go in the M6 routine.



Code: [Select]
Sub Main()

If GetSelectedTool() = GetCurrentTool() Then Exit Sub '***Do nothing if current tool is called again

If GetOEMLED(1866) Then Exit Sub '***Ignore M6 calls LED

Tool = GetSelectedTool()'***Set the requested tool to be the current tool
SetCurrentTool(Tool)

Code "G53 G0 Z0" '***Move Z axis to machine zero - fully retracted for tool change
While IsMoving()
  Sleep(100)
Wend

'***Get the respective backlash clearance allowance for knee moves
If GetOEMLED(801) Then '***On  = English Measure INCH
  ClearAllow = 0.125  
Else                   '***Off = Metric Measure MM
  ClearAllow = 3.0    
End If

'***Lookup the offset in the tool table, T100 is our 3d Haimer Probe
ToolOffset = GetToolParam(GetCurrentTool(), 2)
ProbeOffset = GetToolParam(100, 2)
OffSetDifference = ProbeOffset-ToolOffset'***Calculate the difference between the probe and the new tool - can be negative or positive

'***Calculate the new knee machine coordinate value based on tool length difference
KneeRefPosition = GetUserDRO(1012) '***Get the knee ref position - set when pressing "Z Zero" at probing stage, this is a hidden DRO
TargetKneePosition = KneeRefPosition - OffsetDifference

'***Rapid to a position lower than needed to allow for a final slow move up
Code "G53 G0 C" & (TargetKneePosition + ClearAllow)
While IsMoving()
  Sleep(100)
Wend

'***Now move the knee UP slowly to its final position
Code "G53 G1 C" & TargetKneePosition & " F100"
While IsMoving()
  Sleep(100)
Wend

End Sub
      
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives