Machsupport Forum
Mach Discussion => General Mach Discussion => Topic started by: GytarrMann19 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
-
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
-
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
-
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
-
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
-
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
-
"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
-
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
-
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
-
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
-
Not sure if backlash works in Rotational Axis, never tried it. If I get a chance (and remember ;) ) I will see if I can test it out. I was going to be using it on my spindle when I used SwapAxis() for rigid tapping but I got a floating holder at a good price so never bothered.
Hood
-
Thanks for the reply Hood. Any idea why the "Ang short rot on G0" option does not stop the turret from turning both ways?
Kevin
-
It shouldnt, maybe attach your xml and I will test here
Hood
-
Here is my .xml file. Hopefully you can tell something from it. Thanks again for the help, Hood! The forum is lucky to have people like you.
Kevin
-
The problem is you are using absolute g-code for the A axis, change the g-code to work in incremental moves.
-
How would I do that? My current macro is posted at the start of this thread. I'm using absolute positioning so that the turret arrives at the same place every time. To do it incrementally, how do I make the macro calculate the required number of degrees to arrive at the commanded position?
Thanks for your reply!
Kevin
-
Yes seems thats the issue, you would need to take the G53 out of the macro. You would have to make sure that the A was zero in work offset coords when you home.
Hood
-
Backlash on A doesnt seem to be working with the SS from what I can see.
Hood
-
The tool change routine would look something like this :-
Dim new_tool As Integer
Dim old_tool As Integer
Dim move_a As Integer
Dim a_angle As Integer
new_tool=GetSelectedTool()
old_tool=GetCurrentTool()
a_angle=45
If new_tool>0 And new_tool <9 Then
If old_tool <> new_tool Then
move_a = 8 - old_tool + new_tool
move_a = move_a Mod 8
move_a = move_a * a_angle
ActivateSignal(OutPut7)
Sleep 500
Code "G00 G91 A" & move_a
While IsMoving()
Wend
DeActivateSignal(OutPut7)
Code "G90"
SetCurrentTool(new_tool)
End If
End If
Graham
-
Thanks for the replies guys. I haven't had a chance to try out the new Macro, but I did remove the G53 from the exisiting one which so far seems to work fine. Upon further thought, the best solution would be one that ran in both directions, but when moving in "reverse" would move a couple degrees past the required position and then back up to take up the lash. But for now, the current macro works, and I'm happy.
I'll be trying the new macro in the next day or two and I'll let you know how it works.
Thanks again!
Kevin
-
Just a heads up, was reading the changelog for the SS and the latest plugin supports backlash comp on the A, B and C axis.
Hood
-
Thanks again Hood.