Hello Guest it is March 28, 2024, 10:31:46 PM

Author Topic: sleep issue  (Read 3538 times)

0 Members and 1 Guest are viewing this topic.

sleep issue
« 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   

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: sleep issue
« 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
Re: sleep issue
« 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?

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: sleep issue
« Reply #3 on: November 11, 2011, 08:09:42 AM »
You have a 1 second delay in your sub. Try removing the Sleep(1000)
Gerry

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

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: sleep issue
« 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.

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: sleep issue
« 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
Re: sleep issue
« Reply #6 on: November 14, 2011, 02:02:05 AM »
Ok, I will hunt the dragon.

Thank you for the answers.