Hello Guest it is March 28, 2024, 09:23:26 AM

Author Topic: macro for 4 slot tool change hep  (Read 7394 times)

0 Members and 1 Guest are viewing this topic.

Re: macro for 4 slot tool change hep
« Reply #30 on: April 26, 2019, 04:22:45 AM »
hi there must be a small error in the last post on input 23

the most frustrating ting i have with my system, is every time i rum VB code, with an error. VB locks down  and i need to restart my hole system. 

it dossent lave much for troubleshooting.

I have deliberately failed to include the x-z axis movement as I cannot test it yet.

my drives are on the way:)


Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: macro for 4 slot tool change hep
« Reply #31 on: April 26, 2019, 04:31:55 AM »
you mean the last code with the timeout included?
do you get any message in the statusline?

very hard to test here without the real Hardware.
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: macro for 4 slot tool change hep
« Reply #32 on: April 26, 2019, 04:37:33 AM »
ok mistake found.

Code: [Select]
Public NewTool As Integer

Sub Main
'//Declarations
Dim StartTime, ActTime As Single
MaxToolNum = 4      'Max number of tools for the changer

OldTool = GetCurrentTool()
Tool = GetSelectedTool()

If OldTool = Tool Then
Message ("Selected Tool already loaded")
Exit Sub
End If

If Tool > MaxToolNum Then
Tool = Question ("Enter New Tool Number up to " & MaxToolNum)
End If

doagain:

Call StartTool

While NewTool <> Tool
Call CheckPins
Wend

Call StopTool

're check
Call CheckPins
If NewTool <> Tool Then
GoTo doagain
End If

SetCurrentTool(NewTool)
End Sub


'//// Subroutines /////////

Sub StartTool
   ActivateSignal(Output8)
End Sub

Sub CheckPins
   If GetCsmioIn(91,6) = True Then
      NewTool = 1
      End If
   If GetCsmioIn(91,5) = True Then
      NewTool = 2
      End If
   If GetCsmioIn(91,4) = True Then
      NewTool = 3
      End If
   If GetCsmioIn(91,3) = True Then
      NewTool = 4
      End If
End Sub

Sub Stoptool
   DeActivateSignal(Output8)
   ActivateSignal(Output9)
   'wait for input 23 or timeout
StartTime = Timer

   
   While GetCsmioIn(91,7) = False
Sleep(20)
ActTime = Timer
If ActTime > StartTime + 3 Then
MsgBox "Timeout Input23!!"
DeActivateSignal(Output9)
DoButton(3)
Sleep(300)
Exit Sub
End If
   Wend
   DeActivateSignal(Output9)
End Sub 

'CSMIO Eingang lesen
Function GetCsmioIn (ByVal adr As Integer, ByVal n As Integer) As Boolean
If(GetInBit(adr, n)) Then
GetCsmioIn = true
Else
GetCsmioIn = false
End If
End Function



anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: macro for 4 slot tool change hep
« Reply #33 on: April 26, 2019, 04:57:54 AM »
nice it registered the error. but the relay is still on until i hit the ok one the message box. it must somehow deactivate relay 9 again. without having to press ok first. :)

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: macro for 4 slot tool change hep
« Reply #34 on: April 26, 2019, 05:06:16 AM »
Code: [Select]
Public NewTool As Integer

Sub Main
'//Declarations
Dim StartTime, ActTime As Single
MaxToolNum = 4      'Max number of tools for the changer

OldTool = GetCurrentTool()
Tool = GetSelectedTool()

If OldTool = Tool Then
Message ("Selected Tool already loaded")
Exit Sub
End If

If Tool > MaxToolNum Then
Tool = Question ("Enter New Tool Number up to " & MaxToolNum)
End If

doagain:

Call StartTool

While NewTool <> Tool
Call CheckPins
Wend

Call StopTool

're check
Call CheckPins
If NewTool <> Tool Then
GoTo doagain
End If

SetCurrentTool(NewTool)
End Sub


'//// Subroutines /////////

Sub StartTool
   ActivateSignal(Output8)
End Sub

Sub CheckPins
   If GetCsmioIn(91,6) = True Then
      NewTool = 1
      End If
   If GetCsmioIn(91,5) = True Then
      NewTool = 2
      End If
   If GetCsmioIn(91,4) = True Then
      NewTool = 3
      End If
   If GetCsmioIn(91,3) = True Then
      NewTool = 4
      End If
