Hello Guest it is March 28, 2024, 11:22:39 AM

Author Topic: help needed with atc macro for mill retrofit  (Read 11646 times)

0 Members and 1 Guest are viewing this topic.

Re: help needed with atc macro for mill retrofit
« Reply #10 on: March 17, 2017, 12:50:22 PM »
for the moment i am little bit confused about the ligic of input1 for doing one step of ATC

in the original macro:

--> UNTIL IN4 OR STOPSW
--> REPEAT
--> UNTIL !IN4 OR STOPSW
--> REPEAT
--> UNTIL IN4 OR STOPSW
--> REPEAT
--> UNTIL !IN4 OR STOPSW

it looks like it is ON at the start

then OFF ON OFF ON

to do one step at ATC

please describe the pattern of input1 to do one step.

Thomas

Hello, that correct it will start ON
then OFF ON OFF ON (ending in ON)
this would equal 1 tool position so if i was at tool 1 and ran that id end up at tool 2 if i was at 1 and ran it in ccw it would be tool 8.

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: help needed with atc macro for mill retrofit
« Reply #11 on: March 17, 2017, 03:22:18 PM »
ok then something like this should be closer:
Code: [Select]
Sub Main()
'Global variables declaration

Dim CCWPos as Integer
Dim CWPos as Integer


NewTool = GetSelectedTool()
OldTool = GetCurrentTool()

While NewTool > 8
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 > 8 Then'requested tool higher then tool numbers
   Else
   End If
If NewTool < 1 Then'tool number to low
   Else
   End If

code("m05")
   Call ZatcPosition
   Call AtcIn'Activate air cylinder valve to put old tool back to carrousel
   Call Unclamp'Spindle: Tool Unclamp
   Call AtcDown'lowers atc
   Call LeastTravel'determine the least travel to move and Turns CW or CCW
   Call AtcUp'raises atc
   Call Clamp'Spindle: Tool Clamp
   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-1") '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 p01")
End Function

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

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

'Sequence to determine the least travel to move for TC, CW or CCW
Function LeastTravel()
   NewTool = GetSelectedTool()
   OldTool = GetCurrentTool()
 
    NTool = 8 ' Number of tools changer holds
   CWPos = GetSelectedTool() - GetCurrentTool() ' Assume a CW move
   If CWPos < 0 Then ' CWPos < 0 ==> rtp < atp
      CWPos = CWPos + NTools
   End If
   CCWPos = NTools - CWPos
   If CWPos < CCWPos Then
      Call CW()
   Else
      Call CCW()
   End If
End Function

Function CW()'Rotation CW
   Dim x As Integer
   Dim CTPos As Integer 'Carrousel Tool Position Relative to OldTool Position
   CTPos=0
   ActivateSignal(OUTPUT7)'Turns the AC Motor On
   Deactivatesignal(output8)'atc motor revirsing relay
   Sleep(50)

For x=0 To CWPos
           While IsActive(input1)'Wait for INPUT1 is off
Sleep(10)
   Wend
           While NOT IsActive(input1)'Wait for INPUT1 is on
Sleep(10)
   Wend
           While IsActive(input1)'Wait for INPUT1 is off 
Sleep(10)
   Wend
           While NOT IsActive(input1)'Wait for INPUT1 is on
Sleep(10)
   Wend
            x=x+1
        Next x
    CTPos=x
   DeactivateSignal(OUTPUT7)
   Deactivatesignal(output8)'atc motor revirsing relay
End Function

Function CCW()'Rotation CCW
   Dim y As Integer
   Dim CTPos As Integer 'Carrousel Tool Position Relative to OldTool Position
   CTPos=0
   Activatesignal(output8)'atc motor revirsing relay
   ActivateSignal(OUTPUT7)'Turns the AC Motor On
    Sleep(50)
   
  For y=0 To CCWPos
           While IsActive(input1)'Wait for INPUT1 is off
Sleep(10)
   Wend
           While NOT IsActive(input1)'Wait for INPUT1 is on
Sleep(10)
   Wend
           While IsActive(input1)'Wait for INPUT1 is off 
Sleep(10)
   Wend
           While NOT IsActive(input1)'Wait for INPUT1 is on
Sleep(10)
   Wend
            y=y+1
        Next y
   CTPos=y
   DeactivateSignal(OUTPUT7)
   Deactivatesignal(output8)
End Function

Function AtcUp()'lifts atc
   DeActivateSignal(OUTPUT5)'relay for solonoid to lower/lift atc
   code("G04 p01")'pause
End Function

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

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





anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: help needed with atc macro for mill retrofit
« Reply #12 on: March 17, 2017, 09:34:34 PM »
Hello, i tried that and its much better. i will tinker with it a bit and try to see what the issues, it seems to work fine if i change 1 tool number at a time (ex. t7 to t8) if i go multiple (ex. t1 to t4) it acts up. it seems like it over shoots the sensor some times like the response time is to slow so instead of ending with input1 active it will over shoot and end in a non active state.

Thanks for all your help so far.

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: help needed with atc macro for mill retrofit
« Reply #13 on: March 19, 2017, 11:12:57 AM »
something new ?
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: help needed with atc macro for mill retrofit
« Reply #14 on: May 04, 2017, 07:38:15 PM »
hello, ended up replacing the motor with a stepper motor coding will be much simpler now, i have one issue i need to solve,

in my new macro i have an equation which works but i need to figure out how to get the answer then move the stepper accordingly

ex.

s = (newtool - 1)*45
code "g00 a(s)"

so if it was tool 5 the equation would be

s = (5-1)*45
code" g00 a180"

when i'm in vb editor and i hover over "S" it will show the answer (ex. 180) but in the code line its not reading "S" as a number

whats the proper way to do that?

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: help needed with atc macro for mill retrofit
« Reply #15 on: June 21, 2017, 08:42:28 AM »
code "g00 a" + CStr(s)
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.