Hello Guest it is April 28, 2024, 06:58:25 PM

Author Topic: ATC FOR CINCINNATI MILL  (Read 2838 times)

0 Members and 1 Guest are viewing this topic.

ATC FOR CINCINNATI MILL
« on: January 19, 2022, 11:11:08 PM »
HI I NEED SOME HELP WITH THIS ATC CODE
THE CODE WILL PULL THE OLD TOOL OUT OF THE SPINDLE AND WILL PUT ANOTHER TOOL IN FROM
THE CAROUSEL BUT IT REALY DONT KNOW HOW MUCH TO TURN THE CAROUSEL CW OR CCW SO REALLY IM TRYING TO INSERT A PEASE OF CODE INTO MINE




 
Re: ATC FOR CINCINNATI MILL
« Reply #1 on: January 20, 2022, 09:48:36 PM »
I TESTED THIS TODAY AND IT TURN CW OR CCW DEPENDING ON TOOL# BUT IT WILL ONLY DO ONE SLOT

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: ATC FOR CINCINNATI MILL
« Reply #2 on: January 21, 2022, 04:31:12 AM »
try this
Code: [Select]
''Sequence to determine the least travel to move for TC, CW or CCW
'atp = Actual tool position, rtp = Requested tool positon
'Sub LeastTravel()
NewTool = GetSelectedTool()
OldTool = GetCurrentTool()

NewTool = 10
OldTool = 12


NTool =24 ' Number of tools changer holds
CWPos = NewTool - OldTool ' Assume a CW move
If CWPos < 0 Then ' CWPos < 0 ==> rtp < atp
CWPos = CWPos + NTool
End If
CCWPos = NTool - CWPos
If CWPos < CCWPos Then
Call CW(CWPos)
Else
Call CCW(CCWPos)
End If
'End Sub

Function CW(ByVal Pos As Integer)'Rotation CW
   Dim x As Integer

   ActivateSignal(OUTPUT16)'UnLock Pin
   While IsActive(OEMTRIG12)
   Wend
   ActivateSignal(OUTPUT15)'Turns Carousel CW
   For x=1 To Pos
While IsActive(OEMTRIG11)
Sleep(50)
Wend
While Not IsActive(OEMTRIG11)
Sleep(50)
Wend
Next x
    CTPos=x
DeactivateSignal(OUTPUT15)
Deactivatesignal(OUTPUT16)
End Function

Function CCW(ByVal Pos as Integer)'Rotation CCW
Dim y As Integer
ActivateSignal(Output16)'UnLock Pin
While IsActive (OEMTRIG12)
Wend
Activatesignal(OUTPUT14)'Turn Carousel CCW
For y=1 To Pos
While IsActive(OEMTRIG11)
Sleep(50)
Wend
While Not IsActive(OEMTRIG11)
Sleep(50)
Wend
Next y
DeactivateSignal(OUTPUT14)
Deactivatesignal(OUTPUT16)
End Function
 



anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: ATC FOR CINCINNATI MILL
« Reply #3 on: January 21, 2022, 11:34:42 AM »
THANKS AGAIN THAT WAS REALY GOOD I DID SOME CHANGES AND IT LOOKS LIKE IS COUNTING BUT IT WILL GO FROM TOOL#1 TO TOOL#9 IF I CALL #8 SO IT IS COUNTING 8 POS

