Hello,

I am working on a D&M retrofit. I designed a 6 tool tool changer and am having trouble with the VB script macro. I am not sure if the problem is Mach3, the Pokeys57cnc board I am using or the fact that I am using Vista 32 bit. Below is my Macro:

'ToolChange Macro For Rotary type tool changer mounted to end of X axis
Sub Main()
OldTool = GetOEMDRO (1200) 'Tool In spindle DRO
x = GetToolChangeStart( 0 )
y = GetToolChangeStart( 1 )
z = GetToolChangeStart( 2 )
a = GetToolChangeStart( 3 )
b = GetToolChangeStart( 4 )
c = GetToolChangeStart( 5 )
tool = GetSelectedTool()
NewTool = tool
'Tool Changer Macro (Bed Type)
MaxToolNum = 6 'Max number off tools for the changer
ToolDown = -1.5 'Z Pos to Get or drop a tool
ToolUp = 0.0 'Z Hieght to Rapid from tool to tool
Yprep = 2.81 'Y pos for turret alignment
Xout = 2.0 'X pos to clear spindle for turret rotation
Xin = .095 'X pos for tool to clip for pickup
If NewTool = OldTool Then
Exit Sub
End If
While NewTool > MaxToolNum
NewTool = Question ("Enter New Tool Number up to " & MaxToolNum)
Wend
Code "G00 G53 Z" & ToolUp 'Moves spindle up to 0 for safe pos
While IsMoving()
Wend
Code "G53 Y" & Yprep 'Moves center of tool turret to centerline of spindle
Code "G4 P.5"
While IsMoving()
Wend
Code "G53 X" & Xout 'Moves X away from spinle sor turret rotation clearence
Code "G4 P.5"
While IsMoving()
Wend
Call MovePos(OldTool) 'Rotates turret to tool position from table below
While IsMoving()
Wend
Code "G53 Z" & ToolDown 'Brings spindle down
Code "G4 P.75"
While IsMoving()
Wend
Code "G53 X" & Xin 'Moves X tword spinle to clip tool
While IsMoving()
Wend
ActivateSignal(Output2) 'Turn On Draw bar to release the tool
Code "G4 P1.0" 'Wait for the tool to release
Code "G53 Z" & ToolUp 'Lift spindle to clear tool turret
Code "G4 P.5"
While IsMoving()
Wend
Call MovePos(NewTool) 'Rotate turret to new tool from table below
While IsMoving()
Wend
Code "G53 Z" & ToolDown 'Lowers spindle to pick up new tool
Code "G4 P.75"
While IsMoving()
Wend
DeActivateSignal(Output2) 'Turn Off Draw bar to Clamp the tool
Code "G4 P1.0" 'Wait for the tool to Clamp
While IsMoving()
Wend
Code "G53 X" & Xout 'Moves X away from spindle to un clip tool
While IsMoving()
Wend
Code "G53 Z" & ToolUp 'Moves spindle to 0 safe pos for move
While IsMoving()
Wend
Code "G53 A 0.0" 'Rotates turret to 0 park pos
Call SetUserDRO (1200,NewTool)
SetCurrentTool( NewTool )
Code "G00 X" & x & " Y" & y 'Move back to where the tool change was prompted
End Sub

Sub MovePos(ByVal ToolNumber As Integer)

Select Case ToolNumber
Case Is = 1
APos = 86.25
Case Is = 2
APos = 122.25
Case Is = 3
APos = 158.25
Case Is = 4
APos = 194.25
Case Is = 5
Apos = 230.25
Case Is = 6
Apos = 266.25

End Select

Code "G53 X" & XPos & " Y" & YPos
End Sub


The tool changer is a 6 tool rotary that is mounted on the end of the x axis. It has a nema 17 motor to rotate the tools and is configured as an angular axis with a 360 degree roll over. The sequence above is for the tool changer to move to the Y position after the z has gone to 0 in machine coordinates. Move x to 2 inches to clear the the spindle while the turret turns. Rotate the turret to the appropriate position. lower the spindle and then move the x position in to clip the tormach type tooling. Activate output 2 to release the air actuated draw bar and then move z back to 0 in machine coordinates. Move x back to 2 inches and Rotate tool changer to new tool and then lower z to pick up new tool. move x back in to clip tool. Deactivate output 2 to grip tool and then move x out to clear spindle. Raise z to 0 and move back to x and y position before the tool change.

This is the basic operation and the intention is to add auto z zero later and or possibly tool offset comp. The problem is the Macro shows no bugs and when I do a m6 tX call in MDI it moves to position but the rotary axis dose not turn. the other issue is upon completion of the tool change the y axis re-zeros at it's tool change location but not the x?

This project has been an overwhelming nightmare trying to integrate Mach3 with Pokeys57cnc. This is one of the many issues I have been having and am hoping someone can give me a clue what I am doing wrong while I continue with support on the other issues. I may post in another section of the form in regard to the other issues? I would like to include a photo of the tool changer here but am having difficulty figuring out how to attach it.

I have been told that Mach3 has too many glitches and I should upgrade to Mach4. I have two other machines that run flawlessly on Mach3 and have never experienced these issues before? However they are running on old XP machines with a parallel port. I tried to come into the 21st century and think I am now regretting it! The learning curve is steep and every step I take someone wants me to go deeper before I can get past the step I am on?

Please help as I am sure I am not the first to tread this path!

Thanks,

Jeff K.Click image for larger version. 

Name:	2017-01-31 16.53.47.jpg 
Views:	14 
Size:	115.4 KB 
ID:	355306Click image for larger version. 

Name:	2017-01-31 16.53.35.jpg 
Views:	14 
Size:	106.8 KB 
ID:	355308