Hello Guest it is March 19, 2024, 07:33:12 AM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - TPS

121
modified your code a bit:

Code: [Select]

'M6 Start, Rack type tool changer with T0 empty tool return
'This macro is made for a ATC with pneumatic tool rack and two sensors in the Spindle (opencollet and closed collet)
'This macro is write by Graham Waterworth from machsupport forum and CncWoodProjects (i learned a lot with Graham it's a profesional programer)
'This macro is FREE and can be modified but can't be sold or used commercially, and mention the creators.
'For the moment this macro is a test but when all working i go to put in a mach3 forum all variables (without sensors, without tool peneumatic and the all in one version).
'Be sure to change the tools positions, inputs and outputs pins corresponding of your machine (every cnc is different).
'First try to test if it's working in the air (put a Zpos above the tools for example in my case my tool rack is in -110 anf for test i used -80 without tool inside).

'--- Variables:------

NewTool = GetSelectedTool()   'Tool required
OldTool = GetCurrentTool()   'Tool in spindle
MaxToolNum = 8 'Maximum number of tools
FFeed = 250                  'Fast feed on and off tool
ZSafe = -5 'Safe Z
DrawBar = Output11 'Output Port of mach3 (open the collet for tool change)
ToolRack = Output12 'Output Port of mach3 for open the output for activate pneumatic tool rack and in future can use this output for raise dust shoe too (at same time if you don't wan't to put an independent output)
Xpos = 0 'X position of tool in rack
YPos = 0 'Y position of tool in rack
ZPos = 0 'Z position of tool in rack
YPosSlide = 264.00 'Safe start for sliding the tool in and out of rack
SpindleEmpty = 0 'Is the spindle empty
'This two variables are for security and see if the tool open and know if a tool is inside
Const OpenColletSensor = 2 'Sensor for see if the collet are openend
Const ToolInside = 1 'Tool are inside the spindle sensor (doesn't work for see if the collet are closed because the sensor only works in some positions of the spindle for see if are closed without tool, but for indicate the tool is inside work in all positions)



'this variables are for future upgrades and are commented
'ToolRackSensor = Input "x"     'When i have time i wan't to add a limit switch for stop the process if the toolrack doesnt move to position (aircompresor off for example).



'-------Security Check: is spindle running? ----
If GetOEMLED (11) Then
Message "Spidnle working STOP the spindle and retry!! ABORT!!!"
Exit Sub
End If



'-------Security check: Is the machine moving? if is moving wait ----
While IsMoving() 'Wait for finish moving
Sleep(100) 'Sleep for avoid cpu consumption
Wend 'continue with the main program




'Check if the requested tool is within range
If OldTool = 0 Then
SpindleEmpty = 0 'No tool in spindle
Else
SpindleEmpty = 1 'Spindle has a tool loaded
End If




'Do we need a new tool
If NewTool = OldTool Then
'I don't need to change tool
Message "Correct Tool already loaded."
Exit Sub
End If

If NewTool = 0 Then
  If SpindleEmpty = 0 Then
  'No tool to put away exit
Else
    'Put tool away
Call PutToolInRack
End If
SetCurrentTool(NewTool) 'Set the NewTool as current tool
Sleep(250) 'Wait for DRO to update
Exit Sub
Else
  If NewTool > MaxToolNum Or NewTool < 0 Then
  'Stop program and exit
    Message "Tool out of range [Tool #" & NewTool & "]"
    Code "M30"
    Exit Sub
Else
  If SpindleEmpty = 0 Then
  'Get new tool
GetToolFromRack
Else
    'Swap tools
Call PutToolInRack
Call GetToolFromRack
End If
SetCurrentTool(NewTool) 'Set the NewTool as current tool
Sleep(250) 'Wait for DRO to update
  End If
End If