I STILL NEED TO SET RIGHT SLEEP() BEFORE DEACTIVATESIGNAL(14) AND (15) BECAUSE THE PICKTAIL WHERE WE GETTING THE (OEMTRIG11) IS ON THE HYDROMOTOR SHAFT AND IS GOT
45 DEGREES OFF ON BOTH DIRECTIONS BEFORE IT GOES ON FOR 270 DEGREES AND THEN OFF
FOR 45 DEGREES TO THE PERFECT SLOT AND LOCKING PIN POS BUT I THINK IT COULD BE ADJUSTED
LATER


 ''''Sequence to determine the least travel to move for TC, CW or CCW
'atp = Actual tool position, rtp = Requested tool positon
'Sub LeastTravel()
   NewTool = GetSelectedTool()
   OldTool = GetCurrentTool()
   
   'NewTool = 10
   'OldTool = 12
   
   
   NTool =24 ' Number of tools changer holds
   CWPos = NewTool - OldTool ' Assume a CW move
   If CWPos < 0 Then ' CWPos < 0 ==> rtp < atp
      CWPos = CWPos + NTool
   End If
   CCWPos = NTool - CWPos
   If CWPos < CCWPos Then
      Call CW(CWPos)
   Else
      Call CCW(CCWPos)
   End If
'End Sub

Function CW(ByVal Pos As Integer)'Rotation CW
   Dim x As Integer

   ActivateSignal(OUTPUT16)'UnLock Pin
   While IsActive(OEMTRIG12)
   Wend
   ActivateSignal(OUTPUT15)'Turns Carousel CW
   For x=1 To Pos
      While IsActive(OEMTRIG11)
         Sleep(50)
      Wend
      While Not IsActive(OEMTRIG11)
         Sleep(150)
      Wend
   Next x
    CTPos=x
   DeactivateSignal(OUTPUT15)
   Deactivatesignal(OUTPUT16)
   SetCurrenttool(NewTool)
End Function

Function CCW(ByVal Pos as Integer)'Rotation CCW
   Dim y As Integer
   ActivateSignal(Output16)'UnLock Pin
   While IsActive (OEMTRIG12)
   Wend
   Activatesignal(OUTPUT14)'Turn Carousel CCW
   For y=1 To Pos
      While IsActive(OEMTRIG11)
         Sleep(50)
      Wend
      While Not IsActive(OEMTRIG11)
         Sleep(150)
      Wend
   Next y
   DeactivateSignal(OUTPUT14)
   Deactivatesignal(OUTPUT16)
   SetCurrentTool(NewTool)
End Function

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: ATC FOR CINCINNATI MILL
« Reply #4 on: January 21, 2022, 11:45:30 AM »
is OEMTRIGGER(11) on or off if the carousel is in position for locking?
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: ATC FOR CINCINNATI MILL
« Reply #5 on: January 21, 2022, 01:00:28 PM »
on your youtube video it looks like the lock pin is retracted earlier so the carousel will "snap in" if it reaches
final position.
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: ATC FOR CINCINNATI MILL
« Reply #6 on: January 21, 2022, 04:58:40 PM »
WELL IS WORKING GOOD THANKS SO MUCH SO HAPPY
NOW IM GOING TO TRY INSERTING THE TOOL ARM CODE TO THIS ONE



'''''Sequence to determine the least travel to move for TC, CW or CCW
'atp = Actual tool position, rtp = Requested tool positon
'Sub LeastTravel()
   NewTool = GetSelectedTool()
   OldTool = GetCurrentTool()
   

   NTool =24 ' Number of tools changer holds
   CWPos = NewTool - OldTool ' Assume a CW move
   If CWPos < 0 Then ' CWPos < 0 ==> rtp < atp
      CWPos = CWPos + NTool
   End If
   CCWPos = NTool - CWPos
   If CWPos < CCWPos Then
      Call CW(CWPos)
   Else
      Call CCW(CCWPos)
   End If
'End Sub

Function CW(ByVal Pos As Integer)'Rotation CW
   Dim x As Integer

   ActivateSignal(OUTPUT16)'UnLock Pin
   While IsActive(OEMTRIG12)
   Sleep (200)
   Wend
   ActivateSignal(OUTPUT15)'Turns Carousel CW
   For x=1 To Pos
      'While IsActive(OEMTRIG11)
         Sleep(500)
      'Wend
      While IsActive(OEMTRIG11)
         'Sleep(10)
      Wend
   Next x
    CTPos=x
   DeactivateSignal(OUTPUT16)
   Deactivatesignal(OUTPUT15)
   SetCurrenttool(NewTool)
   SetUserDro(1220,NewTool)
   'SetUserDro(1224,NewTool)
End Function

Function CCW(ByVal Pos as Integer)'Rotation CCW
   Dim y As Integer
   ActivateSignal(Output16)'UnLock Pin
   While IsActive (OEMTRIG12)
   Sleep (200)
   Wend
   Activatesignal(OUTPUT14)'Turn Carousel CCW
   For y=1 To Pos
      'While IsActive(OEMTRIG11)
         Sleep(500)
      'Wend
      While IsActive(OEMTRIG11)
         'Sleep(10)
      Wend
   Next y
      CTPos=y
   DeactivateSignal(OUTPUT16)
   Deactivatesignal(OUTPUT14)
   SetCurrentTool(NewTool)
   SetUserDro(1220,NewTool)
   'SetUserDro(1224,NewTool)
End Function
 
