1611
General Mach Discussion / Re: Exporting tool table
« on: November 15, 2018, 09:28:56 AM »
i guess he wanted to move the toolinformation from one mach3 to an other mach3 machine.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
I also can't find any documentation about Csmio macro functions like GetCsmioIn, SetCsmioOut and stuff like that.
'------------------------------------------------------------------------------
' CS-Lab s.c. - Auto toolchanger for lathe (rotary type of ATC)
' (C) 2011
' v1.2 - 2011-11-05
' v1.3 - 2018-11-06 TPS modified for BCD coded toolpos
'------------------------------------------------------------------------------
' CONFIG
'------------------------------------------------------------------------------
Const TOOLCOUNT = 8 ' max Tool #
' Actual ATC position inputs (CSMIO-IP inputs)
Const BCD1 = 14
Const BCD2 = 13
Const BCD4 = 12
Const BCD8 = 11
' ATC sensors inputs
Const GenevaSensor = 10 ' Geneva Cam on position
' digital outputs for ATC control (CSMIO outputs)
Const OutRun = 2 ' unlock and rotate
'------------------------------------------------------------------------------
' program variables - don't modify
'------------------------------------------------------------------------------
Dim ToolNew, ToolOld, ToolSlot As Integer
Dim ToolRdy As Boolean
Dim ATC_CloseRetry
Dim ActATCPos
'------------------------------------------------------------------------------
' MACRO START
'------------------------------------------------------------------------------
if(GetOEMLed(800)) Then ' MACH is at RESET condition
Message("System is at ESTOP - Tool Change terminated")
Sleep(150)
WaitForMove
End
End If
SetUserLED(1001, 1) ' User LED - toolchange in progress (Pause Feed Hold condition)
' Get actual tool # and new tool #
ToolOld = GetCurrentTool()
ToolNew = GetSelectedTool()
' little trick for double slots ATC
If(ToolNew >= 10) Then
ToolSlot = ToolNew - 10
Else
ToolSlot = ToolNew
End If
If(ToolOld >= 10) Then
ToolOld = ToolOld - 10
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) ' Pause Feed Hold off
End
End If
If (ToolSlot > TOOLCOUNT) Then
SetCurrentTool( ToolOld )
SetUserLED(1001, 0) ' Pause Feed Holf off
DoOEMButton(1003) ' Stop
DoOEMButton(1002) ' G-Code Rewind
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("Succesful loaded tool T" & ToolNew)
WaitForMove
SetUserLED(1001, 0) ' Pause Feed Hold off
End
End If
' unlock and rotate ATC
RunATC
Sleep(150)
' wait to ATC will be on the desired position
ToolRdy = false
While(Not ToolRdy)
'read the BCD code
ActATCPos = 0
If GetCsmioIn(BCD1) Then
ActATCPos = ActATCPos + 1
End If
If GetCsmioIn(BCD2) Then
ActATCPos = ActATCPos + 2
End If
If GetCsmioIn(BCD4) Then
ActATCPos = ActATCPos + 4
End If
If GetCsmioIn(BCD8) Then
ActATCPos = ActATCPos + 8
End If
If (ActATCPos = (ToolSlot - 1)) Then
ToolRdy = true
End If
Wend
' stop rotation and lock ATC
ATC_CloseRetry = 0
' Check lock sensor, retry lock if needed
While(Not GetCsmioIn(GenevaSensor) And ATC_CloseRetry < 4)
StopATC
ATC_CloseRetry = ATC_CloseRetry + 1
Wend
' double check for succesful ATC lock
If (Not GetCsmioIn(GenevaSensor)) Then
SetCurrentTool( 0 )
SetUserLED(1001, 0) ' Pause Feed Hold off
' DoOEMButton(1021) ' Reset
DoOEMButton(1002) ' G-Code 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) ' Pause Feed Hold off
End
' -----------------------------------------------------------------------------
Public Function GetCsmioIn (n As Integer) As Boolean
Dim reg As Integer
If(n < 16) Then
reg = 90
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(OutRun, true)
Sleep(150)
End Sub
' -----------------------------------------------------------------------------
Sub StopATC ()
Call SetCsmioOut(OutRun, 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