Hello Guest it is November 22, 2019, 03:09:20 PM

Author Topic: ATC VB script example for rotary changer...  (Read 29875 times)

0 Members and 1 Guest are viewing this topic.

Offline poppabear

*
  • *
  •  2,233 2,233
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
ATC VB script example for rotary changer...
« on: September 11, 2007, 02:40:35 PM »
I saw a bunch of questions on how to write an ATC so I put one up, it uses the C axis to move the turret/carracell

This script is for a 8 position Rotary Turret tool changer on a Lathe, but you could adapt it to a Mill or any other rotary changer.
Just Change the number of Tools, also you may need to add a tool change point.
It has activation for release and lock of the turret.
You can tick off the use "rotary roll over" tick box so that the angles read better for you under general.
Also, it is a "find the shortest path" to the next tool.

You will need to change the ".txt" to a ".m1s" extension and drop it in your Lathe or Mill, you can drop a C axis to watch the rotorary.

Enjoy,

Scott
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/
Re: ATC VB script example for rotary changer...
« Reply #1 on: September 11, 2007, 10:34:18 PM »
Scott:

   Thanks for posting the script!!  I am in the finishing stages of a lathe retro fit that has an 8 station turret and a solenoid operated air cylinder to lock/unlock the turret!! It uses a small stepper to index the turret.

    I was wondering how I could possibly figure this out!  When I get done with that machine, I have a 24 position tool changer on the mill that needs to be controlled by Mach.

    Do you have a preference on Parallell, ModIO or Modbus PLC  IO for something as simple as the lathe turret?

   Again, Thanks for the posting

   Jim

Offline poppabear

*
  • *
  •  2,233 2,233
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: ATC VB script example for rotary changer...
« Reply #2 on: September 12, 2007, 08:22:00 AM »
Jim,

    Thanks for replying, I saw 33 downloads but no post back, I was beginning to wonder if anyone thought it helpful.

As far as ATC control type, it depends on complexity of the ATC.

For Simple ATC's (like the one posted), there is not alot of I/O, so parallel is fine for it, and if you doing a mill and your C axis is open you can use it there as well just change the tool number in your carracell and add your I/O for your swap motions.

For medium complexity ATC's that have alot of error/checking and other movements I use a DL06.

for Hight complexity ATC's, that have above plus a "read-a-head" swap arm type tool changer (commecial machines), I use a DL06 with 2 motion control modules, the caracell and swap arm are completly independant of mach, after the tool change mach continues machining and the PLC driven ATC continues on with putting back the old tool, and loading the new tool. So Tool change time is about 2-3 seconds for the swap.

You can do a high complexity lathe as well, by having a Turret and a tail stock turret, you can have your turret for your profile and X movement tools, and your tail for your Drills/live holder.

I have a guy in KY, who wants me to retrofit a "Y axis" lathe with live tooling, now THAT is gonna be fun!!!!.........

scott
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/
Re: ATC VB script example for rotary changer...
« Reply #3 on: September 12, 2007, 09:51:53 AM »
Hi Scott,

Thanks much for the example. When I download and open, I get a one line display. Not knowing VB I don't know how to break it into multiple lines so I could possibly make some sense out of it.
Have I done something wrong in the download or is there another way to download so it will read in multiple lines?

Thanks,

Claude

Offline poppabear

*
  • *
  •  2,233 2,233
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: ATC VB script example for rotary changer...
« Reply #4 on: September 12, 2007, 11:59:20 AM »
use word wrap
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/

Offline drew

*
  •  79 79
    • View Profile
Re: ATC VB script example for rotary changer...
« Reply #5 on: October 01, 2007, 01:51:31 PM »
I am working on my HNC tool changing macro. It is changing tools now but the Code "G4 PXX"  doesn't work as I expected. And the While loops in the Case statement maynot be holding up the execution of the macro as I ecpected also. Big THANKS poppabear just something to start from is a huge help! OEMTRIG 1-4 are from the original turret encoder signales. The dwell needed between I/O signales seens to be my bigest problem right now. I'm still working on it and insight is appecerated. Anyway here it is.

Sub main()
NumSlots=0
OldTurretPos=(GetOEMDRO(824))     'current tool position
NextTool = GetSelectedTool()      'tool to be indexed
EncoderBCD = 0                    'encoder position is number
TurretLock = False        'turret locked down limit switch
EncoderinPos = False        'NextTool and encoder position match
TestM6 = True                'test run sub replace NextTool value by question

If TestM6 Then                               'if test get tool to index
  NextTool = Question("Tool to index ")
  End If

If NextTool>8 Or NextTool<1 Then      'valid tool check
  Message("Next Tool out of range")
  Exit Sub
  End If

