Hello Guest it is March 28, 2024, 01:57:59 PM

Author Topic: Turret macro is giving me issues  (Read 2792 times)

0 Members and 1 Guest are viewing this topic.

Turret macro is giving me issues
« 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

Offline RICH

*
  • *
  •  7,427 7,427
    • View Profile
Re: Turret macro is giving me issues
« Reply #1 on: May 08, 2016, 06:43:24 AM »
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
 
Re: Turret macro is giving me issues
« Reply #2 on: May 08, 2016, 09:19:41 PM »
Thank you rich. I will give that a go this week and report back with the outcome
Re: Turret macro is giving me issues
« Reply #3 on: May 09, 2016, 01:56:13 PM »
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.

Offline rcaffin

*
  •  1,052 1,052
    • View Profile
Re: Turret macro is giving me issues
« Reply #4 on: May 10, 2016, 06:23:39 AM »
Gary has it.
Cheers
Roger

Offline RICH

*
  • *
  •  7,427 7,427
    • View Profile
Re: Turret macro is giving me issues
« Reply #5 on: May 10, 2016, 09:25:16 AM »
Quote
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
« Last Edit: May 10, 2016, 09:29:07 AM by RICH »
Re: Turret macro is giving me issues
« Reply #6 on: June 12, 2016, 07:40:22 PM »
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.
« Last Edit: June 12, 2016, 07:42:15 PM by mikeyz3385 »
Re: Turret macro is giving me issues
« Reply #7 on: June 20, 2016, 08:13:26 PM »
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