Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: MojsterMiha 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!
-
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
-
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!
-
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!
-
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.
-
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!
-
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
-
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!
-
Try it with this at the start of the macro
Graham.
Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
-
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!
-
ok try this it is a combination of Brains, the macropump and your custom macro.
Put the following in the Macro pump and the other part in your M555, then turn on macro pump and reboot mach.
'Macro Pump
If GetUserLED(2001) Then
Message("Z in position for tool change")
SetUserLED(2000,0)
SetUserLED(2001,0)
end If
If GetUserLED(2002) Then
Message("ERROR - Switch is not triggered")
SetUserLED(2002,0)
SetUserLED(2003,0)
end If
'This next stuff goes in your M555.
'M555 here is your intiating macro (or you can use M6)
SetUserLED(2000,1)
SetUserLED(2003,1)
code "G01 G53 Z201 F1000" 'this moves in Machine coordinates
While IsMoving()
WEnd
Download the brain zip file and unzip, put it in your brain folder, from within mach, goto operator, goto brain control and enable the brain called. ATC_Zaxis.brn, hit the view button and then test your system by loading the M555 in your MDI line.
give us feedback.
scott
-
Hello,
I have work on first code and I find a problem.
The problem is: DooemButton(1003) ' Stop Button
This is the cause for "Terminating Script"
If I put any other OEM Button all works fine.
If I try to stop moving with DooemButton(1001) 'Pause - Hold , moving stops but it takes too long (~ 90mm) also if I set deceleration to
very small value - 0.4 s (the speed of moving is 1500 mm/min).
I have try also DooemButton(1002) 'Rewind The axis stops but then takes too long before continue with other code.
Is there any other way to stop moving when switch is triggered?
Our machines are with servos, so quick stop (without long deceleration) isn´t a problem.
Thanks all for your help.