Hello Guest it is December 14, 2019, 12:51:54 PM

Author Topic: Re: ATC VB script example for rotary changer...  (Read 4869 times)

0 Members and 1 Guest are viewing this topic.

Offline BOB88

  •  20 20
    • View Profile
Re: ATC VB script example for rotary changer...
« on: June 08, 2008, 01:34:51 PM »
Hi Drew,

Your program has helped me a lot to learn about script with mach3.  My turret has 8 positions, but no raise solenoid or index pins or BCD switches.
It is cycled one turret position by actuating a single air solenoid for about .55 seconds.

The turret is cycling fine by the following script in the file:    M20.m1s      located in the macros folder.

ActivateSignal(Output8)  'mapped to Port1 pin5, applies air to index cylinder
Code "G04 P.55"
While IsMoving()
Sleep 100
DeActivateSignal(Output8)   'turns off air to index solenoid which completes one index cycle.

So, any time I do M20 the turret advances and locks one position.  Great so far.

Now, I need to come up with the number of cycles or moves needed to get to the desired next tool.
In the M6Start.m1s, I'd like to calculate the unsigned value of the (CurrentTool minus SelectedTool)  which will give me the number of advances necessary to get to the next tool.  Then I can call or execute M20 that number of times to get to the selected tool.

How would you do that?  When you said M6 is not used in lathe but T0101, T0202,etc.  did you mean that M06 does not appear in the G-Code program itself, but just the T-numbers and that MACH3 knows to look at the M6Start when it sees a T-number?  (I noticed that you tested for M6)

Thank you for sharing your knowledge with newcomers to MACH.


Re: Re: ATC VB script example for rotary changer...
« Reply #1 on: June 08, 2008, 06:48:27 PM »
Here is the main part of my tool changer routine. This is a 6 position changer, but you could edit it for more.

'MsgBox ("current tool " & tool)
NewTool= getselectedtool()
'msgbox ("new tool " & NewTool)

if NewTool=tool then
 exit sub
end if

if NewTool>tool then
  steps=6 - (tool-NewTool)
End If

If tool Mod 2 Then 'even number
  code "G00 Z 2"
  code "G53 G00 X 0"   'move X to machine home 0
  code "G00 z -2"
End If

'msgbox(" move steps " & steps)

for I=1 to steps
  code "G91 G00 A72"
code "g00 A-12"
code "G90"
While IsMoving()

next I

The Mod 2 part handles the retract for tool change- the even number slots inmy changer are for boring tools, so I need to retract in Z before a change. The Odd number tools are turning tools, so I want to retract X first.

Offline BOB88

  •  20 20
    • View Profile
Re: Re: ATC VB script example for rotary changer...
« Reply #2 on: June 12, 2008, 02:24:24 PM »
I need a way to tell Mach3 what the "currenttool" is at startup.  In other words a way to ask the question "What is the current position of the turret"  and be able to type in the number from 1-8.  That will be the current tool at startup since, without BCD switches, there is no way to know where the turret is without asking. 

Also, how do these programs deal with tool 00 which Mach allows as a legitimate tool number?

Thank you,


Re: Re: ATC VB script example for rotary changer...
« Reply #3 on: December 17, 2008, 09:05:51 PM »
BOB you could build a simple absolute encoder based on switches(photo?optic and a disc) so anytime mach checked the switch combinations it would know what tool number is active.

Just a thought, (;-) TP

Offline Graham Waterworth

  • *
  •  1,922 1,922
  • Yorkshire Dales, England
    • View Profile
Re: ATC VB script example for rotary changer...
« Reply #4 on: December 20, 2008, 12:49:49 PM »
You could try something like this :-

go to MDI and type 'T11 M6' for tool 1, then in your macro check tool number and if its greater than 10 subtract 10 and set current tool to that new number and drop out.

Without engineers the world stops