Hello Guest it is October 14, 2019, 03:04:04 PM

Author Topic: Tool change macro needed for lathe turret!  (Read 15217 times)

0 Members and 1 Guest are viewing this topic.

Offline mike^3

*
  •  117 117
    • View Profile
Tool change macro needed for lathe turret!
« on: August 04, 2013, 03:18:48 PM »
Hello!  ;D

I have a 8 position tool changer turret on my lathe.

I need a tool change macro that will do perform these steps.

Steps:

1. Move carriage to Z0.2 and X0.2 machine zero
2. activate and output (solenoid to raise turret off bed) and keep it activated until the turret is at the right position.
3. rotate clock wise (only 1 direction) to the called for tool, which will be 0-360inches (really degrees) of travel. The tools will be at 45 degree segments, i.e. tool 1 is at 0inch tool 2 is at 90inches.
4. de activate solenoid that raised turret to lock tool in place.
5. continue program.

I assume someone has this macro already done, looked through quite a few posts, and found a few that were close, but did not have a few steps, also, I have 0 experience coding a toolchanger! :)

Any help would be appreciated!!!

Thank u,

Mike

Offline BR549

*
  •  6,902 6,902
    • View Profile
Re: Tool change macro needed for lathe turret!
« Reply #1 on: August 04, 2013, 04:52:26 PM »
First thing you must do is create a way to initialize or refhome the tool turret so Mach3 KNOWS where tool1 is  (A0.000 deg).

DO you have a home switch on the turret?

(;-) TP

Offline mike^3

*
  •  117 117
    • View Profile
Re: Tool change macro needed for lathe turret!
« Reply #2 on: August 04, 2013, 10:19:40 PM »
Hi!

I can easily put one on0. And ref the home switch the the A axis. What next?

Offline BR549

*
  •  6,902 6,902
    • View Profile
Re: Tool change macro needed for lathe turret!
« Reply #3 on: August 04, 2013, 11:34:14 PM »
Then you create code to run the turret

ActivateSignal(output1)       'Unlock the turret with air cylinder

If GetCurrentTool() = 1 then

Offline BR549

*
  •  6,902 6,902
    • View Profile
Re: Tool change macro needed for lathe turret!
« Reply #4 on: August 04, 2013, 11:59:56 PM »
Well I lost the code on save I
ll try again

(;-) TP

Offline BR549

*
  •  6,902 6,902
    • View Profile
Re: Tool change macro needed for lathe turret!
« Reply #5 on: August 05, 2013, 12:19:36 AM »
First you create a macro to add to the initiation string found in Gen Config. It is to ref Home the A axis to 0.000

' M1000
ActivateSignal(output1)
Sleep(1000)
RefCombination(8)
While Ismoving()
Wend
DeacctivateSignal(output1)
Sleep(2000)
END


Then create the Turrent code to add to the end of the M6start macro. This code is in simple form and does not contain safety code to verify the Turrent actually unlocked and relocked each cycle. That would require additional safety switches at each end of the stroke of the turrent.

You also have to set the toolchange mode to Auto Tool Change in Gen Config.

ActivateSignal(output1)                    'unlock the turrent
Sleep(1000)                                    'Give it time to move to end of stroke

If GetCurrentTool() = 1 then             ' Check for the Tool #
   Code"G0 A0.000"                     ' Move to position
   While Ismoving()                     'wait for the movement to stop
   Wend
   End If

If GetCurrentTool() = 2 then
   Code"G0 A45"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 3 then
   Code"G0 A90"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 4 then
   Code"G0 A135"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 5 then
   Code"G0 A180"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 6 then
   Code"G0 A225"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 7 then
   Code"G0 A270"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 8 then
   Code"G0 A315"
   While Ismoving()
   Wend
   End If

DeacctivateSignal(output1)                     'Release air cylinder
Sleep(2000)                                          'Give it time to move to end of stroke

End


THAT is it in a nut shell, (;-) TP
« Last Edit: August 05, 2013, 12:21:23 AM by BR549 »

Offline mike^3

*
  •  117 117
    • View Profile
Re: Tool change macro needed for lathe turret!
« Reply #6 on: August 05, 2013, 07:34:09 AM »
So.....would the final code be this?

' M1000
ActivateSignal(output1)
Sleep(1000)
RefCombination(8)
While Ismoving()
Wend
DeacctivateSignal(output1)
Sleep(2000)
END

ActivateSignal(output1)                    'unlock the turrent
Sleep(1000)                                    'Give it time to move to end of stroke

If GetCurrentTool() = 1 then             ' Check for the Tool #
   Code"G0 A0.000"                     ' Move to position
   While Ismoving()                     'wait for the movement to stop
   Wend
   End If

If GetCurrentTool() = 2 then
   Code"G0 A45"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 3 then
   Code"G0 A90"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 4 then
   Code"G0 A135"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 5 then
   Code"G0 A180"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 6 then
   Code"G0 A225"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 7 then
   Code"G0 A270"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 8 then
   Code"G0 A315"
   While Ismoving()
   Wend
   End If

DeacctivateSignal(output1)                     'Release air cylinder
Sleep(2000)                                          'Give it time to move to end of stroke

End

Ill check and see if it works, also you mentioned safety switches? Would this be a switch that would sense the turret up, and then if it doesnt get the signal it will estop?

THANKS!

Offline BR549

*
  •  6,902 6,902
    • View Profile
