Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: muecker on March 26, 2007, 02:35:33 PM
-
I have two buttons that operators use, one for homing and one for setting a height controlled by external PLC. When either of these buttons are pressed, the CPU usage max's out at 100%. Usually it works fine, but occasionally after using them, they report machine crashes. Below are the two scripts. Is there a way to optimise these, or if not are these scripts really the culprit?
Here they are:
Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
Dim LevelSet As Boolean
dim ctr1 as Long
Dim TS as single
Dim TE as single
Dim TT as single
Dim Checked as Boolean
Checked = false
ctr1 = -100000
Ready = 0
SystemReady = GetUserLED(1020) and not GetUserLED(1024) and not IsActive(input1) and not IsActive(input4) and IsOutputActive(output10)
If SystemReady then
Ready = MsgBox ("Machine Must be Idle, Press Okay to Continue",305,"Solder Height Check")
If Ready = 1 Then 'move to solder check position
Zheight = GetOEMDRO(1051)
XPos = GetOEMDRO(1052)
YPos = GetOEMDRO(1053)
code "g55"
Do While IsMoving()
loop
code "g1 z0 f20"
Do While IsMoving()
loop
code "g0 x" & XPos
Do While IsMoving()
loop
code "g0 y" & YPos
Do While IsMoving()
loop
code "g1 f20"
Do While IsMoving()
loop
code "g1 z" & Zheight
Do While IsMoving()
loop
ActivateSignal(Output9)
Do Until ctr = 100000
ctr = ctr + 1
Loop
DeActivateSignal(Output9)
TS = Timer
Do Until IsActive(Input3)
TE = Timer
TT = TE -TS
If TT > 60 then
Checked = true
Exit Do
Else
End If
Loop
code "g55"
code "g1 z0 f20"
code "g0 x0 y0"
Else
End If
If Checked = true then
MsgBox("Level Check Failed")
Else
End If
Else
MsgBox("System not Ready")
End If
And the other:
Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
Dim Zhomed As Boolean
Dim Yhomed As Boolean
Dim Xhomed As Boolean
DoOEMButton( 1024 )
While IsMoving()
Wend
Zhomed = GetOEMLED(809)
If Zhomed = true then
DoOEMButton(1003)
Else
DoOEMButton( 135)
End If
DoOEMButton( 1023 )
While IsMoving()
Wend
Yhomed = GetOEMLED(809)
If Yhomed = true then
DoOEMButton(1003)
Else
DoOEMButton( 134)
End If
DoOEMButton( 1022 )
While IsMoving()
Wend
Xhomed = GetOEMLED(809)
If Xhomed = true then
DoOEMButton(1003)
Else
DoOEMButton( 133)
End If
-
Change these things and see if it makes a difference:
Put parentheses around your NOT objects:
example;
SystemReady = GetUserLED(1020) and not(GetUserLED(1024)) and not(IsActive(input1)) and not(IsActive(input4)) and IsOutputActive(output10)
If SystemReady then
Why do you put BOTH Do loops AND while Ismoving() statements suspect lag is here:
example;
If Ready = 1 Then 'move to solder check position
Zheight = GetOEMDRO(1051)
XPos = GetOEMDRO(1052)
YPos = GetOEMDRO(1053)
code "g55"
While IsMoving()
Wend
-
I didnt notice that i put those do loops in there. I'll try changing it.
Thanks