miércoles, 11 de febrero de 2015

DRV8825 missing microsteps

The problem

I received my new Smoothieware capable Azteeg X5 mini board last friday, hoping to make my 3d printing experience much smoother. I started to configure everything and I stumbled on a very odd movement from the motors, something like this:






Thinking that this should be a known problem, I started searching for a solution, but surprisingly I found none. The folks at the #smoothieware IRC channel were very helpful, but still we didn't find an explanation to the jerky movement. While talking about it, the topic of the different decay modes of the DRV8825 appeared in the chat. I read about it in the datasheet and decided to give it a try.

I changed the decay mode to "fast decay", the movement now was much smoother, but the motors were making a really horrible and high pitch noise. Looking at the datasheet revealed that the PWM frequency of the driver was 30kHz, not audible even for the finest ear. This was clearly a sign that something was wrong and lower frequency, audible, subharmonics were being generated.

I make a living as an electronic engineer, as such I have to deal with these sort of problems everyday and I have grown to have very little tolerance to these kind of suboptimal behaviors. So I had to find out what was going on, that noise is just pain to my ears!


The culprit

Let's see what we have, the DRV8825 is a stepper driver with some nice microstepping capabilities as the following graph shows on its datasheet:

Nice, I say, but then why is my motor either skipping steps or making the noise of hell? Let's dig deeper.

So there is a "Current regulation" section, which says basically that the output current is regulated in small steps to do the microstepping, as shown in the waveform above. But when reading the details you can see that it is actually doing.... PEAK CURRENT control... oh, no!

Peak current control is known to have the problem of presenting subharmonic oscillation when you require duty cycles of more than 50%. That would explain the noise when I configured the "fast decay" mode. In this case, it would be logical to have subharmonics at 15kHz and 7.5kHz which are audible even for the coarsest ear...

I needed to measure these currents to see what was going on, so I brought home the nice Tek current probes that I use at work.

First measurement, fast decay and subharmonic oscillation


Ok, here is our nice sinewave, or is it not so nice? We said that peak current control could have subharmonic oscillation, which would explain the noise. let's look deeper.




Oooooh, isn't that a nice tipical little subharmonic oscillation? Even more, there are some microsteps that are done continuously at 15kHz instead of 30kHz, like in the next scope capture. No wonder there is noise...



 Ok, so this explains why we have so much noise with the fast decay mode. In fact, when you think about it, fast decay mode is a really bad idea, because it will almost always be in this oscillatory mode, since it is comparing with the peak of the current for the positive part of the sine wave, which will always need duty cycles higher than 50%, which is the problematic point of operation for peak current control. 

Then, hopefully, in the negative half of the sine wave, it will not oscillate because we have duty cycles less than 50% right?.... WRONG, because it turns out that in the negative part it does valley current control. And guess when does valley current mode control present subharmonic oscillation.... exactly, with duty cycles less than 50%. So it will always be oscillation except for the brief period near the zero crossing where it does something different.


Second measurement, mixed decay and the dreaded blanking time

Avoiding the oscillations in the fast decay mode will be very hard, if not impossible. So I decided to go back to mixed decay mode. Let's see how the current looks like:



AAAAAAGHGH!!! What the hell is that?? pain in my eyes!!

OK, let me explain what is shown in the scope. The yellow and pink traces show the currents of each phase of a motor. And the blue and green traces are the voltages on each terminal of the phase with the yellow current.

As per the datasheet, mixed decay mode is:




This is good, because it minimizes the possibility of subharmonic oscillation that we had in fast decay.

Well, at least it is clear why the motor doesn't move smoothly. What should be a nice sine wave is actually a square-sine hybrid. The question is why does it step directly from zero to about 600mA of current? Lets zoom into the problematic square region to see what is happening:



There we have, a lonely voltage pulse measuring about 4us. 4us is about 12% of the 33us period of the PWM signal. So that means that we should be getting a voltage of 12% of 12V across the motor phase, which is around 1.4V. My steppers have a resistance of 2ohm aprox. So that would mean a current of 1.4V/2ohm = 700mA... everything seems to match. But then, why is the pulse so wide? So, after a deeper read at the datasheet, I notice the following:



Oooh, that makes total sense. It needs the blanking time to allow the measurement across the shunt to settle after the transition in the H-Bridge.

But we found out what is the problem, in mixed decay mode, the driver cannot do any voltage lower than 12% of the supply voltage. So the small currents needed for the microstepping will not be possible.

