A curious/sad finding; with 1/32 microstepping (DRV8825) I am limited to 250mm/s on X/Y

gplus
(Øystein Krog) #1

A curious/sad finding; with 1/32 microstepping (DRV8825) I am limited to 250mm/s on X/Y for moves in just 1 axis, and ~125mm/s for diagonal moves!
After some analysis I think this is due to the arduino/RAMPS slow CPU + Marlin max step frequency, but I am not certain.

I was getting really nasty “stutters” when moving at high speed and I thought it was a mechanical problem.
So I made a lot of changes in the linear movement setup, including new bearings, different types of bearings (ball bearings, bushings etc) but the symptoms remained the exact same.
Tweaking the stepper voltage did nothing except increase the temperature.

To track down the problem I made a test gcode file that exercised the X axis a lot by just moving back and forth quickly, this would repro the problem fairly often, but it was also fairy random.
I was able to study the problem up close, and was able to touch the components/bend them etc to see if that would affect it, nothing mechanical I did really affected it though.

Then I started messing with Marlin config parameters (the LCD really helped here) and I noticed that just scrolling in the menus tended to provoke the problem, which made me suspect the board was getting overloaded.
Messing with jerk and acceleration made no difference, but lowering max speed did!

I then stumbled upon this link: http://softsolder.com/2013/05/08/m2-vs-marlin-speed-calculations/
Marlin’s step frequency is 40 kHz and my step/mm on the X/Y is 160, which gives a maximum movement speed of 250mm/s.
After checking I found that is the exact value the max X/Y speed was set to…

By lowering X/Y max speed to just 240 mm/s the problem no longer appears… but I can’t be sure that my hypothesis is correct.
I modified the step frequency in Marlin, lowering to 30000 seemed to introduce a stutter every time the X direction reversed. Increasing the frequency to 50000 did not seem to do anything, which I guess may indicate that the arduino is indeed getting overloaded.

Am I correct in my analysis?

(Chuck McManis) #2

I am guessing you are, there is another variable which is the reactance of the stepper circuit (it can act like a damped resonator at its resonant frequency) but given my experience with the Atmel chips I would agree your orignial hypothesis is correct. You’re asking for it to do a lot there.

(Stephen Baird) #3

Sounds like you need to move to a Smoothieboard or similar if you want to move faster.

(Øystein Krog) #4

@Chuck_McManis Yes I probably am, however it does seem like there is some potential for improvement in Marlin for this scenario. Right now I have to limit all axis moves to ~120mm/s just to avoid those rare occasions when total speed/stepper rate becomes too high.
I read somewhere that Marlin will combine steps if it can’t keep up, I wonder if there is a problem in that code?

@Stephen_Baird Yeah, but then I also can’t use Marlin and all the features it has. The Marlin code is quite messy so I have been tempted to switch to something else for that reason alone, but it’s near impossible for me to switch when must-have features like auto-bed leveling (with servo activation) are missing.
One interesting possibility is the arduino due port of Marlin.

(Chuck McManis) #5

@Oystein_Krog
if the Atmega 328P (CPU on the Arduino) is running at 16Mhz (a typical speed) then at 40Khz you have basically about 266 assembly language instructions between each step. C code generates 1 - 10 instructions per line. So If the code is doing nothing more than moving one stepper you’re good to go, but moving 2 cuts available instructions in half, and displaying stuff on the LCD probably another 25%. It is a nice little chip but you can ask too much of it :slight_smile:

(Mike Downey) #6

have you tried putting a scope on the step pulse to the driver board? If it is missing steps due to software, you should see inconsistencies in the step pulse. If not, it should be nice square wave.

also, keep in mind that when you go from 1/16 to 1/32 stepping, the overall torque of the motor is reduced, which can also cause missed steps if there are mechanical friction issues (which it sounds like you have already addressed).

(Øystein Krog) #7

I don’t currently have a scope, but I have been looking at some of the cheaper alternatives. What kind of specs would I need for this?

(Mike Downey) #8

since you are looking for a 40khz pulse, even a fairly low end scope should work. There is a pin for direction (forward and backwards) and another pin for stepping. The jumpers for M0,M1, and M2 dictate the travel per step (in your case 1/32 or a full step) so that when you toggle the step pin, it increments one microstep (triggering on the rising edge).

you are just looking for a smooth pulsetrain. If the software cant keep up, then you should see inconsistencies on the scope. The drivers say they can handle up to 250khz, but this will also depend on your mechanical system. If the loads are high, the motor wont be able to move as fast as you are trying and it will slip.

(Øystein Krog) #9

This bug has now been fixed in Marlin (dev).
https://github.com/MarlinFirmware/MarlinDev/issues/35