Here is my macro code that i have found here around on the forum for the tool changer
Sub Main()
NumSlots=6
OldTurretPos=(GetOEMDRO(803))
OldToolSlot=Abs(GetOEMDRO(803))
NextTool = GetSelectedTool()
NextToolSlot = (NextTool-1)*60
If OldToolSlot = NextToolSlot Then
SetCurrentTool(NextTool)
Exit Sub
End If
If NextTool>6 Or NextTool<1 Then
Message("Next Tool out of range")
Exit Sub
End If
MoveDis = (NextToolSlot-OldTurretPos)
 If Abs(MoveDis) <180 Then 
   If MoveDis > 0 Then     
     MoveDis = 360 + MoveDis     
   Else     
     MoveDis = MoveDis - 360   
   End If     
 End If 
 
ActivateSignal(OUTPUT3)  'Release Turret holding pin 
Code "G4 P0.5" 
While IsMoving ()       
Wend 
Code "G00 G91 a" & MoveDis        
While IsMoving ()       
Wend 
DeActivateSignal(OUTPUT3)  'Engage Turret holding pin      
SetCurrentTool(NextTool)
Code "G90"
End Sub  
But how i will make this macro to give a signal to my arduino to rotate the motor so the tool to be changed? 
My goal is whenever there is spotted in g-code this ---> M6 T*********x 
i want the spindle to stop rotating, 
then  my turret tool changer to move in a safe spot and 
then to trigger my arduino to rotate the motor at the specific tool 
and after all these have been done i want my TC to move back 
at the work station where it was and the spindle to start rotating again.
My thought was to connect the arduino through modBus. 
Then somehow , i guess through a brain, to check all the time the G-code 
and if M6 T*********x is spotted then M6start.m1s has to be triggered. 
I am thinking that all the above i want to be done will be in that macro 
and that macro i have found already it's not doing all these things i want.
			
			
			
				Hello Brett and thanks for your info! It seems that has a lot to be done!
Sooooo back to research once again! But thanks for giving me the path that i have to walk through!
Really helpfull and appreciated! I will be back again on here and i hope it will be for the results of my project!
Thanks once again Brett!
Constantine