Hello Guest it is March 29, 2024, 04:08:31 AM

Author Topic: Tweaking the Tool-Change...  (Read 4829 times)

0 Members and 1 Guest are viewing this topic.

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Tweaking the Tool-Change...
« on: September 18, 2016, 06:16:00 AM »
Stumbled upon a situation today brought on by the massive flexibility of my Bridgeport CNC conversion, the tool-change was set to go to a programmed position - this could cause the tool to be dragged over clamps etc or with a large lump on the bed which overhangs could cause it to be mashed into the rear body of the machine.

The safest option seems to be to do nothing but lift the Z up to machine zero then wait.

This is my current M6Start macro, M6End is empty.

My question - if i comment out the block marked ************************************X, i think that will do it, BUT is there anything in the rest of the macro that does anything useful, apart from the block that parks the Z axis??

Code: [Select]
Sub Main()

Dim XScale, YScale, ZScale
Dim ZClear, Zoffset, ZClearMach
Dim ClearAllow
Dim Response

If GetOEMLED(1866) Then Exit Sub

If GetOEMLED(801) Then ' On = English Measure INCH

ClearAllow = 0.125 ' Max Z Travel = .125in below Machine Z zero

Else ' Off = Metric Measure MM

ClearAllow = 2.0 ' Max Z Travel = 2mm below Machine Z zero

End If

Zclear = GetOEMDRO(1814) ' Get Z Clearance Plane from DRO

Zoffset = GetOEMDRO(49)

ZClearMach = Zoffset + Zclear

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

'Get Axis Scale factors
XScale = GetOEMDRO(59)
YScale = GetOEMDRO(60)
ZScale = GetOEMDRO(61)

'Set All Axis' Scale to 1
Call SetOEMDRO(59,1)
Call SetOEMDRO(60,1)
Call SetOEMDRO(61,1)
Sleep(250)

tool = GetSelectedTool()
SetCurrentTool( tool )
SetVar(1, GetOEMDRO(800))
SetVar(2, GetOEMDRO(801))
SetVar(3, GetOEMDRO(802))
TCX=GetOEMDRO(1200)
TCY=GetOEMDRO(1201)
TCZ=GetOEMDRO(1202)


Code "G90"

Code "G53 G0 Z" & ZClear
While IsMoving()
Wend


Code "G53 G0 X" & TCX & " Y" & TCY ***************************************************************X
While IsMoving()                              ***************************************************************X
Wend                                             ***************************************************************X

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

Call SetOEMDRO(59,XScale)
Call SetOEMDRO(60,YScale)
Call SetOEMDRO(61,ZScale)
Sleep(250)

End Sub

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Tweaking the Tool-Change...
« Reply #1 on: September 21, 2016, 07:34:08 AM »
Ok, yes, that mod works much better, safer too :) I have no idea if the rest of the remaining code has any operational effect now but I'll leave it where it is.

Next - when Mach hits an M06 and gets to the "Press cycle start to continue.." point (manual tool change), is it possible, ok or unwise to run another macro?

I'm working on smoothing out the tool change on my aux spindle (no fixed height tooling), but is it possible to run a Z probe routine while at the above point in the M06 cycle???

I have been advised by a learned chap to simply create the g-code one file per tool, but that seems a little kludgy having been using the excellent semi-auto setup on the 2010 screen-set :)
Re: Tweaking the Tool-Change...
« Reply #2 on: September 21, 2016, 12:27:03 PM »
I have added gcode to my post processor (+  Commands output at toolchange) it takes the Z bit upwards first then goes to a place near my zero zero mind you I dont use big clamps,

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Tweaking the Tool-Change...
« Reply #3 on: September 21, 2016, 01:28:46 PM »
Nice idea.

Normally it would go to a park position, but after running a few jobs I realised that could be dangerous - having a tool in the spindle and going to machine zero as the code did once would have been fatal as i have a large vise bolted near the machine home area.

Then there was the custom G28 position - tried that and it was better but still could send the table in a direction that would cause bad things to happen if, as i did this weekend, have a large lump of metal overhanging the rear of table - it would have just mashed it into the rear column :)

So, the best option is to just do nothing - turn the spindle off and let me jog it where i know it is safe and then change the tool :)