End
'--------------------------------------------------------------------------
Sub PutToolInRack
'Fisrt check if any tool are inside (maybe i made a manual tool change with an independent button i have in the cnc for make manual tool changes)
If Not IsActive(ToolInside) Then 'If the collet doesn't have a tool inside
Sleep(1000)
Message("The spindle doesn't have tool inside! and mach3 think i have a tool loaded!!")   'this part i need to polish it because not's necesary to stop the tool change only avoid to put tool in rack because i dont have tool, but for the moment i want to see when i have this problem see what error i made
Sleep(1000)
Exit Sub
Else 'continue main code
Code "G00 G53 Z" & ZSafe                'Move to Z axis safe
Call WaitMove(100) 'Wait for finish moving to Zsafe
ActivateSignal(ToolRack) 'Activate the pneumatic tool holder
Call ToolPos (OldTool,XPos, Ypos, ZPos) 'Get rack position
Code "G53 X" & Xpos & " Y" & YPosSlide 'Move to sliding position
Call WaitMove(100)
Code "G01 G53 Z" & Zpos & " F" & FFeed 'Move spindle down
Call WaitMove(100)
Code "G53 Y" & Ypos    'Slide tool into rack
Call WaitMove(100)
ActivateSignal(DrawBar) 'Activate the drawbar and release the tool
Sleep(1000) 'Wait 1 second for open the drawbar
Code "G00 G53 Z" & ZSafe 'Move to safe tool height
Call WaitMove (100)
DeActivateSignal(DrawBar)               'Clamp drawbar (without wait for close the collet because it's not needed here).
DeActivateSignal(ToolRack)              'Return tool rack to retract position

End If     'This part is finished and can continue to next security check

'Check if the tool are droped at toolrack
If IsActive(ToolInside) Then 'If the collet have a tool inside STOP!!! the tool arent droped
Sleep(1000)
Message("The spindle still have tool inside!!")
Exit Sub

Else    'if tool arent inside all go in right direction
Message("Tool number [Tool #" & OldTool & "] are in tool rack")   'Only for debug and more info
Sleep(1000)
End If

'continue main code
Sleep(250)
SpindleEmpty = 0                        'No tool in spindle
End Sub

'------------------------------------------------------------------------

Sub GetToolFromRack
'First check if any tool are inside
If IsActive(ToolInside) Then 'If have a tool inside spindle
Sleep(1000)
Message("The spindle have tool inside! and mach3 think i don't have a tool loaded!!")   'something failed and the spindle aren't empty
Sleep(1000)
Exit Sub
Else
'Get tool from rack 'start getting the tool from toolrack
Code "G00 G53 Z" & ZSafe                'Move Z axis safe
Call WaitMove(100)
ActivateSignal(ToolRack) 'Activate the pneumatic tool holder
Sleep(500) 'Little wait for wait pneumatic tool holder (toolrack)
Call ToolPos (NewTool,XPos, YPos, ZPos) 'Get tool position
Code "G53 X" & Xpos & " Y" & YPos 'Move to new tool position
Call WaitMove(100)
ActivateSignal(DrawBar) 'Activate the drawbar (open collet)
Code "G01 G53 Z" & ZPos & " F" & FFeed 'Down to engage the tool
Call WaitMove(100)
DeActivateSignal(DrawBar) 'Clamp the tool
Sleep(2000) 'Wait for tool to clamp

