Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: brindle stephen on February 17, 2018, 01:45:55 PM

Title: macro for turret for boxford tcl
Post by: brindle stephen on February 17, 2018, 01:45:55 PM
hi i am not getting this macro thing at all i have a boxford 125 tcl with 8 turret tool changer how do you get it to work please help i have been trying for weeks now my email is stephen.brindle@icloud.com thanks any help would be great  ???
Title: Re: macro for turret for boxford tcl
Post by: TPS on February 18, 2018, 05:09:37 AM
hey thats a macro for a boxford 125 i have written some time ago for an other guy here.
sorry it is in german, but with a Little Google translator you should be able to understand it.

Code: [Select]

' TPS 29.01.2018 Version 1.0
' BOXFORD 125TCL
' 8 Positionen Werkzeugwechsler mit A-Achse

Sub Main()

  Dim newtool As Integer
  Dim acttool As Integer
  Dim grad_pro_tool As Integer
  Dim grad_nach_pin As Integer
  Dim grad_rueckwaerts as Integer
  Dim Anzahl_Takte As Integer
  Dim Dist_schnell As Double
  Dim F_fast As Integer
  Dim F_slow As Integer

If IsLoading() Then
'wenn ein neues File geladen wird nichts tun
' Exit Sub
Else

grad_pro_tool = 45 ' Distanz für einen Werkzeugschritt
grad_nach_pin = 10 ' freifahren Pin
grad_rueckwaerts = 25 ' zurückfahren an Pin
f_fast = 4000 ' Speed drehen schnell
f_slow = 2000 ' Speed rückwärts gegen Pin

newtool = GetSelectedTool() ' die neue Werkzeugnummer holen
acttool = GetCurrentTool() ' die aktuelle Werkzeugnummer holen

'lass uns ein paar Basic's checken

' neues und altes Werkzeug = 0
If ((newtool = 0) and (acttool = 0)) Then
message("neues und altes Werkzeug = 0 -> nicht's tun")
Sleep(500)
Exit Sub
End If

' neues Werkzeug = 0
If (newtool = 0) Then
message("neues Werkzeug = 0 -> nicht's tun")
Sleep(500)
Exit Sub
End If

' neues und altes Werkzeug sind gleich
If newtool = acttool Then
message("neues und altes Werkzeug sind gleich -> nicht's tun!")
Sleep(500)
Exit Sub
End If
 
  'Werkzeugnummer gültig ?
If  (((newtool > 8) Or (newtool < 1)) and (newtool <> 0)) Then
DoButton(3)
Sleep(500)
Message (" Werkzeugnummer " & newtool & " nicht im Bereich (1-8). Abbruch ! ")
Exit Sub
End If

'X-Achse nicht referenziert
If GetOEMLED(807) Then
DoButton(3)
Sleep(500)
Message ("X-Achse nicht referenziert -> Abbruch !!")
Exit Sub
End If

'Z-Achse nicht referenziert
If GetOEMLED(809) Then
DoButton(3)
Sleep(500)
Message ("Z-Achse nicht referenziert -> Abbruch !!")
Exit Sub
End If

'jetzt geht's los
Message "Werkzeugwechsel von: " +CStr(acttool) + " nach: " + CStr(newtool)

'Anzahl der Takte zwischen den Werkzeugen berechnen
If newtool > acttool Then Anzahl_Takte = newtool - acttool  
If newtool < acttool Then Anzahl_Takte = 8 - acttool+newtool
    
'Distantz in Schritte umrechnen
Dist_schnell = (Anzahl_Takte * grad_pro_tool) + grad_nach_pin

msgbox("Takte: " + cstr(Anzahl_Takte) + " Distanz schnell: " + Cstr(Dist_schnell))

Message "Wechsel X-Achse freifahren"
Code "G90 G53 G0 X2"
While IsMoving()
Sleep(15)
Wend

Message "Wechsel Z-Achse freifahren"
Code "G90 G53 G0 Z2"
While IsMoving()
Sleep(15)
Wend

'A-Achse nullen
Code "G92 A0"
'incremental Mode , Einheiten pro Minute , Exakter Stop
Code "G91 G94 G61"

