Hello Guest it is October 14, 2024, 12:52:08 AM

Author Topic: atc for okuma and howa  (Read 4682 times)

0 Members and 1 Guest are viewing this topic.

Offline mark4

*
  •  167 167
atc for okuma and howa
« on: February 11, 2016, 01:20:38 PM »
this is a new post about the tool changer didnt want to get the two mixed up

i am setting up a tool changer for a turret lathe and i want to use the tool changer from cs-labs but am having problems figuring out the outputs i dont have it set up the way gthey do some of wich i could change some of wich not and my turret unlock sw is only closed or open not two switches if that isnt bad enough the tool changer is 12 position i will add what i have done so far and add notes and will add my inputs and outputs i am sure that sombody who has a better grasp on the inputs/outputs will have an easy time with this thank you for your help
mark cook
marks machine repair llc

'------------------------------------------------------------------------------
' CS-Lab s.c. - Auto toolchanger for lathe (rotary type of ATC)
' (C) 2011
' v1.2 - 2011-11-05
'------------------------------------------------------------------------------

'------------------------------------------------------------------------------
' CONFIG
'------------------------------------------------------------------------------
Const OpenSensDelay        = 800    ' Time Delay [ms] after ATC unlock
Const TimeLock            = 1000     ' ATC locking time delay
Const TOOLCOUNT            = 12     ' max Tool #

' Actual ATC position inputs (CSMIO-IP/A-IO-0 inputs)
Const InT1 = 2
Const InT2 = 3
Const InT3 = 4                                                                             these inputs were for the csmio/ip-a i need them to be for the csmio-io
Const InT4 = 5                                                                             100,2 ect i think i did it right see below
Const InT5 = 6
Const InT6 = 7
Const InT7 = 8
Const InT8 = 9
Const InT9 = 10
Const InT10 = 11
Const InT11 = 12
Const InT12 = 13

' ATC sensors inputs
rem Const InOpenSensor        = 0>0     ' ATC unlocked (rotating)          I dont know what to do with this my switch input is 100,1 modbus
rem Const InCloseSensor        = 0>1    ' ATC locked - safe                  this orriginally had two different outputs i only have one

' digital outputs for ATC control (CSMIO outputs)
rem Const OutRun            = 4        ' unlock and rotate                                               again dont know how to define this signal
rem Const OutLock            = 5        ' stop rotation and lock at current position            my outputs are index normal 90,13
                                                                                                                              index reverse 90,14 tool lift which is unlock 90,12
'------------------------------------------------------------------------------
' program variables - don't modify
'------------------------------------------------------------------------------
Dim ToolNew, ToolOld, ToolSlot As Integer
Dim ToolRdy As Boolean
Dim ATC_CloseRetry
Dim InToolSens(TOOLCOUNT)

'------------------------------------------------------------------------------
  ' MACRO START
