Hello Guest it is April 20, 2021, 02:41:01 PM

Author Topic: M6 - Turret not picking up signal correctly  (Read 3878 times)

0 Members and 1 Guest are viewing this topic.

M6 - Turret not picking up signal correctly
« on: August 04, 2010, 04:10:17 PM »
Hi Guys, first post here. I have built a VB script based on a few examples and other works to work with my Denford Mirac.

It has an 8 station tool changer and the position is identified using grey code - 3 digits , 1s or 0s (on or off)

The problem I'm having is I can only get positions 1 to 6 and when I try to get the positions that work they take around 5 minutes to even find the tool sometimes(spins round a few times, backs in as it thinks it has the tool, spins out as it releases it doesnt over and over). Positions 7 and 8 are 111 and 000 and for some reason the tool changer cant get those postions, it does stop on them but decides its not the tool were looking for. I have verfied the hardware is correct and working properly (I have 3 leds representing the grey code so I can see it visually). It surley can only be the code or Mach3.

Heres the code:

Dim Tool As Integer
Dim OldTool As Integer
Dim NewTool As Integer
Dim MaxToolNum As Integer
NewTool = 10
MaxToolNum = 8 'Maximum positions on Automatic Tool Changer
Tool = GetSelectedTool() 'Get the toolnumber from the command e.g T0101 M6 Tool number 1
OldTool = GetCurrentTool() 'Get current tool number


Call StartToolChanger

While NewTool <> Tool
Call CheckPins
Wend





'//// Subroutines /////////

Sub StartToolChanger
ActivateSignal(Output3) 'Turn on output signal to turn off spindle and turn on the atc
ActivateSignal(Output4) 'Turn atc forward
sleep 3000 'Needed to start atc otherwise it plays up
Call CheckPins

End Sub


Sub CheckPins
If IsActive(Input3) And Not IsActive(Input2) And Not IsActive(Input1) Then
NewTool = 1
Call StopTool
End If
If Not IsActive(Input3) And Not IsActive(Input2) And Not IsActive(Input1) Then
NewTool = 8
Call StopTool
End If
If Not IsActive(Input3) And Not IsActive(Input2) And IsActive(Input1) Then
NewTool = 4
Call StopTool
End If
If IsActive(Input3) And Not IsActive(Input2) And IsActive(Input1)Then
NewTool = 5
Call StopTool
End If
If IsActive(Input3) And IsActive(Input2) And IsActive(Input1) Then
NewTool = 7
Call StopTool
End If
If Not IsActive(Input3) And IsActive(Input2) And IsActive(Input1)Then
NewTool = 6
Call StopTool
End If
If Not IsActive(Input3) And IsActive(Input2) And Not IsActive(Input1) Then
NewTool = 2
Call StopTool
End If
If IsActive(Input3) And IsActive(Input2) And Not IsActive(Input1) Then
NewTool = 3
call StopTool
End If
End Sub

Sub Stoptool
DeActivateSignal(Output4) ' Stop running the ATC forward, if you don't do this the inverter will stop and the whole unit
' Will need to be turned off and on again
ActivateSignal(Output5) 'Run ATC in reverse
Sleep 3000 'Wait 3 seconds to allow the toolpost to lock in
DeActivateSignal(Output5) 'Stop running ATC in reverse
Sleep 1000

If Tool <> NewTool Then
Call StartToolChanger
SetCurrentTool(NewTool)
Else
SetCurrentTool(NewTool)
End If

DeActivateSignal(Output3) 'Turn off output to turn spindle back on

Stop
End Sub


           

Offline BR549

*
  •  6,952 6,952
    • View Profile
Re: M6 - Turret not picking up signal correctly
« Reply #1 on: August 04, 2010, 07:48:09 PM »
I 'll give you some experience from a group of us that worked on tool changer code inside of mach. IT is a bear. Mach is very slow in VB macros and to get any speed out of the tool changer was tough as well.

The grey code(we had a 24 tool changer running) is a challenge to VB because of the slow i/o loop) Never was able to get it to run FAST enought to make it usefull so we went to a ModIO from Peter Holmann instead. A plc would be best as we know that works well.

What seems to happen is as the positions come up mach is not fast enought to interegate the code in time to stop the changer on position. By the time it does the complete logic loop the grey code has changed and the loop has to restart. Then it becomes hit a miss to catch the position in time to process it.

