Uncategorized

Drawbot G-Code Tutorial

When you first turn on the drawbot in Arduino, you should see text similar to this:

== HELLO WORLD ==
(-14.00,-30.00) - {14.00,21.50)
F8.90
A5.00
== DRAWBOT - 2012 Feb 28 - [email protected] ==
All commands end with a semi-colon.
HELP; - display this message
WHERE; - display current virtual coordinates
LIMITS; - display maximum distance plotter can move
DEMO; - draw a test pattern
TELEPORT [Xx.xx] [Yx.xx]; - move the virtual plotter.
As well as the following G-codes (http://en.wikipedia.org/wiki/G-code):
G01-G04,G20,G21,G90,G91
>

Let’s take a look at each of these commands and what they do in detail.

HELP;

Type in this command and you’ll see the help message again.

WHERE;

When you first turn on the robot it assumes that it is at (0,0) and WHERE; would return exactly that.  If you moved X+10 and typed WHERE; again it would say (10,0).  X+ is to the right, Y+ is up just like on graphs you’d draw in class.

LIMITS;

limits are the maximum distance the robot will move the plotter.  This

(-14.00,-30.00) - (14.00,21.50)
F8.90
A5.00

is the part of the message when you turn it on.  the first parenthesis are the bottom left corner, the second parenthesis are the top right corner, F is the “feed rate” (maximum speed) and A is the maximum acceleration.

DEMO;

You’ve seen the youtube drawbot video with the test pattern and halftones?  This is how you draw that test pattern.  It’s a great place to start to check if your steppers are backwards or your speeds are too high.  More on that in a future post.

TELEPORT [Xx.xx] [Yx.xx];

When you first turn on the robot it assumes that it is at (0,0).  Let’s say the actual position on the wall is (3,-5).  You need an easy way to correct this.  TELEPORT X3 Y-5; will tell the robot “no no, you’re actually over here.”  After that you could say G00 X0 Y0; and it would move to the actual (0,0).  If you don’t specify an X or Y, the current value will be used.

G00 [Xx.xx] [Yx.xx] [Fx.xx];

G01 [Xx.xx] [Yx.xx] [Fx.xx];

Draw a straight line from the current position to (X,Y) with a maximum speed of F.  If you don’t specify an X,Y, or F, the current value will used.

G02 [Xx.xx] [Yx.xx] [Fx.xx] [Ix.xx] [Jx.xx];

G03 [Xx.xx] [Yx.xx] [Fx.xx] [Ix.xx] [Jx.xx];

Draw a circular arc to from the starting point here to (X,Y).  The center of the circle is (I,J) away from the starting point.  G02 draws a clockwise arcs.  G03 draws a counter-clockwise arc.

G04 [Px.xx];

Dwell, aka wait P milliseconds.  Remember that you need 1000 milliseconds to pause for one second.

G20;

Programming in inches (in).  The robot works internally in centimeters (cm), so it will divide all coordinates you give it by 2.54 (cm/in).

G21;

Programming in millimeters (mm).  The robot works internally in centimeters (cm), so it will divide all coordinates you give it by 0.1 (cm/mm).  This is the default.

G90;

Absolute mode.  In this mode, a G00 X1 Y0; will move to (1,0).  This is the default.

G91;

Relative mode.  In this mode, a G00 X1 Y0; will move 1 cm to the right.