'------------------------------------------------------------------------------
    If(GetOEMLed(800)) Then
        Message("The System Is In ESTOP - Toolchange Interrupted")
        Sleep(150)
        WaitForMove
        End
    End If

      SetUserLED(1001, 1) ' User LED - toolchange in progress
     
      InToolSens(0) = InT1
      InToolSens(1) = InT2
      InToolSens(2) = InT3
      InToolSens(3) = InT4
      InToolSens(4) = InT5
      InToolSens(5) = InT6
      InToolSens(6) = InT7
      InToolSens(7) = InT8
      InToolSens(8) = InT9                                    i changed this to 12 from 8
      InToolSens(9) = InT10
      InToolSens(10) = InT11
      InToolSens(11) = InT12
    ' Get actual tool # and new tool #
    ToolOld = GetCurrentTool()
    ToolNew = GetSelectedTool()

    ' little trick for double slots ATC
    If(ToolNew >= 12) Then
        ToolSlot = ToolNew - 12                             double slots i dont think i need and i dont understand at all
    Else
        ToolSlot = ToolNew
    End If
   
    If(ToolOld >= 12) Then
        ToolOld = ToolOld - 12
    End If
   
    ' The same position - no need to move
    If (ToolSlot = ToolOld) Then
        SetCurrentTool( ToolNew )
        Message("ATC is on position "& ToolSlot & " and new tool is " & ToolNew)
        WaitForMove
        SetUserLED(1001, 0)
        End
    End If
   
    If (ToolSlot > TOOLCOUNT) Then
        SetCurrentTool( ToolOld )
        SetUserLED(1001, 0)
        DoOEMButton(1003)
        DoOEMButton(1002)
        Sleep(150)
        Message("There is no tool T" & ToolNew & " in ATC")
        Sleep(150)
        End
    End If
   
   
    ' T0 is a fake tool, no need to change
    If (ToolSlot = 0) Then
        ToolNew = 0
        SetCurrentTool( ToolNew )
        Message("Load a Tool Number: " & ToolNew)
        WaitForMove
        SetUserLED(1001, 0)
        End
    End If
   

    ' unlock and rotate ATC
    RunATC
    Sleep( OpenSensDelay )
    ' check ATC open sensor set to 0
    If (Not GetCsmioIn(100,0)) Then
        LockATC
        SetCurrentTool( 0 )
        SetUserLED(1001, 0)
        DoOEMButton(1021)
        DoOEMButton(1002)
        Sleep(150)
        Message("ATC Locked - Toolchange Failed.")
        Sleep(150)
        End
    End If
   
    ' wait to ATC will be on the desired position
    ToolRdy = false
    While(Not ToolRdy)
        If(GetCsmioIn((InToolSens(ToolSlot - 1)))) Then
            ToolRdy = true
        End If
    Wend
   
   
    ' stop rotation and lock ATC
    LockATC
    ATC_CloseRetry = 0
    ' Check lock sensor, retry lock if needed
    While(Not GetCsmioIn(100,1) And ATC_CloseRetry < 4)
        LockATC
        ATC_CloseRetry = ATC_CloseRetry + 1
    Wend
   
    ' double check for succesful ATC lock
    If (Not GetCsmioIn(100,1)) Then                         changed this probably shouldnt have
        SetCurrentTool( 0 )
        SetUserLED(1001, 0)
        DoOEMButton(1021)
        DoOEMButton(1002)
        Sleep(150)
        Message("ATC Lock Alert. Check ATC.")
        Sleep(150)
        End
    End If
 
    SetCurrentTool( ToolNew )
    Message("Succesful Loaded Tool T" & ToolNew)
    Sleep(150)
    WaitForMove
    SetUserLED(1001, 0)
    End
' -----------------------------------------------------------------------------
Public Function GetCsmioIn (n As Integer) As Boolean
    Dim reg As Integer
   
    If(n < 15) Then
        reg = 100
    Else
        reg = 91
        n = n - 16
    End If
   
    If(GetInBit(reg, n)) Then
        GetCsmioIn = true
    Else
        GetCsmioIn = false
    End If
    Exit Function
End Function
' -----------------------------------------------------------------------------
Sub RunATC ()
    Call SetCsmioOut(OutLock, false)
    Sleep(150)
    Call SetCsmioOut(OutRun, true)
    Sleep(150)
End Sub
' -----------------------------------------------------------------------------
Sub LockATC ()
    Call SetCsmioOut(OutRun, false)
    Sleep(150)
    Call SetCsmioOut(OutLock, true)
    Sleep(TimeLock)
    Call SetCsmioOut(OutLock, false)
    Sleep(150)
End Sub
' -----------------------------------------------------------------------------
Public Sub SetCsmioOut (ByVal n As Integer, ByVal state As Boolean)
    If(state) Then
        SetOutBit(90, n)
    Else
        ResetOutBit(90, n)
    End If
End Sub
' -----------------------------------------------------------------------------
Sub WaitForMove ()
    While IsMoving()
        Sleep(15)
    Wend
End Sub

CSMIO/IP-A    12BR    SOL 8 TOOL LIFT    
   OUTPUT 12    TOOL LIFT PORT 10 PIN 12    90,12
CSMIO/IP-A    13BR    SOL 9 INDEX NORMAL    
   OUTPUT 13    INDEX NORMAL PORT 10 PIN 13    90,13
CSMIO/IP-A    14BR    SOL 10 INDEX REVERSE    
   OUTPUT 14    INDEX REVERSE PORT 10 PIN 14    90,14
