Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 12:47:49 PM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Mach Discussion
| |-+  VB and the development of wizards
| | |-+  Help with optimising button script
Pages: 1   Go Down
Print
Author Topic: Help with optimising button script  (Read 1029 times)
0 Members and 2 Guests are viewing this topic.
muecker
Active Member

Offline Offline

Posts: 8


View Profile
« on: March 26, 2007, 01: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
Logged
poppabear
S S SYSTEMS, LLC
Global Moderator
*
Offline Offline

Posts: 1,707


Briceville, TN, USA


View Profile WWW
« Reply #1 on: March 26, 2007, 09:05:38 PM »

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

Logged

Commercial Mach3: Screens (regular and flash), Wizards, Plug-ins, Brains, PLCs, Macros, ATC's, machine build, retrofit and Prototyping
http://sites.google.com/site/volunteerfablab/
muecker
Active Member

Offline Offline

Posts: 8


View Profile
« Reply #2 on: March 27, 2007, 06:21:47 AM »

I didnt notice that i put those do loops in there. I'll try changing it.

Thanks
Logged
Pages: 1   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!