I have modified the M06 start to simply raise the Z and stop.

The M06End now has a probing routine in it, it knows where the last position was so it can return there, what the last feed was etc, it should probe, warn me to remove the plate, rapid to the last position, restart the cycle.

Will test it out soon (on some dummy tools ;) )
Re: Tweaking the Tool-Change...
« Reply #4 on: September 21, 2016, 06:15:59 PM »
Sounds like a good plan :)
Re: Tweaking the Tool-Change...
« Reply #5 on: September 22, 2016, 07:41:58 AM »
One thing I remembered to tell you, did you see the screenset called Blue Screenset, it has a touchplate sensor tester led on the main screen

Find it here http://www.machsupport.com/software/downloads-updates/screensets/

there is a good page on additional features on the cncforum

find it here http://www.cnczone.com/forums/mach-wizards-macros-amp-addons/56079-cnc-software-53.html#post436238

I installed it and the probe tester led on the main page really helps

I also wrote a warning to remind me to probe the z in the post processor,

"the older I get the dafter I get"

regards

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Tweaking the Tool-Change...
« Reply #6 on: September 22, 2016, 07:48:20 AM »
One-step ahead ;)

The 2010 screen-set has the Probe led on the main page - just where it's needed :)

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Tweaking the Tool-Change...
« Reply #7 on: September 25, 2016, 10:48:57 AM »
Ah well, nearly but no luck ;)

Seems that when you use the CSMIO, you can not do any type of probe routine in the M6End macro :(

Any attempt to probe results in instant "ePid error" and Mach goes into reset.

The probing routine is sound and works when performed manually so its not that, you can also jog all axes when in the tool change sequence so its not that, it just will not handle a probe between M6Start and M6End.

That leaves only one option - create the G-Code with only one tool per file and not have any M6 calls in the code or set the "Ignore Tool Change" option in config.

Well, it was worth a try ;)
Re: Tweaking the Tool-Change...
« Reply #8 on: September 26, 2016, 03:22:17 AM »
I have a custom made macro for the M6START that was compiled from segments of different code found here and elsewhere.  I've written it to utilize the "Tool Change Location" DROs on the settings page for the (manual) tool change location (X, Y only using a SafeZ move) and probe start height (Z DRO).  I have then added a couple of prompt/response pop-ups to tell what tool is being requested and to press OK when changed, then another to prompt for the Tool Zero probe (with the option to Cancel which skips that part of the macro).  No additional macros necessary.  When I'm all done, I press cycle start which returns to the original X and Y tool location by way of a SafeZ height then down to the original Z location then continues on with the program.  I've added a button onto the Settings screen which allows me to set the Tool Change Location DROs to the current tool location so my routine is to decide where I want that location to be prior to running the program by moving to that location and touching/clicking that button.

