Well its been a while since I updated, I managed to blow up the breakout board so I had to fit some new chips anyway...

I have made some adjustments to the program to suit the Mirac the way I have it set up. So in Mach3 when the code
T0101 M6 Appears this is saying T offset, toolnumber then M6 is tool change macro

Heres the macro:

Dim Tool As Integer
Dim OldTool As Integer
Dim NewTool As Integer
Dim MaxToolNum As Integer

MaxToolNum = 8 'Maximum positions on Automatic Tool Changer
Tool = GetSelectedTool() 'Get the toolnumber from the command e.g T0101 M6 Tool number 1
OldTool = GetCurrentTool() 'Get current tool number


Call StartToolChanger

While NewTool <> Tool
Call CheckPins
Wend

Call StopTool

SetCurrentTool(NewTool)

'//// Subroutines /////////

Sub StartToolChanger
ActivateSignal(Output3) 'Turn on output signal to turn off spindle and turn on the atc
ActivateSignal(Output4) 'Turn atc forward
End Sub


Sub CheckPins
If IsActive(Input3) And Not IsActive(Input2) And Not IsActive(Input1) Then
NewTool = 1
End If
If Not IsActive(Input3) And Not IsActive(Input2) And Not IsActive(Input1) Then
NewTool = 2
End If
If Not IsActive(Input3) And Not IsActive(Input2) And IsActive(Input1) Then
NewTool = 3
End If
If IsActive(Input3) And Not IsActive(Input2) And IsActive(Input1)Then
NewTool = 4
End If
If IsActive(Input3) And IsActive(Input2) And IsActive(Input1) Then
NewTool = 5
End If
If Not IsActive(Input3) And IsActive(Input2) And IsActive(Input1)Then
NewTool = 6
End If
If Not IsActive(Input3) And IsActive(Input2) And Not IsActive(Input1) Then
NewTool = 7
End If
If IsActive(Input3) And IsActive(Input2) And Not IsActive(Input1) Then
NewTool = 8
End If
End Sub

Sub Stoptool
DeActivateSignal(Output4) ' Stop running the ATC forward, if you don't do this the inverter will stop and the whole unit
' Will need to be turned off and on again
ActivateSignal(Output5) 'Run ATC in reverse
Sleep 3000 'Wait 3 seconds to allow the toolpost to lock in
DeActivateSignal(Output5) 'Stop running ATC in reverse
DeActivateSignal(Output3) 'Turn off output to turn spindle back on
End Sub

I've yet to test it but it works fine in VBscript. Should have a chance to test it tommorow.

The outputs corrospond to the following:

Output 3 is the ATC power contactor and Spindle Power Contactor, the Spindle Power contactor is wired to the normally closed side of the relay and and ATC power contactor is wired to the normally open side of the relay

Output 4 is the ATC Forward Relay

Output 5 is the ATC Reverse Relay