Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: jve on April 04, 2018, 11:19:19 AM

Title: ATC Geneva wheel for mill
Post by: jve on April 04, 2018, 11:19:19 AM
HI Guys,

I need some help, I am doing a retrofit in a mill that have a ATC with a geneva wheel
It  is working fine with the inputs and output the problem that i have is the count and i cannot figerout what is the problem
when the ATC is in tool1 for example and i insert T2M6 the ATC go to tool 2 but when the ATC is in tool 1 and i insert T3M6 it go to tool 2 so it is only counting 1


Title: Re: ATC Geneva wheel for mill
Post by: TPS on April 04, 2018, 12:21:41 PM
Hello,

i think the Problem is in this Sub:


'Sequence to determine the least travel to move for TC, CW or CCW
'atp = Actual tool position, rtp = Requested tool positon
Sub LeastTravel()
   NTool = 16 ' 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 Sub

should be IMHO


'Sequence to determine the least travel to move for TC, CW or CCW
'atp = Actual tool position, rtp = Requested tool positon
Sub LeastTravel()
   NTools = 16 ' 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 Sub

Title: Re: ATC Geneva wheel for mill
Post by: jve on April 05, 2018, 12:52:54 AM
I Change the Ntools to Ntool and vice versa but no luck i think that the problem is in the count of OEMTrig 9 it is only counting 1 , i spend long hours but i cannot see the mistake 

'Sequence to determine the least travel to move for TC, CW or CCW
'atp = Actual tool position, rtp = Requested tool positon
Sub LeastTravel()
   NTool = 16 ' Number of tools changer holds
   CWPos = GetSelectedTool() - GetCurrentTool() ' Assume a CW move
   If CWPos < 0 Then ' CWPos < 0 ==> rtp < atp
      CWPos = CWPos + NTool
   End If
   CCWPos = NTool - CWPos
   If CWPos < CCWPos Then
      call CW()
   Else
      call CCW()
   End If
End Sub

Function CW()'Rotation CW
   Dim x As Integer
   Dim CTPos As Integer 'Carrousel Tool Position Relative to OldTool Position
   CTPos=0
   ActivateSignal(OUTPUT9)'Turns the AC Motor On cw

   Sleep(50)

   For x=0 To CWPos
           While IsActive(OEMTrig9)'Wait for OEMTrig9 is off
      Sleep(10)
      Wend
           While NOT IsActive(OEMTrig9)'Wait for OEMTrig9 is on
      Sleep(10)
      Wend

            x=x+1
        Next x
    CTPos=x
   DeactivateSignal(OUTPUT9)

End Function

Function CCW()'Rotation CCW
   Dim y As Integer
   Dim CTPos As Integer 'Carrousel Tool Position Relative to OldTool Position
   CTPos=0
   Activatesignal(OUTPUT9)'atc motor revirsing relay
   ActivateSignal(OUTPUT10)'Turns the AC Motor On
    Sleep(50)
   
     For y=0 To CCWPos
           While IsActive(OEMTrig9)'Wait for OEMTrig9 is off
      Sleep(10)
      Wend
           While NOT IsActive(OEMTrig9)'Wait for OEMTrig9 is on
      Sleep(10)
      Wend

            y=y+1
        Next y
   CTPos=y
   DeactivateSignal(OUTPUT9)
   Deactivatesignal(OUTPUT10)'atc motor revirsing relay
End Function

Function AtcUp()'MAG UP
   DeActivateSignal(OUTPUT11)'relay for solonoid to lower/MAG UP
   code("G04 p01")'pause
           While IsActive(OEMTrig5)'Wait for OEMTrig5 is off Mag up
      Sleep(10)
      Wend
           While NOT IsActive(OEMTrig5)'Wait for OEMTrig5 is on Mag up
      Sleep(10)
      Wend
End Function
Title: Re: ATC Geneva wheel for mill
Post by: TPS on April 05, 2018, 01:27:32 AM
try to use a Input instead of OEMTrig.

