Hello Guest it is April 25, 2024, 01:16:07 PM

Author Topic: Problem Vb Script  (Read 3147 times)

0 Members and 1 Guest are viewing this topic.

Problem Vb Script
« on: November 21, 2012, 10:36:12 AM »
Hello group.
I have the following code attached to a button:

If getuserled(1000)=0 Then
   setuserled(1000,1)
   avance = getuserdro(1000)
   If avance < 5 Then
      avance = 5
   End If
   
   If avance > 500 Then
      avance = 500
   End If
   
   porcentaje = avance/14
   setoemdro(3,porcentaje)
   setuserdro(1001,avance)
   jogon(0,1)
Else
   setuserled(1000,0)
   setuserled(1001,0)
   setuserdro(1001,getuserdro(1000))
   jogoff(0)
End If

when I run it step by step from the Vb Script editor the program works perfectly.
when I run the program from the button does not work.
which may be the problem?

thanks for the help.
Re: Problem Vb Script
« Reply #1 on: November 21, 2012, 11:39:35 AM »
I would think you need to let the screen update, so you need some way to pause the program like a Sleep(1000) command between set commands. That's why it works in single step, it has time to keep up with your keyboard.

or try a series of lines like this before the next set command.

While IsMoving ()
Sleep 100
Wend
« Last Edit: November 21, 2012, 11:43:03 AM by Ya-Nvr-No »
Re: Problem Vb Script
« Reply #2 on: November 21, 2012, 12:51:14 PM »
insert the code after the jogon(0,1) command, the program still does not work.
jogon(0,1)
while ismoving()
sleep 1000
wend.

Pressing the button lights the led, it updates the job slow, the jogon(0,1) command is not executed.
Re: Problem Vb Script
« Reply #3 on: November 21, 2012, 12:55:31 PM »
just try the sleep command there leave out the ...... while ismoving() wend

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: Problem Vb Script
« Reply #4 on: November 21, 2012, 05:51:09 PM »
For User LED's, you need to use GetOEMLED() instead of GetUserLED(). SetUserLED() is correct.
I'd try it like this:

If Not GetOEMLED(1000) Then
  SetUserLED(1000,1)
   avance = getuserdro(1000)
   If avance < 5 Then
      avance = 5
   End If
   
   If avance > 500 Then
      avance = 500
   End If
   
   porcentaje = avance/14
   setoemdro(3,porcentaje)
 Sleep(125)
   setuserdro(1001,avance)
 Sleep(125)
   jogon(0,1)
Else
   setuserled(1000,0)
   setuserled(1001,0)
   setuserdro(1001,getuserdro(1000))
 Sleep(125)
   jogoff(0)
End If
Gerry

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

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html