Thanks Hood, I am going to do testing with the following tool change macro-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'Toolchange Macro for Mach3 and Hardinge CHNC 8 station turret.
'June 20th 2011 (based upon Macros from Hood and Fdos & possibly others)
Tool = GetSelectedTool()
If Tool = GetCurrentTool() Then 'Ignore and Exit if already there
End
End If
If Tool <1 Then 'If tool called is < 1
MsgBox ("Error! Tool "& tool & " Out Of Range") 'error message
DoOemButton (1003) 'Stop Button
End 'End macro
End If
If Tool >8 Then 'If tool called is > 8
MsgBox ("Error! Tool "& tool & " Out Of Range")
DoOemButton (1003)
End
End If
Message ("Waiting for Turret Station " & tool)
If Tool=1 Then 'tool = 1
Call SetModOutput (66,1) 'Reg D12
Do
If GetInput (67) = tool Then 'Reg D13
Call SetModOutput (66,0) 'Reset D12
Exit Do
End If
Loop
End If
If Tool=2 Then 'tool = 2
Call SetModOutput (66,2)
Do
If GetInput (67) = tool Then
Call SetModOutput (66,0)
Exit Do
End If
Loop
End If
If Tool=3 Then 'tool = 3
Call SetModOutput (66,3)
Do
If GetInput (67) = tool Then
Call SetModOutput (66,0)
Exit Do
End If
Loop
End If
If Tool=4 Then 'tool = 4
Call SetModOutput (66,4)
Do
If GetInput (67) = tool Then
Call SetModOutput (66,0)
Exit Do
End If
Loop
End If
If Tool=5 Then 'tool = 5
Call SetModOutput (66,1)
Do
If GetInput (67) = tool Then
Call SetModOutput (66,0)
Exit Do
End If
Loop
End If
If Tool=6 Then 'tool = 6
Call SetModOutput (66,2)
Do
If GetInput (67) = tool Then
Call SetModOutput (66,0)
Exit Do
End If
Loop
End If
If Tool=7 Then 'tool = 7
Call SetModOutput (66,3)
Do
If GetInput (67) = tool Then
Call SetModOutput (66,0)
Exit Do
End If
Loop
End If
If Tool=8 Then 'tool = 8
Call SetModOutput (66,4)
Do
If GetInput (67) = tool Then
Call SetModOutput (66,0)
Exit Do
End If
Loop
End If
Message ("Station " & tool & " OK") 'Status Msg
SetCurrentTool( tool )
End
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I have the above saved as M6Start.m1s in my mach3/lathe/macro folder. I know that the macro runs because I get a "Waiting for turret X" message when I manually enter in a toolchange like T0101.
Now that I have Modbus communication, the next step is to figure out how Fdos acomplished the following-
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
For anyone thats interested here's the M6Start macro for the 4 station turret on my Hardinge.
It passes the requested station # to the Cubloc PLC via a holding register mapped to 66 in mach and D12 on the Cubloc.
The Cubloc always has it's actual station # available in D13 (67 in Mach) via it's turret encoder routine. = 0 when invalid = 1 to 4 for valid stations.
I'll probably post the Cubloc program when it's developed a bit more.
The Macro below is partially based on Hoods Churchill Macro. Thanks Robin...
Wayne.....
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
*********, I'm lost...