While Not TurretLock Or Not EncoderinPos
  If OldTurretPos <> NextTool Then      'if same tool skip index
 
   DeActivateSignal(OUTPUT8)  'Release Turret holding pin
   Code"G04 P200"
   ActivateSignal(OUTPUT7)  'Rase and rotate Turret

   '=== Index Tool ===
  Select Case NextTool
    Case  1 'Tool#1
     While Not(Not IsActive(OEMTRIG4) And Not IsActive(OEMTRIG3) And Not IsActive(OEMTRIG2) And IsActive(OEMTRIG1))
   Wend
    Case  2 'Tool#2
     While Not(Not IsActive(OEMTRIG4) And Not IsActive(OEMTRIG3) And IsActive(OEMTRIG2) And Not IsActive(OEMTRIG1))
   Wend
    Case  3 'Tool#3
     While Not(Not IsActive(OEMTRIG4) And Not IsActive(OEMTRIG3) And IsActive(OEMTRIG2) And IsActive(OEMTRIG1))
   Wend
    Case  4 'Tool#4
     While Not(Not IsActive(OEMTRIG4) And IsActive(OEMTRIG3) And Not IsActive(OEMTRIG2) And Not IsActive(OEMTRIG1))
   Wend
    Case  5 'Tool#5
     While Not(Not IsActive(OEMTRIG4) And IsActive(OEMTRIG3) And Not IsActive(OEMTRIG2) And IsActive(OEMTRIG1))
   Wend
    Case  6 'Tool#6
     While Not(Not IsActive(OEMTRIG4) And IsActive(OEMTRIG3) And IsActive(OEMTRIG2) And Not IsActive(OEMTRIG1))
   Wend
    Case  7 'Tool#7
     While Not(Not IsActive(OEMTRIG4) And IsActive(OEMTRIG3) And IsActive(OEMTRIG2) And IsActive(OEMTRIG1))
   Wend
    Case  8 'Tool#8
     While Not(IsActive(OEMTRIG4) And Not IsActive(OEMTRIG3) And Not IsActive(OEMTRIG2) And Not IsActive(OEMTRIG1))
   Wend

    End Select
   
    ActivateSignal(OUTPUT8)  'Engauge Turret holding pin
     Code"G04 P800"
    DeActivateSignal(OUTPUT7)  'Lower and lock Turret
     Code"G04 P400"
    DeActivateSignal(OUTPUT8)  'Release Turret holding pin
    NumSlots=NumSlots+1


 End If ' same tool skip
 
EncoderBCD = ((8*IsActive(OEMTRIG4)) + (4* IsActive(OEMTRIG3)) + (2* IsActive(OEMTRIG2)) + (1* IsActive(OEMTRIG1)))     
If NextTool = EncoderBCD Then
   EncoderinPos = True
   Else                  'NextTool and encoder position match
     Message("Tool out of Position")
     EncoderinPos= False            'NextTool and encoder position match
     OldTurretPos= 0
     'Code "G04 P500"            'force turret rotation
   End If
   
If IsActive(INPUT1) Then
   TurretLock = True            'turret locked down limit switch
   Else
     Message("Turret not Locked Down")
     TurretLock = False            'turret locked down limit switch
     OldTurretPos=0            'force turret rotation                 
   End If
   
Wend  'verify tool in position and turret down

Message("Tool "& NextTool &" loaded " & NumSlots)
SetCurrentTool(NextTool)
End sub
             
If I had something important to say it would be here.

Offline drew

*
  •  79 79
    • View Profile
Re: ATC VB script example for rotary changer...
« Reply #6 on: October 01, 2007, 04:07:14 PM »
Ok I found out why the dwell was not working(see macro). Macro now works really well. When indexing tool 5 It stops at 7 then goes to 5 but I can live with that. I have not discovered the minimun dwell amount that will work. These do not seem to be too much. The encoder magnet may need to be adjusted for proper operation. I actually look for the tool position before the tool that is requested then check position after it is stoped.The code is ...

Sub main()
NumSlots=0
OldTurretPos=(GetOEMDRO(824))     'current tool position
NextTool = GetSelectedTool()      'tool to be indexed
EncoderBCD = 0                    'encoder position is number
TurretLock = False        'turret locked down limit switch
EncoderinPos = False        'NextTool and encoder position match
TestM6 = True                'test run sub replace NextTool value by question

If TestM6 Then             'if test get tool to index
  NextTool = Question("Tool to index ")
  End If

If NextTool>8 Or NextTool<1 Then   'valid tool check
  Message("Next Tool out of range")
  Exit Sub
  End If

