I ran my first automated CNC operation yesterday. I wrote a little program to make a simple pattern that reminded my of Spirograph. I decided to run it in the air first. The steps-per-inch setting way wrong and the pattern was too large. The mill table hit a limit switch. I fixed that up, put a pencil in my drill chuck and taped a piece of paper to the mill table. The first attempt failed when the mill pushed the pencil into the table instead of lifting it up. My Z axis direction is inverted. I got a chance to test the E-stop button! Both safety measures working!
The run was excruciatingly slow as my "Full Acceleration Distance" (see Acceleration post) was way too high. I patched up the program and ran it again. It ran much faster and completed without incident:
m.setHeading(0.0f);
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 4; j++) {
m.forward(0.25f);
m.right(90.0f);
}
m.right(45.0f);
}
m.down(0.25f); // todo: Z is inverted
m.setHeading(0.0f);
m.forward(0.125f);
m.up(0.25f);
m.setHeading(90.0f);
int steps = 16;
float step = (float) (2 * 0.125 * Math.PI) / steps;
float turn = 360 / (float) steps;
for (int i = 0; i < steps; i++) {
m.forward(step);
m.right(turn);
}
m.moveTo(0, 0, 0);
The circle is off center. Can you spot the error in the code?
All in all I'm pretty happy with it. I've got quite a bit of tuning of various parameters to do. My steppers are 200 turns per revolution running in 1/2 step mode, so 400 turns per revolution. The screws are 20 turns per inch, so the steppers make 8000 steps per inch. I ran another simple path to move the table one inch and my DRO says it's a bit short. I ran it at full speed and it went farther than at half speed. I believe this indicates the deceleration phase was too short and the machine (the motor most likely, I think) was overrunning. I tweaked the FAD and got the same distance from full and half speed runs. Unfortunately the distance was not 1.000 inches. I compensated for backlash but it was still short. Not sure what's going on there.