'ToolChange Macro For Emco PC Tun 50 tool changer 2008-05-22 Bengt Sjölund'Macro code written by Henrik Olsson - Bengt SjölundSub Main()OldTool = GetOEMDRO (1200) 'Tool In spindle DRO You must add this to your settings screentool = GetSelectedTool()NewTool = tool'Tool Changer Macro (Turret Type)MaxToolNum = 6      'Max number off tools for the changerIf NewTool = OldTool Then Exit SubEnd IfWhile NewTool > MaxToolNumWendWhile IsMoving()WendCall SetUserDRO (1200,NewTool)SetCurrentTool( NewTool )Debounce = 10    	'msMinPulseWidth = 200    	'msMaxPulseWidth = 1650    'msIf NewTool = OldTool ThenEndEnd IfIf NewTool > OldTool Then  Steps = NewTool - OldTool		Else  Steps = MaxToolNum - OldTool + NewToolEnd IfSteps = Steps + 1i = 0					ActivateSignal(Output2)			CountPulses:  If IsActive(OEMtrig7) Then		  Sleep Debounce			    If IsActive(OEMtrig7) Then		   i = i + 1				      If i = Steps Then			    DeActivateSignal(Output2)		    End					   End If      Sleep MaxPulseWidth			  End IfEnd If  Sleep MinPulseWidth			GoTo CountPulses			End SubMain       