Things that can help.  ADD another triggerpoint(switch) that activates at each station. Then force the changer to STOP until Mach can interegate the grey code. Then based on what it sees stop or continue. An 8 station changer would not be too bad but a 24 was painfully SLOW and clunky.

Now this is NOT saying it can't be made to work, you will just have to work out the variables based on YOUR system. You will have to work out a system that mach can deal with. I think a BRIANS approach could be made to work nicely. Let the brain do the logic loop and signal VB to process the results.

A plugin would be best (faster)  but harder to impliment.

This was our results, Your mileage may vary
« Last Edit: August 04, 2010, 07:50:29 PM by BR549 »

Offline BR549

*
  •  6,952 6,952
    • View Profile
Re: M6 - Turret not picking up signal correctly
« Reply #2 on: August 05, 2010, 11:39:47 AM »
Another thought, can you make the dwell longer on your encoder for the grey code? that would give mach more time to see it. I looked at your code and it seems ok up front with simple testing Just need to work out the timing issues with the encoder and VB. With your mechanism you should be able to stretch the encoder signal out to JUST before the next tool position as you do a back down to lock it in it would just take a bit longer to back down

The Brians are much faster BUT I don't see a fast way to access VB from the brians. and you end up with the same problem
« Last Edit: August 05, 2010, 11:42:40 AM by BR549 »

Offline BR549

*
  •  6,952 6,952
    • View Profile
Re: M6 - Turret not picking up signal correctly
« Reply #3 on: August 05, 2010, 09:52:53 PM »
IF you get a change try the code something like this to see IF it is any faster.



'Macro Tool Changer

Sub Main()

Dim Tool As Integer
Dim OldTool As Integer
Dim NewTool As Integer
Dim MaxToolNum As Integer

NewTool = 10
MaxToolNum = 8 'Maximum positions on Automatic Tool Changer
Tool = GetSelectedTool() 'Get the toolnumber from the command e.g T0101 M6 Tool number 1
OldTool = GetCurrentTool() 'Get current tool number



If Tool > MaxtoolNum Then GoTo 6
If TOOL = OldTool Then GoTo 7
 
ActivateSignal(Output3) 'Turn on output signal to turn off spindle and turn on the atc
sleep(10)
ActivateSignal(Output4) 'Turn atc forward
sleep (3000) 'Needed to start atc otherwise it plays up

While  NewTool <> Tool
   ' CheckPins
If IsActive(Input3) And Not IsActive(Input2) And Not IsActive(Input1) Then
NewTool = 1
GoTo 5       'StopTool
End If
If Not IsActive(Input3) And Not IsActive(Input2) And Not IsActive(Input1) Then
NewTool = 8
GoTo 5       'StopTool
End If
If Not IsActive(Input3) And Not IsActive(Input2) And IsActive(Input1) Then
NewTool = 4
GoTo 5       'StopTool
End If
If IsActive(Input3) And Not IsActive(Input2) And IsActive(Input1)Then
NewTool = 5
GoTo 5       'StopTool
End If
If IsActive(Input3) And IsActive(Input2) And IsActive(Input1) Then
NewTool = 7
GoTo 5       'StopTool
End If
If Not IsActive(Input3) And IsActive(Input2) And IsActive(Input1)Then
NewTool = 6
GoTo 5       'StopTool
End If
If Not IsActive(Input3) And IsActive(Input2) And Not IsActive(Input1) Then
NewTool = 2
GoTo 5       'StopTool
End If
If IsActive(Input3) And IsActive(Input2) And Not IsActive(Input1) Then
NewTool = 3
GoTo 5       'StopTool
End If

Wend

5:
' Stoptool
DeActivateSignal(Output4) 'StopATC
sleep(10)
ActivateSignal(Output5) 'Run ATC in reverse
Sleep (3000) 'Wait 3 seconds to allow the toolpost to lock in
DeActivateSignal(Output5) 'Stop running ATC in reverse
Sleep (1000)
SetCurrentTool(NewTool)
DeActivateSignal(Output3) 'Turn off output to turn spindle back on
sleep(10)
GoTo 7

6:
MsgBox ("Tool out of RANGE")
Goto 7
 
7:

 End Sub