Re: Tool change macro needed for lathe turret!
« Reply #7 on: August 05, 2013, 06:03:24 PM »
Actually I forgot a piece of the code that moved to Machine location here is an updated version to include that part. What you see here is 2 parts first the Macro that will initiate the Turrent and ref home the turrent on Mach3 startup. It is macro M1000. The 2nd part is the code that goes in the M6Start macro that drives the tool changer based on Tool#. YES the extra switches would be to tell IF the turrent reach full unlock and full lockup or else the Machine STOPS.

' M1000

RefCombination(1)
While Ismoving()
Wend
RefCombination(4)
While Ismoving()
Wend
Code"G53 X0.2"
While Ismoving()
Wend
Code"G53 Z0.2"
While Ismoving()
Wend

ActivateSignal(output1)
Sleep(1000)
RefCombination(8)
While Ismoving()
Wend
DeacctivateSignal(output1)
Sleep(2000)
END


Then create the Turrent code to add to the end of the M6start macro. This code is in simple form and does not contain safety code to verify the Turrent actually unlocked and relocked each cycle. That would require additional safety switches at each end of the stroke of the turrent AND a few more lines of code .

You also have to set the toolchange mode to Auto Tool Change in Gen Config.

Code"G53 X0.2"                              'Move to tool change location
While Ismoving()
Wend                          
Code"G53 Z0.2"
While Ismoving()
Wend

ActivateSignal(output1)              'unlock the turrent
Sleep(1000)                                    'Give it time to move to end of stroke

If GetCurrentTool() = 1 then        ' Check for the Tool #
   Code"G0 A0.000"         ' Move to position
   While Ismoving()           'wait for the movement to stop
   Wend
   End If

If GetCurrentTool() = 2 then
   Code"G0 A45"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 3 then
   Code"G0 A90"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 4 then
   Code"G0 A135"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 5 then
   Code"G0 A180"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 6 then
   Code"G0 A225"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 7 then
   Code"G0 A270"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 8 then
   Code"G0 A315"
   While Ismoving()
   Wend
   End If

DeacctivateSignal(output1)              'Release air cylinder
Sleep(2000)                                          'Give it time to move to end of stroke

End
« Last Edit: August 05, 2013, 06:05:08 PM by BR549 »

Offline mike^3

*
  •  117 117
    • View Profile
Re: Tool change macro needed for lathe turret!
« Reply #8 on: August 07, 2013, 11:20:01 AM »
Awesome, so....

You mentioned that I need to add the tool change macro to the end of m6start, yet it already has the end command do i just delete the END command and post it?

' M1000

RefCombination(1)
While Ismoving()
Wend
RefCombination(4)
While Ismoving()
Wend
Code"G53 X0.2"
While Ismoving()
Wend
Code"G53 Z0.2"
While Ismoving()
Wend

ActivateSignal(output1)
Sleep(1000)
RefCombination(8 )
While Ismoving()
Wend
DeacctivateSignal(output1)
Sleep(2000)
END                                     *********************************this

Also you had mentioned the turret homing, when I click the ref all home, I can see that the m1000 (m1000 is homing right?) is the ref all home on startup right? And I see RefCombination(1) and RefCombination(4) and RefCombination(8 ) What are these? I am setting the A axis as the turret, so wouldnt it be something like this in there:

ActivateSignal(output1)
Sleep(1000)
RefCombination(8 )                         ********************what does this do?*************************
While Ismoving()
Wend
DeacctivateSignal(output1)
Sleep(2000)
END

Code"G53 A0"                                        *********************wouldnt this need to be in there?******************
While Ismoving()
Wend


Also what would be the code for sensing the turret is up and down before continuing?
Something like 

DeacctivateSignal(output1)
Then wait for 5v on Input 1 if no input within 5 secs, display message *turret not in position* with 2 option buttons is turret down? YES/NO if clicked yes, then continue the program, if no then estop the machine

I know your helping me a ton, I really really really appreciate it!

Offline BR549

*
  •  6,902 6,902
    • View Profile
Re: Tool change macro needed for lathe turret!
« Reply #9 on: August 07, 2013, 12:39:04 PM »
OK lets start over. THe M1000 is a macro you have to create via the CB editor. Then save it in the Macros directory. Next on the initiation line in Gen config you add the M1000 to the code that is already there.

That tells Mach3 when it starts up to RUN the macro code. It should refhome the machine then Refhome the turrent. NOW the machine knows where it is in machine space.

Next is the Code to ADD to the M6start macro . THat code drives the turrent when a tool change is called.



To add the end of stroke switches code it is ;

Code"G53 X0.2"                              'Move to tool change location
While Ismoving()
Wend                          
Code"G53 Z0.2"
While Ismoving()
Wend

ActivateSignal(output1)              'unlock the turrent
While not Isactive(output2)         'wait for the switch to signal end of stroke
Sleep(1000)                                'Give it time for the motion to fully stop
Wend

If GetCurrentTool() = 1 then        ' Check for the Tool #
   Code"G0 A0.000"         ' Move to position
   While Ismoving()           'wait for the movement to stop
   Wend
   End If

If GetCurrentTool() = 2 then
   Code"G0 A45"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 3 then
   Code"G0 A90"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 4 then
   Code"G0 A135"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 5 then
   Code"G0 A180"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 6 then
   Code"G0 A225"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 7 then
   Code"G0 A270"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 8 then
   Code"G0 A315"
   While Ismoving()
   Wend
   End If

DeacctivateSignal(output1)              'Release air cylinder
While NOT Isactive(output3)
Wend
Sleep(1000)                                          'Give it time to complete end of stroke

End


(;-) TP