Marek,
Ok, here you go. You will need to Enable "Outputs" 1-4 in mach3, if you are already
using those, just pick other outputs and change them below. there are 20 outputs for
your use.
'==========================================================
'M6Start.m1s
Sub Main()
NewTool = GetSelectedTool()
OldTool = GetCurrentTool()
MaxToolNum = 4 'Max number of tools for the changer
While NewTool > MaxToolNum
NewTool = Question ("Enter New Tool Number up to " & MaxToolNum)
Wend
If NewTool = OldTool Or NewTool = 0 Then
Exit Sub
End If
If OldTool <> NewTool Then
'This section of code will turn on the correct tool number output to the input
'you need on the PLC.
If (NewTool = 1) Then
ActivateSignal(OUTPUT1) 'this output goes from Mach to your PLC input 1
End If
If (NewTool = 2) Then
ActivateSignal(OUTPUT2) 'this output goes from Mach to your PLC input 2
End If
If (NewTool = 3) Then
ActivateSignal(OUTPUT3) 'this output goes from Mach to your PLC input 3
End If
If (NewTool = 4) Then
ActivateSignal(OUTPUT4) 'this output goes from Mach to your PLC input 4
End If
End If
SetOEMDRO(824,NewTool)
Code "G4 P4" 'A pause time of 4 seconds to give your turret time to index
While IsMoving
Wend
'This section of code Turns the Output from Mach off after your turret
'has indexed to the new position.
If (NewTool = 1) Then
DeActivateSignal(OUTPUT1) 'this output goes from Mach to your PLC input 1
End If
If (NewTool = 2) Then
DeActivateSignal(OUTPUT2) 'this output goes from Mach to your PLC input 2
End If
If (NewTool = 3) Then
DeActivateSignal(OUTPUT3) 'this output goes from Mach to your PLC input 3
End If
If (NewTool = 4) Then
DeActivateSignal(OUTPUT4) 'this output goes from Mach to your PLC input 4
End If
End Sub
Main
'have fun,
'Scott


LinkBack URL
About LinkBacks





