Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: natefoerg on January 20, 2014, 01:33:48 PM
-
Hello, I am a good ways through building a conversion for my 3 axis BP mill. I purchased a Cat40 spindle from a Tree mill that has a ball bearing gripper that is operated by an air cyllinder inside the spindle itself. I have almost finished construction of an aluminum (7/8's thick) structure that mounts onto my mill from the Knee ways up to above where the head normally is. The entire head and ram assembley (with my traditional cnc Z axis quill) will be removed and sold. The aluminum structure has robust linear roller (not ball) ways that carry the spindle and motor and its associated parts (like a traditional VMC)
My tool changer is of a fairly novel design. When the spindle and its housing are fully retracted (Z+ limit) (about 30 inches from the mills table(gaining a ton of Z height with this conversion BTW)) a hole that is in the position of the front of the original Ram is opened. from this opening a carriage emerges riding on smaller linear rails that houses the tools. I plan on a carraige with 6 tools for now. The spindle then deposits the tool in its original location, retracts and descends to pick up the new tool. Spindle then retracts again, carraige retracts also and then the spindle descends to its lotation for machining.
I have the spindles air cyllinder functional and it is controlled with a C6 board and solenoid through Mach with a M998 and M999 command.
I have read Hoss's "wine rack" style macro about a thousand times trying to wrap my head around how it works. I have been studying the VB mach manual and reading everything I can find.
Here is what I want to do.
Code calls for tool change.
Macro determines if tool called is tool in use.
If tool called is not tool in use, retract spindle(Z) fully.
Move tool carriage axis (in this case I will use U because I already have a 4th axis) to current tool loaded in spindles location.
Lower spindle(Z) to tool storage depth.
Activate M998 to release tool.
Retract spindle (Z) fully.
Move tool carraige axis to called tool location.
Lower spindle (Z) to tool storage depth.
Activate M999 to grab tool.
Retract spindle(Z) fully.
Retract tool carraige to its home location. (I presume this will be U0, and I plan on having the tools in locations such as U2, U4, U6, etc..)
Lower spindle(Z) to its program location (with correct Z offset) and resume machining.
Here is my Macro so far-
I have yet to test it, as I am away from the machine till tonight. Am I on the right track?
If GetSelectedTool() = GetCurrentTool() Then
End
End If
If CurrentTool() = 1 Then
Code "G53 G0 Z24" 'Z full retract at rapid speed.
While IsMoving()
Code "G53 G1 U0 F20" 'U tool position 1 at 20IPM.
While IsMoving()
Code "G53 G1 Z18 F20"
While IsMoving()
ActivateSignal(Output1) 'Unclamps drawbar.
Sleep .5 'Pauses half second for drawbar to fully unclamp.
Code "G53 G0 Z24" 'Z full retract at rapid speed.
If CurrentTool() = 2 Then
Code "G53 G0 Z24" 'Z full retract at rapid speed.
While IsMoving()
Code "G53 G1 U4 F20" 'U tool position 2 at 20IPM.
While IsMoving()
Code "G53 G1 Z18 F20"
While IsMoving()
ActivateSignal(Output1) 'Unclamps drawbar.
Sleep .5 'Pauses half second for drawbar to fully unclamp.
Code "G53 G0 Z24" 'Z full retract at rapid speed.
If CurrentTool() = 3 Then
Code "G53 G0 Z24" 'Z full retract at rapid speed.
While IsMoving()
Code "G53 G1 U8 F20" 'U tool position 3 at 20IPM.
While IsMoving()
Code "G53 G1 Z18 F20"
While IsMoving()
ActivateSignal(Output1) 'Unclamps drawbar.
Sleep .5 'Pauses half second for drawbar to fully unclamp.
Code "G53 G0 Z24" 'Z full retract at rapid speed.
If CurrentTool() = 4 Then
Code "G53 G0 Z24" 'Z full retract at rapid speed.
While IsMoving()
Code "G53 G1 U12 F20" 'U tool position 4 at 20IPM.
While IsMoving()
Code "G53 G1 Z18 F20"
While IsMoving()
ActivateSignal(Output1) 'Unclamps drawbar.
Sleep .5 'Pauses half second for drawbar to fully unclamp.
Code "G53 G0 Z24" 'Z full retract at rapid speed.
If CurrentTool() = 5 Then
Code "G53 G0 Z24" 'Z full retract at rapid speed.
While IsMoving()
Code "G53 G1 U16 F20" 'U tool position 5 at 20IPM.
While IsMoving()
Code "G53 G1 Z18 F20"
While IsMoving()
ActivateSignal(Output1) 'Unclamps drawbar.
Sleep .5 'Pauses half second for drawbar to fully unclamp.
Code "G53 G0 Z24" 'Z full retract at rapid speed.
If CurrentTool() = 6 Then
Code "G53 G0 Z24" 'Z full retract at rapid speed.
While IsMoving()
Code "G53 G1 U24 F20" 'U tool position 6 at 20IPM.
While IsMoving()
Code "G53 G1 Z18 F20"
While IsMoving()
ActivateSignal(Output1) 'Unclamps drawbar.
Sleep .5 'Pauses half second for drawbar to fully unclamp.
Code "G53 G0 Z24" 'Z full retract at rapid speed.
If GetSelectedTool = 1 Then
Code "G53 G0 Z24" 'Z full retract at rapid speed.
While IsMoving()
Code "G53 G1 U4 F20" 'U tool position 1 at 20IPM.
While IsMoving()
ActivateSignal(Output1) 'Unclamps drawbar.
Sleep .5 'Pauses half second for drawbar to fully unclamp.
Code "G53 G1 Z18 F20" 'Move to Z tool pickup height at 20IPM.
While IsMoving()
DeActivateSignal(Output1) 'Clamps drawbar.
Sleep 1 'Pauses one second for drawbar to fully clamp.
Code "G53 G0 Z24" 'Z full retract at rapid speed.
While IsMoving()
Code "G53 G0 U-4" 'retracts U tool rack to home position at rapid speed.
While IsMoving()
End If.
If GetSelectedTool = 2 Then
Code "G53 G0 Z24" 'Z full retract at rapid speed.
While IsMoving()
Code "G53 G1 U8 F20" 'U tool position 2 at 20IPM.
While IsMoving()
ActivateSignal(Output1) 'Unclamps drawbar.
Sleep .5 'Pauses half second for drawbar to fully unclamp.
Code "G53 G1 Z18 F20" 'Move to Z tool pickup height at 20IPM.
While IsMoving()
DeActivateSignal(Output1) 'Clamps drawbar.
Sleep 1 'Pauses one second for drawbar to fully clamp.
Code "G53 G0 Z24" 'Z full retract at rapid speed.
While IsMoving()
Code "G53 G0 U-4" 'retracts U tool rack to home position at rapid speed.
While IsMoving()
End If.
If GetSelectedTool = 3 Then
Code "G53 G0 Z24" 'Z full retract at rapid speed.
While IsMoving()
Code "G53 G1 U8 F20" 'U tool position 3 at 20IPM.
While IsMoving()
ActivateSignal(Output1) 'Unclamps drawbar.
Sleep .5 'Pauses half second for drawbar to fully unclamp.
Code "G53 G1 Z18 F20" 'Move to Z tool pickup height at 20IPM.
While IsMoving()
DeActivateSignal(Output1) 'Clamps drawbar.
Sleep 1 'Pauses one second for drawbar to fully clamp.
Code "G53 G0 Z24" 'Z full retract at rapid speed.
While IsMoving()
Code "G53 G0 U-4" 'retracts U tool rack to home position at rapid speed.
While IsMoving()
End If.
If GetSelectedTool = 4 Then
Code "G53 G0 Z24" 'Z full retract at rapid speed.
While IsMoving()
Code "G53 G1 U12 F20" 'U tool position 4 at 20IPM.
While IsMoving()
ActivateSignal(Output1) 'Unclamps drawbar.
Sleep .5 'Pauses half second for drawbar to fully unclamp.
Code "G53 G1 Z18 F20" 'Move to Z tool pickup height at 20IPM.
While IsMoving()
DeActivateSignal(Output1) 'Clamps drawbar.
Sleep 1 'Pauses one second for drawbar to fully clamp.
Code "G53 G0 Z24" 'Z full retract at rapid speed.
While IsMoving()
Code "G53 G0 U-4" 'retracts U tool rack to home position at rapid speed.
While IsMoving()
End If.
If GetSelectedTool = 5 Then
Code "G53 G0 Z24" 'Z full retract at rapid speed.
While IsMoving()
Code "G53 G1 U16 F20" 'U tool position 5 at 20IPM.
While IsMoving()
ActivateSignal(Output1) 'Unclamps drawbar.
Sleep .5 'Pauses half second for drawbar to fully unclamp.
Code "G53 G1 Z18 F20" 'Move to Z tool pickup height at 20IPM.
While IsMoving()
DeActivateSignal(Output1) 'Clamps drawbar.
Sleep 1 'Pauses one second for drawbar to fully clamp.
Code "G53 G0 Z24" 'Z full retract at rapid speed.
While IsMoving()
Code "G53 G0 U-4" 'retracts U tool rack to home position at rapid speed.
While IsMoving()
End If.
If GetSelectedTool = 6 Then
Code "G53 G0 Z24" 'Z full retract at rapid speed.
While IsMoving()
Code "G53 G1 U20 F20" 'U tool position 6 at 20IPM.
While IsMoving()
ActivateSignal(Output1) 'Unclamps drawbar.
Sleep .5 'Pauses half second for drawbar to fully unclamp.
Code "G53 G1 Z18 F20" 'Move to Z tool pickup height at 20IPM.
While IsMoving()
DeActivateSignal(Output1) 'Clamps drawbar.
Sleep 1 'Pauses one second for drawbar to fully clamp.
Code "G53 G0 Z24" 'Z full retract at rapid speed.
While IsMoving()
Code "G53 G0 U-4" 'retracts U tool rack to home position at rapid speed.
While IsMoving()
End If.
-
Just tried the Macro in a PC here at work in the Mach 3 VB editor and got the following error on line 122 "Buffer too small"
-
Change While IsMoving to:
WhileIsMoving()
Wend
and change Sleep .5 to:
Sleep(500)
And Sleep1 to:
Sleep(1000)
-
So a friend has helped me with the code a bit...
If GetSelectedTool() = GetCurrentTool() Then
End
Else
Code "G53 G0 Z24" 'Z full retract at rapid speed.
While IsMoving()
Wend
CurrentTool = GetCurrentTool()
SelectedTool = GetSelectedTool()
Select Case CurrentTool
Case 1
Code "G53 G1 U0 F20" 'U tool position 1 at 20IPM.
Case 2
Code "G53 G1 U4 F20" 'U tool position 2 at 20IPM.
Case 3
Code "G53 G1 U8 F20" 'U tool position 3 at 20IPM.
Case 4
Code "G53 G1 U12 F20" 'U tool position 4 at 20IPM.
Case 5
Code "G53 G1 U16 F20" 'U tool position 5 at 20IPM.
Case 6
Code "G53 G1 U24 F20" 'U tool position 6 at 20IPM.
End Select
While IsMoving()
Wend
Code "G53 G1 Z18 F20" 'Moves to tool release Z position.
While IsMoving()
Wend
ActivateSignal(Output1) 'Unclamps drawbar.
Sleep .5 'Pauses half second for drawbar to fully unclamp.
Code "G53 G0 Z24" 'Z full retract at rapid speed.
While IsMoving()
Wend
Select Case SelectedTool
Case 1
Code "G53 G1 U0 F20" 'U tool position 1 at 20IPM.
Case 2
Code "G53 G1 U4 F20" 'U tool position 2 at 20IPM.
Case 3
Code "G53 G1 U8 F20" 'U tool position 3 at 20IPM.
Case 4
Code "G53 G1 U12 F20" 'U tool position 4 at 20IPM.
Case 5
Code "G53 G1 U16 F20" 'U tool position 5 at 20IPM.
Case 6
Code "G53 G1 U20 F20" 'U tool position 6 at 20IPM.
End Select
While IsMoving()
Wend
Code "G53 G1 Z18 F20" 'Move to Z tool pickup height at 20IPM.
While IsMoving()
Wend
DeActivateSignal(Output1) 'Clamps drawbar.
Sleep 1 'Pauses one second for drawbar to fully clamp.
Code "G53 G0 Z24" 'Z full retract at rapid speed.
While IsMoving()
Wend
Code "G53 G0 U-4" 'retracts U tool rack to home position at rapid speed.
While IsMoving()
Wend
'Lower spindle(Z) to its program location (with correct Z offset)
End If
I am not sure how this macro can know what tool is currently loaded and what tool is requested.
I think that I may need to have it "pull" from a dro 1200.
How can I do this?
-
The macro above is working. but only when running from the VB editor.
I have renamed in M6Start.m1s and placed it in the macros folder.
I have changed the config to allow for ATC.
Should I not be able to have this macro run and change a tool when I MDI T1 or any other T number I enter?
-
Gerry-
Thanks BTW, your notes were helpful. In particular the Sleep is working for the correct time now. is it in milliseconds?
-
Yes, milliseconds.
You need to use T1 M6 from MDI. It's the M6 that changes tools, not the Tx.
-
Thanks Gerry.
using T1m6 in MDI did indeed update the tool on the mach 3 program screen. Sadly, it did not actually execute the tool change.
I am getting an "unknown t word" error in the box that reads error msgs at the bottom of the program screen. Is this telling me that my M6start macro has an issue that does not allow it to load correctly into mach when starting up mach?
I tried putting m6 and m6start in my initilization string, seperated by commas and a space.
Should I have no space? no commas and a space?
I have a feeling that the macro is functional in VB, but not functional in Mach/MDI, because it is not loading or loading right.
I am attaching my XML.
Thanks!
-
put a space between T1 and M6
T1 M6, not T1M6
-
Between that and going back and getting the "ignore tool change" button to stay unchecked, it is functional!
Thanks so much.