Hello Guest it is March 28, 2024, 07:01:44 AM

Author Topic: Act sometimes  (Read 6429 times)

0 Members and 1 Guest are viewing this topic.

Act sometimes
« on: September 02, 2014, 03:09:33 AM »
Hi,

I am trying to work out how to make an automated tool change occur.  I have been reading up on many different examples here, but I cannot seem to find a feature I would like. 

I would like mach to  go to a tool change location and wait for a manual change if a tool does not exist in the rack of prepared tools.  This would use the m6end macro and prompt for a cycle start after the change.

However, if the tool is present, I want the machine to make the change and not ask for a cycle start- but just continue with the new tool.

Any insight on how to do this?

Thanks,

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Act sometimes
« Reply #1 on: September 02, 2014, 04:15:06 AM »
Hi,

this needs a little bit of code like this

Code: [Select]

'move to tool change position
Code "G1 X?? Y?? Z??"

'check tool present
Again:

If IsActive(INPUT1) Then
    ' tool is present       
    ' do code when tool present
Else
    'tool not present
    'ask operator
    Response = MsGBox ("tool loaded ?" , 4)
    If Response = 6 then
        Go To Again
    Else   
        GoTo Ende
    End If   

End If

'Code if everything was fine

Exit Sub

Ende:
   'code if operator pressed abort



it's just a sample not tested.

regards Thomas
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Act sometimes
« Reply #2 on: September 02, 2014, 11:49:44 AM »
Thanks,

Would I setup it up in general configuration to "automatic tool changer only"?

By doing so, It will not call the m6end macro  when m6start is finished- correct?  So if I want the commands that are currently in the m6end macro to work, I will need to move them to m6start and add them as part of the "tool not present" condition - correct?

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Act sometimes
« Reply #3 on: September 02, 2014, 03:16:40 PM »
hello Daregone,

for my mind i think you have to find your 'own' way for
a tool change macro, however its called.

i think with this M6Start stop thing you will not get happy.

excuse my bad english.

Thomas
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Act sometimes
« Reply #4 on: September 02, 2014, 03:44:56 PM »
Thank you for comments, perhaps someone else has some ideas.

