Module 16 // CNC Motion Control
CNC Plotter Machine
Integrates dual-axis stepper driver logic gates to trigger precision drawing trajectories when coordinate matrix values narrow down. The Arduino converts programmed motion vectors into physical pen movements for automated sketching and plotting operations.
CNC Driver Mapping
| Driver Logic Pin | Vector Mapping | Target Uno Pin |
|---|---|---|
| X STEP | ====> | Digital Pin 2 |
| X DIR | ====> | Digital Pin 3 |
| Y STEP | ====> | Digital Pin 4 |
| Y DIR | ====> | Digital Pin 5 |
| Servo Pen Lift | ====> | Digital Pin 9 |
CNC Motion Firmware
#include <Servo.h>
const int X_STEP = 2;
const int X_DIR = 3;
const int Y_STEP = 4;
const int Y_DIR = 5;
Servo penServo;
void stepMotor(int stepPin,int steps)
{
for(int i=0;i<steps;i++)
{
digitalWrite(stepPin,HIGH);
delayMicroseconds(600);
digitalWrite(stepPin,LOW);
delayMicroseconds(600);
}
}
void setup()
{
pinMode(X_STEP,OUTPUT);
pinMode(X_DIR,OUTPUT);
pinMode(Y_STEP,OUTPUT);
pinMode(Y_DIR,OUTPUT);
penServo.attach(9);
penServo.write(90);
}
void loop()
{
penServo.write(30);
digitalWrite(X_DIR,HIGH);
stepMotor(X_STEP,200);
digitalWrite(Y_DIR,HIGH);
stepMotor(Y_STEP,200);
digitalWrite(X_DIR,LOW);
stepMotor(X_STEP,200);
digitalWrite(Y_DIR,LOW);
stepMotor(Y_STEP,200);
penServo.write(90);
delay(2000);
}