Re: ATC FOR CINCINNATI MILL
« Reply #7 on: January 21, 2022, 05:10:29 PM »
WHEN THE YOU DEACTIVATESIGNAL(OUTPUT16) THE PIN LOCKS THE CAROUSEL JUST A MOMENT BEFORE THAT THE CW OR CCW HYDROMOTOR HAS TO BE OFF, THE PIN HAS SOME KIND OF CAM
THAT WILL CENTER IT IN THE SLOT SO THERE IS ROOM FOR MISTAKE ON THE TIMING THAT IS WHY ON THE VIDEO LOOKS LIKE IT WAS GOING TO KEEP TURNING AND CAME BACK IN PLACE
 
IM SO THANKFULL FOR WHAT YOU DONE
Re: ATC FOR CINCINNATI MILL
« Reply #8 on: January 21, 2022, 05:46:29 PM »
FOR NOW IM GOING TO TRY THIS WITHOUT LOOKING AT THE DROS ON THE CAROUSEL



    'CINCINNATI-750 MACH3 CNC SOFTWARE RETROFIT
   
   Dim OLDTOOL,NewTool,Slot,HomeSensor,Count As Integer
   
  OldTool=GetCurrentTool()
  NewTool=GetSelectedTool()
  Slot=GetUserDro(1220)
 
  HomeSensor=(GetOEMTRIG10)
  Count=(GetOEMTRIG11)
 
 
  TIS1=GETOEMDRO(1201)       'TOOL IN SLOT
  TIS2=GetOemDro(1202)
  TIS3=GetOemDro(1203)
  TIS4=GetOemDro(1204)
  TIS5=GetOemDro(1205)
  TIS6=GetOemDro(1206)
  TIS7=GetOemDro(1207)
  TIS8=GetOemDro(1208)
  TIS9=GetOemDro(1209)
  TIS10=GetOemDro(1210)
  TIS11=GetOemDro(1211)
  TIS12=GetOemDro(1212)
  TIS13=GetOemDro(1213)
  TIS14=GetOemDro(1214)
  TIS15=GetOemDro(1215)
  TIS16=GetOemDro(1216)
  TIS17=GetOemDro(1217)
  TIS18=GetOemDro(1218)
  TIS19=GetOemDro(1219)
  TIS20=GetOemDro(1230)
  TIS21=GetOemDro(1231)
  TIS22=GetOemDro(1232)
  TIS23=GetOemDro(1233)
  TIS24=GetOemDro(1234)
 
 
 
   If NewTool=OldTool Then
     MsgBox "SAME TOOL"
       Exit Sub
   
   
 

   End If
  If NewTool=TIS1 Or NewTool=TIS2 Or NewTool=TIS3 Or NewTool=TIS4 Or NewTool=TIS5 Or NewTool=TIS6 _
  Or NewTool=TIS7 Or NewTool=TIS8 Or NewTool=TIS9 Or NewTool=TIS10 Or NewTool=TIS11 Or NewTool=TIS12 _
  Or NewTool=TIS13 Or NewTool=TIS14 Or NewTool=TIS15 Or NewTool=TIS16 Or Newtool=TIS17 Or NewTool=TIS18 _
  Or NewTool=TIS19 Or NewTool=TIS20 Or NewTool=TIS21 Or NewTool=TIS22 Or NewTool=TIS23 Or NewTool=TIS24 Then 
   
   

    CODE "M19"
    GoToSafeZ()
  While IsMoving
  Wend
   Message "TOOL IN CAROUSEL"
  ActivateSignal (Output13)'move tool arm to spindle on
  While IsActive (OEMTRIG9)=0
  Sleep (300)
  Wend
 DeActivateSignal (Output13)'move tool arm to spindle off
 ActivateSignal (Output9)'extend tool arm
 While IsActive (OEMTRIG3)=0
 Sleep (300)
 Wend
 ActivateSignal (Output11)'PBD unlock
 While IsActive (OEMTRIG7)=0
 Sleep (300)
 Wend
 Code "M7"
 ActivateSignal (Output10)'tool arm down
 While IsActive (OEMTRIG5)=0
 Sleep (300)
 Wend
 ActivateSignal (Output12)'move tool arm to carousel on
 While IsActive (OEMTRIG8)=0
 Sleep (300)
 Wend
 Code "M9"
 DeActivateSignal (Output10)'tool arm up
 While IsActive (OEMTRIG4)=0
 Sleep (1000)
 Wend
 DeActivatesignal (Output9)'tool arm retract
 DeActivateSignal (Output12)'move tool arm to carousel off
 DeActivateSignal (Output11)'PBD lock
  Message "Spindle Is Empty"
  SetUserDro(1224,0)
  Sleep (2000)
 
