Hey everyone. I've been trying to make a CNC plotter for a while. Encountered tons of problems along the way. Some of them were just small mistakes and some made me scratch my head for quite a long time . Now I'm stuck with one of them.
The plotter is made out of 2 steppers which I've got from scraping old CD drivers. One of the axis(From now on it will be called "Y" axis) has a metal sheet attached and the other one - just a simple pen("X" axis). Each stepper is controlled by an L298N motor driver. Instead of using a battery as an energy supplier I'm using an Ac adapter which outputs 12Volts and 0.4 Amperes. The current is a little too high for a direct connection to the L298N. It's reduced to 6.1V via "DC to DC step down", after that it flows to the motor drivers. The core of the pen is usually on the ground (the spring is pushing it from the top), to lift it a servo motor turns a certain amount of degrees, pulls a string which squezzes the spring and the pen core goes up.
Now here is the problem:
- At some points on the metal sheet (paper on top of it) the pressure from pen core is so high that the Y axis cannot move. At the other points the pressure is too low and the pen does not write at all. I did tried equalizing the heights of all 4 long-threadeds (long, metal, bolt-like pieces) to make the "table" as flat as possible - did not worked out, since a small height difference of about 0.1 milimeter can be a cause for the problem to appear. In addition, adjusting the value of degrees the servo must turn to lift or lower the pen, is not a soliution I'm looking for, since that doesn't give proper results and if it did - It would need a recalibration everytime before using the thing.
A guy on reddit proposed a soliution for this - increase the input voltage. Sounds good, however then I stumbled upon another obstacle.
- After first command is sent(stepper moved) the voltage drops to 4.5V, no matter what was the starting point. In this case it's dropping from 6.1 to 4.5, but if the starting voltage value of the output from "Step Down" would have been, let's say 10V, it would still drop to 4.5V
CNC photos and a rough connection diagram:
Code:
#include <Servo.h>
#include <Stepper.h>
byte number;
int steps=0;
bool gotTheNumber=false;
bool xStep=false;
bool yStep=false;
Stepper xStepper(stepsPerRevolution, 8, 9, 10, 11);
Stepper yStepper(stepsPerRevolution, 4, 5, 6, 7);
Servo myServo;
void setup(){
xStepper.setSpeed(30);
yStepper.setSpeed(30);
Serial.begin(9600);
Serial.println("Started");
myServo.attach(12);
myServo.write(70);
}
void loop(){
if(Serial.available()){
Serial.read();
}
while(Serial.available()==0){/*do nothing*/}
while(Serial.available()>0){
number=Serial.read();
if(number=='X'){
xStep=true;
continue;
}
if(number=='Y'){
yStep=true;
continue;
}
if(number>='0'&&number<='9'){
steps = steps*10 + (number-'0');
delay(5);
continue;
}
if(number=='N'){
steps=steps*-1;
gotTheNumber=true;
continue;
}
if(number=='P'){
gotTheNumber=true;
continue;
}
if(number=='U'){
Serial.println("Pen Up!");
myServo.write(70);
continue;
}
if(number=='D'){
Serial.println("Pen Down!");
myServo.write(34);
continue;
}
else{
Serial.println("\nInvalid Entry! ");
}
}
if(gotTheNumber){
if(xStep){
Serial.print("\nxStep: ");
Serial.println(steps);
xStepper.step(steps);
xStep=false;
gotTheNumber=false;
steps=0;
}
if(yStep){
Serial.print("\nyStep: ");
Serial.println(steps);
yStepper.step(steps);
yStep=false;
gotTheNumber=false;
steps=0;
}
}
}
Some examples of how I send commands: "X57N","D","Y13P"
Please ask if more information is needed. Any help would be appreciated.







