Hello Guest it is April 18, 2024, 06:41:06 PM

Author Topic: M6Start macro problem  (Read 2172 times)

0 Members and 1 Guest are viewing this topic.

M6Start macro problem
« on: March 22, 2022, 09:30:00 AM »
Hi guys,

I see here many of us have some sort of problems with ATC macro. Well, I am not exception neither.

We are now finishing retrofit on Hurco MB1 CNC mill that has 18 tool changer powered by "geneva" mechanism.

My ATC VB code raised a bit by now but I have strange behavior on bare beginning of my macro where it stuck when I call code "G53 G0 Z-104". Z axe do not move at all and macro stuck in While IsMoving loop.

This happens only after referencing axes. If I do E-stop reset after referencing, macro will work errorless but if I reference again for eg. only Z axe macro stuck at the same place.
At the same time if I type "G53 G0 Z-104" on MDI line Z axe moves no matter of referencing nor E-stop. It's a strange and it looks like referencing leave some variable or some motion mode active so it interrupt motion call from M6 macro.

If I do E-stop after ref., machine is capable of doing relatively complex G code including multiple tool changes without any problem.

I do not have my macro code here yet to share, but its beginning is fairly simple down to the point where it usually stuck. I can share it later.

Is there any idea what can cause this like problem.

Regards and thanks in advance.

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: M6Start macro problem
« Reply #1 on: March 22, 2022, 01:11:08 PM »
without the seeing the code it will be hard to help.
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: M6Start macro problem
« Reply #2 on: March 22, 2022, 06:12:43 PM »
Ok here is it...
Whole macro is around 500 lines so I cut it just so you can see this part where problem happens.
If I run only this part of macro it will do the same as described in my previous post.
If it is needed I can post whole macro no problem at all.


Code: [Select]

Const TOOLCOUNT = 18 ' max Tool #
Const ATCFEEDRATE = 10 ' tool change feedrate

Const ToolZlockPos = -104.0 ' Z axe tool lock height abs
Const ToolZrotatePos = 10.0 ' Z axe tool rotate height abs

'------------------------------------------------------------------------------
' program variables - don't modify
'------------------------------------------------------------------------------
Dim ToolNew, ToolOld, CWturn, CCWturn, ActATCPos, CarousellRot As Integer
Dim ToolRdy, FloodLast, JogLast As Boolean
'------------------------------------------------------------------------------
  ' MACRO START
'------------------------------------------------------------------------------
Sub Main()

Message("ATC in progres...")

If(GetOEMLed(800)) Then ' MACH is at RESET condition
Message("ESTOP active - Tool Change terminated")
Sleep(150)
'WaitForMove
End
End If


If(GetOEMLed(807) Or GetOEMLed(808) Or GetOEMLed(809)) Then ' Machine not referenced
Message("You must reference machine first!")
Sleep(150)
'WaitForMove
End
End If

SetUserLED(1001, 1) ' User LED - toolchange in progress (Pause Feed Hold condition)

If Not IsActive(AtcHomePosSw) Or IsActive(AtcChangePosSw) Then
MachMsg("Wrong tool!", "Error!!!", 0)
End
End If

' Get actual tool # and new tool #
ToolOld = GetCurrentTool()
ToolNew = GetSelectedTool()

SetOemDro(SelectedToolDRO, ToolNew) 'sellected tool

FloodLast = GetOemLed(13) ' get flood led
JogLast = GetOemLed(JogLed) ' get Jog led

Message("Old tool =" & ToolOld &", New tool = " & ToolNew)

If GetOemLed(JogLed) Then 'disable Jog
DoOEMbutton(JogButton)
End If

DoOEMbutton(183) 'reset speed override


' The same position - no need to move
If (ToolNew = ToolOld) Then
SetCurrentTool( ToolNew )
Message("ATC is on position T "& ToolNew)
'WaitForMove
End
End If

If (ToolNew > TOOLCOUNT) Then
SetCurrentTool( ToolOld )
SetUserLED(1001, 0) ' Pause Feed Holf off
DoOEMButton(1003) ' Stop
DoOEMButton(1002) ' G-Code Rewind
Sleep(150)
Message("Tool number too high (above 18)")
Sleep(150)
End
End If

' T0 is a fake tool, no need to change
If (ToolNew = 0) Then
ToolNew = 0
SetCurrentTool( ToolNew )
Message("Succesful loaded tool T" & ToolNew)
'WaitForMove
End
End If

DoOEMButton(225)

