Optimizing Speed and Acceleration for Nema34 Motor Control with DM680E Driver

Hi 👋🏻 My friend and I wrote this code to control a Nema34 motor with a DM680E driver for a drilling cycle. We want to dynamically adjust the speed between fast movement (for chip removal and advancing) and slow movement (for drilling into the material), while maintaining smooth acceleration transitions between these speeds. We’ve mentioned needing two speed parameters—fast and slow—but we’re unsure about the exact values that would be optimal for this application. If anyone has advice on how to calculate or determine the best speed and acceleration values for this setup, it would be greatly appreciated. We have tried to implement speed adjustments, but the results were not as expected. Either there were unexpected jerks or no noticeable change in speed. If anyone has experience with this, what might we be missing in terms of smooth acceleration management?
3 Replies
Camila_99$$
Camila_99$$•3mo ago
#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);
}
Marvee Amasi
Marvee Amasi•3mo ago
Update your source code with this , i used comments to well explain the code better
Marvee Amasi
Marvee Amasi•3mo ago
I defined two speeds (FAST_SPEED and SLOW_SPEED) to differentiate between fast movements ie chip removal or advancing and slow movements, drilling. So bfore each movement, setMaxSpeed() is called to dynamically change the speed based on the task. The slow speed is applied for drilling operations, while the fast speed is used for moving between positions
Want results from more Discord servers?
Add your server