Final Proposal – A2Z

April 11, 2008

For my A2Z final I will be writing a custom library of drawing commands for my drawing machine.  The commands will be written in C, for Arduino, and will translate custom G-Code commands from a text file, through a Processing sketch which reads the commands in and sends them out line by line.

Here is the code for some early commands I have been working on:

case 5:
p.x = (long)(search_string(‘X’, instruction, size) * x_units);
p.y = (long)(search_string(‘Y’, instruction, size) * y_units);
p.z = (long)(search_string(‘Z’, instruction, size) * z_units);

x.setTarget(x.current + p.x);
ddaMove();
y.setTarget(y.current + p.y);
ddaMove();
x.setTarget(x.current – p.x);
ddaMove();
y.setTarget(y.current – p.y);
ddaMove();
break;

//Custom 2
case 6:
p.x = (long)(search_string(‘X’, instruction, size) * x_units);
p.y = (long)(search_string(‘Y’, instruction, size) * y_units);
p.z = (long)(search_string(‘Z’, instruction, size) * z_units);

for (int op = 0; op < 4; op++) {

x.setTarget(x.current + p.x * 2);
ddaMove();
y.setTarget(y.current + p.y * 2);
ddaMove();
x.setTarget(x.current – p.x);
ddaMove();
y.setTarget(y.current – p.y);
ddaMove();

}

break;

//Custom 3
case 7:

p.x = (long)(search_string(‘X’, instruction, size) * x_units);
p.y = (long)(search_string(‘Y’, instruction, size) * y_units);
p.z = (long)(search_string(‘Z’, instruction, size) * z_units);

for (int op = 0; op < 4; op++) {

int num = 2;

x.setTarget(x.current + p.x * num);
ddaMove();
y.setTarget(y.current + p.y * num);
ddaMove();
x.setTarget(x.current – p.x);
ddaMove();
y.setTarget(y.current – p.y);
ddaMove();

//num++;

}

break;

More commands to come as well as a homing function and edge detection.