'---check of the sensor for see if the tool are loaded with the sensor of the spindle---
If Not IsActive(ToolInside) Then 'If the tool aren't loaded (empty tool rack, maybe i extracted the tool manually and i don't put it in the tool rack)
Sleep(1000)
Message ("No tool in spindle -> Abort")
Sleep(200)
Code "M30" 'stop the program
End If

'we got a tool in spindle so we continue
Code "G53 Y" & YPosSlide 'Slide out of rack
Code "G00 G53 Z" & ZSafe 'Move to Z safe position
DeActivateSignal(ToolRack) 'Retract the pneumatic toolrack
SpindleEmpty = 1                'Spindle has tool loaded
End If '

End Sub



Sub WaitMove(ByVal Dtime As Integer)
  While IsMoving()
    Sleep(Dtime)
  Wend
End Sub

Sub ToolPos(ByVal ToolNumber As Integer, ByRef XPos, ByRef YPos, ByRef ZPos)
'Subroutine to find tool location coordinates
Select Case ToolNumber
Case is = 1 'If the tool number is 1 then read these XYZ positions
Xpos = 112.25 'Here specify  the Machine coords of the tool 1 position.
Ypos = 304.79 'same for all cases
Zpos = -80.00
Case is = 2
Xpos = 212.25
Ypos = 304.79
Zpos = -80.00
Case is = 3
Xpos = 312.25
Ypos = 304.79
Zpos = -80.00
Case is = 4
Xpos = 412.25
Ypos = 304.79
Zpos = -80.00
Case is = 5
Xpos = 512.25
Ypos = 304.79
Zpos = -80.00
Case is = 6
Xpos = 612.25
Ypos = 304.79
Zpos = -80.00
Case is = 7
Xpos = 711.50
Ypos = 304.79
Zpos = -80.00
Case is = 8
Xpos = 111.50
Ypos = 304.79
Zpos = -50.00
End Select
End Sub       



122
in here:
Code: [Select]
Sub GetToolFromRack
'Fisrt check if any tool are inside
If IsActive(ToolInside) Then 'If have a tool inside spindle
Sleep(1000)
Message("The spindle have tool inside! and mach3 think i don't have a tool loaded!!")   '
Sleep(1000)
Exit Sub
Else
'Get tool from rack
Code "G00 G53 Z" & ZSafe                'Move Z axis safe
Call WaitMove(100)
ActivateSignal(ToolRack)
Call ToolPos (NewTool,XPos, YPos, ZPos) 'Get tool position
Code "G53 X" & Xpos & " Y" & YPos 'Move to new tool position
Call WaitMove(100)
ActivateSignal(DrawBar) 'Activate the drawbar (open collet)
ActivateSignal(ToolRack) 'Activate the pneumatic tool holder
Code "G01 G53 Z" & ZPos & " F" & FFeed 'Down to engage the tool
Call WaitMove(100)
DeActivateSignal(DrawBar) 'Clamp the tool
Sleep(2000) 'Wait for tool to clamp
'---check of the sensor for see if the tool are loaded with the sensor of the spindle---
??? If Not IsActive(ToolInside) Then 'If the tool aren't loaded (empty tool rack, maybe i extracted the tool manually and i don't put it in the tool rack)
Sleep(1000)
??? End If

??? Else
Code "G53 Y" & YPosSlide 'Slide out of rack
Code "G00 G53 Z" & ZSafe 'Move to Z safe position
DeActivateSignal(ToolRack) 'Retract the pneumatic toolrack
SpindleEmpty = 1                        'Spindle has tool loaded
???
End Sub


your If Then Else conditions are mixed up.
just a first quick view.

123
would be helpfull if you post your complete macro code, not only a Sub,
and explain what exactly is not working.

124
General Mach Discussion / Re: Mach 3 atc on boxford lathe
« on: April 24, 2023, 02:13:29 AM »
modified your code a little bit:

Code: [Select]
' (C) Graham Waterworth Mach forum.
' rough draft for a lock back to pawl type tool changer
' this has not been tried on any tool changer
' use/modify it as you wish, I take no responsibility
' for any damage to you or your equipment.

' NOTE current values are for a Boxford 125/160 lathe
' 8 position tool changer using MM calibration.
' set axis steps per to 20

If IsLoading() Then
  ' do now't, program loading
Else

' dim some vars

  Dim next_tool As Integer
  Dim current_tool As Integer
  Dim steps_per_tool As Integer
  Dim steps_after_pawl As Integer
  Dim max_tools As Integer
  Dim rotateCW As Integer
  Dim moves As Integer
  Dim fast_feed As Integer
  Dim slow_feed As Integer
  Dim axis As String
  Dim zero As Integer
  Dim to_pawl As Integer

' set up some vars

  zero = 0
  axis = "A" ' change to what ever axis you use for tool changer
  rotateCW = 0 ' set to 1 for CCW and 0 for CW rotation
  max_tools = 8 ' number of tools on turret
   
   ' stepper driver should be set to 1 step NO MICRO STEPPING!
   
  steps_per_tool = 900 ' number of steps needed to move 1 tool position (45 deg)
  steps_after_pawl = 100 ' set to amount to clear pawl after move (5 deg)
  steps_to_lock_back_on_pawl = 140 ' number of steps to lock onto pawl (7 deg)
  next_tool = GetSelectedTool()
  current_tool = GetCurrentTool()
  fast_feed = 1000 ' set to safe rapid rotation speed
  slow_feed = 200 ' set to safe creep speed back onto pawl.

' do some tool changing

  If next_tool > max_tools Then
    Message "Tool number too high, program stopped."
    Code "M30"
    End
  End If
   
  If next_tool<1 Then
    Message "Tool number too low, program stopped."
    Code "M30"
    End
  End If
   
  If next_tool=current_tool Then
    ' do nowt, we got it already

  Else

       'X-Axis not in reference
If GetOEMLED(807) Then
DoButton(3)
Sleep(500)
Message ("X-Axis not referenced -> Abort !!")
                Code "M30"
Exit Sub
End If

'Z-Axis not in reference
If GetOEMLED(809) Then
DoButton(3)
Sleep(500)
Message ("Z-Axis not referenced -> Abort !!")
                Code "M30"
Exit Sub
End If


      Message "ATC X-Axis to TC position"
      Code "G90 G53 G0 X2"
      While IsMoving()
         Sleep(15)
      Wend

      Message "ATC Z-Axis to TC position"
      Code "G90 G53 G0 Z2"
      While IsMoving()
         Sleep(15)
      Wend

  ' lets do some checking
    If next_tool > current_tool Then moves = next_tool - current_tool
    If next_tool < current_tool Then moves = max_tools - current_tool + next_tool
   ' work out how far to move
    rapid_move = (moves * steps_per_tool) + steps_after_pawl
    to_pawl = zero - steps_to_lock_back_on_pawl
   ' reverse moves if needed   
    If rotateCW = 1 Then
      rapid_move = zero - rapid_move
      to_pawl =  Abs(to_pawl)
    End If
   ' set axis to zero
    Code "G92 " & axis & "0"
    Code "G91 G94 G61"
   ' start the move
    Code "G01 " & axis & rapid_move & " F" & fast_feed
    Code "G04 P250"
    While IsMoving()
    Wend
   ' move back to locking point
    Code "G01 " & axis & to_pawl &  " F" & slow_feed
    While IsMoving()
    Wend
   ' tell mach3 new tool
    SetCurrentTool next_tool
    Code "G90" ' back to absolute movement
  End If
End If

' end of tool change   

125
General Mach Discussion / Re: Mach 3 atc on boxford lathe
« on: April 23, 2023, 12:56:46 PM »
here:
https://www.machsupport.com/forum/index.php/topic,36624.msg251085.html#msg251085

you can find a macro i poted some year's ago it shows how to move to "safe" position first.
this will also make necessary to have the axis referenced/homed to know for sure the position
in machinecoords.

126
CS-Lab / Re: Auto Tuning in MACH3
« on: April 21, 2023, 03:32:16 AM »
hello,
in this case i think the best is to contact

Andrew Rogozynski or Wojtek Trawicki via    office@cs-lab.eu
from CS-Lab.

they normaly answer within a few day's

127
General Mach Discussion / Re: Mach 3 atc on boxford lathe
« on: April 19, 2023, 12:04:53 PM »
Graham's script has parameter's for the step's per tool

from Graham's script:
Code: [Select]
  steps_per_tool = 900 ' number of steps needed to move 1 tool position (45 deg)
  steps_after_pawl = 100 ' set to amount to clear pawl after move (5 deg)
  steps_to_lock_back_on_pawl = 140 ' number of steps to lock onto pawl (7 deg

and it looks like your machine is set to degrees witch means it needs 45 step's per tool.
so you have to set the parameters right.

Code: [Select]
  steps_per_tool = 45 ' number of steps needed to move 1 tool position (45 deg)
  steps_after_pawl = 5 ' set to amount to clear pawl after move (5 deg)
  steps_to_lock_back_on_pawl = 7 ' number of steps to lock onto pawl (7 deg)

i would expect.

129
General Mach Discussion / Re: Mach 3 Plasma technician in toronto area
« on: April 13, 2023, 02:35:51 AM »
Hi, i am not a THC specilaist, wonder wether you found this:

https://www.warp9td.com/index.php/gettingstarted/setting-up-the-smoothstepper-and-mach#THC

130
you can try to use the teachfile for this (not tested!!):

Code: [Select]
'====== Dice Vending Machine ======
'M301
'Last edited 4/6/2023 by Aaron Potts

Sub Main

    'Last argument for Dialog is not asigning an id, it is specifying the
    'function that will handle interactions with the dialog elements.
    Begin Dialog DiceVendingMachine 200, 150, "Dice Vending Machine v1.0", .DialogHandler
        OKButton      10, 130, 40, 15, .ok
        CancelButton 152, 130, 40, 15, .cancel

        OptionGroup .diceChoiceGroup
        OptionButton  20, 10, 40, 10, "Full Poly", .fullPoly
        OptionButton  75, 10, 50, 10, "Poly, No D6", .polyNoD6

        CheckBox 140, 10, 40, 10, "Custom", .custom

        GroupBox 10, 30, 180, 90, "Custom Run:", .customGroup
        CheckBox 40, 45, 40, 10, "D20", .d20Check
        Text     90, 45, 40, 10, "How Many?", .d20Text
        TextBox 135, 45, 20, 10, .d20Qty

        CheckBox 40, 57, 40, 10, "D12", .d12Check
        Text     90, 57, 40, 10, "How Many?", .d12Text
        TextBox 135, 57, 20, 10, .d12Qty

        CheckBox 40, 69, 40, 10, "D10", .d10Check
        Text     90, 69, 40, 10, "How Many?", .d10Text
        TextBox 135, 69, 20, 10, .d10Qty

        CheckBox 40, 81, 40, 10, "D8", .d8Check
        Text     90, 81, 40, 10, "How Many?", .d8Text
        TextBox 135, 81, 20, 10, .d8Qty

        CheckBox 40, 93, 40, 10, "D6", .d6Check
        Text     90, 93, 40, 10, "How Many?", .d6Text
        TextBox 135, 93, 20, 10, .d6Qty

        CheckBox 40, 105, 40, 10, "D4", .d4Check
        Text     90, 105, 40, 10, "How Many?", .d4Text
        TextBox 135, 105, 20, 10, .d4Qty
    End Dialog

    'Initialize a dialog object.
    Dim DVM As DiceVendingMachine

    'Store the value returned from the dialog:
    '-1 = OK
    '0 = Cancel
    buttonPressed = Dialog(DVM) 'This line is necessary.


   'Create a new Teach File in Mach3\Gcode
   MyTeachFile = "TeachMe.nc"
   Err = OpenTeachFile(MyTeachFile)
   If Err <> 0 Then

    If DVM.diceChoiceGroup = 0 And DVM.custom = 0 Then
        Code "M98 (Automated Dice Set 4D6 Rotary.TAP)"
    End If
    If DVM.diceChoiceGroup = 1 And DVM.custom = 0 Then
        Code "M98 (Automated Dice Set No D6.TAP)"
    End If
    If DVM.d20Check = 1 And DVM.custom = 1 Then
        Code "M98 (Make D20.tap) L" & DVM.d20Qty
    End If
    If DVM.d12Check = 1 And DVM.custom = 1 Then
        Code "M98 (Make D12.tap) L" & DVM.d12Qty
    End If
    If DVM.d10Check = 1 And DVM.custom = 1 Then
        Code "M98 (Make D10.tap) L" & DVM.d10Qty
    End If
    If DVM.d8Check = 1 And DVM.custom = 1 Then
        Code "M98 (Make D8.tap) L" & DVM.d8Qty
    End If
    If DVM.d6Check = 1 And DVM.custom = 1 Then
        Code "M98 (Make D6.tap) L" & DVM.d6Qty
    End If
    If DVM.d4Check = 1 And DVM.custom = 1 Then
        Code "M98 (Make D4.tap) L" & DVM.d4Qty
    End If

    'Close the Teach file
    Code "M30"
    CloseTeachFile()
    'Now load the teach file for execution
    Call LoadTeachFile()
   Else
    'OpenTeachFile failed
    Message "Unable to open Teach File"
   End If   
End Sub

'A function is required to control visibility of dialog elements.
Function DialogHandler(ControlID$, Action%, SuppValue%)

    'Toggle visibility of custom dice elements.
    Select Case Action%
        Case 1 'Action% = 1 when the dialog is first called.
            DlgEnable "customGroup", 0

            DlgVisible "d20Check", 0
            DlgVisible "d20Text", 0
            DlgVisible "d20Qty", 0
            DlgEnable "d20Text", 0
            DlgEnable "d20Qty", 0

            DlgVisible "d12Check", 0
            DlgVisible "d12Text", 0
            DlgVisible "d12Qty", 0
            DlgEnable "d12Text", 0
            DlgEnable "d12Qty", 0

            DlgVisible "d10Check", 0
            DlgVisible "d10Text", 0
            DlgVisible "d10Qty", 0
            DlgEnable "d10Text", 0
            DlgEnable "d10Qty", 0

            DlgVisible "d8Check", 0
            DlgVisible "d8Text", 0
            DlgVisible "d8Qty", 0
            DlgEnable "d8Text", 0
            DlgEnable "d8Qty", 0

            DlgVisible "d6Check", 0
            DlgVisible "d6Text", 0
            DlgVisible "d6Qty", 0
            DlgEnable "d6Text", 0
            DlgEnable "d6Qty", 0

            DlgVisible "d4Check", 0
            DlgVisible "d4Text", 0
            DlgVisible "d4Qty", 0
            DlgEnable "d4Text", 0
            DlgEnable "d4Qty", 0
        Case 2 'Action% = 2 anytime there is an interaction with an element other than a TextBox or ComboBox.
            If ControlID$ = "custom" Then
                'If no 0 or 1 after, then toggles elements.
                DlgEnable "fullPoly"
                DlgEnable "polyNoD6"

                DlgEnable "customGroup"
               
                DlgVisible "d20Check"
                DlgVisible "d20Text"
                DlgVisible "d20Qty"

                DlgVisible "d12Check"
                DlgVisible "d12Text"
                DlgVisible "d12Qty"

                DlgVisible "d10Check"
                DlgVisible "d10Text"
                DlgVisible "d10Qty"

                DlgVisible "d8Check"
                DlgVisible "d8Text"
                DlgVisible "d8Qty"

                DlgVisible "d6Check"
                DlgVisible "d6Text"
                DlgVisible "d6Qty"

                DlgVisible "d4Check"
                DlgVisible "d4Text"
                DlgVisible "d4Qty"
            End If
            If ControlID$ = "d20Check" Then
                DlgEnable "d20Text"
                DlgEnable "d20Qty"
            End If
            If ControlID$ = "d12Check" Then
                DlgEnable "d12Text"
                DlgEnable "d12Qty"
            End If
            If ControlID$ = "d10Check" Then
                DlgEnable "d10Text"
                DlgEnable "d10Qty"
            End If
            If ControlID$ = "d8Check" Then
                DlgEnable "d8Text"
                DlgEnable "d8Qty"
            End If
            If ControlID$ = "d6Check" Then
                DlgEnable "d6Text"
                DlgEnable "d6Qty"
            End If
            If ControlID$ = "d4Check" Then
                DlgEnable "d4Text"
                DlgEnable "d4Qty"
            End If
            If ControlID$ = "ok" Then
                Exit Function 'By default, OK buton doesn't do anything.
            End If
    End Select
End Function