'''''Sequence to determine the least travel to move for TC, CW or CCW
'atp = Actual tool position, rtp = Requested tool positon
'Sub LeastTravel()
   NewTool = GetSelectedTool()
   OldTool = GetCurrentTool()
   

   NTool =24 ' Number of tools changer holds
   CWPos = NewTool - OldTool ' Assume a CW move
   If CWPos < 0 Then ' CWPos < 0 ==> rtp < atp
      CWPos = CWPos + NTool
   End If
   CCWPos = NTool - CWPos
   If CWPos < CCWPos Then
      Call CW(CWPos)
   Else
      Call CCW(CCWPos)
   End If
'End Sub

Function CW(ByVal Pos As Integer)'Rotation CW
   Dim x As Integer

   ActivateSignal(OUTPUT16)'UnLock Pin
   While IsActive(OEMTRIG12)
   Sleep (200)
   Wend
   ActivateSignal(OUTPUT15)'Turns Carousel CW
   For x=1 To Pos
      'While IsActive(OEMTRIG11)
         Sleep(500)
      'Wend
      While IsActive(OEMTRIG11)
         'Sleep(10)
      Wend
   Next x
    CTPos=x
   DeactivateSignal(OUTPUT16)
   Deactivatesignal(OUTPUT15)
   SetCurrenttool(NewTool)
   SetUserDro(1220,NewTool)
   'SetUserDro(1224,NewTool)
End Function

Function CCW(ByVal Pos as Integer)'Rotation CCW
   Dim y As Integer
   ActivateSignal(Output16)'UnLock Pin
   While IsActive (OEMTRIG12)
   Sleep (200)
   Wend
   Activatesignal(OUTPUT14)'Turn Carousel CCW
   For y=1 To Pos
      'While IsActive(OEMTRIG11)
         Sleep(500)
      'Wend
      While IsActive(OEMTRIG11)
         'Sleep(10)
      Wend
   Next y
      CTPos=y
   DeactivateSignal(OUTPUT16)
   Deactivatesignal(OUTPUT14)
   SetCurrentTool(NewTool)
   SetUserDro(1220,NewTool)
   'SetUserDro(1224,NewTool)
End Function
 
 
 
   
   ActivateSignal(Output9)
   While IsActive(OEMTRIG3)=0
   Sleep (300)
   Wend
   ActivateSignal(Output10)
   While IsActive(OEMTRIG5)=0
   Sleep (300)
   Wend
   ActivateSignal(Output13)
   While IsActive(OEMTRIG9)=0
   Sleep (300)
   Wend
   Code "M7"
   ActivateSignal(Output11)
   While IsActive(OEMTRIG7)=0
   Sleep (300)
   Wend
   DeActivateSignal(Output10)
   While IsActive(OEMTRIG4)=0
   Sleep (500)
   Wend
   Code "M9"
   DeActivateSignal(Output11)
   While IsActive(OEMTRIG6)=0
   Sleep (500)
   Wend
   DeActivateSignal(Output9)
   While IsActive(OEMTRIG3) = 1
   Sleep (2000)
   Wend
   DeActivateSignal(Output13)
   Sleep (1000)
   ActivateSignal(Output12)
   While IsActive(OEMTRIG8)=0
   Wend
   DeActivateSignal(Output12)

   
   
   End If
 
  SetUserDro(1224,NewTool)
  SetUserDro(1220,NewTool)
  SetCurrentTool(NewTool)
  DeActivateSignal(Output17)
  While IsMoving
  Wend
  Exit Sub
 
  'End If
  'If NewTool<>Slot Then
  'CODE "M19"
  'While IsMoving
  'Wend
  'MsgBox "TOOL NOT IN CAROUSEL"
 
  'End If
 
  'SetUserDro(1224,NewTool)
  'SetCurrentTool(NewTool)
  'DeActivateSignal(Output17)
  'While IsMoving
  ''Wend
  'Exit Sub
 
 
 
 
 
 
 End
 
 
 

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: ATC FOR CINCINNATI MILL
« Reply #9 on: January 22, 2022, 04:18:49 AM »
the final macro will have to do a couplr more things. did some changes to your code witch might go into right direction. pls use the CODE tab's to post code to keep the formating and keep it readable


Code: [Select]
'CINCINNATI-750 MACH3 CNC SOFTWARE RETROFIT
   

'------------------------------------------------------------------------------------------------------------
Dim acttool As Integer
Dim newtool As Integer
Dim Slot As Integer 'Slot is OEMDRO(1220) this will keep position of carousel
Dim HomeSensor As Integer
Dim Count As Integer
Const MaxTool = 24 'MaxTool number
'------------------------------------------------------------------------------------------------------------

Sub Main()
   
Slot=GetOEMDro(1220)
 
HomeSensor=(GetOEMTRIG10)
Count=(GetOEMTRIG11)
 
'let's do some basic check's
'Get the new ATC Pos
newtool = GetSelectedTool() ' get the newtool
acttool = GetCurrentTool() ' get the acttool
Message "New ATC Position = " &newtool
Sleep(200)

' new and acttool = 0
If ((newtool = 0) and (acttool = 0)) Then
DoButton(1003)
message("new and old tool = 0 -> abort toolchange  !")
Sleep(500)
Exit Sub
End If

' new and acttool are the same
If newtool = acttool Then
message("acttool and newtool are the same -> do nothing!")
Sleep(500)
Exit Sub
End If
 
'check toolnumber in range
If  (((newtool > MaxTool) Or (newtool < 1)) And (newtool <> 0)) Then
DoButton(1003)
Message (" toolnumber " & newtool & " is not in range (1-" &MaxTool &"). abort toolchange  ! ")
MsgBox  (" toolnumber " & newtool & " is not in range (1-" &MaxTool &"). abort toolchange  ! ")
Exit Sub
End If

 
  TIS1=GETOEMDRO(1201)       'TOOL IN SLOT
  TIS2=GetOemDro(1202)
  TIS3=GetOemDro(1203)
  TIS4=GetOemDro(1204)
  TIS5=GetOemDro(1205)
  TIS6=GetOemDro(1206)
  TIS7=GetOemDro(1207)
  TIS8=GetOemDro(1208)
  TIS9=GetOemDro(1209)
  TIS10=GetOemDro(1210)
  TIS11=GetOemDro(1211)
  TIS12=GetOemDro(1212)
  TIS13=GetOemDro(1213)
  TIS14=GetOemDro(1214)
  TIS15=GetOemDro(1215)
  TIS16=GetOemDro(1216)
  TIS17=GetOemDro(1217)
  TIS18=GetOemDro(1218)
  TIS19=GetOemDro(1219)
  TIS20=GetOemDro(1230)
  TIS21=GetOemDro(1231)
  TIS22=GetOemDro(1232)
  TIS23=GetOemDro(1233)
  TIS24=GetOemDro(1234)
 
If NewTool=TIS1 Or NewTool=TIS2 Or NewTool=TIS3 Or NewTool=TIS4 Or NewTool=TIS5 Or NewTool=TIS6 _
Or NewTool=TIS7 Or NewTool=TIS8 Or NewTool=TIS9 Or NewTool=TIS10 Or NewTool=TIS11 Or NewTool=TIS12 _
Or NewTool=TIS13 Or NewTool=TIS14 Or NewTool=TIS15 Or NewTool=TIS16 Or Newtool=TIS17 Or NewTool=TIS18 _
Or NewTool=TIS19 Or NewTool=TIS20 Or NewTool=TIS21 Or NewTool=TIS22 Or NewTool=TIS23 Or NewTool=TIS24 Then
   
CODE "M19"
GoToSafeZ()
While IsMoving
Wend
Message "TOOL IN CAROUSEL"

'only unload tool
If newtool = 0 Then
'turn carousel if not in Position
If newtool <> Slot Then
LeastTravel(newtool)
SetOEMDro(1220,newtool)
End if
'now unload tool
UnloadSpindle
End If

'only load tool
If acttool = 0 Then
'turn carousel if not in Position
If acttool <> Slot Then
LeastTravel(Slot)
SetOEMDro(1220,Slot)
End if
'now load tool
LoadSpindle
End If

'full tool change
If ((acttool <> 0) And (newtool <> 0)) Then
'unload tool
'turn carousel if not in Position
If newtool <> Slot Then
LeastTravel(newtool)
SetOEMDro(1220,newtool)
End if
'now unload tool
UnloadSpindle
'load tool
'turn carousel if not in Position
If acttool <> Slot Then
LeastTravel(Slot)
SetOEMDro(1220,Slot)
End if
'now load tool
LoadSpindle
End If

SetUserDro(1224,newtool)
SetCurrentTool(newtool)
Code "G43H" & newtool
DeActivateSignal(Output17)
While IsMoving
Wend


End If
 
End Sub

'''''Sequence to determine the least travel to move for TC, CW or CCW
'atp = Actual tool position, rtp = Requested tool positon
Function LeastTravel(ByVal ATCPos As Integer)

   NewPos = ATCPos
   OldPos = GetOEMDro(1220)
   

   NTool =24 ' Number of tools changer holds
   CWPos = NewPos - OldPos ' Assume a CW move
   If CWPos < 0 Then ' CWPos < 0 ==> rtp < atp
      CWPos = CWPos + NTool
   End If
   CCWPos = NTool - CWPos
   If CWPos < CCWPos Then
      Call CW(CWPos)
   Else
      Call CCW(CCWPos)
   End If
