Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: Overloaded on February 14, 2008, 06:49:56 PM

Title: Open/Close Spindle Collet....Best Way
Post by: Overloaded on February 14, 2008, 06:49:56 PM
Howdy folks,
I want to use an air operated collet closer on my 5C lathe spindle.
There will be either a puller on the tool plate or a solid stop on the plate with constant feed pressure on the stock.
Basically, the part would be machined and parted off, then the spindle stops and the puller moves to and grips the stock. (or the stop moves into pos.)
Now I need to open the collet, then pull the stock Z+, (or allow it to hit the stop), then close the collet, move the puller (or stop) clear and resume the program.
The closer is a double acting cyl. with a 4 way 2 solenoid valve. 2 outputs from Mach through relays I suppose.
Then 1 input from the stock limit switch. (prox.)

What is the simplest way to do this..Brain? Or can It be done in G code ?    VB is only slightly more familiar than Chinese to me, I would need MUCH help with a macro.
Also, will want it to run continuously until the stock gets to a limit switch.... or stop at the end of any given part cycle. Controlled on screen ? I CAN make a button work........sometimes.  :D
Thanks for all,
RC
Title: Re: Open/Close Spindle Collet....Best Way
Post by: Ian Ralston on February 14, 2008, 07:22:01 PM
A quick and dirty G code solution would be to use the Y axis outputs on your BOB. Say, 0 volts is the collet closed position, when you want to open the collet, send G00 Yaa from Mach, where Yaa takes long enough to open the collet and feed to a stop. To close, send G00 Y -bb where bb takes long enough to close the collet. The DIR 5 volts from the BOB is used to drive the relay controlling your solenoid valve via a power transistor or SSR.
No need to stop the spindle if your puller is bearing mounted so it can rotate and your feed stop limit switch can be used to interup the Mach charge pump circuit. Not very sophisticated but should work.

Ian
Title: Re: Open/Close Spindle Collet....Best Way
Post by: Overloaded on February 14, 2008, 07:45:27 PM
Thats pretty keen Ian. I can see that working.
I'll tinker with it this weekend.
That IS "Down and Dirty".
The pump going down would require referencing every time though... wouldn't it ? That would be a pain.
Thanks Ian,
RC
Title: Re: Open/Close Spindle Collet....Best Way
Post by: poppabear on February 14, 2008, 10:10:17 PM
Here is a "Puller Macro", it assumes that you have constant pressure to feed your stock forward.  You would put this macro right before the M30.
it also assumes that your stop plate has a push in trigger switch or some other way to tell the stock has made contact with the stop. You would set the Stop at a certain X, Z position (that would obviously be out of the tool path). You will need to open the Macro in the VB scripter and set the X, Z position for your stop. It will also use OUTPUT5 and 6 (hopefully outputs that you arnt currently using, if you are you will need to change these, make sure to enable them in ports and pins under outputs, and set what port pin you want them to activate, same for the Input. I will use INPUT4 for your Stop Switch). You may have to adjust the pause times as well they are in seconds.

here is the Macro, open up VB scripter and paste it in, do a save as M800 for instance.

Sub Main()

'M800.m1s Bar Stock Feeder

'OUTPUT5 is open collet, OUTPUT6 is close collet, INPUT4 Barstop signal

Dim StopPositionX, StopPositionZ

StopPositionX=4      'Stop location in X axis in machine coordinates
StopPositionZ=4      'Stop location in Z axis in machine coordinates

Code "M5"   'Stop Spindle
Code "G0 G53 X" & StopPositionX & " Z" & StopPositionZ
While IsMoving()
Wend

ActivateSignal(OUTPUT5)   'Open collet
Code "G4 p2"         '2 second pause give stock time to move forward
While IsMoving()      'Give more or less seconds depending feed forward time
Wend               'I didnt use a wait for or a while statement so not to tie you your processor.

If Not(IsActive(INPUT4)) Then
Message("------Stock did not move forward, check stock feed, abort feed op.")
Exit Sub
End If

ActivateSignal(OUTPUT6)   'Close collet
Code "G4 p1"         '1 second pause gives collet time to clamp
While IsMoving()      'Give more or less seconds depending on closure time.
Wend

End Sub

'Let me know how it works out
'Scott
Title: Re: Open/Close Spindle Collet....Best Way
Post by: Overloaded on February 14, 2008, 11:54:02 PM
Scott,
That looks excellent. Thanks for the 'Commenting...VERY helpful.
I ran it on my home PC, no machine or stop switch and it seemed to be OK.
Anxious to set it up on the lathe this weekend.
1 question...
  I do not see where this will continue to repeat until the stock is gone. Will see Sunday.
I would also like to stop the machine at the end of a finished part at any time. Preferably with the collet open.
I DO see that the stop switch doubles as an "out of matl." shut down as well as a "Feed Jam" alarm. I LIKE IT...
I'll keep you posted.
Thanks MUCH Scott,
RC

I will try M47 in place of M30. I suppose it should run untill it's out of stock or jams up.
Thanks again
Title: Re: Open/Close Spindle Collet....Best Way
Post by: Overloaded on February 15, 2008, 12:38:36 AM
The M47 did not work in place of M30. The code repeats regardless of whether the material fed or not.
If I do like the pic, will it only rerun the code if it fed to the switch ?
Otherwise M30 will rewind and stop ?
Thanks

Looks like out 5 and 6 are active at the same time...New plan below should take care of this. ?

I set a hotkey to IN4 to simulate a run and it did as expected with the M47 in the macro.

