Hello Guest it is October 20, 2019, 12:56:15 AM

Author Topic: Emco Turn tool changer macro  (Read 13182 times)

0 Members and 1 Guest are viewing this topic.

Emco Turn tool changer macro
« on: December 03, 2010, 10:10:23 AM »
Hi

I am in the process of retrofitting an Emco PC-Turn 50 to Mach3. Just trying to get the basics working on the bench (in the warm) and the only remaining obstacle is the tool changer. The tool changer is the type that uses a small dc motor to rotate a 6 position tool holding disk to the relevant position and then reverses against a ratchet to lock into a repeatable position.

I am intending to use the original 6 slot disk and optical detector to count the tool positions round with a microswitch to reference tool 1 position.

Having never attempted a Mach macro before, not entirely surprisingly, my first attempt is throwing errors. I dont understand the error so cant fix it.

I am trying to trigger the macro using M6 Tx (where x is the tool number)

The error message is: Scripter Compile Error. In:M6Start.mis

Can anybody give me a hint / some help with this.

Thanks

Paul

The Macro.....

Code: [Select]
'M6Start.M1s
'Input1 is an optical sensor used to count tool positions
'Input2 is from a microswitch used to determine tool 0 position
'OUTPUT3 drives the tool changer forward, de activating it allows the tool changer to rotate back against the ratchet pawl at low power and is the default

Sub Main()

NewTool = GetSelectedTool()
OldTool = GetCurrentTool()
MaxToolNum = 6 'Max number of tools for the changer
CurrPos = OldTool

While NewTool > MaxToolNum
NewTool = Question ("Enter New Tool Number up to " & MaxToolNum)
Wend

If NewTool = OldTool Then
    'there is nothing to do so we just exit
    Exit Sub

'If OldTool is 0 that means we dont know where the tool changer is currently positioned and need to reference to the microswitch for tool 1 position.
If OldTool = 0
    'need to establish tool 0 position from microswitch
    While NotIsActive(INPUT2)
        ActivateSignal(OUTPUT3) ' rotate tool changer forward
    Wend
    , input 2 must now be active so the microswitch has been triggered
    DeActivateSignal(OUTPUT3)
    CurrPos = 1
Endif

If CurrPos <> NewTool Then
    While CurPos <>  NewTool
        ActivateSignal(OUTPUT3) 'start rotating forward
        If NotIsActive(INPUT1) And Not IsActive(INPUT2)
            CurrPos ++
            If CurrPos = 7
                CurPos = 1
            Endif
            If IsActive(INPUT2)
                CurPos = 1
            Endif
            If CurPos = NewTool
                DeActivateSignal(OUTPUT3) 'stop rotating forward, rotate backward now
                CurrentTool = NewTool 'sets up the current tool variable as the start point for a future tool change
                Sleep(200) 'Allow a time interval for the toolchanger to settle back against the ratchet pawl
            Else
                Sleep(100) 'wait for the motor to rotate past the current position then test again
            Endif
        End If
    Wend
End If

End Sub
Main
« Last Edit: July 28, 2014, 10:12:47 PM by Ya-Nvr-No »
Re: Emco Turn tool changer macro
« Reply #1 on: December 03, 2010, 04:07:06 PM »
I just fixed your errors, not sure it will do what you want but it will compile and you can at least step thru it.

Code: [Select]
'M6Start.M1s
'Input1 is an optical sensor used to count tool positions
'Input2 is from a microswitch used to determine tool 0 position
'OUTPUT3 drives the tool changer forward, de activating it allows the tool changer to rotate back against the ratchet pawl at low power and is the default

NewTool = GetSelectedTool()
OldTool = GetCurrentTool()
MaxToolNum = 6 'Max number of tools for the changer
CurrPos = OldTool

While (NewTool > MaxToolNum)
    NewTool = Question ("Enter New Tool Number up to " & MaxToolNum)
Wend

    'there is nothing to do so we just exit
If (NewTool = OldTool) Then
    Exit Sub
End If

'If OldTool is 0 that means we dont know where the tool changer is currently positioned and need to reference to the microswitch for tool 1 position.
    'need to establish tool 0 position from microswitch
If (OldTool = 0) Then
    While Not IsActive(INPUT2)
        ActivateSignal(OUTPUT3) ' rotate tool changer forward
    Wend
    ' Input 2 must Now be active so the microswitch has been triggered
    DeActivateSignal(OUTPUT3)
    CurrPos = 1
End If

