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

0 Members and 1 Guest are viewing this topic.

Offline Cncman2nv

  • Active Member
  • Posts: 90
    • View Profile
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
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)
oldtoolNumber = getoemdro(824)
TurretTool = getoemdro(2001)

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

Exit Sub
End If
If newtoolNumber = TurretTool Then
Exit Sub
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
Sleep 5000

If newtoolNumber <> TurretTool Then
DoOEMButton( MachResetOEMBtn )

Exit Sub

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

Offline TPS

  • Active Member
  • Posts: 1,119
    • 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)

anything is possible, just try it.
if you find some mistakes, in my bad bavarian english,they are yours.