'A-Achse plus schnell
Message "A-Achse plus schnell zum neuen Werkzeug"
Code "G01 A" & Dist_schnell & "F" & f_fast
While IsMoving()
Sleep(15)
Wend

'A-Achse langsam zurückfahren
Message "A-Achse zurueck langsam zum Pin"
Code "G01 A-" & grad_rueckwaerts &  "F" & f_slow
While IsMoving()
Sleep(15)
Wend

'neues Werkzeug im System anmelden
SetCurrentTool(newtool)

'wieder auf Absolutmodus schalten
Code "G90" ' back to absolute movement

Message ""
End If

End Sub              


Title: Re: macro for turret for boxford tcl
Post by: brindle stephen on February 20, 2018, 04:44:17 AM
Hi have you got it in English as google translate won’t do it thanks steve
Title: Re: macro for turret for boxford tcl
Post by: TPS on February 20, 2018, 05:27:27 AM
ok here we go, code with comments in english:

Code: [Select]

' TPS 29.01.2018 Version 1.0
' BOXFORD 125TCL
' 8 position ATC with A-Axis

Sub Main()

  Dim newtool As Integer
  Dim acttool As Integer
  Dim grad_pro_tool As Integer
  Dim grad_nach_pin As Integer
  Dim grad_rueckwaerts as Integer
  Dim Anzahl_Takte As Integer
  Dim Dist_schnell As Double
  Dim F_fast As Integer
  Dim F_slow As Integer

If IsLoading() Then
'do nothing during load GCode
' Exit Sub
Else

grad_pro_tool = 45 ' distance between TC places
grad_nach_pin = 10 ' overtravel pin
grad_rueckwaerts = 25 ' trafel back to pin
f_fast = 4000 ' Speed turn fast
f_slow = 2000 ' Speed slow reverse to pin

newtool = GetSelectedTool() ' get the actual tool number
acttool = GetCurrentTool() ' get the new tool number

'let's do some basic checks

' new tool and act tool = 0
If ((newtool = 0) and (acttool = 0)) Then
message("new and acttool = 0 -> do nothing")
Sleep(500)
Exit Sub
End If

' new tool = 0
If (newtool = 0) Then
message("new tool = 0 -> do nothing")
Sleep(500)
Exit Sub
End If

' new tool = act tool
If newtool = acttool Then
message("new tool = act tool -> do nothing")
Sleep(500)
Exit Sub
End If
 
  'check toolnumber ?
If  (((newtool > 8) Or (newtool < 1)) and (newtool <> 0)) Then
DoButton(3)
Sleep(500)
Message (" toolnumber " & newtool & " not in range (1-8). Abort ! ")
Exit Sub
End If

'X-Axis not in reference
If GetOEMLED(807) Then
DoButton(3)
Sleep(500)
Message ("X-Axis not referenced -> Abort !!")
Exit Sub
End If

'Z-Axis not in reference
If GetOEMLED(809) Then
DoButton(3)
Sleep(500)
Message ("Z-Axis not referenced -> Abort !!")
Exit Sub
End If

'let's do something
Message "change tool from: " +CStr(acttool) + " to: " + CStr(newtool)

'calculate number of tools between tools
If newtool > acttool Then Anzahl_Takte = newtool - acttool 
If newtool < acttool Then Anzahl_Takte = 8 - acttool+newtool
   
'number of tool to steps
Dist_schnell = (Anzahl_Takte * grad_pro_tool) + grad_nach_pin


Message "ATC X-Axis to TC position"
Code "G90 G53 G0 X2"
While IsMoving()
Sleep(15)
Wend

Message "ATC Z-Axis to TC position"
Code "G90 G53 G0 Z2"
While IsMoving()
Sleep(15)
Wend

'set A-Axis zero
Code "G92 A0"
'incremental Mode , units per Minute , Exact Stop
Code "G91 G94 G61"

'A-Axis  plus fast
Message "A-Axis plus fast to new tool"
Code "G01 A" & Dist_schnell & "F" & f_fast
While IsMoving()
Sleep(15)
Wend

'A-Axis slow back to pin
Message "A-Axis slow back to pin"
Code "G01 A-" & grad_rueckwaerts &  "F" & f_slow
While IsMoving()
Sleep(15)
Wend