If (CurrPos <> NewTool) Then
    While CurrPos <>  NewTool
        ActivateSignal(OUTPUT3) 'start rotating forward
        If Not IsActive(INPUT1) And Not IsActive(INPUT2) Then
            CurrPos = CurrPos +1
            If CurrPos = 7 Then
                CurrPos = 1
            End If
            If IsActive(INPUT2) Then
                CurrPos = 1
            End If
            If CurrPos = NewTool Then
                DeActivateSignal(OUTPUT3) 'stop rotating forward, rotate backward now
                CurrentTool = NewTool 'sets up the current tool variable as the start point for a future tool change
                Sleep(200) 'Allow a time interval for the toolchanger to settle back against the ratchet pawl
            Else
                Sleep(100) 'wait for the motor to rotate past the current position then test again
            End If
        End If
    Wend
End If

« Last Edit: July 28, 2014, 10:11:33 PM by Ya-Nvr-No »
Re: Emco Turn tool changer macro
« Reply #2 on: December 03, 2010, 04:46:51 PM »
Thanks very much for the help.

I'll get it hooked up to the sensors physically and see how it goes.

Paul
Re: Emco Turn tool changer macro
« Reply #3 on: February 24, 2011, 11:19:04 AM »
Hello,

I am also wrestling with a macro for my Emco5cnc tool turret.

I have some questions about the INPUT and OUTPUT statements.
What are they looking at?
I have an signal from an optical sensor on A-HOME , it lights yellow.
However it does not do anything under Mach3.

What stands for INPUT1, INPUT2, OUTPUT3 in the snip below???

thanks,
Jos
Holland


If (OldTool = 0) Then
    While Not IsActive(INPUT2)
        ActivateSignal(OUTPUT3) ' rotate tool changer forward
    Wend
    ' Input 2 must Now be active so the microswitch has been triggered
    DeActivateSignal(OUTPUT3)
    CurrPos = 1
End If

If (CurrPos <> NewTool) Then
    While CurrPos <>  NewTool
        ActivateSignal(OUTPUT3) 'start rotating forward
        If Not IsActive(INPUT1) And Not IsActive(INPUT2) Then
            CurrPos = CurrPos +1
            If CurrPos = 7 Then
                CurrPos = 1
            End If
            If IsActive(INPUT2) Then
                CurrPos = 1
            End If
            If CurrPos = NewTool Then
                DeActivateSignal(OUTPUT3) 'stop rotating forward, rotate backward now
                CurrentTool = NewTool 'sets up the current tool variable as the start point for a future tool change
                Sleep(200) 'Allow a time interval for the toolchanger to settle back against the ratchet pawl
            Else
Re: Emco Turn tool changer macro
« Reply #4 on: February 25, 2011, 04:16:39 PM »
Hi

I eventually got mine to work.

Here is the final version of the macro with comments embedded to show what's going on. You can also get it to write to a logfile to give you some diagnostics if it's not doing what you want.

Hope it helps.

Paul

Code: [Select]
'M6Start.M1s
'Input1 is an optical sensor used to count tool positions
'Input2 is from a microswitch used to determine tool 0 position
'OUTPUT6 drives the tool changer forward, de activating it allows the tool changer to rotate back against the ratchet pawl at low power and is the default
'Un comment the Open statement, various write# statements and the close# function to write a logfile for diagnostic purposes

'Close #1
'Open "M6start_log.txt" For Output As #1 'open a file to write logs to
NewTool = GetSelectedTool()
'NewTool = 2
'Write #1, "NewTool ", NewTool
OldTool = GetCurrentTool()
'Write #1, "OldTool ", OldTool
MaxToolNum = 6 'Max number of tools for the changer
CurrPos = OldTool

While (NewTool > MaxToolNum)
    NewTool = Question ("Enter New Tool Number up to " & MaxToolNum)
Wend

    'there is nothing to do so we just exit
If (NewTool = OldTool) And (NewTool > 0) Then
'Write #1, "New tool number is the same as old tool number. Nothing to do "
     Exit Sub
End If

'If OldTool is 0 that means we dont know where the tool changer is currently positioned and need to reference to the microswitch for tool 1 position.
    'need to establish tool 0 position from microswitch
If (OldTool = 0) Then
'Write #1, "Old tool number is zero, looking for reference position"
ActivateSignal(OUTPUT5)' Set toolchanger for full speed move
        'Write #1, "Activated Output 5 to enable toolchanger motor"
        ActivateSignal(OUTPUT6)' rotate tool changer forward
        'Write #1, "Activated Output 6 to set forward direction"
    While Not IsActive(INPUT2)
    Wend
    ' Input 2 must Now be active so the microswitch has been triggered at position 1
    CurrPos = 1
    'Write #1, "Reference position found "
    ' Decide whether to just stop for the normal toolchange process
    If ( CurrPos <> NewTool) Then
    DeActivateSignal(OUTPUT6)
    DeActivateSignal(OUTPUT5)
    Else
    ' Or if we actuallly wanted tool 1 then stop and lock
           DeActivateSignal(OUTPUT5) 'stop rotating forward, rotate backward now
  'Write #1, "DeActivateSignal Output 5 toolchanger reverse "
           SetCurrentTool(NewTool) 'sets up the current tool variable as the start point for a future tool change
           'Write #1, "Setting CurrentTool to NewTool value ", NewTool
           Sleep(2500) 'Allow a time interval for the toolchanger to settle back against the ratchet pawl
           'Write #1, "Waited 2.5 seconds for toolchanger to lock "
           DeActivateSignal(OUTPUT6) 'Disable toolchanger motor
           'Write #1, "DeActivateSignal Output 6 toolchanger stop "
    End If