USER LED    1010    TOOL POSITION 1    MOD100 D2    INPUT    LS11    MODBUS
USER LED    1011    TOOL POSITION 2    MOD100 D3    INPUT    LS12    MODBUS
USER LED    1012    TOOL POSITION 3    MOD100 D4    INPUT    LS13    MODBUS
USER LED    1013    TOOL POSITION 4    MOD100 D5    INPUT    LS14    MODBUS
USER LED    1014    TOOL POSITION 5    MOD100 D6    INPUT    LS15    MODBUS
USER LED    1015    TOOL POSITION 6    MOD100 D7    INPUT    LS16    MODBUS
USER LED    1016    TOOL POSITION 7    MOD100 D8    INPUT    LS17    MODBUS
USER LED    1017    TOOL POSITION 8    MOD100 D9    INPUT    LS18    MODBUS
USER LED    1018    TOOL POSITION 9    MOD100 D10    INPUT    LS19    MODBUS
USER LED    1019    TOOL POSITION 10    MOD100 D11    INPUT    LS20    MODBUS
USER LED    1020    TOOL POSITION 11    MOD100 D12    INPUT    LS21    MODBUS
USER LED    1021    TOOL POSITION 12    MOD100 D13    INPUT    LS22    MODBUS
USER LED    1022    TURRET INDEX    MOD100 D1    INPUT    LS9    MODBUS
USER LED    1023    TURRET UNLOCK    MOD100 D0    INPUT    LS10    MODBUS
USER LED    1024    TURRET LOCK    MOD100 D0    INPUT    LS10    MODBUS
   
thank you

Offline mark4

*
  •  167 167
Re: atc for okuma and howa
« Reply #1 on: February 21, 2016, 09:34:30 PM »
hi i have been modifying the tool changer macro and think i have it right can somebody proof read it for me and see if i have made any errors thank you
    '------------------------------------------------------------------------------
' CS-Lab s.c. - Auto toolchanger for lathe (rotary type of ATC)
' (C) 2011
' v1.2 - 2011-11-05
'------------------------------------------------------------------------------

'------------------------------------------------------------------------------
' CONFIG
'------------------------------------------------------------------------------
Const OpenSensDelay      = 800   ' Time Delay [ms] after ATC unlock
Const TimeLock         = 1000    ' ATC locking time delay
Const TOOLCOUNT         = 12    ' max Tool #

' Actual ATC position inputs (CSMIO-IP/A-IO-0 inputs)
Const InT1 = 2
Const InT2 = 3
Const InT3 = 4
Const InT4 = 5
Const InT5 = 6
Const InT6 = 7
Const InT7 = 8
Const InT8 = 9
Const InT9 = 10
Const InT10 = 11
Const InT11 = 12
Const InT12 = 13

' ATC sensors inputs
Const InCloseSensor      = 0    ' turret locked or unlocked
Const InDex            = 1      ' hydraulic motor index switch
rem Const InCloseSensor      = 25   ' ATC locked - safe

' digital outputs for ATC control (CSMIO outputs)
Const Out            = 0   'unlock turret
Const RotateLeft         = 13   'rotate left
Const RotateRight         = 14   'rotate right
rem Const OutRun         = 4      ' unlock and rotate
rem Const OutLock         = 5      ' stop rotation and lock at current position
rem i think i did this area right

'------------------------------------------------------------------------------
' program variables - don't modify
'------------------------------------------------------------------------------
Dim ToolNew, ToolOld, ToolSlot As Integer
Dim ToolRdy As Boolean
Dim ATC_CloseRetry
Dim InToolSens(TOOLCOUNT)
rem this i left alone
'------------------------------------------------------------------------------
  ' MACRO START
