Hello Guest it is April 16, 2024, 02:14:03 AM

Author Topic: VB script consuming too much resources  (Read 4685 times)

0 Members and 1 Guest are viewing this topic.

VB script consuming too much resources
« on: February 19, 2007, 05:24:49 PM »
Ok, I have a VB script running in the macro pump, and it uses 99% of my computers resources, so sometimes it slows down, It may be my way of coding or something. Anyone here sees something wrong with the code?


BB=0
CC=0
DD=0
EE=0
FF=0

Do While GetUserLed(1020)=1

Code "G01 A36"
While IsMoving()
Sleep 100
Wend

If IsActive(Input1)=TRUE Then
BB=1
Else
BB=0
End If

If BB=0 And DD=0 And FF=0 Then
DeActivateSignal(OUTPUT1)
DeActivateSignal(OUTPUT2)
DeActivateSignal(OUTPUT3)
ElseIf BB=1 And DD=0 And FF=0 Then
ActivateSignal(OUTPUT1)
DeActivateSignal(OUTPUT2)
DeActivateSignal(OUTPUT3)
ElseIf BB=0 And DD=1 And FF=0 Then
DeActivateSignal(OUTPUT1)
ActivateSignal(OUTPUT2)
DeActivateSignal(OUTPUT3)
ElseIf BB=0 And DD=0 And FF=1 Then
DeActivateSignal(OUTPUT1)
DeActivateSignal(OUTPUT2)
ActivateSignal(OUTPUT3)
ElseIf BB=1 And DD=1 And FF=1 Then
ActivateSignal(OUTPUT1)
ActivateSignal(OUTPUT2)
ActivateSignal(OUTPUT3)
ElseIf BB=1 And DD=0 And FF=1 Then
ActivateSignal(OUTPUT1)
DeActivateSignal(OUTPUT2)
ActivateSignal(OUTPUT3)
ElseIf BB=1 And DD=1 And FF=0 Then
ActivateSignal(OUTPUT1)
ActivateSignal(OUTPUT2)
DeActivateSignal(OUTPUT3)
ElseIf BB=0 And DD=1 And FF=1 Then
DeActivateSignal(OUTPUT1)
ActivateSignal(OUTPUT2)
ActivateSignal(OUTPUT3)
End If

CODE "G04 P375"
While IsMoving()
Sleep 100
WEnd

DeActivateSignal(OUTPUT1)
DeActivateSignal(OUTPUT2)
DeActivateSignal(OUTPUT3)

CODE "G04 P375"
While IsMoving()
Sleep 100
WEnd

FF=EE
EE=DD
DD=CC
CC=BB

Loop   

End

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: VB script consuming too much resources
« Reply #1 on: February 19, 2007, 05:37:50 PM »
Hey Fer,
   I remember seeing something about this a while back. I can't remember for the life of me what it was for sure. I think it may have been the While if statements.


Brett
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: VB script consuming too much resources
« Reply #2 on: February 19, 2007, 06:38:07 PM »
Do you have this line at the start of your code?

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

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: VB script consuming too much resources
« Reply #3 on: February 19, 2007, 06:49:07 PM »
no, let me add it, and let you know
Fernando
Re: VB script consuming too much resources
« Reply #4 on: February 19, 2007, 07:02:59 PM »
Is there a VB command, that acts as a dwell? i dont know, like:

DWELL 100
or
PAUSE 100

where the 100 is in milliseconds?

Regards
Fernando
Re: VB script consuming too much resources
« Reply #5 on: February 19, 2007, 07:15:40 PM »
Thanks a lot Ger,
That did it, CPU load less than 1%

Still, Is there a DWELL or PAUSE command?

Regards
Fernando

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: VB script consuming too much resources
« Reply #6 on: February 19, 2007, 08:30:16 PM »
the code"G4" doesn't work for you? I don't know of a "pause", but I'm not a programmer either. :)
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: VB script consuming too much resources
« Reply #7 on: February 19, 2007, 08:32:39 PM »
It delays, but its not as precise As I would like it to be... I could try lowering the argument on the sleep command to make it better
Thanks
Fernando