Still, we want to use mixed decay mode because it has an interesting way to do fast and slow decay at the same time which reduces the subharmonic oscillation problem, although it still doesn't completely solve it.

So then, the problem is that it cannot effectively do small steps in the rising part of the sine wave because the minimum voltage it can do is 12% of the supply voltage (1.4V in my case) my motors are rated for 3.1V, so 1.4V is half of the nominal voltage, that is a very big minimum step.

The solution, a dog


The conclusion is that this problem will happen to any motor with nominal voltage much lower than the supply, because for those, 12% of the supply will already be a big deal, and achieving small currents will not be possible.

The first try is obvious, let's lower the supply!, the problem is that the minimum supply is 8.2V, so that doesn't quite fix it yet. And also it would have an effect on other parts of the printer, so its not a good solution.

OK, we could add some resistance in series with the motor winding so that the 1.4V produces just about 100mA!

Yes, that could work, but if we do some numbers we'll see that we will have a power loss of around 12W on each resistor (we would need 12ohm resistor in addition to the 2 ohm of the motor to turn 1.4V into 100mA. And at a current of 1Arms that would create 12W per resistor), and we need one per phase, that means six resistors for three motors.... 72W.... oooh thats crazy. No way.

Well, it seems like the minimum 700mA step is fixed, so if we increase the current of the sine wave, 700mA will be less significant, right? Yes, right, but you need to go to very high current to make it neglectible, and that will create heating and other problems, so also not a solution really.

What can we do?, we need to find a way to make small current levels to have smooth microstepping. Not finding a solution, and knowing that every good idea I've had was always while walking the dog, I decided to take her out for a while.





OK, this time it didn't work, but an interesting idea appeared on my head while taking a shower (another great inspiration place) the next day. The idea is the following, the driver has a "pseudo-dead zone" near zero where it is not able to produce low currents, something like this:



You can see that if we ask for anything higher than 12%, "What you get" is "What you want", but if you want something lower than 12%, you will always get 12%. So, we have to avoid getting into that 12% area at all cost.

So, if we had a way to modify the motor so that with a voltage of 1.4V there would be no current flowing, then the driver would be able to generate all the currents because it would always be spitting out more than the minimum voltage. And it turns out that 1.4V is about the voltage drop of two diodes.... Aha!

So then, if we connect this circuit in series with a phase of the motor:

We will be subtracting 1.4V from each side of the sine wave, and the driver would be able to drive low currents. Let's test it!

To see the effect of only one diode, I tried first to add only two diodes in antiparallel, instead of four and compare it with the original phase with no diodes. This is the result:



Well, it looks like we have something! The pink is with no diodes and the yellow with two antiparallel diodes, nice! Lets place the four diodes.



Now the pink one is with the four diodes... sweet! thats exactly what we wanted!

What about losses?, this game of the diodes is similar to the resistors idea we had before and there were a lot of losses there. Let's calculate it with the same 1Arms that we had before. It is simple, lets say we use a 1N5404 diode, which can stand up to 3A. In each diode we have about 0.9V and with 1A current that would make 0.9W losses, such diode has a Rthja of 15K/W, so it will heat 15C above ambient temperature, pretty safe. If you had 3A, it would mean a temperature of around 45C above ambient temperature.

If you want to use a different diode, make sure you calculate the power losses correctly, and in general, be careful when you work with electricity, you don't want to set anything on fire.


Conclusion

If you have a board with a DRV8825, a motor with lower voltage rating then your supply, and when you move the 3D printer slowly (100 mm/min feedrate) it does not move smoothly. Then you need to put this circuit between your motor and your controller board using 1N5404 to 1N5408 diodes:

You can see the result in the video:



If this fix helps you, leave a comment below, it will be great to know!

