Camila_99$$
DIIDevHeads IoT Integration Server
•Created by Camila_99$$ on 10/18/2024 in #🪲-firmware-and-baremetal
Optimizing Speed and Acceleration for Nema34 Motor Control with DM680E Driver
#include <Arduino.h>
#include <AccelStepper.h>
AccelStepper stepper(1, 9, 8); // mode 1 = half-step, etc... 200 steps/revolution
// pin 9 = PUL 8 = DIR
void setup() {
stepper.setMaxSpeed(4000);
stepper.setAcceleration(2500);
}
void loop() {
// screw pitch = 2.5mm/rev, motor = 200 steps/rev + 1/2 step mode = 400 steps/rev
// 30mm travel = 12 revs / 200 * 2 * 12 = 4800 steps
// slow speed drilling
stepper.moveTo(-4800); // position +30mm drilling 1/3
stepper.runToPosition();
delay(250);
// fast speed movement
stepper.moveTo(0); // position 0mm / chip removal
stepper.runToPosition();
delay(250);
// fast speed movement
stepper.moveTo(-4800); // fast advance to +30mm for drilling 2/3
// slow speed drilling
stepper.moveTo(-9600); // position +60mm drilling 2/3
stepper.runToPosition();
delay(250);
// fast speed movement
stepper.moveTo(-4800); // position +30mm / chip removal
stepper.runToPosition();
delay(250);
// fast speed movement
stepper.moveTo(-9600); // fast advance to +60mm for drilling 3/3
// slow speed drilling
stepper.moveTo(-14400); // position +90mm drilling 3/3 end of drilling
stepper.runToPosition();
delay(250);
// fast speed movement
stepper.moveTo(0); // return to starting position
stepper.runToPosition();
delay(250);
}
#include <Arduino.h>
#include <AccelStepper.h>
AccelStepper stepper(1, 9, 8); // mode 1 = half-step, etc... 200 steps/revolution
// pin 9 = PUL 8 = DIR
void setup() {
stepper.setMaxSpeed(4000);
stepper.setAcceleration(2500);
}
void loop() {
// screw pitch = 2.5mm/rev, motor = 200 steps/rev + 1/2 step mode = 400 steps/rev
// 30mm travel = 12 revs / 200 * 2 * 12 = 4800 steps
// slow speed drilling
stepper.moveTo(-4800); // position +30mm drilling 1/3
stepper.runToPosition();
delay(250);
// fast speed movement
stepper.moveTo(0); // position 0mm / chip removal
stepper.runToPosition();
delay(250);
// fast speed movement
stepper.moveTo(-4800); // fast advance to +30mm for drilling 2/3
// slow speed drilling
stepper.moveTo(-9600); // position +60mm drilling 2/3
stepper.runToPosition();
delay(250);
// fast speed movement
stepper.moveTo(-4800); // position +30mm / chip removal
stepper.runToPosition();
delay(250);
// fast speed movement
stepper.moveTo(-9600); // fast advance to +60mm for drilling 3/3
// slow speed drilling
stepper.moveTo(-14400); // position +90mm drilling 3/3 end of drilling
stepper.runToPosition();
delay(250);
// fast speed movement
stepper.moveTo(0); // return to starting position
stepper.runToPosition();
delay(250);
}
4 replies