While Not TurretLock Or Not EncoderinPos
  If OldTurretPos <> NextTool Then      'if same tool skip index
 
   DeActivateSignal(OUTPUT8)  'Release Turret holding pin
     Code"G04 P200"
     While Ismoving()
      Wend
   ActivateSignal(OUTPUT7)  'Rase and rotate Turret

   '=== Index Tool ===
  Select Case NextTool
    Case  1 'Tool#1  encoder pos8
     While Not(IsActive(OEMTRIG4) And Not IsActive(OEMTRIG3) And Not IsActive(OEMTRIG2) And Not IsActive(OEMTRIG1))
   Wend
    Case  2 'Tool#2  encoder pos1
     While Not(Not IsActive(OEMTRIG4) And Not IsActive(OEMTRIG3) And Not IsActive(OEMTRIG2) And IsActive(OEMTRIG1))
   Wend
    Case  3 'Tool#3  encoder pos2
     While Not(Not IsActive(OEMTRIG4) And Not IsActive(OEMTRIG3) And IsActive(OEMTRIG2) And Not IsActive(OEMTRIG1))
   Wend
    Case  4 'Tool#4  encoder pos3
     While Not(Not IsActive(OEMTRIG4) And Not IsActive(OEMTRIG3) And IsActive(OEMTRIG2) And IsActive(OEMTRIG1))
   Wend
    Case  5 'Tool#5  encoder pos4
     While Not(Not IsActive(OEMTRIG4) And IsActive(OEMTRIG3) And Not IsActive(OEMTRIG2) And Not IsActive(OEMTRIG1))
   Wend
    Case  6 'Tool#6  encoder pos5
     While Not(Not IsActive(OEMTRIG4) And IsActive(OEMTRIG3) And Not IsActive(OEMTRIG2) And IsActive(OEMTRIG1))
   Wend
    Case  7 'Tool#7  encoder pos6
     While Not(Not IsActive(OEMTRIG4) And IsActive(OEMTRIG3) And IsActive(OEMTRIG2) And Not IsActive(OEMTRIG1))
   Wend
    Case  8 'Tool#8  encoder pos7
     While Not(Not IsActive(OEMTRIG4) And IsActive(OEMTRIG3) And IsActive(OEMTRIG2) And IsActive(OEMTRIG1))
   Wend

    End Select
   
    ActivateSignal(OUTPUT8)  'Engauge Turret holding pin
     Code"G04 P400"
     While Ismoving()
      Wend
    DeActivateSignal(OUTPUT7)  'Lower and lock Turret
     Code"G04 P800"
     While Ismoving()
      Wend
    DeActivateSignal(OUTPUT8)  'Release Turret holding pin
    NumSlots=NumSlots+1


 End If ' same tool skip
 
EncoderBCD = 0

If IsActive(OEMTRIG4) Then
  EncoderBCD = EncoderBCD + 8
  End If
If IsActive(OEMTRIG3) Then
  EncoderBCD = EncoderBCD + 4
  End If
If IsActive(OEMTRIG2) Then
  EncoderBCD = EncoderBCD + 2
  End If
If IsActive(OEMTRIG1) Then
  EncoderBCD = EncoderBCD + 1
  End If
     
Message("Tool Encoder "& EncoderBCD)
Code"G04 P400"
     While Ismoving()
      Wend

If NextTool = EncoderBCD Then
   EncoderinPos = True
   Else                  'NextTool and encoder position match
     Message("Tool out of Position")
     EncoderinPos= False            'NextTool and encoder position match
     OldTurretPos= 0            'force turret rotation
   End If
   
If IsActive(INPUT1) Then
   TurretLock = True            'turret locked down limit switch
   Else
     Message("Turret not Locked Down")
     TurretLock = False            'turret locked down limit switch
     OldTurretPos=0            'force turret rotation                 
   End If
   
Wend  'verify tool in position and turret down

Message("Tool "& NextTool &" loaded " & "Loop count "& NumSlots)
SetCurrentTool(NextTool)
End sub
                   

If I had something important to say it would be here.

Offline poppabear

*
  • *
  •  2,233 2,233
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: ATC VB script example for rotary changer...
« Reply #7 on: October 01, 2007, 05:02:53 PM »
Just a curious finding, your G4 P400  (that is in secondes 400 seconds, unless you have g4 checked in milliseconds).

I know you probably dont want to hear this, but It may be easier to do the timing issues with the timers and the logic in Brian.

Scott
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/

Offline drew

*
  •  79 79
    • View Profile
Re: ATC VB script example for rotary changer...
« Reply #8 on: October 02, 2007, 02:16:56 PM »
I am dwelling in milliseconds .The turret is currently indexing to the correct tool every time with an occasional unscheduled stop along the way. Index times run about 4 seconds for a clean stop at the right tool  and 8 seconds if it stops at a wrong tool first. I didn't understand the 'logic in Brian' is that a reference to the DL06?
Thanks Drew
If I had something important to say it would be here.

Offline poppabear

*
  • *
  •  2,233 2,233
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: ATC VB script example for rotary changer...
« Reply #9 on: October 02, 2007, 06:37:02 PM »
no,

    Download the latest Mach3, and open up "Brian editor", it is like a graphically driven soft plc program.
It run much faster and with less cpu than the macro pump. Although, the macro pump is still usufull for more complex things.

Brian has timers and logic, both that you can use ro redo your ATC.

Scott
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/