'------------------------------------------------------------------------------
G53 X.5 Z.5 'move to safe tool change coordinates
   If(GetOEMLed(800)) Then
      Message("The System Is In ESTOP - Toolchange Interrupted")
      Sleep(150)
      WaitForMove
      End
   End If

     SetUserLED(1001, 1) ' User LED - toolchange in progress
     
     InToolSens(0) = InT1
     InToolSens(1) = InT2
     InToolSens(2) = InT3
     InToolSens(3) = InT4
     InToolSens(4) = InT5
     InToolSens(5) = InT6
     InToolSens(6) = InT7
     InToolSens(7) = InT8
     InToolSens(8) = InT9
     InToolSens(9) = InT10
     InToolSens(10) = InT11
     InToolSens(11) = InT12

   ' Get actual tool # and new tool #
   ToolOld = GetCurrentTool()
   ToolNew = GetSelectedTool()
   
   If(ToolNew >=12) Then
      ToolSlot = ToolNew
      Else "Out of Range"
   End If
   
   ' The same position - no need to move
   If (ToolSlot = ToolOld) Then
      SetCurrentTool( ToolNew )
      Message("ATC is on position "& ToolSlot & " and new tool is " & ToolNew)
      WaitForMove
      SetUserLED(1001, 0)
      End
   End If
   ' left alone
   If (ToolSlot > TOOLCOUNT) Then
      SetCurrentTool( ToolOld )
      SetUserLED(1001, 0)
      DoOEMButton(1003)   'stop
      DoOEMButton(1002)   'gcode rewind
      Sleep(150)
      Message("There is no tool T" & ToolNew & " in ATC")
      Sleep(150)
      End
   End If
   ' left alone
   
   ' T0 is a fake tool, no need to change
   If (ToolSlot = 0) Then
      ToolNew = 0
      SetCurrentTool( ToolNew )
      Message("Load a Tool Number: " & ToolNew)
      WaitForMove
      SetUserLED(1001, 0)
      End
   End If
   
   ' unlock and rotate ATC lost here
   RunATC
   Sleep( OpenSensDelay )
   ' check ATC close sensor set to 0
   If (GetCsmioIn(InCloseSensor)) Then
      LockATC
      SetCurrentTool( 0 )
      SetUserLED(1001, 0)
      DoOEMButton(1021)   'reset
      DoOEMButton(1002)   'gcode rewind
      Sleep(150)
      Message("ATC Locked - Toolchange Failed.")
      Sleep(150)
      End
   End If
   
   ' wait to ATC will be on the desired position also lost here
   ToolRdy = false
   While(Not ToolRdy)
      If(GetCsmioIn((InToolSens(ToolSlot - 1)))) and (GetCsmioIn(InDex)) Then
         ToolRdy = true
      End If
   Wend
   
   
   ' stop rotation and lock ATC lost here
   LockATC
   ATC_CloseRetry = 0
   ' Check lock sensor, retry lock if needed
   While(Not GetCsmioIn(InCloseSensor) And ATC_CloseRetry < 4)
      LockATC
      ATC_CloseRetry = ATC_CloseRetry + 1
   Wend
   
   ' double check for succesful ATC lock
   If (Not GetCsmioIn(InCloseSensor)) Then
         SetCurrentTool( 0 )
      SetUserLED(1001, 0)
      DoOEMButton(1021)   'reset
      DoOEMButton(1002)   'gcode rewind
      Sleep(150)
      Message("ATC Lock Alert. Check ATC.")
      Sleep(150)
      End
   End If
 
   SetCurrentTool( ToolNew )
   Message("Succesful Loaded Tool T" & ToolNew)
   Sleep(150)
   WaitForMove
   SetUserLED(1001, 0)
   End
' -----------------------------------------------------------------------------
Public Function GetCsmioIn (n As Integer) As Boolean
   Dim reg As Integer
   
   If(n < 14) Then 'inputs modbus
      reg = 100
   
   End If
   
   If(GetInBit(reg, n)) Then
      GetCsmioIn = true
   Else
      GetCsmioIn = false
   End If
   Exit Function
End Function
' i think i understand this and it doesent need to be adjusted anymore
' -----------------------------------------------------------------------------
Sub RunATC ()
   Call SetCsmioOut(Out, true) 'unlock the turret orriginal outrun
   Sleep(150)
   Call SetCsmioOut(rotateleft, true) 'rotate left original outlock
   Sleep(150)
End Sub
' -----------------------------------------------------------------------------
Sub LockATC ()
   Call SetCsmioOut(rotateleft, false) 'stop rotation
   Sleep(150)
   rem Call SetCsmioOut(OutLock, true)
   Sleep(TimeLock)
   Call SetCsmioOut(Out, false) 'lock the turret
   Sleep(150)
End Sub
' -----------------------------------------------------------------------------
Public Sub SetCsmioOut (ByVal n As Integer, ByVal state As Boolean)
   If(state) Then
      SetOutBit(90, n)
   Else
      ResetOutBit(90, n)
   End If
End Sub
' -----------------------------------------------------------------------------
Sub WaitForMove ()
   While IsMoving()
      Sleep(15)
   Wend
End Sub                                                     
Re: atc for okuma and howa
« Reply #2 on: March 26, 2016, 12:07:51 AM »
Very nice, it makes me understand more.
โปรแกรม สถิติบาคาร่า