Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: poppabear 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
-
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
-
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
-
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
-
use word wrap
-
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
-
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
-
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
-
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
-
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
-
Scott has Brian on the brain. ;D
Watch the brains intro video tutorials, they will help.
Brett
-
:o I didn't know Mach had brains. ;) Drew
-
When using any of the toolchange macros described above, what file name would one save the macro to in order for it to work with Mach3. M06.m1s ???
Normal tool change command is M06 TXX. The M06 calls for a tool change but how does the T value get passed to the macro?
TIA from a macro writing infant,
Claude
-
Claude,
Call it "M6Start.m1s"
The T value is grabbed by the Macro from the G code and from your tool number dro.
scott
-
I just guessed to save it as "M6Start.m1s" like Scott replied. In MDI put "t0606" hit enter and it runs the macro.
Drew
ps This example is for a Mach lathe setup not a mill.
-
Hi, I've just posted a simple toolchanger BRAIN that might be worth looking at to give you some idea's for your application. Your ATC brain would be simpler as you only need to compare the tool encoder position to your tool request.
John
-
For Drew,
Does your VB script for the HNC Turret changer require a PLC? How did you connect to the turret encoder, and air cylinders, to read the BCD code? Can it all be done through parallel port inputs and outputs? I'm doing an HNC and would really like to try out MACH3 if I can get by the Turret programming problem. The machine has a Fanuc Control with Fanuc 00 motor/encoders on it now, which are coming off.
-
My machine pics at http://www.machsupport.com/forum/index.php/topic,4618.0.html
My turret uses only LPT and M6Start.m1s macro ( no PLC, macropump or brains) to control 2 solenoids and read the 4 bit BCD and turret down(lock) position. Note when tool changing in lathe only the 'T' code is used no M6 in the g-code program.
The macro indexes at the current machine position so move your turret to a safe position before hand.
My Hnc had a GE 550 control. What fanuc control did/does your Hnc have?
-
Hi everyone this is my first post here, I have been using Mach3 for years and am about to retrofit a mill with an analam 3300mk control and thought to add an arm type tool changer but not sure about the software part. I have a DL-06 plc and can wire everything up with no problem but programming from scratch is not my strong point. Any help would be greatly appreciated.