Hello Guest it is March 29, 2024, 07:51:29 AM

Author Topic: 4 Way Lathe ATC Macro  (Read 2715 times)

0 Members and 1 Guest are viewing this topic.

4 Way Lathe ATC Macro
« on: August 13, 2018, 03:44:47 PM »
I'm in the process of needing to make some changes to my M6ATC start macro. the changes that are needed are when the G-code program calls for a new tool my automatic tool changer once in a while skips the tool change (unknown why) then tool no longer matches the programmed tool. I need the macro to trigger the Mach3's reset button to keep the tool change from completing or the machine from continuing with the wrong tool.
Below are some of my attempted edits. It works but Mach's reset button is always triggered even when the tool changer changed tools correctly
the tool changer is controlled through a ADC click PLC using serial modbus and brains. I have created two dro's on a screen to compare the tool that the PLC/ATC is on and the tool that the G-code called

Here is a youtube video of the lathe with tool changer https://www.youtube.com/watch?v=xyirJ8cPgQo
I will post a screen shot of the tool change page later

**********I make no clime to have any knowledge about VB scripting or syntax so please accept my apologies before reading on.**********

Sub main()

Const maxtoolnum = 4

Dim newtoolNumber As Integer
Dim oldtoolNumber As Integer
Dim NewtoolDro As Integer
Dim TurretTool As Integer
Dim XTCpos As Double
Dim ZTCpos As Double
Dim BTCpos As Double
Dim Input4 As Integer

XTCpos = GetoemDRO (1817)
ZTCpos = GetOemDRO (1819)
BTCpos = GetOemDRO (2017)
newtoolnumber = (getselectedtool)
setOemdro(2000,newtoolnumber)
oldtoolNumber = getoemdro(824)
TurretTool = getoemdro(2001)



If newtoolNumber > maxtoolnum Then
MsgBox "Tool number Range is 1-4 Check tool number "

Exit Sub
main
End If
If newtoolNumber = TurretTool Then
Exit Sub
main
End If
Code "G53 G90 G40 G00 B" & BTCpos
Code "g53 g90 G40 G00 X" & XTCpos
Code "G53 G90 G40 G00 Z" & ZTCpos

While IsMoving()
Sleep 50
Wend
Sleep 5000



If newtoolNumber <> TurretTool Then
DoOEMButton( MachResetOEMBtn )

Exit Sub
Main


'MsgBox ("newtool = " & GetSelectedTool)
'MsgBox ("oldtool = " & oldtool )
'MsgBox ("dro 2000 = " & getoemdro (2000) )
'End If
End Sub
Main
Adam

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: 4 Way Lathe ATC Macro
« Reply #1 on: August 14, 2018, 08:53:33 AM »
Looks like you whant to wait until PLC has changed tool, and reports it in OEMDro(2001) ?

if so you have to use something like this




While newtoolNumber <> TurretTool
    TurretTool = getoemdro(2001)
    Sleep(100)

WEND
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
8 Way Lathe ATC Macro
« Reply #2 on: March 30, 2019, 02:59:07 PM »
hola. estoy por comenzar la macro para un cnc emco pc turn 120 y controlar la torreta de las herramientas con un plc, esta parte ya funciona y solo me falta eso, alguna sugerencia? puedes ver mis avances aqui:

https://youtu.be/j8amCPtNk1g

https://youtu.be/ENoZRBLiYvs


Google Translate:-

Hi. I'm about to start the macro for a cnc emco pc turn 120 and control the turret of the tools with a plc, this part already works and I just need that, any suggestions? You can see my progress here:_

https://youtu.be/j8amCPtNk1g

https://youtu.be/ENoZRBLiYvs

« Last Edit: March 31, 2019, 01:59:27 AM by Tweakie.CNC »