what Controller are you using?
Title: Re: ATC Geneva wheel for mill
Post by: jve on April 05, 2018, 03:46:08 AM
Hi ,
I am Using CSMIO IPS
Title: Re: ATC Geneva wheel for mill
Post by: TPS on April 05, 2018, 03:50:34 AM
so why do you not read the Input drectly.
this work 100%, if have used it many times.

for eample

While GetCsmioIn(91,15) = False  
   Sleep(20)
Wend


'CSMIO read input
Public 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




here is a links witch Shows the adresses:

http://en.cs-lab.eu/wp-content/uploads/2016/06/csmio-ip-s-konfiguracja-we_wy-artykul.pdf

Title: Re: ATC Geneva wheel for mill
Post by: jve on April 05, 2018, 04:13:53 AM
i Try with INPUT4 but still no luck i cannot understand why it is count 1 pulse on input4
Title: Re: ATC Geneva wheel for mill
Post by: jve on April 05, 2018, 04:24:35 AM
Hi I Can see the input is reading i can see from csmio input21 and from mach3 it is true input 4 i can see the led on and off

i dont know if it is from the logic since for example input 4 if the ATC jump for 2 tools it need to count 2 pulse in input 4 and it is always counting 1
Title: Re: ATC Geneva wheel for mill
Post by: TPS on April 05, 2018, 04:24:43 AM
if you put some Addition MSGBox instruction to your CW Routine you can how often
Input gets triggered

Function CCW()'Rotation CCW
   Dim y As Integer
   Dim CTPos As Integer 'Carrousel Tool Position Relative to OldTool Position
   CTPos=0
   Activatesignal(OUTPUT9)'atc motor revirsing relay
   ActivateSignal(OUTPUT10)'Turns the AC Motor On
    Sleep(50)
    
     For y=0 To CCWPos
           While IsActive(OEMTrig9)'Wait for OEMTrig9 is off
      Sleep(10)
      Wend
MSGBox "Input is off"
           While NOT IsActive(OEMTrig9)'Wait for OEMTrig9 is on
      Sleep(10)
      Wend
MSGBox "Input is on"
            y=y+1
        Next y
   CTPos=y
   DeactivateSignal(OUTPUT9)
   Deactivatesignal(OUTPUT10)'atc motor revirsing relay
End Function
Title: Re: ATC Geneva wheel for mill
Post by: TPS on April 05, 2018, 04:31:48 AM
sorry seems i going to get bild

Function CW()'Rotation CW
   Dim x As Integer
   Dim CTPos As Integer 'Carrousel Tool Position Relative to OldTool Position
   CTPos=0
   ActivateSignal(OUTPUT9)'Turns the AC Motor On cw

   Sleep(50)

   For x=0 To CWPos
           While IsActive(OEMTrig9)'Wait for OEMTrig9 is off
      Sleep(10)
      Wend
           While NOT IsActive(OEMTrig9)'Wait for OEMTrig9 is on
      Sleep(10)
      Wend

            x=x+1
        Next x
this is wrong,not needed, the for next Loop is counting itselv.
Title: Re: ATC Geneva wheel for mill
Post by: jve on April 05, 2018, 04:35:36 AM
I Can see the input it is always 1 pulse  , 1 count
Title: Re: ATC Geneva wheel for mill
Post by: TPS on April 05, 2018, 04:40:04 AM
see my last post on page 1
Title: Re: ATC Geneva wheel for mill
Post by: jve on April 05, 2018, 04:48:48 AM
I try this too but still no luck this is my last one

Sub Main()
'Global variables declaration

Dim CCWPos as Integer
Dim CWPos as Integer


NewTool = GetSelectedTool()
OldTool = GetCurrentTool()

While NewTool > 16
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 > 16 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 SpidleOrient'Activate drive spindle orient
   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 SpidleOrient()'Spindle Orientation
      ActivateSignal(OUTPUT1)'Move spindle to position output#
      ActivateSignal(OUTPUT8)'Move spindle to position output#
      code("g04 p01")
           While IsActive(OEMTrig11)'Wait for OemTrig11 is off spindle drive oreient ready
      Sleep(10)
      Wend
           While NOT IsActive(OEMTrig11)'Wait for OemTrig11 is on spindle drive output
      Sleep(10)
      Wend
End Function