End Function

Function CW(ByVal Pos As Integer)'Rotation CW
Dim x As Integer

ActivateSignal(OUTPUT16)'UnLock Pin
While IsActive(OEMTRIG12)
Sleep (200)
Wend
ActivateSignal(OUTPUT15)'Turns Carousel CW
For x=1 To Pos
      'While IsActive(OEMTRIG11)
         Sleep(500)
      'Wend
      While IsActive(OEMTRIG11)
         'Sleep(10)
      Wend
Next x
    CTPos=x
DeactivateSignal(OUTPUT16)
Deactivatesignal(OUTPUT15)
SetCurrenttool(NewTool)
SetUserDro(1220,NewTool)
End Function

Function CCW(ByVal Pos as Integer)'Rotation CCW
Dim y As Integer
ActivateSignal(Output16)'UnLock Pin
While IsActive (OEMTRIG12)
Sleep (200)
Wend
Activatesignal(OUTPUT14)'Turn Carousel CCW
For y=1 To Pos
      'While IsActive(OEMTRIG11)
         Sleep(500)
      'Wend
      While IsActive(OEMTRIG11)
         'Sleep(10)
      Wend
Next y
CTPos=y
DeactivateSignal(OUTPUT16)
Deactivatesignal(OUTPUT14)
SetCurrentTool(NewTool)
SetUserDro(1220,NewTool)
   'SetUserDro(1224,NewTool)