'Message("Spindle stop...")
DoSpinStop() ' Stop spindle roration
'Message("Moving Z...")
ZtoChPosition ' Z axe to tool change position <<<--- HERE MACRO STUCK



End Sub


' -----------------------------------------------------------------------------
Sub ZtoChPosition() 'Move to Z tool position and wait until position reached
code("G53 G00 Z"& ToolZlockPos & "F" & ATCFEEDRATE) 'Z value as to be checked for exact match with carrousel height
WaitForMove ()
Sleep(1000)
End Sub

' -----------------------------------------------------------------------------
Sub WaitForMove ()
CntLoop = 60

While(IsMoving() And CntLoop > 0 )
CurPos = GetOemDRO(802)
Pom = CurPos - Destination
Sleep(250)
CntLoop = CntLoop - 1
If CntLoop = 0 Then
If RetryDialog("Error!!!", "IsMoving() timeout, Retry?") Then
CntLoop = 20
Else
End
End If
End If
Wend
End Sub               

Re: M6Start macro problem
« Reply #3 on: March 22, 2022, 06:44:05 PM »
Sorry I missed some parts of code...

Code: [Select]
Const TOOLCOUNT = 18 ' max Tool #
Const ATCFEEDRATE = 10 ' tool change feedrate

Const ToolZlockPos = -104.0 ' Z axe tool lock height abs
Const ToolZrotatePos = 10.0 ' Z axe tool rotate height abs

'------------------------------------------------------------------------------
' program variables - don't modify
'------------------------------------------------------------------------------
Dim ToolNew, ToolOld, CWturn, CCWturn, ActATCPos, CarousellRot As Integer
Dim ToolRdy, FloodLast, JogLast As Boolean
'------------------------------------------------------------------------------
  ' MACRO START
'------------------------------------------------------------------------------
Sub Main()

Message("ATC in progres...")

If(GetOEMLed(800)) Then ' MACH is at RESET condition
Message("ESTOP active - Tool Change terminated")
Sleep(150)
'WaitForMove
End
End If


If(GetOEMLed(807) Or GetOEMLed(808) Or GetOEMLed(809)) Then ' Machine not referenced
Message("You must reference machine first!")
Sleep(150)
'WaitForMove
End
End If

SetUserLED(1001, 1) ' User LED - toolchange in progress (Pause Feed Hold condition)

If Not IsActive(AtcHomePosSw) Or IsActive(AtcChangePosSw) Then
MachMsg("Wrong tool!", "Error!!!", 0)
End
End If

' Get actual tool # and new tool #
ToolOld = GetCurrentTool()
ToolNew = GetSelectedTool()

SetOemDro(SelectedToolDRO, ToolNew) 'sellected tool

FloodLast = GetOemLed(13) ' get flood led
JogLast = GetOemLed(JogLed) ' get Jog led

Message("Old tool =" & ToolOld &", New tool = " & ToolNew)

If GetOemLed(JogLed) Then 'disable Jog
DoOEMbutton(JogButton)
End If

DoOEMbutton(183) 'reset speed override


' The same position - no need to move
If (ToolNew = ToolOld) Then
SetCurrentTool( ToolNew )
Message("ATC is on position T "& ToolNew)
'WaitForMove
End
End If

If (ToolNew > TOOLCOUNT) Then
SetCurrentTool( ToolOld )
SetUserLED(1001, 0) ' Pause Feed Holf off
DoOEMButton(1003) ' Stop
DoOEMButton(1002) ' G-Code Rewind
Sleep(150)
Message("Tool number too high (above 18)")
Sleep(150)
End
End If

' T0 is a fake tool, no need to change
If (ToolNew = 0) Then
ToolNew = 0
SetCurrentTool( ToolNew )
Message("Succesful loaded tool T" & ToolNew)
'WaitForMove
End
End If

DoOEMButton(225)

'Message("Spindle stop...")
DoSpinStop() ' Stop spindle roration
'Message("Moving Z...")
ZtoChPosition ' Z axe to tool change position <<<--- HERE MACRO STUCK



End Sub


' -----------------------------------------------------------------------------
Sub ZtoChPosition() 'Move to Z tool position and wait until position reached
code("G53 G00 Z"& ToolZlockPos & "F" & ATCFEEDRATE) 'Z value as to be checked for exact match with carrousel height
WaitForMove
Sleep(1000)
End Sub

' -----------------------------------------------------------------------------
Sub WaitForMove
CntLoop = 60