What I am really trying to do is use the m6start and m6end scripts that are part of the 2010 screenset (they are based on the macros written by Big-Tex November 29 2010
' and modified by Poppa Bear, with Greolt's and Arbo's changes 08Dec2010)  

I have set up my machine with 3 markers that I want to be considered tools and that can be activated by g-code and not require any intervention by an operator.  If the g-code calls for some other tool (an endmill, for example) then the the code will proceed as normal (going to a tool change position, checking tool height, etc...)

Here is a video of the mechanical components (a bit rough, but demonstrate how I would like it to work.)
http://youtu.be/-Pu8RzoEMLY
« Last Edit: September 02, 2014, 03:49:07 PM by Daregone »

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Act sometimes
« Reply #5 on: September 03, 2014, 03:10:29 AM »
Hello,

i think i understans now what you want.

needs a little bit of code in the start macro:

lets say
marker red = tool 5
marker blue = tool 6
marker black = tool 7

' Get actual tool # and new tool #
ToolOld = GetCurrentTool()
ToolNew = GetSelectedTool()

If (ToolNew = 5) Then
    'add here the code activate red marker
    code " G01 X?? Y??"
    'and so on
End If

If (ToolNew = 6) Then
    'add here the code activate blue marker
    code " G01 X?? Y??"
    'and so on
End If

If (ToolNew = 7) Then
    'add here the code activate black marker
    code " G01 X?? Y??"
    'and so on
End If

hope i understood what you realy wnat to do.

Thomas
« Last Edit: September 03, 2014, 03:12:47 AM by TPS »
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Act sometimes
« Reply #6 on: September 03, 2014, 03:28:49 AM »
You are close to getting what I am trying to do .  I really appreciate the time you have taken. 

I will try to be clear.  I am currently using the modified  Big Tex m6start and m6end macros.  I want to add code similar to what you have written to the existing macros. 

Currently, when a tool change is encountered, the machine will go to a defined location and wait for the  manual tool change.  It will not continue until user hits the start cycle button.  Once the start cycle button is hit, the machine activate the m6end macro and perform the tool height check, the proceed with the rest of the g-code.

I want to keep thieves features (tool height, tool change position, etc...) when  it encounters a m6 and is not a marker.  But if it is a marker, I want it to select according to something like your code.

Basically, I want markers to be used without manual interference (even hitting cycle start) and cutting tools to go through ta full tool change sequence (pause, go to tool change position ). And prompt for the cycle start, then the perform a height check, before continuing with the g-code.

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Act sometimes
« Reply #7 on: September 03, 2014, 03:48:14 AM »
ok then i expanded the sample a little bit:

Code: [Select]
let's say
'marker red = tool 5
'marker blue = tool 6
'marker black = tool 7

' Get actual tool # and new tool #
ToolOld = GetCurrentTool()
ToolNew = GetSelectedTool()

'here we do the marker things

'here we do the code to deactivate the markers
If ((ToolOld = 5) or (ToolOld = 6) or (ToolOld = 7))
    'code to desactivate markers
    code "G01 X?? Y??"
    'and so on
End If


If ((ToolNew = 5) or (ToolNew = 6) or (ToolNew = 7))

    If (ToolNew = 5) Then
        'add here the code activate red marker
        code " G01 X?? Y??"
        'and so on
    End If

    If (ToolNew = 6) Then
        'add here the code activate blue marker
        code " G01 X?? Y??"
        'and so on
    End If

    If (ToolNew = 7) Then
        'add here the code activate black marker
        code " G01 X?? Y??"
        'and so on
    End If
    Exit Sub

else
'here we do the original M6Start things

End If

regards Thomas
« Last Edit: September 03, 2014, 04:02:04 AM by TPS »
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Act sometimes
« Reply #8 on: September 03, 2014, 03:33:12 PM »
I think the issue is not how to select the the tool -(ie, using "If-Then") .   I am pretty sure I understand how to do that.

The problem is in how mach3 works when a M6 is called.  In the general configuration tab, there are 3 options for how to handle m6:

   1. Ignore it
   2. Stop the spindle and wait for a cycle start.  This seems to be when it runs m6start.m1s, waits for the cycle start, then runs m6end.m1s
   3. use ATC.  I believe this only runs m6start.m1s.

I am currently using these two macros' with a setting of "Stop Spindle, wait for cycle start":

m6start.m1s
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)

If TCZ>0 Then
MsgBox "Tool Change Z Position" & (Chr(13)) & "can NOT be above Z=0"& (Chr(13)) & "System going in to E-Stop",16,"Tool Change Z Position Error!!!!!"
'Reset Scale before E-Stop
Call SetOEMDRO(59,XScale)
Call SetOEMDRO(60,YScale)
Call SetOEMDRO(61,ZScale)
Sleep(250)
DoOEMButton(1021) ' Put Mach3 in Reset to end Tool Change
Exit Sub 'ERROR! exit the macro
End If

If ZClearMach>0 Then

Response = MsgBox ("Warning !!!" & (Chr(13)) & "Z Clearance Plane is Above Z Axis Home Switch." & (Chr(13)) & "Press OK To Retract Safely Below Switch" & (Chr(13)) & "Or Press Cancel for E-Stop",49,"Insufficient Z Clearance!!")

If Response = 1 Then ' If OK
ZClearMach = 0 - ClearAllow ' Retract to Z Machine zero - .125in or 2mm
ElseIf Response = 2 Then ' If Cancel
'Reset Scale before E-Stop
Call SetOEMDRO(59,XScale)
Call SetOEMDRO(60,YScale)
Call SetOEMDRO(61,ZScale)
Sleep(250)
DoOEMButton(1021) ' Put Mach3 in Reset to end Tool Change
Exit Sub
End If
End If

Code "G90"
If ZClearMach > TCZ Then
Code "G53 G0 Z" & ZClearMach
While IsMoving()
Wend
Else
Code "G53 G0 Z" & TCZ
While IsMoving()
Wend

End If

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

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
  

and

m6end.m1s
Code: [Select]
Sub Main()


' Based on the macros written by Big-Tex November 29 2010
' and modified by Poppa Bear, with Greolt's and Arbo's changes 08Dec2010


