Hello Guest it is March 28, 2024, 03:35:27 PM

Author Topic: Terminating Script  (Read 12324 times)

0 Members and 2 Guests are viewing this topic.

Terminating Script
« on: January 14, 2008, 03:33:39 PM »
Hi,

I want to write simple macro for moving Z axis in position for tool change - moving Z+ until switch is triggered.
If switch is not triggered in 200 mm then moving must stop and report an ERROR.

Code:

Code "G01 Z200  F1000"
Message "Moving on switch for tool change position "

While IsMoving()
If  IsActive(Input2)Then
DooemButton(1003)
Message "Z in position for tool change"
End If
Wend

If Not IsActive(Input2)Then
Message "ERROR - Switch is not triggered"
'Exit Sub
End If

When I run this code from VB Script Editor works fine but when I call it from Mach3 then after switch is triggered
I get message "Terminating Script"
I have tray diffrent things (also reinstaling Mach3) and itś always the same.

Any suggestion ????

Is this  recommended way to stop axis when switch is triggered?

Thanx!



Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Terminating Script
« Reply #1 on: January 14, 2008, 08:13:29 PM »
Sub Main()

ZPos = GetOEMDRO(802)

 
Code "G01 Z201 F1000"   'Gives movement past trigger point

If IsActive(INPUT2) Then
DoOEMButton(1003)
Message("Z in position for tool change")
       If ZPos>200 Then  'Gives movement past trigger point
       DoOEMButton(1003)
       Message("ERROR - Switch is not triggered")
       Exit Sub
       End If
End If

   
End Sub
Main

'Try that.........Scott
fun times
Re: Terminating Script
« Reply #2 on: January 15, 2008, 02:28:49 PM »
Thanx!

I try this code but Z axis move to position Z 210 and nothing else.

I have add While Ismoving() and Wend




Sub Main()

ZPos = GetOEMDRO(802)


Code "G01 Z201 F1000"   'Gives movement past trigger point

While Ismoving()

If IsActive(INPUT2) Then
DoOEMButton(1003)
Message("Z in position for tool change")
       If ZPos>200 Then  'Gives movement past trigger point
       DoOEMButton(1003)
       Message("ERROR - Switch is not triggered")
       Exit Sub
       End If
End If

Wend
   
End Sub
Main


And then moving stops when switch is triggered (without "Terminating Scipt") but if switch isn´t triggered unthil
axis reach position Z=201 I don´t get Message "ERROR - Switch is not triggered"

What I can do?

Thank you!
Re: Terminating Script
« Reply #3 on: January 15, 2008, 02:34:59 PM »
Hi, again

I try this code running from VB script editor.

Sub Main()

ZPos = GetOEMDRO(802)


Code "G01 Z201 F1000"   'Gives movement past trigger point

If IsActive(INPUT2) Then
DoOEMButton(1003)
Message("Z in position for tool change")
       If ZPos>200 Then  'Gives movement past trigger point
       DoOEMButton(1003)
       Message("ERROR - Switch is not triggered")
       Exit Sub
       End If
End If

   
End Sub
Main

and problem was like I described in previous post.
Now I have try running code from Mach3 and I still get Message "Terminating Script" when switch is triggered.

Regards!

Offline Graham Waterworth

*
  • *
  •  2,668 2,668
  • Yorkshire Dales, England
    • View Profile
Re: Terminating Script
« Reply #4 on: January 15, 2008, 06:05:55 PM »
Do you have a Z homing switch?

Is the switch you want to trigger the zero return switch?

If you have zero return switches then you can use G53 and a set position from zero return for the tool change position.

If the switch is the zero return switch then you can use G28.1 Z0 to go there or G53 Z0

If none of these are true then look at using G31 Z201. and check the parameter #2002 for the trigger point in Z.  Set up a user macro and call it with Mnnn P#2002

Pick up param(1) in the macro and check its value. work your magic as needed.

Graham.
Without engineers the world stops
Re: Terminating Script
« Reply #5 on: January 16, 2008, 05:50:43 AM »
No, the switch isn´t the same like for Z homing.

I alredy using a touch probe and I can´t use G31.
(perhaps I didn´t understand this option correct - can you post some sample?)

I don´t understand why my and code from poppabear work from VB Script editor and don´t work from Mach3
Sometimes I also get ERROR message from Mach: "Art Code 9991"
I try  on three diffrent computer and the problem is the same.

My company bought three licenses for Mach 3 last year on my suggest and now I have problem to solve simple tool changer.

I´m in very inconvenient situation.

I would like to move Z axis in  position - on switch and give signal to PLC for starting procedure for
tool change (If switch is not triggered unthil moving, must be reported an ERROR)
After finishing of tool change procedure PLC give back a signal and tool change is finish - program move forward.




I will be very grateful for any suggestion.

Thanx!

Offline Graham Waterworth

*
  • *
  •  2,668 2,668
  • Yorkshire Dales, England
    • View Profile
Re: Terminating Script
« Reply #6 on: January 16, 2008, 07:27:54 AM »
Try it this way

Graham.


Sub Main()

ZPos = GetOEMDRO(802)

Code "G01 Z201 F1000"   'Gives movement past trigger point

while ismoving()
  If IsActive(INPUT2) Then
    DoOEMButton(1003)
    Message("Z in position for tool change")
    exit sub
  end if
wend

' Movement past trigger point
DoOEMButton(1003)
Message("ERROR - Switch is not triggered")
End Sub

Main

Without engineers the world stops
Re: Terminating Script
« Reply #7 on: January 16, 2008, 10:38:07 AM »
Thanx,

But still  nothing.
When I running code from Mach3 calling it like M555 (From MDI line and from program)I get message "Terminating Script"

Z moves on position Z 201 and then ... "Terminating Script" (in case where switch is not triggered)
If Itrigger a switch I get "Terminating Script" also.
From VB Script editor works fine - without "Terminating Script"

Regards!

Offline Graham Waterworth

*
  • *
  •  2,668 2,668
  • Yorkshire Dales, England
    • View Profile
Re: Terminating Script
« Reply #8 on: January 16, 2008, 11:40:52 AM »
Try it with this at the start of the macro

Graham.


Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)

Without engineers the world stops
Re: Terminating Script
« Reply #9 on: January 16, 2008, 01:58:22 PM »
Still nothing!

Does this code works by you or by anybody else or only I have this problem ???

It is possible that there is some Bug in Mach3?


I´m desperate and without hope.




Regards!