Arduino missing steps?

Hello everyone! I am building custom FarmBot.
And from very beginning, i.e. when first time I connected together RPI, ARDUINO , RAMPS and stepper motor, I noticed periodical hits in motor when it rotated.

I did not mentioned it for a while.

But now I decided to dig into this trouble.
What I did:

  1. Tried other types of drivers. Other A4988s and DRV8825. No difference. (Issue disappeared when i connected Leadshine DM422C, wich has powerful brains (DSP) )
  2. Tried original and Chineese Arduino boards. No difference.
  3. Tried several different stepper motors. No difference.

So finally I supposed that this is arduino software(ATmega is very slow) issue.
I took oscilloscope and here it is:

Steps is missing (or late) and it is very sad. It catches the eye.
Here is the video.

Maybe it is not very noticeable in this video but it is very noticeable when stepper motor is installed and moves an axis.

Is it possible to fix arduino firmware to eliminate this thouble?

4 Likes

I’ve really been meaning to hook an oscilloscope up to the Arduino/Farmduino and check this out. Glad someone finally got around to it. You are correct in your assumption that the Atmega 2560 chip is just a bit to slow. One thing you can do to eliminate missed steps is to reduce the speed of the motors, or increase the number of missed steps. I’ve found that there is a sweet spot of about 3-5 missed steps. I haven’t been inside the Firmware repository in an awfully long time, but last i remember, the motor control portions are pretty well optimized. We’ve limits of the CPU before, and i suspect this is just another case of that. The 2560 has a clock speed of 16 mhz or 16000000 hz, and the motor control loop executes about 250 LOC inside the motor control loop. I don’t know how many instructions this is, but i suspect with all the assignment, variable storage, and serial + string formatting calls we are just executing too may instructions per clock cycle.

Hello!

Just experimented with axis speed. When I slow down maximum axis speed to 125 steps per second, I stop seeing delays (interrupts) on oscilloscope.

But at 250 steps per sec delays presist and I distinctly hear and feel by hand periodic hits in stepper motor.


250 steps per sec it quite slow(
Hits happening strongly periodycally several (approx. 2-3) times per second.
Maybe some interrupt happens?

We don’t use encoders in ours custom configuration, because they are quite expensive.

Unfortunately, I don’t have spare time to try debugging this issue by myself. This can take a lot of time(

2 Likes