Function AtcIn()'Put old tool back to carrousel
      ActivateSignal(OUTPUT12)'Move carrousel air cylinder to the tool change position adjust output# to match atc slide
      code("g04 p01")
           While IsActive(OEMTrig3)'Wait for OEMTrig3 is off Mag Out
      Sleep(10)
      Wend
           While NOT IsActive(OEMTrig3)'Wait for OEMTrig3 is on carrousel in
      Sleep(10)
      Wend
End Function

Function Unclamp()'Spindle: Tool Unclamp
       ActivateSignal(OUTPUT13)'Release the tool, adjust output number for drawbar output
       ActivateSignal(OUTPUT14)'Clean tool
code("g04 p01")'pause
           While IsActive(OEMTrig8)'Wait for OEMTrig8 is off Unclamp
      Sleep(10)
      Wend
           While NOT IsActive(OEMTrig8)'Wait for OEMTrig8 is on Unclamp
      Sleep(10)
      Wend
End Function

Function AtcDown()'lowers atc to rotate
   ActivateSignal(OUTPUT11)'solonoid to lower atc
   code("G04 p01")'pause
           While IsActive(OEMTrig6)'Wait for OEMTrig6 is off Mag down
      Sleep(10)
      Wend
           While NOT IsActive(OEMTrig6)'Wait for OEMTrig6 is on Mag down
      Sleep(10)
      Wend
End Function

'Sequence to determine the least travel to move for TC, CW or CCW
'atp = Actual tool position, rtp = Requested tool positon
Sub LeastTravel()
   NTool = 16 ' Number of tools changer holds
   CWPos = GetSelectedTool() - GetCurrentTool() ' Assume a CW move
   If CWPos < 0 Then ' CWPos < 0 ==> rtp < atp
      CWPos = CWPos + NTool
   End If
   CCWPos = NTool - CWPos
   If CWPos < CCWPos Then
      call CW()
   Else
      call CCW()
   End If
End Sub

Function CW()'Rotation CW
   Dim x As Integer
   Dim CTPos As Integer 'Carrousel Tool Position Relative to OldTool Position
   CTPos=0
   ActivateSignal(OUTPUT9)'Turns the AC Motor On cw
   Sleep(50)

   For x=0 To CWPos
           While IsActive(INPUT4)'Wait for INPUT4 is off
      Sleep(10)
      Wend
           While NOT IsActive(INPUT4)'Wait for INPUT4 is on
      Sleep(10)
      Wend
        Next x
    CTPos=x
   DeactivateSignal(OUTPUT9)

End Function

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

Function AtcUp()'MAG UP
   DeActivateSignal(OUTPUT11)'relay for solonoid to lower/MAG UP
   code("G04 p01")'pause
           While IsActive(OEMTrig5)'Wait for OEMTrig5 is off Mag up
      Sleep(10)
      Wend
           While NOT IsActive(OEMTrig5)'Wait for OEMTrig5 is on Mag up
      Sleep(10)
      Wend
End Function

Function Clamp()'power drawbar unactivated
   DeactivateSignal(OUTPUT13)'unactivating drawbar relay
   DeactivateSignal(OUTPUT14)'unactivating Clean tool
           While IsActive(OEMTrig7)'Wait for OEMTrig7 is off Clamp
      Sleep(10)
      Wend
           While NOT IsActive(OEMTrig7)'Wait for OEMTrig7 is on Clamp
      Sleep(10)
      Wend
End Function

Function AtcOut()'retracts atc
      deActivateSignal(OUTPUT12)'atc retract cylinder relay Mag Inn
      code("g04 p01")
           While IsActive(OEMTrig4)'Wait for OEMTrig4 is off Mag Inn
      Sleep(10)
      Wend
           While NOT IsActive(OEMTrig4)'Wait for OEMTrig4 is on Mag Inn
      Sleep(10)
      deActivateSignal(OUTPUT1)'Spindle Orientation
      deActivateSignal(OUTPUT8)'Spindle Orientation
     
   Wend 
End Function




Title: Re: ATC Geneva wheel for mill
Post by: TPS on April 05, 2018, 04:56:11 AM
for the next add two msgbox instructions, to see that the right fuction is called, and the right Count is calculated