I'm changing valve to a 4way, 2 position, 1 sol., spring return.
Output 5 ACTIVE will OPEN the collet.
Will put a switch or toggle button on screen to manually operate the closer.
Will also like to prohibit spindle if collet is OPEN.
Thanks,
RC
Title: Re: Open/Close Spindle Collet....Best Way
Post by: Overloaded on February 15, 2008, 08:27:24 AM
This seems to WORK !
Can't wait to try in on the machine.
I'll quit buggin' ya now.....gotta go to work....DAMN !
RC
Title: Re: Open/Close Spindle Collet....Best Way
Post by: poppabear on February 15, 2008, 10:10:22 PM
RC,

    The reason you cant get M47 to work in M800, is you cant run a macro from within a macro it is a no-go in Mach.

Also:  I got the Redface real bad......  Sorry I forgot to put the DeActivate outputs in, I just kinda rushed through the macro and didnt really test it out to much.......sorry I forgot them

NOTE: You CAN put the M47 in place of the M30 in your G code file and it should do what you want.

Scott
Title: Re: Open/Close Spindle Collet....Best Way
Post by: poppabear on February 15, 2008, 10:34:31 PM
your other questions:

1).

In screen designer put this in a button"

Open collet  (goes on the button label)

code "M5"     'Stop spindle (safety feature)
code "G4 P3"  'Gives time for spindle to spin down to 0
While IsMoving()
WEnd

DeActivateSignal(OUTPUT5) 'Opens collet

2).

Put this in your Macropump

'Macropump.m1s

If IsOutputActive(OUTPUT5) Then  'If your collet is open
code "M5"         'Force Spindle speed to "0", or you can make a disable spindle output here
Message("-----Cannot start Spindle until Collet is closed!!!!!")
End If

'scott
Title: Re: Open/Close Spindle Collet....Best Way
Post by: Overloaded on February 15, 2008, 10:47:04 PM
Good stuff Scott... THANKS !
May not get to it till next week.
In reply #6...The M47 IN the M800 worked perfectly. I simulated the input 4 with a hotkey.
With the program running, if in4 is on, it keeps repeating. In4 off and it stops and gives the message.
But...it should not work ? ? ?  Strange.

Thanks, RC
Title: Re: Open/Close Spindle Collet....Best Way
Post by: poppabear on February 15, 2008, 11:22:06 PM
perhaps I should restate that then.

  If two macros are BOTH running at the same time doing things at the same time then it wont work.
In Mach there is only room for One macro to run at a time, (NOTE: macro pump is compiled).
If you have a macro within a macro and when the second macro executes within the 1st but the 1st isnt really doing anyting else at that time, then It would work. But if both Macros are trying to do different things to the same object the only the last one processed in the pipe will win.

Read Art's "Mach Mysteries" explained and he goes into this in more detail.

Scott
Title: Re: Open/Close Spindle Collet....Best Way
Post by: Overloaded on July 23, 2008, 11:51:01 PM
Had this working well in sim.
IN4 with a hotkey.....shows in diag.
Enabled Out 5.
Now it stops at the M801 and goes no further.
Doesn't move to Z4  X4
Can you see why ?
Thanks,
rc
Title: Re: Open/Close Spindle Collet....Best Way
Post by: Graham Waterworth on July 24, 2008, 06:10:42 AM
Replacing "Code M5" with the VB command DoSpinStop() is better.

Graham.
Title: Re: Open/Close Spindle Collet....Best Way
Post by: poppabear on July 24, 2008, 06:37:23 AM
Hey Overloaded here is the corrected file, you had an "floating IF in there"

here is the code line with the if that was in your code just sitting there. (I put stars around it so you can see it).

**If** deActivateSignal(OUTPUT5)   'Close collet
Code "G4 p1"         '1 second pause gives collet time to clamp
While IsMoving()      'Give more or less seconds depending on closure time.
Wend

Here is the corrected code, and I change the M5 to dospinstop():

Sub Main()


'M800.m1s Bar Stock Feeder


'OUTPUT5 is open collet, OUTPUT6 is close collet, INPUT4 Barstop signal



Dim StopPositionX, StopPositionZ



StopPositionX= 4      'Stop location in X axis in machine coordinates

StopPositionZ= 4      'Stop location in Z axis in machine coordinates

DoSpinStop()          'Stop Spindle


Code "G0 G53 X" & StopPositionX & " Z" & StopPositionZ

While IsMoving()

Wend



ActivateSignal(OUTPUT5)   'Open collet

Code "G4 p2"         '2 second pause give stock time to move forward

While IsMoving()      'Give more or less seconds depending feed forward time

Wend                  'I didnt use a wait for or a while statement so not to tie you your processor.



If Not(IsActive(INPUT4)) Then

Message("Out of Stock")

Exit Sub

End If

DeActivateSignal(OUTPUT5)   'Close collet

Code "G4 p1"         '1 second pause gives collet time to clamp

While IsMoving()      'Give more or less seconds depending on closure time.

Wend

End Sub

'scott



Title: Re: Open/Close Spindle Collet....Best Way
Post by: Overloaded on July 24, 2008, 08:18:53 AM
Thanks to you both.
Scott, not saying the floating "If" is not in the original...but I cannot see it in the editor here.
No doubt it's there but it seems to be hidden.
Is that possible ?
Here are two screenshots. The first one (801) is the original with the "If" and doesn't run, the second one (802) runs fine.
Can you show a screenshot of what you see when you open the original with the "Floater"?
Thanks,
RC