38 comentarios:

  1. I tried this, it works for the low speed part vibration.
    But nothing about noise, right?
    The noise is related to the 100khz stepping frequency?

    ResponderEliminar
    Respuestas
    1. With this, we take mixed decay mode, which minimizes noise, note 'minimizes', it doesn't disappear but it is much lower than in fast decay mode. The problem of mixed decay is that vibration you noticed, and this solves that. In this way, we take the good things of mixed decay, with the good things of fast decay, by paying the cost of some diodes and some power dissipation.

      The nose is not related with the 100kHz stepping frequency, but with the 15kHz subharmonic oscillation. You would be amazed at the sound your motor does if we could eliminate this problem!

      Eliminar
    2. https://www.youtube.com/watch?v=dPCj8FHOSP0
      Got the DRV8825 noise record ;p
      But fount TMC2100 much more interesting now.

      Eliminar
  2. I have an Openbeam Kossel Pro that uses a DRV8825 Controller with LDO Stepper motors (2.8v 1.65ohm) and a 24v power supply.
    12% of 24v = 2.8v min volt
    2.8v / 1.65ohm = 1.7a min amp
    Does this mean i'm not getting 1/2 of my microsteps? Minimum amp is greater then the set current limit of 1.25a

    So for a 24v system like what diode configuration do I need to run?
    i'm thinking 8 1N5404 in anti parallel per coil. Making that 16 diodes per motor?

    ResponderEliminar
  3. I think the analysis of the diodes effect is wrong. I think the main reason the diodes help is you are dissipating power when the bridge is in recirculation mode (ie: both lower FETs on). The diodes dissipate power due to the voltage drop, collapsing the magnetic field in the stepper and helping you to operate in what is more like mixed-decay mode rather than slow-decay mode. Regardless, the diodes definitely help, and great job with the blog post!

    ResponderEliminar
  4. Congratulations for your search.
    I would use the mixed decay and get smooth microstepping (1/32) and wanted to know if I use a source of 12V (think it was the power that used) and stepper motors 12v 0.4A 30 Ohm resistance, and I will I could use 8 diodes 1N5404 ?

    Thank you and congratulations again for work ...
    Jota

    ResponderEliminar
  5. Thanks for your research, I noticed the issue with the DRV8825 driver causing some priting artifacts, and I could feel that ~40% fo the steps were going at once from the extruder gear. I then tested attaching a laser diode to a stepper motor and could clearly see the issue. 8 diodes per motor and the problem is gone ;-) Thanks again

    ResponderEliminar
  6. This is genius.
    I had this problem when I used a Rumba with 8825 drivers.
    Would you be willing to either write this up for the Reprap.org Wiki, or allow me to do so, with attribution? Alternately I can link here from an article in the Troubleshooting section.

    ResponderEliminar
    Respuestas
    1. Hi Paul,

      Thanks for the appreciation, I'm glad you liked it.

      Feel free to write in the reprap.org wiki, I would appreciate if you link to this site from there, so I get motivation to write more often ;-)

      Eliminar
    2. Thank you.
      I have so far written a brief summary there and linked here. I will write up a bit more there. There was a user there that had an odd pattern in their perimeter on one side - caused by this. Two others I think are also having this issue currently. (I had this issue myself with a Rumba that had these drivers before I got a smoothie). Thanks again for your research. It will help a lot of folks.

      Eliminar
  7. Many thanks for this, it helped me solve a problem I was having with ripples in the extruded filament. Looking at your measurements, it looks like 90% of the benefit is there with a single diode pair, so that's what I used on the extruder motor, and the problem is resolved. When I get some more diodes I will add them to the other motors as well. Thanks again!

    ResponderEliminar
    Respuestas
    1. you're welcome, I'm glad it helped you. I'm not usually writing blog posts, but regarding this drv8825 topic I found so much misinformation that I decided to write something a bit more rigorous.

      So I'm very happy that it is helping other people.

      Eliminar
  8. Can this problem have this effect?
    https://drive.google.com/file/d/0B_jwSVrnQA08cXdCckNuSGpzUmc/view?usp=sharing
    https://drive.google.com/file/d/0B_jwSVrnQA08T29EZFgwN0ExQ1k/view?usp=sharing
    https://drive.google.com/file/d/0B_jwSVrnQA08NTctb245UHZrWXM/view?usp=sharing

    ResponderEliminar
  9. Hi there, I just stumbled upon this in my search for fixing my stuttering motors, can you take pictures of your diode wiring? im trying to figure out which color/letter i'm supposed to be splicing into(1a/b/2a/b) Can you also show the diode/recommend a diode to use? Thank you

    ResponderEliminar
  10. got an x3 pro 8 motor controller with 8825 drivers, so I am bookmarking this for later, really hope it helps or I dont have a problem with my 425oz in motors I got for the build

    ResponderEliminar
  11. Just a note - if you are soldering diodes at home, it is easier to use bridge rectifier(https://en.wikipedia.org/wiki/Diode_bridge), connect input/output to AC terminals (~ ~) and short DC terminals (+ -) together. A lot easier soldering, 2 packages instead of 8 per motor.

    You can even use single diode between + - to increase voltage further, but that increasing voltage did not work well for me).

    ResponderEliminar
  12. Amazing write I will definitely try this solution . Does this also work with noisy Allegros A4988 drivers ?

    ResponderEliminar
  13. Can I use 1N4004 to 1N4008 Diodes too?

    ResponderEliminar
  14. Hi, the recovery time of diodes are important?
    Because of way is used, don't seems critical and shockty or ultrafast diodes are expensive

    ResponderEliminar
  15. What about using Schottky diodes ? They introduce lower voltage fall, typical 0.2 V

    ResponderEliminar
  16. What about using Schottky diodes? They introduce 0.2 V instead of 0.9

    ResponderEliminar
  17. where exactly did you measured the current?

    ResponderEliminar
  18. fantastic work, thank you very much!!!

    ResponderEliminar
  19. Can I use SM5408 instead of 1N5408?

    ResponderEliminar
  20. Hay que desoldar el pin de 12v y soldar un cable a 5v.

    ResponderEliminar
  21. Hello. I have been researching about this problem and wanted to do some measurements also instead of just analyzing the prints. I have measured the current signal but in my case is far better than yours using mixed decay mode, the sinusodial wave is quite good in my opinión, unfortunately i can't send you a picture here. I Want to ask the type of stepstick you used, or if the driver came soldered to the motherboard since it is now an early model. I measured the current puting two .36ohm resistor en paralel and conected to one phase and measuring the voltaje across it, since this is and old post hope you can read this and reply me. Thanks

    ResponderEliminar
    Respuestas
    1. Hi, my board had the DRV driver soldered on the board. I was measuring with a Tektronix TCP0030A current probe. These probes are pretty high bandwidth and make a very good current measurement.

      If you are measuring with resistors, you have to be careful with the inductance of the resistors. But if you are getting clean signals, that's a good sign. The inductance of the resistors will make a high-pass filter, amplifying noise and showing you very noisy measurements. Reality will be better than your measurement, so if you are getting clean measurements, that's good.

      A different motor will make a big difference, I was posting this mostly to help people that might be getting the same effect as me. In your case, if you found a different solution, go for it.

      Eliminar
  22. Hi all, first of all, I wanted to say Thank you all for your appreciation!! and sorry for not being able to reply to all your questions.

    As you can see, blogging is not something I do regularly, mostly due to lack of time.

    In this case, with this post, I thought I had to share it because these drivers are quite common and probably many people are struggling with this. Since there was also an easy solution to the problem, it made a lot of sense to post it.

    If you would like me to write more about anything along this line, feel free to send me your suggestion. I've never considered blogging, but who knows...

    Cheers guys, happy printing!

    ResponderEliminar
  23. Hello I also sent you this comment on youtube, i decided to put it in here: I am studying this behaviour on drv8825 stepper motors. In mixed decay mode I have found the problem when the stepper motor is running at low speeds, at higher speeds the current waveform is very acceptable but at low speeds it deforms very odd like in your post, I am thinking the real problem is the total impedance, when the motor is at low speeds the total impedance is mainly just the resistance of the winding, at higher speeds the impedance is the resistance plus the reactance of the winding, so it draws more current at low speeds. Then, at blanking time, the current tries to go full since there is no current control during that 4.7us resulting in stepping loss passing that blaking time the h bridge shuts down and current decreased but not much and the problem happens again, and again until it reach the espected amount of current at that microstep, that also happens at higher speeds but much less as the current is little because of high impedance. I hope I have explained myself clear, what do you think about that? Thanks!

    ResponderEliminar
  24. What bridge diode specification should be used for 1.5A stepper please?
    Is a 3A rating high enough, or does it need to be higher since single diodes need 3A rating?

    ResponderEliminar

  25. I Am Very Impressed With The Cracks That I Found On This Website:
    <a href="https://fasisoftz.com/live-home-3d-pro-crack-free-download/>Live Home 3D Pro Crack Free Download</a>

    ResponderEliminar
  26. Casinos in Canada 2021-2022 - GoOmans
    Casinos in goyangfc.com Canada 2021-2022 · Casinos at Casinos https://vannienailor4166blog.blogspot.com/ in Canada. poormansguidetocasinogambling.com Learn about online https://deccasino.com/review/merit-casino/ casinos in Canada, including casino list septcasino for 2021.

    ResponderEliminar