End If

If (CurrPos <> NewTool) Then 'write the start condition to a variable
If IsActive(INPUT1) Then
PreviousSensorState = "Active"
Else
PreviousSensorState = "Inactive"
End If
'Write #1, "PreviousSensorState =", PreviousSensorState
ActivateSignal(OUTPUT5)' Set toolchanger for full speed move
       'Write #1, "ActivateSignal Output 6 toolchanger go"
        ActivateSignal(OUTPUT6) 'start rotating forward
        'Write #1, "ActivateSignal Output 5 toolchanger forward "
     While CurrPos <>  NewTool
     'Some logic to ensure that we only count on the leading edge of a slot in the toolchanger optical disk
         If IsActive(INPUT1) Then
         SensorState = "Active"
         Else
         SensorState = "Inactive"
         End If
         'Write #1, "SensorState =", SensorState
         If SensorState <> PreviousSensorState Then
         If SensorState = "Inactive" Then
         CurrPos = CurrPos +1
         If CurrPos = 7 Then
         CurrPos = 1
         'Write #1, "CurrPos reached 7, reset to 1 "
         End If
         End If
         'Write #1, "CurrPos =", CurrPos
         PreviousSensorState = SensorState
         End If
         If CurrPos = NewTool Then
              DeActivateSignal(OUTPUT5) 'stop rotating forward, rotate backward now
              'Write #1, "DeActivateSignal Output 5 toolchanger reverse "
              SetCurrentTool(NewTool) 'sets up the current tool variable as the start point for a future tool change
              'Write #1, "Setting CurrentTool to NewTool value ", NewTool
              Sleep(1500) 'Allow a time interval for the toolchanger to settle back against the ratchet pawl
              'Write #1, "Waited 1.5 seconds for toolchanger to lock "
              DeActivateSignal(OUTPUT6) 'Disable toolchanger motor
              'Write #1, "DeActivateSignal Output 6 toolchanger stop "
         End If
         sleep(200) ' just slows the iterations down a bit
         'Write #1, "Waited 0.2 second "
     Wend
     'Write #1, "should be job done "
     'Close #1
End If  
« Last Edit: July 28, 2014, 10:12:14 PM by Ya-Nvr-No »
Re: Emco Turn tool changer macro
« Reply #5 on: January 30, 2012, 01:05:27 AM »
i am doing a retrofit in EMCO 55 TURN and I dont know how I make a macro.

Please, help to me to do just that.

Does your macro work???
Re: Emco Turn tool changer macro
« Reply #6 on: January 30, 2012, 02:16:08 AM »
Hi

The Macro does work for me. It depends on 2 inputs one for each tool position and one for establishing the initial tool position (zero).

If you have the sensors or switches in place for those and a relay setup for forward and reverse on the tool changer motor then it should be fine.

Tool change is normally done using M6 so I have used the M6start macro.

Look in your Mach3/macros/turn folder, there will already by an M6start macro there but with nothing in it.

Just replace that with the macro posted above.

If you need to edit it, you can use the VB script editor in the Mach 3 operator menu.

Hope this helps.

Paul
Re: Emco Turn tool changer macro
« Reply #7 on: January 30, 2012, 03:08:44 AM »
thank you!

The tool change has 2 output :one for each tool position and one for establishing the initial tool position.

I am thinking to use the original dc motor with driver (2 inputs: left, right,stop).

What do you think about that?
Re: Emco Turn tool changer macro
« Reply #8 on: January 30, 2012, 07:07:54 AM »
Hi

That's pretty much what I did on the tool changer but I dumped all the original electronics, just retaining the motor. I used a 12v DC supply and a pair of spco relays to control it, one output for power enable and the other for direction.

The tool changer can only run in one direction to change tools, the other way is only used to lock it firmly in position.

Hope this makes sense.

Paul
Re: Emco Turn tool changer macro
« Reply #9 on: January 30, 2012, 12:18:32 PM »
Thank you.

Completely my friend, this make sense.

I want to do exactly that you did. Only I hope to use the original electronic to work.

When I am working in the machine, I will send to you my impressions and the work progress.

Sincerely,
Juan Andres