Hello Guest it is April 26, 2025, 05:15:26 PM

Author Topic: Troubleshooting a lathe tool change script  (Read 6184 times)

0 Members and 1 Guest are viewing this topic.

Offline TXJM

*
  •  14 14
Troubleshooting a lathe tool change script
« on: July 19, 2024, 10:40:28 PM »
I am helping rebuild a small lathe with an 8 position tool changer.  This is my first script in Mach3.  We converted the tool changer from a pure pnuematic with a proprietary control board to a stepper with encoder driven rotary motion with a pnuematic lock.  The cylinder has sensors to read locked and unlocked position.  We have been trouble shooting the code and think it is tied to line two of the code not seeing the value of the variable "Tool".  I can put a number 1 through 8 into the SetCurrentTool function and the toolchanger unlocks, moves and locks as it should.  We also have the inputs rem'd out at this point in the trouble shooting.  One step at the time.  what is the best way to see if the function getting the current tool number and what is the best way to see that the variable, "Tool" changes?  Right now the code is loaded into M06 start and we are to the point that we are running it from the mdi.

Tool = GetSelectedTool()
SetCurrentTool(Tool)

Code"G53 X-0.2 Z-0.2"                     'Move to tool change location
While Ismoving()
Wend                         

ActivateSignal(OUTPUT4)             'unlock the turrent
While not Isactive(INPUT2)          '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 A2.3486"                 ' Move to position
   While Ismoving()                 'wait for the movement to stop
   Wend
   End If

If GetCurrentTool() = 2 then
   Code"G0 A4.6972"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 3 then
   Code"G0 A7.0458"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 4 then
   Code"G0 A9.3944"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 5 then
   Code"G0 A11.743"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 6 then
   Code"G0 A14.0916"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 7 then
   Code"G0 A16.4402"
   While Ismoving()
   Wend
   End If

If GetCurrentTool() = 8 then
   Code"G0 A18.7888"
   While Ismoving()
   Wend
   End If

DeactivateSignal(OUTPUT4)              'Release air cylinder
While NOT Isactive(INPUT3)
Wend
Sleep(1000)                            'Give it time to complete end of stroke

End

Offline TPS

*
  •  2,574 2,574
Re: Troubleshooting a lathe tool change script
« Reply #1 on: July 20, 2024, 03:42:17 AM »
the easiest way to check the content of the variable is to use a msgbox() or Message

Code: [Select]

Tool = GetSelectedTool()

MsgBox Tool 'open a MessageBox

Message Tool 'show value in Status line



btw you know that usage of M6 on a lathe is for example:

M6 TXXYY

where

XX is the tool to select
YY is the offset from tooltable

For example T0202 (or equivalently T202) selects tool 2 with its own offsets and T0207
selects tool 2 wth the offsets for tool 7. T02 is treated as equivalent to T0202 and similarly
for any other value less than or equal to 99.



« Last Edit: July 20, 2024, 03:51:57 AM by TPS »
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.

Offline TXJM

*
  •  14 14
Re: Troubleshooting a lathe tool change script
« Reply #2 on: July 20, 2024, 09:04:46 AM »
We have been testing with M06 T02 or M06 T2.  I will try adding the offsets.  I will also try the Msg box.

Offline Graham Waterworth

*
  • *
  •  2,779 2,779
  • Yorkshire Dales, England
Re: Troubleshooting a lathe tool change script
« Reply #3 on: July 20, 2024, 09:31:31 AM »
On lathe you do not use M06/M6 its just the tool number and offset number T0101
Without engineers the world stops

Offline TXJM

*
  •  14 14
Re: Troubleshooting a lathe tool change script
« Reply #4 on: July 20, 2024, 05:54:29 PM »
Thanks.  It seems to work when we just type in the tool number and offset.