Hello Guest it is April 19, 2024, 02:38:03 PM

Author Topic: Code "gcode" running in VB but not running in sequence  (Read 3803 times)

0 Members and 1 Guest are viewing this topic.

Code "gcode" running in VB but not running in sequence
« on: January 21, 2013, 01:45:08 AM »
This is my first post, trying to learn vbscript from scratch.
I ran a simple gcode below:
S20 M3
G1 Z20
M5
M30
And my machine runs as written correctly in sequence: first turn on spindle, move Z, once Z reached 20mm, stop spindle.
However, I tried running this on Option->VB Scripter Window, with slight modification as such:
code "S20 M3"
code "G1 Z20"
code "M5"
code "M30"
My machine does this: move Z, once Z reached 20mm, turn on spindle, 1 sec later, spindle stopped.

How can I run this simple gcode in sequence?
In case you ask me why vb marco, because I will be needing to add some conditional features like IF ELSE THEN WHILE etc, building from this as a start.
Hoped to get some help please.
« Last Edit: January 21, 2013, 01:54:34 AM by noeltam75 »
Re: Code "gcode" running in VB but not running in sequence
« Reply #1 on: January 21, 2013, 08:54:52 PM »
Anyone? Pls help me to understand this.
Re: Code "gcode" running in VB but not running in sequence
« Reply #2 on: January 21, 2013, 09:37:20 PM »
somemore new findings.
I saved the same codes and named it "M8888.m1s"
Then I ran it at MDI tab at the "INPUT", I typed M8888.
Behold!! It ran in sequence.
So conclusion, it only time that it doesn't run in sequeue is when I click on the "run script" button at the VB Scripter Window.
Strange behaviour.
Anyone?

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: Code "gcode" running in VB but not running in sequence
« Reply #3 on: January 21, 2013, 10:26:33 PM »
If you want everything to run in sequence, the script needs to wait for each move to finish before executing the next one.
To do that, you need to add While IsMoving() statements.

code "S20 M3"
While IsMoving()
Wend
code "G1 Z20"
While IsMoving()
Wend
code "M5"
While IsMoving()
Wend
code "M30"
While IsMoving()
Wend
Gerry

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

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: Code "gcode" running in VB but not running in sequence
« Reply #4 on: January 22, 2013, 02:13:43 AM »
This forum is great.
Thanks ger21!!
Your code works!
Thread closed.

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Code "gcode" running in VB but not running in sequence
« Reply #5 on: January 22, 2013, 11:35:00 AM »
I have found that you can run groups of code together then add in the wait at the right points.  IF you have a group of Gcode then nee to issue a M5 you would do it like this,


code "S20 M3"
code"G1 X1 F20"
code"X1Y1"
code"X0Y1"
code"X0Y0"
code "G1 Z20"       'end of large group of Gcode motions
While Ismoving()
Wend
code "M5"
code "M30"