Machsupport Forum
Mach Discussion => General Mach Discussion => Topic started by: mikeyz3385 on May 07, 2016, 10:23:23 PM
-
Hi everyone, I converted an old cnc lathe that already had a turret on it. After converting the entire machine over to mach3 I needed to control the turret. I receieved a macro from a different site but no one seems to have any info on it.
My turret is equipped with a stepper motor and a pawl. The macro simply rotates the turret past the tool location then backs up tight against the pawl.
I installed this macro and I can successfully index my turret from tools 1-6 as long I call the next tool in order. If for instance I'm using tool 3 and call up tool 6 my turret seems to not rotate far enough, its off by a couple degrees. Is there a math error in the macro? I can't see it being the stepper tuning since It works perfect if I call up the tools in order. I indexed the tools in order for 3 full rotations with no errors but as soon as I command it to call up a tool that's a couple slots away it loses its spot.
Here's the macro I installed:
If IsLoading() Then
'Do Nothing, program loading
Else
' Dim Variables
Dim Num_Tools As Integer
Dim CW_Steps_Per_Tool As Integer
Dim CCW_Steps As Integer
Dim HoldingDRO As Integer
Dim Requested_Tool As Integer
Dim Current_Tool As Integer
Dim CW_Feed As Integer
Dim CCW_Feed As Integer
'Dim moves As Integer
'Dim total_move As Integer
' set up some vars
Num_Tools = 6
CW_Move_Per_Tool = 360/Num_Tools
CCW_Move = 10
HoldingDRO = 1050
Requested_Tool = GetSelectedTool()
Current_Tool = GetCurrentTool()
CW_Feed = 3000
CCW_Feed = 2000
Current_Feed = GetOEMDRO(818)
' start tool change
Message ("Requested Tool No=" & Requested_Tool)
If Requested_Tool > Num_Tools Then
Message "Requested Tool No. too high, program stopped."
Code "M30"
End
End If
If Requested_Tool < 1 Then
'Message "Requested Tool No. too low, program stopped."
Code "M30"
End
End If
If Requested_Tool = Current_Tool Then
' do nothing
Else
' lets do some changing
If Requested_Tool > Current_Tool Then moves = Requested_Tool - Current_Tool
If Requested_Tool < Current_Tool Then moves = Num_Tools - Current_Tool + Requested_Tool
total_move = (moves * CW_Move_Per_Tool)+(CCW_Move/2)
'Move to safe position
Code "G0 G53 Z-1 X-.25"
'Pause for 1/2 second
Code "G04 P0.5"
Code "G91 G94" 'incremental & Feed per minute
Code "G01 A" & total_move & " F" & CW_Feed
Code "G01 A-" & CCW_Move & " F" & CCW_Feed
While IsMoving()
sleep(10)
Wend
SetCurrentTool Requested_Tool
SetUserDRO HoldingDRO, Requested_Tool
Code "G90" ' back to absolute movement
Code "F" & Current_Feed
End If
End If
' end of tool change
-
Quick look at the macro shows that the movements are correct.
I will assume that your steps per unit are correct and were checked with backlash removed to confirm.
See what your total backlash is degrees. Do a 360 degree cw rotation. Now do a 360 degree ccw rotation.
That will show you how much backlash you have. That in itself is can keep from locking / stopping at the pawl
and account for the incorrect position.
RICH
-
Thank you rich. I will give that a go this week and report back with the outcome
-
If this is a stepper motor and you back up against a pawl solidly how are you preventing the stepper motor from loosing steps from doing that, because it definitely will? The only way I can see to make this work is to zero the stepper motor position after the back up motion, then calculate the steps to subsequent positions from there.
-
Gary has it.
Cheers
Roger
-
how are you preventing the stepper motor from loosing steps from doing that
That's the next step that needs to be addressed after assuring the mechanical aspects of the index are confirmed / understood.
There are options and the macro should be modified to address how that is done.
Right on Gary, :)
BTW,
There is a lot of "stuff" floating around, but, just copying something and thinking all is fine, is a good example of how this and many other threads are created.
RICH
-
It keeps starting from a0 while using incremental rather than absolute, so I'm guessing even if it backs up tight against the pawl that it won't matter since the next move is reset to zero anyways. This is truly driving me nuts! I thought I had it figured out the other day. I tore the whole turret apart to find the worm gear a little chewed up on some of the teeth. I removed all of that and decided to go with a pulley setup much like my x and y drive. There is zero backlash also. I still have the same results.
-
Got it working! I originally tried dialing the stepper motor in simply by using an a360.0 command in mdi and adjusting the steps till I got a perfect circle. All was good but the problem was the chewed up gear inside. Once I tore all that out and switched over to a belt drive I was trying to dial it in using the tool macro instead of just commanding the a axis to turn 360 degrees. It left me guessing left and right since it backs up 10 degrees against the pawl. It pays to sit back and take my time.
I must thank all who gave me advice on how to fix this issue. Without any support I would have been completely lost. Thank you