# G-code question

**URL:** https://community.inventables.com/t/g-code-question/22957
**Category:** X-Carve
**Created:** [April 26, 2016, 4:26pm UTC](https://community.inventables.com/t/g-code-question/22957 "2016-04-26T16:26:37Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![StephenLedak](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@StephenLedak](https://community.inventables.com/u/StephenLedak)
#### Post date: [April 26, 2016, 4:26pm UTC](https://community.inventables.com/t/g-code-question/22957/1 "2016-04-26T16:26:37Z")

</div>

I am using the Xcarve unit for a test tool where I work. I reviewed the G-code commands but didn’t find what I’d hopped for. I have two RS232 devices, the Xcarve and a load cell. I am polling the load cell as fast as I can and also polling the Xcarve using the “?” which returns a string that says it busy or not. In doing so, I lose data from the load cell. Is there a command that will have the G-code side send a “in position” type output? That way I can use an Event trap on the the serial line and have it trigger so I know to stop collecting sensor data… I programming in VB6 and doesn’t have the ability to multi-thread.

And yes, I should move on to a more up-to-date language…

I hope there is some hidden features in the G-code instruction set…

Thanks!  
Stephen

---

<div class="post-metadata">

### Author: ![LarryM](https://yyz1.discourse-cdn.com/flex009/user_avatar/community.inventables.com/larrym/32/51450_2.png) [@LarryM](https://community.inventables.com/u/LarryM)
#### Post date: [April 26, 2016, 4:35pm UTC](https://community.inventables.com/t/g-code-question/22957/2 "2016-04-26T16:35:12Z")

</div>

Can you give me a little more information about your process?

Is it something like: start collecting data, tell the X-carve to move to a location, once the X-carve is at that location stop collecting data.

Is this a one time event, or is it repetitive?

If you are not polling the X-carve can you collect the load cell data without loss?

---

<div class="post-metadata">

### Author: ![BillBucket](https://yyz1.discourse-cdn.com/flex009/user_avatar/community.inventables.com/billbucket/32/84345_2.png) [@BillBucket](https://community.inventables.com/u/BillBucket)
#### Post date: [April 26, 2016, 4:48pm UTC](https://community.inventables.com/t/g-code-question/22957/3 "2016-04-26T16:48:21Z")

</div>

Can you just create a custom M-code to trigger a “?” query when the C-carve executes the line of code after moving to the desired position?

---

<div class="post-metadata">

### Author: ![JohnChamplain](https://yyz1.discourse-cdn.com/flex009/user_avatar/community.inventables.com/johnchamplain/32/75884_2.png) [@JohnChamplain](https://community.inventables.com/u/JohnChamplain)
#### Post date: [April 26, 2016, 4:53pm UTC](https://community.inventables.com/t/g-code-question/22957/4 "2016-04-26T16:53:35Z")

</div>

Try sending a “G04 P.1” after each move, and poll for “ok” and a CR in a loop, and when you get it the X-Carve should be in position. May be faster then the “?” command.  
John

---

<div class="post-metadata">

### Author: ![BillBucket](https://yyz1.discourse-cdn.com/flex009/user_avatar/community.inventables.com/billbucket/32/84345_2.png) [@BillBucket](https://community.inventables.com/u/BillBucket)
#### Post date: [April 26, 2016, 4:55pm UTC](https://community.inventables.com/t/g-code-question/22957/5 "2016-04-26T16:55:18Z")

</div>

Oh, does dwell report completion? That’s the way to go then.

---

<div class="post-metadata">

### Author: ![JohnChamplain](https://yyz1.discourse-cdn.com/flex009/user_avatar/community.inventables.com/johnchamplain/32/75884_2.png) [@JohnChamplain](https://community.inventables.com/u/JohnChamplain)
#### Post date: [April 26, 2016, 5:04pm UTC](https://community.inventables.com/t/g-code-question/22957/6 "2016-04-26T17:04:36Z")

</div>

GRBL will not send the “ok-CR” until after the current move in progress has completed.  
More here: [Command to return Grbl command queue state · Issue #932 · grbl/grbl · GitHub](https://github.com/grbl/grbl/issues/932)

Edit: Try with the Px value very small - not sure what is the lowest possible.

---

<div class="post-metadata">

### Author: ![StephenLedak](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@StephenLedak](https://community.inventables.com/u/StephenLedak)
#### Post date: [April 26, 2016, 6:22pm UTC](https://community.inventables.com/t/g-code-question/22957/7 "2016-04-26T18:22:54Z")

</div>

Px value ? not sure what you mean by that…

---

<div class="post-metadata">

### Author: ![StephenLedak](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@StephenLedak](https://community.inventables.com/u/StephenLedak)
#### Post date: [April 26, 2016, 6:23pm UTC](https://community.inventables.com/t/g-code-question/22957/8 "2016-04-26T18:23:14Z")

</div>

Position x…?

---

<div class="post-metadata">

### Author: ![BillBucket](https://yyz1.discourse-cdn.com/flex009/user_avatar/community.inventables.com/billbucket/32/84345_2.png) [@BillBucket](https://community.inventables.com/u/BillBucket)
#### Post date: [April 26, 2016, 7:17pm UTC](https://community.inventables.com/t/g-code-question/22957/9 "2016-04-26T19:17:57Z")

</div>

The Px is the dwell time. The syntax for the dwell is “G4 Px” where G4 is the [dwell g-code](http://www.linuxcnc.org/docs/2.5/html/gcode/gcode.html#sec:G4-Dwell), P is the command input prefix and x is the variable for time in seconds to dwell. So, to dwell for 0.1 seconds you would send “G4 P0.1”