Function CW()'Rotation CW
   Dim x As Integer
   Dim CTPos As Integer 'Carrousel Tool Position Relative to OldTool Position
   CTPos=0

MSGBox "CW Rotation: " &CWPos

   ActivateSignal(OUTPUT9)'Turns the AC Motor On cw
   Sleep(50)

   For x=0 To CWPos
           While IsActive(INPUT4)'Wait for INPUT4 is off
      Sleep(10)
      Wend
           While NOT IsActive(INPUT4)'Wait for INPUT4 is on
      Sleep(10)
      Wend
        Next x
    CTPos=x
   DeactivateSignal(OUTPUT9)

End Function

Function CCW()'Rotation CCW
   Dim y As Integer
   Dim CTPos As Integer 'Carrousel Tool Position Relative to OldTool Position
   CTPos=0

MSGBox "CCW Rotation: " &CCWPos


   Activatesignal(OUTPUT9)'atc motor revirsing relay
   ActivateSignal(OUTPUT10)'Turns the AC Motor On
    Sleep(50)
   
     For y=0 To CCWPos
           While IsActive(INPUT4)'Wait for INPUT4 is off
      Sleep(10)
      Wend
           While NOT IsActive(INPUT4)'Wait for INPUT4 is on
      Sleep(10)
      Wend
        Next y
   CTPos=y
   DeactivateSignal(OUTPUT9)
   Deactivatesignal(OUTPUT10)'atc motor revirsing relay
End Function
Title: Re: ATC Geneva wheel for mill
Post by: jve on April 05, 2018, 05:00:12 AM
so i take it

CW tool 1,2,3,4
CWW tool 4,3,2,1
Title: Re: ATC Geneva wheel for mill
Post by: TPS on April 05, 2018, 05:02:17 AM
so direction an number of step's where right ?
Title: Re: ATC Geneva wheel for mill
Post by: jve on April 05, 2018, 05:15:52 AM
no it was the other way round but i fixed it and still no luck
Title: Re: ATC Geneva wheel for mill
Post by: TPS on April 05, 2018, 05:17:17 AM
then put this part of code:

Function CW()'Rotation CW
   Dim x As Integer
   Dim CTPos As Integer 'Carrousel Tool Position Relative to OldTool Position
   CTPos=0

CWPos = 2

   ActivateSignal(OUTPUT9)'Turns the AC Motor On cw
   Sleep(50)

   For x=0 To CWPos
      While IsActive(INPUT4)'Wait for INPUT4 is off
        Sleep(10)
      Wend
      While Not IsActive(INPUT4)'Wait for INPUT4 is on
        Sleep(10)
      Wend
   Next x
   CTPos=x
   DeactivateSignal(OUTPUT9)

End Function


into Operator -> VB Script Editor  window  and use the green >|| button to step through code to see what is going on
Title: Re: ATC Geneva wheel for mill
Post by: jve on April 05, 2018, 05:23:03 AM
this is the geneva wheel i show the input 4
Title: Re: ATC Geneva wheel for mill
Post by: jve on April 05, 2018, 05:44:15 AM
Now it is counting always 3 in input 4 so if the tool is tool 1 and i input MDI T5M6 it go to tool3
Title: Re: ATC Geneva wheel for mill
Post by: TPS on April 05, 2018, 05:52:18 AM
no you should put this part of code into

main menu -> Operator -> VB Script Editor window

an test the code wirh the green >|| button,
without running any M6 T someting in MDI

Code: [Select]
Function CW()'Rotation CW
   Dim x As Integer
   Dim CTPos As Integer 'Carrousel Tool Position Relative to OldTool Position
   CTPos=0

CWPos = 2

   ActivateSignal(OUTPUT9)'Turns the AC Motor On cw
   Sleep(50)

   For x=0 To CWPos
      While IsActive(INPUT4)'Wait for INPUT4 is off
        Sleep(10)
      Wend
      While Not IsActive(INPUT4)'Wait for INPUT4 is on
        Sleep(10)
      Wend
   Next x
   CTPos=x
   DeactivateSignal(OUTPUT9)