End Sub

Sub Stoptool
   DeActivateSignal(Output8)
   ActivateSignal(Output9)
   'wait for input 23 or timeout
StartTime = Timer

   
   While GetCsmioIn(91,7) = False
Sleep(20)
ActTime = Timer
If ActTime > StartTime + 3 Then
DeActivateSignal(Output9)
MsgBox "Timeout Input23!!"
DoButton(3)
Sleep(300)
Exit Sub
End If
   Wend
   DeActivateSignal(Output9)
End Sub 

'CSMIO Eingang lesen
Function GetCsmioIn (ByVal adr As Integer, ByVal n As Integer) As Boolean
If(GetInBit(adr, n)) Then
GetCsmioIn = true
Else
GetCsmioIn = false
End If
End Function




anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: macro for 4 slot tool change hep
« Reply #35 on: April 26, 2019, 06:01:38 AM »
it works like a charme  8)
the macros you posted on axis movement. i only need to juse one ?
and put it before pressent macro. is this correkt ?

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: macro for 4 slot tool change hep
« Reply #36 on: April 26, 2019, 06:16:41 AM »
this would bo the complete code, with refernce check and X/Z move.

Code: [Select]
Public NewTool As Integer

Sub Main
'//Declarations
Dim StartTime, ActTime As Single
MaxToolNum = 4      'Max number of tools for the changer

OldTool = GetCurrentTool()
Tool = GetSelectedTool()

If OldTool = Tool Then
Message ("Selected Tool already loaded")
Exit Sub
End If

If Tool > MaxToolNum Then
Tool = Question ("Enter New Tool Number up to " & MaxToolNum)
End If

'X-Axis not in reference
If GetOEMLED(807) Then
DoButton(3)
Sleep(500)
Message ("X-Axis not referenced -> Abort !!")
Exit Sub
End If

'Z-Axis not in reference
If GetOEMLED(809) Then
DoButton(3)
Sleep(500)
Message ("Z-Axis not referenced -> Abort !!")
Exit Sub
End If

Message "ATC X-Axis to TC position"
Code "G90 G53 G0 X2"
While IsMoving()
Sleep(15)
Wend

Message "ATC Z-Axis to TC position"
Code "G90 G53 G0 Z2"
While IsMoving()
Sleep(15)
Wend


doagain:

Call StartTool

While NewTool <> Tool
Call CheckPins
Wend

Call StopTool

're check
Call CheckPins
If NewTool <> Tool Then
GoTo doagain
End If

SetCurrentTool(NewTool)
End Sub


'//// Subroutines /////////

Sub StartTool
   ActivateSignal(Output8)
End Sub

Sub CheckPins
   If GetCsmioIn(91,6) = True Then
      NewTool = 1
      End If
   If GetCsmioIn(91,5) = True Then
      NewTool = 2
      End If
   If GetCsmioIn(91,4) = True Then
      NewTool = 3
      End If
   If GetCsmioIn(91,3) = True Then
      NewTool = 4
      End If
End Sub

Sub Stoptool
   DeActivateSignal(Output8)
   ActivateSignal(Output9)
   'wait for input 23 or timeout
StartTime = Timer

   
   While GetCsmioIn(91,7) = False
Sleep(20)
ActTime = Timer
If ActTime > StartTime + 3 Then
DeActivateSignal(Output9)
MsgBox "Timeout Input23!!"
DoButton(3)
Sleep(300)
Exit Sub
End If
   Wend
   DeActivateSignal(Output9)
End Sub 

'CSMIO Eingang lesen
Function GetCsmioIn (ByVal adr As Integer, ByVal n As Integer) As Boolean
If(GetInBit(adr, n)) Then
GetCsmioIn = true
Else
GetCsmioIn = false
End If
End Function


IMPORTANT:

it will move first X than Z axis!

the values of this two code lines:

   Code "G90 G53 G0 X2"

   Code "G90 G53 G0 Z2"

are in machine coord's and maybe Need to be adjusted.



anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: macro for 4 slot tool change hep
« Reply #37 on: April 29, 2019, 03:11:00 AM »
ok thanks. i will try it out when I receive the drives.  ;)