While(IsMoving() And CntLoop > 0 )
CurPos = GetOemDRO(802)
Pom = CurPos - Destination
Sleep(250)
CntLoop = CntLoop - 1
If CntLoop = 0 Then
If RetryDialog("Error!!!", "IsMoving() timeout, Retry?") Then
CntLoop = 20
Else
End
End If
End If
Wend
End Sub

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

Function RetryDialog(CaptionMsg, UserMsg)
If MachMsg(UserMsg, CaptionMsg, 5) = 4 Then
RetryDialog = 1
Else
RetryDialog = 0
End If
End Function


Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: M6Start macro problem
« Reply #4 on: March 23, 2022, 02:45:13 AM »
tested your code here, no problem.
try to run it in VBScripter window to see where it stucks excactly.

btw.
Code: [Select]
code("G53 G00 Z"& ToolZlockPos & "F" & ATCFEEDRATE)

a feedrate does not make sense with a G0, but it should not matter.
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: M6Start macro problem
« Reply #5 on: March 23, 2022, 03:32:45 AM »
Thanks for trying to help.

Yes you are right feedrate have no sense here. It should be G1 instead of G0. Macro is under construction yet and there is more things to clean but I first must solve this strange behavior.

I have tested it many times from VB script editor and if it stucks this happens on this line

Code: [Select]
ZtoChPosition ' Z axe to tool change position <<<--- HERE MACRO STUCK
Here is a code "ZtoChPosition" sub and subs it uses.

Code: [Select]
' -----------------------------------------------------------------------------
Sub ZtoChPosition() 'Move to Z tool position and wait until position reached
code("G53 G00 Z"& ToolZlockPos & "F" & ATCFEEDRATE) 'Z value as to be checked for exact match with carrousel height
WaitForMove
Sleep(1000)
End Sub

' -----------------------------------------------------------------------------
Sub WaitForMove
CntLoop = 60

While(IsMoving() And CntLoop > 0 )
CurPos = GetOemDRO(802)
Pom = CurPos - Destination
Sleep(250)
CntLoop = CntLoop - 1
If CntLoop = 0 Then
If RetryDialog("Error!!!", "IsMoving() timeout, Retry?") Then
CntLoop = 20
Else
End
End If
End If
Wend
End Sub

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

Function RetryDialog(CaptionMsg, UserMsg)
If MachMsg(UserMsg, CaptionMsg, 5) = 4 Then
RetryDialog = 1
Else
RetryDialog = 0
End If
End Function

I am getting timeout message and Z axe do not move at all. If I do E-stop then it works.
Must say I am using ETH-BOX ethernet controller so it probably complicates things a bit.
Running out of idea what cause this problems.


Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: M6Start macro problem
« Reply #6 on: March 23, 2022, 03:56:02 AM »
if you use the >|| Button in VBScripter it usually can not stuck in this line, it allways should jump into the
Sub.

you can try to use the Call keyword:
Code: [Select]
call ZtoChPosition ' Z axe to tool change position <<<--- HERE MACRO STUCK

maybe it help's, never heared about such a problem
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: M6Start macro problem
« Reply #7 on: March 23, 2022, 04:28:24 AM »
Well if I think about the problem a little deeper, macro actually stuck in this sub while waiting for move.

Code: [Select]
' -----------------------------------------------------------------------------
Sub WaitForMove
CntLoop = 60

While(IsMoving() And CntLoop > 0 )
CurPos = GetOemDRO(802)
Pom = CurPos - Destination
Sleep(250)
CntLoop = CntLoop - 1
If CntLoop = 0 Then
If RetryDialog("Error!!!", "IsMoving() timeout, Retry?") Then
CntLoop = 20
Else
End
End If
End If
Wend
End Sub

But just after it calls this G0 move that is never actually done.

Code: [Select]
code("G53 G00 Z"& ToolZlockPos & "F" & ATCFEEDRATE)
So it stuck in endless loop while waiting for move to end.

What can prevent "G53 G0 Z-104" to cause actual move and why IsMoving() wait for move infinitely?
Looks like Mach3 set some variables for G0 move used by IsMoving() but it does not proceed and result is forever loop.

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: M6Start macro problem
« Reply #8 on: March 23, 2022, 04:45:28 AM »
just for a simple test

Code: [Select]
  Code "G53 G0 Z-50"
  While IsMoving()
  Wend
  Code "G53 G0 Z-100"
  While IsMoving()
  Wend

i have used code like this in many of my macros
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: M6Start macro problem
« Reply #9 on: June 16, 2022, 11:20:03 PM »
macro actually stuck in this sub while waiting for move