it is only a prticular test of this part of code
Title: Re: ATC Geneva wheel for mill
Post by: jve on April 05, 2018, 06:05:41 AM
i notice that when i run in mdi it popup a message window say CW rotation 2 and the turret moves 3 positions then i modify the code CWPos=5 and the same popup window but this time rotation 5 and the atc move 6 positions
Title: Re: ATC Geneva wheel for mill
Post by: TPS on April 05, 2018, 06:16:34 AM
the modify

For x=0 To CWPos -1

For y=0 To CCWPos -1
Title: Re: ATC Geneva wheel for mill
Post by: jve on April 05, 2018, 06:27:44 AM
I try But this time the magazine motor turns a little bit i think the problem is in the sub it is not calculating the number of position
Title: Re: ATC Geneva wheel for mill
Post by: TPS on April 05, 2018, 06:31:14 AM
thats why i asked to use the


MSGBox "CW Rotation: " &CWPos

and

MSGBox "CCW Rotation: " &CCWPos

to see that the calculation of steps is right
Title: Re: ATC Geneva wheel for mill
Post by: jve on April 05, 2018, 06:34:29 AM
no the rotation is good but the calculating steps is not
Title: Re: ATC Geneva wheel for mill
Post by: jve on April 05, 2018, 06:35:52 AM
i Think there is something wrong here


'Sequence to determine the least travel to move for TC, CW or CCW
'atp = Actual tool position, rtp = Requested tool positon
Sub LeastTravel()
   NewTool = GetSelectedTool()
   OldTool = GetCurrentTool()
   NTool = 16 ' Number of tools changer holds
   CWPos = GetSelectedTool() - GetCurrentTool() ' Assume a CW move
   If CWPos < 0 Then ' CWPos < 0 ==> rtp < atp
      CWPos = CWPos + NTool
   End If
   CCWPos = NTool - CWPos
   If CWPos < CCWPos Then
      call CW()
   Else
      call CCW()
   End If
End Sub
Title: Re: ATC Geneva wheel for mill
Post by: TPS on April 05, 2018, 06:44:09 AM
no your CWPos and CCWPos are not global:


wrong:

Sub Main()
'Global variables declaration

Dim CCWPos as Integer
Dim CWPos as Integer
...

right:

'Global variables declaration

Global CCWPos as Integer
Global CWPos as Integer

Sub Main()
...
Title: Re: ATC Geneva wheel for mill
Post by: jve on April 05, 2018, 07:51:04 AM
I Real Appreciate you help we are cnc builders please post me private message if you need any help now it is working perfect i had to modify some small changes

'Sequence to determine the least travel to move for TC, CW or CCW
'atp = Actual tool position, rtp = Requested tool positon
Sub LeastTravel()
   NewTool = GetSelectedTool()
   OldTool = GetCurrentTool()
   NTool = 16 ' Number of tools changer holds
   CWPos = GetSelectedTool() - GetCurrentTool() ' Assume a CW move
   If CWPos < 0 Then ' CWPos < 0 ==> rtp < atp
      CWPos = CWPos + NTool
   End If
   CCWPos = NTool - CWPos
   If CWPos < CCWPos Then
      call CW()
   Else
      call CCW()
   End If
End Sub
Title: Re: ATC Geneva wheel for mill
Post by: jve on April 05, 2018, 07:52:00 AM
this is the final

'Global variables declaration

 Global CCWPos As Integer
 Global CWPos As Integer

Sub Main()
NewTool = GetSelectedTool()
OldTool = GetCurrentTool()

While NewTool > 16
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 > 16 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 SpidleOrient'Activate drive spindle orient
   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 SpidleOrient()'Spindle Orientation
      ActivateSignal(OUTPUT1)'Move spindle to position output#
      ActivateSignal(OUTPUT8)'Move spindle to position output#
      code("g04 p01")
           While IsActive(OEMTrig11)'Wait for OemTrig11 is off spindle drive oreient ready
      Sleep(10)
      Wend
           While Not IsActive(OEMTrig11)'Wait for OemTrig11 is on spindle drive output
      Sleep(10)
      Wend
End Function