Often times, I want to skip the tool zero routine (e.g. the first tool change command in a program when I've already installed the tool and set the height with the Tool Zero button on the main screen) or maybe do a manual routine.  But now that you mentioned it, I've never really tried a manual tool probe after an M6Start macro has run, but the intent is that I would be able to select "Remember" to set the current location into the machine, jog to the tool zero location I want, press the Auto Tool Zero and then return with the "Return" button, making sure to select a SafeZ height.  I guess that is something I should test more thoroughly.

For your reference, below is my M6Start and M6End code.  This is Mach3 VBScript as a point of reference as I'm not sure if you're using 3 or 4.  (I'm assuming 3 with the 2010 screen set from reading your posts, but we know what assuming does...  ;) )

M6Start.M1S

Code: [Select]
' Set variables to store some current, selected and user defined values

tool = GetSelectedTool() 'Value for Tool DRO at completion of tool change
CurrentFeedMode = GetOemDRO(819) 'Get current G0/G1 state
CurrentUnitsMM = GetOemLED(802) 'Get Current MM Units state
CurrentAbsCMode = GetOemLED(48) 'Get current G90/G91 state
CurrentFeedRate = GetOemDRO(818) 'Get the current Feed Rate
ToolChangeX = GetUserDRO(1200) 'Get user defined tool change location
ToolChangeY = GetUserDRO(1201)
ToolChangeZ = GetUserDRO(1202) 'NOTE: Z will be used for Auto Tool Zero start height
GageH = GetOEMDRO( 1001 ) 'Gage Block Height
ProbeD = 20 'Depth to probe for touch plate

' Move to user defined tool change location

If CurrentUnitsMM = FALSE Then 'Ensure measurement mode is in MM for macro
Code "G21"
End If
If IsSafeZ() Then 'If SafeZ is defined,
safeZ = GetSafeZ() 'use it for positioning commands
Else
safeZ = 0 'Otherwise, moves are made at MC Z0
End If
Code" G53 G0 Z" & safeZ 'Position spindle for tool change
Code"G53 G0 X" & ToolChangeX & "Y" & ToolChangeY
While IsMoving()
Sleep(10)
Wend
PText = "Tool #" & tool & " requested.  (See Setup Sheet for details.)" _
& Chr(10) & "Insert requested tool and press OK to continue."
MachMsg(PText,"Tool Change Request",0)
SetCurrentTool( tool ) 'Set the Tool DRO to the new tool number

' Auto tool zero

AutoZeroPrompt = "Place probe for Auto Tool Zero and press OK" _
& Chr(10) & "Or press CANCEL to zero tool manually"
AutoZero = MachMsg(AutoZeroPrompt,"Auto Tool Zero",1)
If AutoZero = 1 Then 'AutoZero = 1, User pressed OK
Code "G53 G0 Z" & ToolChangeZ 'ToolChangeZ is MC for starting location of probing
While IsMoving()
Sleep (10)
Wend
ZCurrent = GetOemDro(802) 'Current Z DRO
ZNew = ZCurrent - ProbeD 'Probe depth end height
Code "G90F100" 'slow feed rate to 100 MM/MIN
Code "G31 Z" &ZNew 'Start the probe move
While IsMoving()
Sleep(10)
Wend
If GetOEMLed(825) = True Then 'Probing successful
ProbeTouch = GetVar(2002) 'Exact height touch plate was contacted
Code "G1 Z" & ProbeTouch 'Go there (corrects for potential over-run)
While IsMoving()
Sleep(10)
Wend
Call SetDro(2,GageH) 'Set Z DRO to adjusted value
FinalMove = GageH + 10
Code  "G0 Z" &FinalMove 'Raise probe off of touch plate
While IsMoving()
Sleep(10)
Wend
Message("Press Cycle Start to continue...")
Else 'Probe did not contact touch plate
Message("Zero not achieved - Check probe and try again manually")
End If
Else 'User selected Cancel on Auto Tool Zero prompt
Message("Zero tool manually and press Cycle Start to continue...")
End If

'RESTORE MACHINE STATE VALUES

'Feed Rate

Code "F" &CurrentFeedRate 'restore starting feed rate

'G0/G1 State

If CurrentFeedMode = "80" Then 'Machine still in initial state at start of macro
Code "G0" 'so set move mode to G0
Else
Code "G" & CurrentFeedMode 'Otherwise set move mode to previous value
End If

'G20/G21 State

If CurrentUnitsMM Then 'Units was previously set to mm
Code "G21"
Else 'Units was previously set to inches
Code "G20"
End If

'G90/G91 State

If CurrentAbsCMode Then 'System was using absolute coordinates
Code "G90"
Else 'System was using incremental coordinates
Code "G91"
End If       

M6End.M1S

Code: [Select]
'The default script here moves the tool back To m6start If Any movement has occured during the tool change..

x = GetToolChangeStart( 0 )
y = GetToolChangeStart( 1 )
z = GetToolChangeStart( 2 )
a = GetToolChangeStart( 3 )
b = GetToolChangeStart( 4 )
c = GetToolChangeStart( 5 )
If(IsSafeZ() = 1) Then
SafeZ = GetSafeZ()
Code "G53 G0 Z" & SafeZ
Else
Code "G53 G0 Z0"
End If
Code "G0 A" & a' & "B" & b & "C" & c
Code "G0 X" & x & "Y" & y
Code "G0 Z" & z 

Hope that helps or at least gives you some ideas to work from.

Stephen "Highspeed" Kruse

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Tweaking the Tool-Change...
« Reply #9 on: September 26, 2016, 03:41:27 AM »
Thanks

Is this on a CSMIO controller, it seems specific to this controller setup - my stepper machines all work perfectly.