End Function
 
 
 
Sub LoadSpindle()   
ActivateSignal(Output9)
While IsActive(OEMTRIG3)=0
Sleep (300)
Wend
ActivateSignal(Output10)
While IsActive(OEMTRIG5)=0
Sleep (300)
Wend
ActivateSignal(Output13)
While IsActive(OEMTRIG9)=0
Sleep (300)
Wend
Code "M7"
ActivateSignal(Output11)
While IsActive(OEMTRIG7)=0
Sleep (300)
Wend
DeActivateSignal(Output10)
While IsActive(OEMTRIG4)=0
Sleep (500)
Wend
Code "M9"
DeActivateSignal(Output11)
While IsActive(OEMTRIG6)=0
Sleep (500)
Wend
DeActivateSignal(Output9)
While IsActive(OEMTRIG3) = 1
Sleep (2000)
Wend
DeActivateSignal(Output13)
Sleep (1000)
ActivateSignal(Output12)
While IsActive(OEMTRIG8)=0
Wend
DeActivateSignal(Output12)
Message "Spindle loaded"
Sleep(200)
End Sub   

Sub UnloadSpindle()
ActivateSignal (Output13)'move tool arm to spindle on
While IsActive (OEMTRIG9)=0
Sleep (300)
Wend
DeActivateSignal (Output13)'move tool arm to spindle off
ActivateSignal (Output9)'extend tool arm
While IsActive (OEMTRIG3)=0
Sleep (300)
Wend
ActivateSignal (Output11)'PBD unlock
While IsActive (OEMTRIG7)=0
Sleep (300)
Wend
Code "M7"
ActivateSignal (Output10)'tool arm down
While IsActive (OEMTRIG5)=0
Sleep (300)
Wend
ActivateSignal (Output12)'move tool arm to carousel on
While IsActive (OEMTRIG8)=0
Sleep (300)
Wend
Code "M9"
DeActivateSignal (Output10)'tool arm up
While IsActive (OEMTRIG4)=0
Sleep (1000)
Wend
DeActivatesignal (Output9)'tool arm retract
DeActivateSignal (Output12)'move tool arm to carousel off
DeActivateSignal (Output11)'PBD lock
Message "Spindle Is Empty"
Sleep(200)
End Sub   

anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.