If GetOEMLED(1866) Then Exit Sub

Dim XWork, YWork, ZWork, XMachine, YMachine, ZMachine
Dim XScale, YScale, ZScale
Dim ZNew, ZPlate, Zplatetomaterial
Dim TCZ
Dim XPlate, YPlate
Dim ZClear, ClearAllow, ZMaxRetract
Dim FirstProbeDist, FirstRetractDist, SecProbeDist
Dim CurrentFeed
Dim CurrentAbsInc
Dim Response, CurrUnit

TCZ=GetOEMDRO(1202)
XWork = GetOEMDRO(800) ' Get current X Work Coordinate
YWork = GetOEMDRO(801) ' Get current Y Work Coordinate
ZWork = GetOEMDRO(802) ' Get current Z Work Coordinate
XMachine = GetOemDRO(83) ' Get current X Machine Coordinate
YMachine = GetOemDRO(84) ' Get current Y Machine Coordinate
ZMachine = GetOemDRO(85) ' Get current Z Machine Coordinate
XPlate = GetUserDRO(1811) ' Get X Machine Coordinate of Fixed Plate
YPlate = GetUserDRO(1812) ' Get Y Machine Coordinate of Fixed Plate
CurrentFeed = GetOemDro(818) ' Get Current Feed Rate
Zplatetomaterial = GetUserDRO(1813) ' Get calculated material offset
ZClear = GetOEMDRO(1814) ' Get Z Clearance Plane
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)



'//////// the block below will set all your reusable vars depending on Inch or mm.
'//////// this sets the vars so you only need ONE large block of probing code.

If GetOEMLED(801) Then ' On = English Measure INCH
FirstProbeDist = 6.0 ' Probe Down 6 inches
FirstRetractDist = 0.05 ' Then Retract .05 inches
SecProbeDist = 0.25 ' Then Probe down .25 inches
FirstProbeFeed = 10 ' First Probe Feed @ 10 ipm
SecondProbeFeed = 1 'Second Probe Feed @ 1 ipm
ClearAllow = 0.125 ' Max Z Travel = .125in below Machine Z zero
CurrUnit = "inches"
Else ' Off = Metric Measure MM
FirstProbeDist = 150.0 ' Probe Down 150 mm's
FirstRetractDist = 1.0 ' Then Retract 1 mm
SecProbeDist = 6.0 ' Then Probe down 6 mm's
FirstProbeFeed = 250 ' First Probe Feed @ 250mm/min
SecondProbeFeed = 25 ' Second Probe Feed @ 25mm/min
ClearAllow = 2.0 ' Max Z Travel = 2mm below Machine Z zero
CurrUnit = "mm's"
End If

'//////// Error Condition checking code

If GetOemLED(16)<>0 Then 'Checks for machine coordinates
MsgBox "Must be in Working Coordinates - Putting System in Reset",16,"Machine Coordinates!!!!!"
'Reset Scale before E-Stop
Call SetOEMDRO(59,XScale)
Call SetOEMDRO(60,YScale)
Call SetOEMDRO(61,ZScale)
DoOEMButton(1021) ' Put Mach3 in Reset to end Tool Change
Exit Sub 'ERROR! exit the macro
End If

If GetOemLED(825)<>0 Then
MsgBox "Z Plate is Grounded - Putting System in Reset",16,"Plate Grounded Error!!!!!"
'Reset Scale before E-Stop
Call SetOEMDRO(59,XScale)
Call SetOEMDRO(60,YScale)
Call SetOEMDRO(61,ZScale)
DoOEMButton(1021) ' Put Mach3 in Reset to end Tool Change
Exit Sub 'ERROR! exit the macro
End If

If ZClear <=0 Then
'MsgBox "(Clearance Plane Must be > 0 - Putting System in Reset)",16,"Clearance Plane Error!!!!"
'Reset Scale before E-Stop
Call SetOEMDRO(59,XScale)
Call SetOEMDRO(60,YScale)
Call SetOEMDRO(61,ZScale)
'DoOEMButton(1021) ' Put Mach3 in Reset to end Tool Change
'Exit Sub 'ERROR! exit the macro
'End If