Function AtcIn()'Put old tool back to carrousel
      ActivateSignal(OUTPUT12)'Move carrousel air cylinder to the tool change position adjust output# to match atc slide
      code("g04 p01")
           While IsActive(OEMTrig3)'Wait for OEMTrig3 is off Mag Out
      Sleep(10)
      Wend
           While Not IsActive(OEMTrig3)'Wait for OEMTrig3 is on carrousel in
      Sleep(10)
      Wend
End Function

Function Unclamp()'Spindle: Tool Unclamp
       ActivateSignal(OUTPUT13)'Release the tool, adjust output number for drawbar output
       ActivateSignal(OUTPUT14)'Clean tool
code("g04 p01")'pause
           While IsActive(OEMTrig8)'Wait for OEMTrig8 is off Unclamp
      Sleep(10)
      Wend
           While Not IsActive(OEMTrig8)'Wait for OEMTrig8 is on Unclamp
      Sleep(10)
      Wend
End Function

Function AtcDown()'lowers atc to rotate
   ActivateSignal(OUTPUT11)'solonoid to lower atc
   code("G04 p01")'pause
           While IsActive(OEMTrig6)'Wait for OEMTrig6 is off Mag down
      Sleep(10)
      Wend
           While Not IsActive(OEMTrig6)'Wait for OEMTrig6 is on Mag down
      Sleep(10)
      Wend
End Function

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

Function CW()'Rotation CW
   Dim x As Integer
   Dim CTPos As Integer 'Carrousel Tool Position Relative to OldTool Position
   CTPos=0
   ActivateSignal(OUTPUT9)'Turns the AC Motor On cw
   ActivateSignal(OUTPUT10)'Turns the AC Motor On
   Sleep(50)

   For x=1 To CWPos
           While IsActive(INPUT4)'Wait for INPUT4 is off
      Sleep(10)
      Wend
           While Not IsActive(INPUT4)'Wait for INPUT4 is on
      Sleep(10)
      Wend
        Next x
    CTPos=x
   DeactivateSignal(OUTPUT9)
   Deactivatesignal(OUTPUT10)'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(OUTPUT9)'atc motor revirsing relay
   
    Sleep(50)
   
     For y=1 To CCWPos
           While IsActive(INPUT4)'Wait for INPUT4 is off
      Sleep(10)
      Wend
           While Not IsActive(INPUT4)'Wait for INPUT4 is on
      Sleep(10)
      Wend
        Next y
   CTPos=y
   DeactivateSignal(OUTPUT9)
   Deactivatesignal(OUTPUT10)'atc motor revirsing relay
End Function

Function AtcUp()'MAG UP
   DeActivateSignal(OUTPUT11)'relay for solonoid to lower/MAG UP
   code("G04 p01")'pause
           While IsActive(OEMTrig5)'Wait for OEMTrig5 is off Mag up
      Sleep(10)
      Wend
           While Not IsActive(OEMTrig5)'Wait for OEMTrig5 is on Mag up
      Sleep(10)
      Wend
End Function

Function Clamp()'power drawbar unactivated
   DeactivateSignal(OUTPUT13)'unactivating drawbar relay
   DeactivateSignal(OUTPUT14)'unactivating Clean tool
           While IsActive(OEMTrig7)'Wait for OEMTrig7 is off Clamp
      Sleep(10)
      Wend
           While Not IsActive(OEMTrig7)'Wait for OEMTrig7 is on Clamp
      Sleep(10)
      Wend
End Function

Function AtcOut()'retracts atc
      deActivateSignal(OUTPUT12)'atc retract cylinder relay Mag Inn
      code("g04 p01")
           While IsActive(OEMTrig4)'Wait for OEMTrig4 is off Mag Inn
      Sleep(10)
      Wend
           While Not IsActive(OEMTrig4)'Wait for OEMTrig4 is on Mag Inn
      Sleep(10)
      deActivateSignal(OUTPUT1)'Spindle Orientation
      deActivateSignal(OUTPUT8)'Spindle Orientation
     
   Wend 
End Function


       
Title: Re: ATC Geneva wheel for mill
Post by: TPS on April 05, 2018, 08:00:41 AM
happy to hear that it is working now.