Here is an M6 for a 8 position Denford ATC, the kind that has a 3 input slot reader to code the position of the turret. Also, it has an output that turns on an output that runs the ATC forward at 24 volts, once it is at the correct tool position, the signal dies, and reley goes back to a 12 side that runs the turret backward and locks it, the 12 volt is always on unless moving forward for new tool.
This is from a request from a guy on the CNC zone that has this kind of set up.
Resources:
INPUTS1, 2 and 3 (sensors that read the slot pattern in the turret to code tool/slot number.
OUTPUT3 (this turns on the releay to flip over to the 24 volt opposite polarity side, to run the turret forward in a search for the next tool, it deactivates when the "3 digit" binary code from the inputs above match the Tool/slot for the new tool, it then reverses and locks into position
'M6Start.M1s
Sub Main()
NewTool = GetSelectedTool()
OldTool = GetCurrentTool()
MaxToolNum = 8 '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
While Slot <> NewTool
ActivateSignal(OUTPUT3) 'start rotating forward
If IsActive(INPUT3) And Not IsActive(INPUT2) And Not IsActive (INPUT1) Then
Slot = 1
End If
If Not IsActive(INPUT3) And Not IsActive(INPUT2) And Not IsActive (INPUT1) Then
Slot = 2
End If
If Not IsActive(INPUT3) And Not IsActive(INPUT2) And IsActive (INPUT1) Then
Slot = 3
End If
If IsActive(INPUT3) And Not IsActive(INPUT2) And IsActive(INPUT1) Then
Slot = 4
End If
If IsActive(INPUT3) And IsActive(INPUT2) And IsActive(INPUT1) Then
Slot = 5
End If
If Not IsActive(INPUT3) And IsActive(INPUT2) And IsActive(INPUT1) Then
Slot = 6
End If
If Not IsActive(INPUT3) And IsActive(INPUT2) And Not IsActive (INPUT1) Then
Slot = 7
End If
If IsActive(INPUT3) And IsActive(INPUT2) And Not IsActive(INPUT1) Then
Slot = 8
End If
Wend
Sleep(100)
DeActivateSignal(OUTPUT3) 'stop rotating forward, rotate backward now
End If
SetOEMDRO(824,NewTool)
Code "G4 P2" 'A pause time of 2 seconds to give your reverse turret time to seat
While IsMoving
Wend
End Sub
Main
'have fun,
'Scott