Response = MsgBox ("Warning !!!" & (Chr(13)) & "Z Clearance Plane <= 0 !!!" & (Chr(13)) & "Press OK To Set Retract Plane To  " & Cstr(ClearAllow) & " " & CurrUnit & (Chr(13)) & "Or Press Cancel for E-Stop",49,"Clearance Plane Less Than Or Equal To Zero!!")

If Response = 1 Then ' If OK
ZClear = ClearAllow ' Retract to .125in or 2mm above fixed plate
ElseIf Response = 2 Then ' If Cancel
'Reset Scale before E-Stop
Call SetOEMDRO(59,XScale)
Call SetOEMDRO(60,YScale)
Call SetOEMDRO(61,ZScale)
Sleep(250)
DoOEMButton(1021) ' Put Mach3 in Reset to end Tool Change
Exit Sub
End If
End If

'//////// Start Probing Code, Probe In -Z direction.
'//////// The vars will be Inch or Metric from above if/else statment

Code "G90"  ' Change to Absolute Distance Mode
Sleep(100)

Code "G53 G0 Z" & TCZ ' Move to Tool Change Z Position - Should already be there

While IsMoving()
Wend

Code "G53 G0 X" & XPlate & " Y" & YPlate ' Move to Fixed Plate Location

While IsMoving()
Wend

If GetOemLED(825)<>0 Then
MsgBox "Z Plate is Grounded - Putting System in Reset",16,"Plate Grounded Error!!!!!"
DoOEMButton(1021) ' Put Mach3 in Reset to end Tool Change
Exit Sub 'ERROR! exit the macro
End If

Code "F" & FirstProbeFeed ' Set Feedrate to 10 ipm, or 300 mm/m

Code "(Probing for Z Zero....)"

Zplate = (GetOEMDro(802) - FirstProbeDist) ' Probe move to Current Z - 6in, or 150mm
Code "G90 G31 Z" & Zplate

While IsMoving()
Wend

Zplate = GetVar(2002) ' Read the Touch Point

Code "G1 Z" & (Zplate + FirstRetractDist) ' Move up .05 in, or 1mm in case of overshoot

While IsMoving()
Wend

Code "F" & SecondProbeFeed ' Set Feedrate to 1 ipm, or 25mm/min

Zplate = (GetOEMDro(802)- SecProbeDist) ' Probe move to Current Z - .25in, or 6mm

Code "G90 G31 Z" & Zplate

While IsMoving()
Wend

Call SetOEMDRO(802,Zplatetomaterial) ' Set Z axis DRO to Calculated Offset, making tool tip @ Z=0
Sleep(500) ' Pause for Dro to update


'Make Sure Z Clearance Plane is below Home Switch. If not, Notify User and Proceed.

If GetOEMLED(85) <= Zplatetomaterial + ClearAllow Then

ZMaxRetract = Abs(GetOEMDRO(85) - Zplatetomaterial + ClearAllow)
Else
ZMaxRetract = Abs(GetOEMDRO(85)) + Zplatetomaterial - ClearAllow
End If

If ZClear > ZMaxRetract Then

Response = MsgBox ("Warning !!!" & (Chr(13)) & "Z Clearance Plane is Above Z Axis Home Switch." & (Chr(13)) & "Press OK To Retract Safely Below Switch" & (Chr(13)) & "Or Press Cancel for E-Stop",49,"Insufficient Z Clearance!!")

If Response = 1 Then ' If OK
ZClear = ZMaxRetract ' Retract to Z Machine zero - .125in or 2mm
ElseIf Response = 2 Then ' If Cancel
'Reset Scale before E-Stop
Call SetOEMDRO(59,XScale)
Call SetOEMDRO(60,YScale)
Call SetOEMDRO(61,ZScale)
Sleep(250)
DoOEMButton(1021) ' Put Mach3 in Reset to end Tool Change
Exit Sub
End If
End If


If ZClear <= Zplatetomaterial then 'Plunge into Fixed Plate !!!!

Response = MsgBox ("Warning !!!" & (Chr(13)) & "Z Clearance Plane is Below Fixed Plate!!!" & (Chr(13)) & "Press OK To Retract " & Cstr(ClearAllow) & " " & CurrUnit & (Chr(13)) & "Or Press Cancel for E-Stop",49,"Plunging Into Plate!!")

