Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 10:13:02 AM

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
| | |-+  sleep issue
Pages: 1   Go Down
Print
Author Topic: sleep issue  (Read 343 times)
0 Members and 1 Guest are viewing this topic.
maxsteak
Active Member

Offline Offline

Posts: 13


View Profile
« on: November 10, 2011, 11:01:10 AM »

Hello there,

Based on a simple g-code program, I try to transfer it on vb to improve and make a more complex algorithm. However, when running the simple code below, I cannot see the wait time between down/up unless I put >2seconds.
What's wrong in my code?

Global Const nT_Wid = 3
Global Const Dpitch = 10.0

Sub Main()
  Dim i As Integer
  Code "G17 G21 G91 G64 G40"
  For i = 1 To nT_Wid
    Touch
    Code "G0 X" & Dpitch
  Next i
End Sub
Sub Touch
  Code "G1 F1000" Z5"
  Sleep(1000)
  Code "G0 Z5"
End Sub   
Logged
BR549
Active Member

Online Online

Posts: 2,558


View Profile
« Reply #1 on: November 10, 2011, 05:57:36 PM »

IF you are going to mix Gcode and CB I would suggest using while Ismoving() to insure the code stays in sync.

Global Const nT_Wid = 3
Global Const Dpitch = 10.0

Sub Main()
  Dim i As Integer
  Code "G17 G21 G91 G64 G40"
While Ismoving()
Wend
  For i = 1 To nT_Wid
    Touch
    Code "G0 X" & Dpitch
While Ismoving()
Wend
  Next i
End Sub
Sub Touch
  Code "G1 F1000" Z5"
While Ismoving()
  Sleep(1000)
Wend
  Code "G0 Z5"
While Ismoving()
Wend
End Sub   

(;-) TP
Logged
maxsteak
Active Member

Offline Offline

Posts: 13


View Profile
« Reply #2 on: November 11, 2011, 06:23:26 AM »

Thank you, the ismoving is making the trick.

However, I compare my g-code and vb similar code and see the program is slower in vb than g-code. Is it normal due to additional steps?
Logged
ger21
Global Moderator
*
Offline Offline

Posts: 2,619



View Profile WWW
« Reply #3 on: November 11, 2011, 08:09:42 AM »

You have a 1 second delay in your sub. Try removing the Sleep(1000)
Logged

maxsteak
Active Member

Offline Offline

Posts: 13


View Profile
« Reply #4 on: November 11, 2011, 08:12:10 AM »

I have removed the sleep and compare exactly the same steps, but the total program takes more time on vb than g-code.
Logged
BR549
Active Member

Online Online

Posts: 2,558


View Profile
« Reply #5 on: November 11, 2011, 09:49:33 AM »

SURE it will be slower in CB than in straight Gcode.  LOOK at all the wait states require to make it stable(;-)


I would be using "this" code as a SUB routine in gcode. BUT beware there are dragons ( as Stirling would say) in SUB code as well (;-).

(;-) TP
Logged
maxsteak
Active Member

Offline Offline

Posts: 13


View Profile
« Reply #6 on: November 14, 2011, 02:02:05 AM »

Ok, I will hunt the dragon.

Thank you for the answers.
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!