'anounce new tool to system
SetCurrentTool(newtool)

'back to absolute mode
Code "G90" ' back to absolute movement

Message ""
End If

End Sub               


-put this code in your M6Start macro

-delete all code in M6End macro

-this code Needs A-axis for turn axis of TC

-this code requires that a G91 A360 makes exact one turn on TC

-X/Z axis must be referenced

-X-axis refpos = all way to the right side (away from spindle)

-Z-axis refpos = all way up (away from spindle)

Thomas



Title: Re: macro for turret for boxford tcl
Post by: brindle stephen on February 20, 2018, 05:29:59 AM
Ok will try thanks for your time
Title: Re: macro for turret for boxford tcl
Post by: TPS on February 20, 2018, 05:58:10 AM
Does this code control the spindle speed from Mach 3  for screw cutting thanks again

no it's only controling the toolchange, nothing else.
Title: Re: macro for turret for boxford tcl
Post by: brindle stephen on February 20, 2018, 02:47:22 PM
Hi can you tell me what steps per mm is on the a axis
How do you get g91 to 360 thanks steve
Title: Re: macro for turret for boxford tcl
Post by: brindle stephen on February 20, 2018, 03:39:38 PM
hi all working good thanks for all your help
do you no how to do the spindle speed through mach3
Title: Re: macro for turret for boxford tcl
Post by: brindle stephen on February 20, 2018, 05:38:24 PM
How do you home the a axis then or how do you reference your tool
Say you left it on tool 6
Next time you use it it would think tool 6 is the master tool (yes or no ) please advise
Title: Re: macro for turret for boxford tcl
Post by: TPS on February 21, 2018, 01:29:38 AM
the a axis Needs not to be homed, because it is only doing incremental moves.

to remember the tool (witch is in front when you shut down the machine),

Config -> General Config -> right down Corner ->Tool Selection Pesistent

or just enter the tool number in main Screen by Keyboard.


About your spindle Speed:
do you have some more Information how your spindle is connected to mach3 ?

Thomas
Title: Re: macro for turret for boxford tcl
Post by: glinner81 on November 22, 2022, 04:53:21 PM
hi sorry for resurrecting an old thread. (this is the closest i can find to my issue) i have a boxford 250 cnc with 8 position tool turret, running mach3. i cant for the life of me get the atc to work, i am a complete novice as you can tell. i copied the macros from this thread. but i have a couple of questions: to run the macro m3000 i have saved it into my macros folder. so when i type m3000 in the mdi line i get a pop up for tool number. i type 1 for tool 1 and the macro just says done but nothing happens...
also when i set up the fixtures and tool offsets for t0101 thats fine and then i type t0303 the atc moves anticlockwise and works ok but if then type t0101 again it tries to move clockwise against the locking pin and looses position etc..
any help most greatly appreciated. thanks folks
my screen is attached and set up for the atc with the a axis
Title: Re: macro for turret for boxford tcl
Post by: Graham Waterworth on November 22, 2022, 08:51:43 PM
The macro should be named M6Start.m1s and placed in the macro folder of the profile you are using (Mach3Turn) or what ever you are using.

You need to set the A axis motor tuning so that if you type G91 A45 it moves 1 tool position.

The number is going to be:- number of steps per rev of motor X ratio of worm and wheel of turret.

I think the one I set up years ago was the smaller type and it was set as whole steps (1:1) and it worked out at 360 steps per degree.

Title: Re: macro for turret for boxford tcl
Post by: glinner81 on November 23, 2022, 05:29:31 AM
The dro moves when I type g91 a45 but not the atc. However if I type g0 a45 it will move 45 degrees. But it will travel clockwise which is not good
Title: Re: macro for turret for boxford tcl
Post by: Graham Waterworth on November 23, 2022, 05:45:12 PM
OK, type G01 G91 A45 F250.

If it turns the wrong way you need to swap active hi/low on the A axis Dir Low Active in ports and pins.

Title: Re: macro for turret for boxford tcl
Post by: glinner81 on November 24, 2022, 04:29:02 PM
hi thanks again for reply, im at work so will try tomorrow. its weird coz only sometimes it goes clockwise and others anticlockwise.