Hello Guest it is March 28, 2024, 10:29:33 AM

Author Topic: Trouble with ATC Macro  (Read 2351 times)

0 Members and 1 Guest are viewing this topic.

Trouble with ATC Macro
« on: September 19, 2017, 10:10:26 AM »
Hello, - (Sorry for my poor English)

I'm Fabio, and i'm trying to do a change tool macro for an all pneumatic ATC and i'm stuck in a "for ... next" repetition.

This ATC rotate in one direction only, and it's working quite well (based on a simple routine for origin search - the routine below):

Code: [Select]
'output#4 - avança magazine 'magazine forward
'output#3 - giro magazine 'rotate magazine
'output#1 - trava magazine 'magazine lock

Do While Not GetOEMLED (821)
activatesignal (Output1)
sleep 200
activatesignal (output3)
sleep 200
deactivatesignal (output1)
sleep 1500
deactivatesignal (output3)
Sleep 1000

Loop

End     

I'm trying to count how many stations (or steps) magazine must rotate based on "GetSelectedTool()" , "GetCurrentTool()", and "NTools" (number of slots in magazine), and I created a routine to repeat the counting to position the tool, but it only work just one time - the magazine just run one station and the macro finnish... I.E, If I'm in Tool #1 and ask for Tool #3, it only turn one step...

What I'm doing wrong? (below it's macro, based in one example found in this forum): Can someone help me?

Code: [Select]
Sub Main()
'Global variables declaration

Dim CCWPos As Integer
Dim CWPos As Integer


NewTool = GetSelectedTool()
OldTool = GetCurrentTool()
'OldTool = GetOEMDRO(1200)

While NewTool > 5
NewTool = Question ("Enter New Tool Number up to " & MaxToolNum)
Wend

If NewTool = OldTool Then'Compare between actual tool and requested tool
Else
End If
If NewTool > 5 Then'requested tool higher then tool numbers
Else
End If
If NewTool < 1 Then'tool number to low
Else
End If

code("m05")
Call AtcIn'Activate air cylinder valve to put old tool back to carrousel
Call ZatcPosition
Call Unclamp'Spindle: Tool Unclamp
Call ZatcUp'raises atc
Call Travel'determine the least travel to move and Turns CW or CCW
Call Unclamp'Spindle: Tool Unclamp
Call ZatcDown'lowers atc
Call Clamp'Spindle: Tool Clamp
Call ZAtcUp'raises atc
Call AtcOut'retracts atc
Call SetUserDRO (1200,NewTool)'Store new tool as actual tool value
SetCurrentTool( NewTool )

End Sub

Function ZatcPosition()'Move to Z tool position and wait until position reached
code("G53")'Move in Absolute Machine coordinates
code("G00 Z-35") 'Z value as to be checked for exact match with carrousel height
While(IsMoving())
Sleep(100)'temporisation entre while++
Wend
End Function

Function AtcIn()'Put old tool back to carrousel
ActivateSignal(OUTPUT4)'Move carrousel air cylinder to the tool change position adjust output# to match atc slide
code("g04 p3")
End Function

Function Unclamp()'Spindle: Tool Unclamp
ActivateSignal(OUTPUT5)'Release the tool, adjust output number for drawbar output
code("g04 p01")'pause
End Function

Function ZatcDown()'lowers atc to rotate
ActivateSignal(OUTPUT5)'solonoid to lower atc
code("G04 p01")'pause
End Function

'Determine the travel to move
Function Travel()
NewTool = GetSelectedTool()
OldTool = GetCurrentTool()
NTools = 5 ' Number of tools changer holds
CWPos = NTools - GetSelectedTool()
Call CCW()
End Function

Function CCW()
Dim y As Integer
Dim CTPos As Integer 'Carrousel Tool Position Relative to OldTool Position
CTPos = 0
For y = 0 To CCWPos
Call Roda()
'y=y
Next y

CTPos=y
End Function

Function Roda()
activatesignal (Output1)
sleep 200
activatesignal (output3)
sleep 200
deactivatesignal (output1)
sleep 1500
deactivatesignal (output3)
Sleep 300
End Function

Function ZAtcUp()'lifts atc
code("G53")'Move in Absolute Machine coordinates
code("G00 Z0") 'Z value as to be checked for exact match with carrousel height
While(IsMoving())
Sleep(100)'temporisation entre while++
Wend

End Function

Function Clamp()'power drawbar unactivated
DeactivateSignal(OUTPUT5)'unactivating drawbar relay
End Function

Function AtcOut()'retracts atc
deActivateSignal(OUTPUT4)'atc retract cylinder relay
code("g04 p01")
End Function

Best regards,

Fabio
Re: Trouble with ATC Macro
« Reply #1 on: September 25, 2017, 08:10:27 AM »
Wow - 80 visualizations and no one can help me or suggest something!

No problem - I'll find some solution.

Bert regards

Fabio