If Response = 1 Then ' If OK
ZClear = Zplatetomaterial + ClearAllow ' Retract to .125in or 2mm above fixed plate
ElseIf Response = 2 Then ' If Cancel
'Reset Scale before E-Stop
Call SetOEMDRO(59,XScale)
Call SetOEMDRO(60,YScale)
Call SetOEMDRO(61,ZScale)
Sleep(250)
DoOEMButton(1021) ' Put Mach3 in Reset to end Tool Change
Exit Sub
End If
End If


Code "G0 Z" & ZClear 'Retract to Z Clearance Plane
While IsMoving ()
Wend

Code "G0 X" & GetVar(1) & " Y" & GetVar(2) ' Move to Previous Position prior to M6 being called

While IsMoving()
Wend

Code "F" & CurrentFeed ' Reset Feedrate

If GetOEMLED(801) Then 'ON = English Measure INCH
Code "(Z Axis is now Zeroed in Inches)" ' Puts this message in the status bar
Else 'OFF = Metric Measure MM
Code "(Z Axis is now Zeroed in mm's)" ' Puts this message in the status bar
End If

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)

If Not FileName() = "No File Loaded." Then
If GetOEMLED(1865) Then
MsgBox "Start Spindle, then press OK to Continue",48,"Start Spindle"

' g-code should have an M3 after the M6, so the following commented code is not required

'Else
'DoSpinCW()
'While IsMoving()
'Wend

End If
End If


End Sub  
              

These are the macro's included with the 2010 screensets.

It works fine for doing manual tool changes.  Mach3 encounters a m6 call, it will stop the spindle, move to the tool change position for a manual change, operator hits cycle start, then it checks tool height and continues on...

However, if I put in additional code that looks for certain tools - the ones I want to designate for the markers, then it will still wait for a cycle start entry.  It will still run the m6end macro.

I want it to operate like normal when it encounters any tool number other than the 3 I assign to the markers.  When it encounters those three, it will automatically set the correct marker and continue to run without any additional input from the user.

So, in short,
Markers -are automatic and do not require user input, will automatically change and complete their portion of the g-code file.
other tools (endmills...) will require a manual tool change - will require the use of cycle start to complete the user actions, before completing that tools portion of g-code.

Thanks,

Jason
« Last Edit: September 03, 2014, 03:38:47 PM by Daregone »
Re: Act sometimes
« Reply #9 on: September 03, 2014, 11:51:22 PM »
I think I am on the right track now. I set the general config to automatic. That removes the call to the m6end script. I then combined the two scripts together. I made the old m6end script into a subroutine in the m6start. Then I added a pop message box that prompts the user to change tools. This replaces the cycle start that is forced when you use "spindle stop and wait" option in general config.tool

Ok, all of that means..... I can now build in the conditions for markers to be automatic and still have normal tool change calls. Yay!

This is what I am currently playing with:

Code: [Select]
OldTool = GetCurrentTool()           'Get tool # That is in the spindle             
Tool = GetSelectedTool()             'Get Tool# of the New tool

If Tool <99 Then
If OldTool >99 Then
MsgBox ("Need to Dock and Retract") 'Add code to go to the aux z-axis dock and restract it.
End If
Code "G53 G0 X" & TCX & " Y" & TCY
While IsMoving()
Wend

MsgBox "CHANGE to TOOL  #" & tool &"    then press OK", 0, "Change Tool"
SetCurrentTool( tool )
Call End1()
Else

If OldTool <100 Then
MsgBox ("Need to Dock and lower") 'Add code to go to the aux z-axis dock and lower it.
End If



Select Case Tool
case 100
Message"Tool Changed to Black Marker" 'Will Run Code for Black Marker
Call End1() 'Calls old m6end macro - now a subroutine
case 101
Message"Tool Changed to Red Marker" 'Will Run Code for Red Marker
Call End1()  'Calls old m6end macro - now a subroutine
case 102
Message"Tool Changed to Blue Marker" 'Will Run Code for Blue Marker
Call End1() 'Calls old m6end macro - now a subroutine
End Select

 End If
SetCurrentTool( tool )