Hello Guest it is March 28, 2024, 04:39:35 PM

Author Topic: Lathe Turret Macro  (Read 9710 times)

0 Members and 1 Guest are viewing this topic.

Lathe Turret Macro
« on: August 18, 2011, 10:29:00 PM »
Hello all,

This is the Macro I shamelessly stole from Hood in another post. It works, but only in one direction. I.E., I can index from position 1 to position 2, etc., but If i try to go from 1 to 8, I get a message saying "limit switch triggered." If I go into the homing config menu and reverse the direction, it works in the new direction, but not in the previous. I hope that makes sense. The machine is a mid 80s CHNC with 8 position turret. I removed the original air motor and replaced with a stepper running as the A axis. The stepper indexes ok, and the macro raises and lowers the turret correctly. Jut won't let me go in both directions. Additionally, I have a switch to sense turret up/down position. I'd like to add something to the code to ensure the stepper doesn't run until Mach knows the turret is up for sure. Any ideas?

Next issue: I have a home switch for the turret. How do I get Mach to home it from the basic lathe screen. Can I add a "home turret" button in with the home x and z buttons?

I really appreciate the help from the forum. This is my first experience with Mach. I currently have my X and Z axes moving nicely with servos and Granite drives, the spindle runs via VFD and AC induction motor, and the coolant pump, air collet closer and part chute are working nicely as well. All via SmoothStepper and C23 BOB. The turret is my last big challenge.

Thanks,
Kevin

Here is the Macro I'm using:

If GetSelectedTool() = GetCurrentTool() Then
End
 End If
 
Code "G53 G0 Z-1"
While IsMoving()
Wend
 
 If GetSelectedTool = 1 Then
 ActivateSignal(OutPut7)
 Sleep 500
 Code "G53 G0 A0"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut7)
 End If
 
 
 If GetSelectedTool = 2 Then
 ActivateSignal(OutPut7)
 Sleep 500
 Code "G53 G0 A45"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut7)
 End If

 
 If GetSelectedTool = 3 Then
 ActivateSignal(OutPut7)
 Sleep 500
 Code "G53 G0 A90"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut7)
 End If
 
 
 If GetSelectedTool = 4 Then
 ActivateSignal(OutPut7)
 Sleep 500
 Code "G53 G0 A135"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut7)
 End If


 If GetSelectedTool = 5 Then
 ActivateSignal(OutPut7)
 Sleep 500
 Code "G53 G0 A180"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut7)
 End If
 
 
 If GetSelectedTool = 6 Then
 ActivateSignal(OutPut7)
 Sleep 500
 Code "G53 G0 A225"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut7)
 End If

 
 If GetSelectedTool = 7 Then
 ActivateSignal(OutPut7)
 Sleep 500
 Code "G53 G0 A270"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut7)
 End If
 
 
 If GetSelectedTool = 8 Then
 ActivateSignal(OutPut7)
 Sleep 500
 Code "G53 G0 A315"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut7)
 End If

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Lathe Turret Macro
« Reply #1 on: August 19, 2011, 02:48:59 AM »
Sounds like you either are sharing the same pin number of the turrets home switch with the limits or that you have set the home switch for A to also be a limit for A.

Regarding the Homing, if you open the screen in Screen4 (or other screen editor programme) you could change the Home All button to a VB button. Save the screenset with a different name (so it wont get overwritten if you upgrade) then from View menu in Mach load the renamed screen. Then when in Mach operator menu then Edit VB Buttons, Home All should be flashing, click on it and put this in

DoButton( 24 )
DoButton( 22 )
DoButton( 25 )

That will home Z then X then A, if you want a different order then just switch them around.


What input are you using to monitor the Up/Down of the turret?

Hood
Re: Lathe Turret Macro
« Reply #2 on: August 19, 2011, 01:34:17 PM »
Neither of the conditions you mention with home switches is true, and today it seems to be working fine. I would like however for the turret to always rotate in the same direction, on account of the backlash in the gear train. I tried applying backlash compensation to the A axis but it doesn't appear to do anything. I'm going to try playing with the screen editor this afternoon. I'm sure I'll have questions. For turret up/down, I'm using input 1, active when the turret is up.

Thanks again!
Kevin
Re: Lathe Turret Macro
« Reply #3 on: August 19, 2011, 05:19:59 PM »
So I got my hands on Mach3Screen, and used it to add the homing capabilities. One trouble- i need to be able to raise the turret when homing it. How do I accomplish this?

Kevin

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Lathe Turret Macro
« Reply #4 on: August 19, 2011, 05:50:07 PM »
Ok to rotate only one way you should have the option on general config called "Ang short rot on G0"    disabled.

To raise the turret whilst homing you would need to add some VB to the homing button you made, I presume you have DoButton(25) in it at the moment?
You would need to have something like

ActivateSignal(OutPut7)
DoButton(24)
DeActivateSignal(OutPut7)

For your toolchange to wait on the input this may  work

  If GetSelectedTool = 1 Then
 Do
  ActivateSignal(OutPut7)
If IsActive(Input1) Then Exit Do
Loop
 Code "G53 G0 A0"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut7)
 End If 

You will need to alter the rest of the tool calls to similar to the one above.

Hood

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Lathe Turret Macro
« Reply #5 on: August 19, 2011, 08:31:10 PM »
Just tested the VB out and it seems to work fine but would grab a lot of CPU if the turret didnt lift for some reason so put a sleep 10 in (like example below) and that should sort things.

  If GetSelectedTool = 1 Then
 Do
  ActivateSignal(OutPut7)
If IsActive(Input1) Then Exit Do
Sleep 10
Loop
 Code "G53 G0 A0"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut7)
 End If
Re: Lathe Turret Macro
« Reply #6 on: August 20, 2011, 05:33:36 PM »
 "Ang short rot on G0"  is disabled, but the turret still rotates both ways. On the VB code for homing, what can I add to make the script wait for the DoButton(25) to complete before the turret lowers? I have it set up now with just a sleep, but it would be neater if it waited for the code rather than just an arbitrary length of time. Again, thanks for the help. This is turning out to be a lot easier than I thought it would.

Kevin

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Lathe Turret Macro
« Reply #7 on: August 20, 2011, 05:37:52 PM »
I thought that would have stopped rotation both ways as I was thinking to go the opposite way you would need a negative move, however it may be because the macro is using G53. Will have to test out later.

While IsMoving()
Wend

After the DoButton should make it wait.

Hood

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Lathe Turret Macro
« Reply #8 on: August 20, 2011, 08:25:04 PM »
Just tried here and the A will only move one way with a positive value commanded. Only thing I can think of is you possibly dont have the A set as a rotational axis. If thats not it can you attach your xml and I will have a look and see if I can find the issue.
Hood
Re: Lathe Turret Macro
« Reply #9 on: December 16, 2011, 04:19:35 PM »
Well this is a late reply! The shop got so busy over the summer I haven't had a chance to touch this machine till now. The turret is reassembled, homes correctly, and indexes correctly over and over in one direction. Again, it does not work right at all in the other direction due to the backlash issue. The A axis is set as rotational, and "Ang short rot on G0" is unchecked.

Does the backlash compensation feature not work? Or just not with this application?

Thanks again,

Kevin