Friday 6 April 2012

StepStuck

When I built my Mendel I used A3977 stepper drivers. Before that I did some maths to show that the component values need to be carefully selected to match the motor in order to achieve 8× microstepping. Makerbot produced a board with four potentiometers and I published settings for motors popular at the time.

Since then Pololu stepper drivers have become popular (and the StepStick clone), but they only have one thing that you can adjust: the current. They also have 16× microstepping, which makes the range of component values that work even smaller. I was always pretty sure the off-time would be wrong for the motors we use and while commissioning my second Mendel90 I could hear that it was wrong, so I decided to look into it.

When stepping one motor at a constant speed you should hear a single pitch at the step rate. If the off-time is too short then the lowest current microsteps cannot be achieved, the motor pauses twice every 16 microsteps so you hear a lower pitch sound as well.


If you step the motor very slowly (G1X10F1) you can hear a sequence of steps with a pause.


The reason for this is that the lowest current step when ×16 microstepping is 9.8%. If the current is set to 1A then that is only 98mA. The minimum on-time for the chip is fixed at 1μs and my formula predicts the off-time needs to be at least 54μs with 1.65Ω motors. That would require a 47k resistor but the value fitted is only 10K. That gives an off time of 12μs which isn't even long enough for 8× microstepping. The situation is even worse on the Z axis with two motors in parallel.

The problem with increasing the resistor to 47k is that the switching frequency drops to 14kHz, which is audible. So my conclusion is that the A4983 is not really suitable for driving such low resistance motors. The A3977 allows you to control the minimum on-time so you can avoid the switching frequency becoming too low.

Later Pololus and some StepSticks use the A4988 chip. That has an interesting section in the datasheet: -
Low Current Microstepping. Intended for applications where the minimum on-time prevents the output current from regulating to the programmed current level at low current steps. To prevent this, the device can be set to operate in Mixed decay mode on both rising and falling portions of the current waveform. This feature is implemented by shorting the ROSC pin to ground. In this state, the off-time is internally set to 30 μs. 
Conceptually an easy mod to do, simply short out R4, but due to the size and location of the resistor and the age of my eyes it was not at all easy. I applied the mod to a StepStick and it worked, the steps are now regular, no missing beats. Running is a bit quieter but I think the motors are more noisy when stationary. More investigation is needed.

What to do with my A4983 Pololus? Well if I increase the current to 1.3A and change the resistor to 36K then the minimum frequency is 17kHz, which is ultrasonic to me nowadays due to the age of my ears. Alternatively switching to 8× microstepping and using a 22K resistor keeps it above 30kHz and the current can be 1A.

I don't think constant off-time choppers are the best idea. The current range is too limited and the switching frequency varies wildly. As the two halves of the chip run at different frequencies they can generate beat frequencies in the audio band.

The other thing I don't like is that they regulate the peak current so there is an offset of half the ripple current which can make the first step inaccurate.






55 comments:

  1. Interesting observations and explains perhaps the difference in motor noise I have here as the steppers I use are :-

    4.5 ohms on X & Y
    4.6 ohms on Z
    2.7 ohms on the Extruder

    Will have to try slow stepping though before I know for sure.

    ReplyDelete
  2. PS. Only one Stepper motor is used on Z as its belt driven.

    ReplyDelete
  3. With 4.5R I predict you can do 8x @ 1A but for 16x you need 20K.

    ReplyDelete
    Replies
    1. I seem to have been very Lucky with some of my Design decisions now. ;-)

      Yes I do use 8x stepping on X Y and Z. (This means you can use the cheaper Drivers)
      That use the original stepper chip I got samples of 3 or more years ago.

      Though I have not looked at the circuit values on the pcbs as yet.
      As yet the circuit has not been published for this board. however a whole lot have been sold every month on Ebay.

      Reasons with 0.9 steppers and a 14 tooth XML drive you do not need any more steps than 8x.

      A Step Stick or Pololu 16x is used for the Extruder drive, so need to take look at that now.

      Delete
  4. Which board are you referring to?

    The main motivation for x16 is quieter operation.

    ReplyDelete
  5. Ebay no 280820726145 using A4984

    I had the A4980 version as samples

    https://picasaweb.google.com/lh/photo/gqaSCyzrMEf1K6ybmnDjiRXkqRLYvk0CSGhegiraDZM?feat=directlink

    0.9 steppers at 8x is still very quiet I think.

    ReplyDelete
  6. I'm currently messing about with this board..

    http://reprap.org/wiki/BIQ_SanguinoCNC

    for the Big Bertha CNC and a CNC lathe Idea. The boards only arrived on Thursday so still testing.

    The experimental CNC lathe is using 128x stepper driver and 4.2A Stepper mounted on two of the Huxley seedling ABS reel A frames.

    This is to try to automate making extruder parts.

    Use on Big Bertha is for making bigger Huxley Seedling frames / 3D printers/CNC Parts.

    No Pictures yet

    ReplyDelete
  7. does that make any influence in quality, speed, or anything I can notice beside noise?

    ReplyDelete
  8. I think it will have a small effect on quality but I not sure it will be noticeable. Extruding slowly with a very fine nozzle would be where it shows up if it does.

    ReplyDelete
  9. Hi nophead
    For my Mendel90 I bought a set of 4 A4988 pololu stepper drivers and 5 NEMA 17 Stepper Motor Model 17HS19-1684S, all from Think3DPrint3D at http://www.emakershop.com/Seller=226
    The only calibration I have attempted so far is to set the Ref voltage to 0.4V, the same as I use on the Huxley.
    Given that these are bigger motors and the power supply is 12V (compared with 19V for the Huxley) it would not surprise me at all to learn that my current set-up could be improved. It certainly works, but I have no idea whether it is micro-stepping as it ought to, or lacking in power.
    I have to say I am quite put off by the thought of having to start soldering SMT components on the drivers, but any suggestions about how to go about tuning up the motor drivers would be gratefully received.

    ReplyDelete
  10. The easy way to tell if it is microstepping correctly is to just step it very slowly, so you can hear each step and be able to hear the gap where some are missing as in the second video.

    Using 12V rather than 19V helps in this respect as the off time would need to be even longer with 19V. Increasing the current helps. Using 8x helps and wiring the Z motors in series helps.

    Having said that I don't know which is best from a noise or print quality point of view (8x or 16x with some steps missing), or if it matters much at all.

    If you are not confident with SMT soldering it is best to leave them as is I think because that is how everybody else in the world operates them. Just don't kid yourself you have 16x microstepping.

    I will do some more experimenting as I have my second Mendel90 set to correctly microstep, so I can compare it with the first. My first impression is that it is more noisy when idle. I think this is because with the correct off time the switching frequency is lower, which means the ripple current is higher and that is what makes the motors vibrate at rest.

    Although the switching is ultrasonic the two coils beat with each other and produce an audible whine. On my other machines this hasn't been noticeable although if I put my ear near the motor and turn the pulley a little I can hear it.

    ReplyDelete
  11. I would love to hear your thoughts on the A4982 used on the MakerBot BotSteps.

    ReplyDelete
  12. The A4982 seems like the A4988 in that it has the "Low Current Microstepping" option and the extra protection. Oddly it doesn't have 8x microstepping but it is available in TSSOP which I think is preferable for getting the heat out.

    I must admit Allegro have a confusing selection of very similar chips with inconsistent numbering, e.g. A4982 is a later chip than A4983.

    ReplyDelete
  13. Looking at the schematic for the A4988, ROSC is connected to ground through a 10K resistor and to VDD through another resistor that is not populated, so it's basically connected directly to ground. This should mean that it's already in the low-current microstepping mode, right?

    ReplyDelete
  14. No, it isn't a digital input, i.e. the 10K is not a pull down. Its value sets the speed of the internal oscillator, which sets the constant off time. Connecting it to VDD or ground are two special cases.

    ReplyDelete
  15. Ah, so to switch it to that mode, all you would have to do is make a solder bridge across that resistor (or do it the proper way, by replacing the 10K with a 0-ohm shunt).

    ReplyDelete
  16. Yes it is a bit far to bridge reliably with only solder. I used a thin wire, actually wire wrap wire AKA mod wire. Soldered it both ends and then cut off the bit I was holding it with using a scalpel.

    ReplyDelete
  17. This is why I save the leads I clip off of PTH components.

    ReplyDelete
  18. Mod wire is a lot finer than that, about 0.2mm, and it is insulated, so you can hold one end while soldering the other across the two pads. You could use a single strand from stranded wire, they are also often 0.2mm.

    ReplyDelete
  19. Which one is the R4 resistor on the board?

    ReplyDelete
    Replies
    1. It's the one next to the DIR pin.

      Delete
    2. Great, thanks!
      Will try the mod on my Pololus.

      Delete
  20. I tried this to fix an issue with my bot resulting uneven steps creating the appearance of visible voxels, which look like tree rings when printing organic shapes. Pictures: https://plus.google.com/u/0/105535247347788377245/posts/N6JqqFd4hF9

    I used pololu drivers (chinese clones, actually) with A4988 chips and replaced R4 on each with a small wire. This does not seem to have had any effect.

    ReplyDelete
    Replies
    1. What motors are you using?

      Delete
    2. My X and Y motors are 39.1 15.3 ohm, respectively. The Y motor is from Makerbot and the X is from a batch I got on ebay. I don't think either of them has a (useful) serial number.

      Delete
  21. They are not low resistance motors so probably don't suffer from this problem. You might have the opposite problem: if the current is set higher than than you can get from the voltage divided by the resistance then you get a flat top on the sine wave and miss steps there instead of at the zero crossing point.

    ReplyDelete
    Replies
    1. That sounds like it's consistent with what I see when I look at the LEDs while trying to step the motor slowly. They stay pretty bright until they go out. Would replacing R4 with a lower value do the job? Maybe closer to 1K? I think I have some of those in the right size...

      Is there an equation I should be using to calculate the ideal value? I'm looking through the datasheet, but a lot of it is greek to me.

      Delete
  22. The maths is here: http://hydraraptor.blogspot.co.uk/2009/08/motor-maths.html and the previous article it links to shows the various types of microstepping distortion you can get.

    There are some values for Makerbot motors here: http://hydraraptor.blogspot.co.uk/2009/08/motor-maths.html but they are for the A3977.

    With high resistance motors the original 10K is probably about right but you need to adjust the current low enough to not clip the peaks. The main issue then is the torque might be a bit low and the chopping frequency becomes audible as the on time approaches infinity. Lowering R4 helps this as does increasing the supply voltage. Basically it is completely the opposite problem to that described above.

    ReplyDelete
  23. Wow, great find. Thanks for keeping such great documentation. I had exactly the same problem.

    I have 2.1 ohms on my x,y, and 2 z motors and 2.8 ohms on my extruder. I just held a copper alligator clip up to the contacts of R4 for testing and the motor ran smoothly, no low pitch. I think I will try to solder a short wire to each end of the resistor; is this what is meant by shorting it, or is one expected to connect a wire all the way to the pin? And again, thanks for the completeness of you blog, problems and solutions; your blog has been so much help in building my first printer.

    ReplyDelete
    Replies
    1. You just need to bridge the resistor contacts. I removed it and replaced it with a short wire but you could leave it on. A proper job would be to replace it with a zero Ohm resistor.

      Delete
    2. Replaced the resistor on all four of my pololus with a single strand of 7 strand 22AWG wire. Motors have been running smoothly since. Thanks again.

      Delete
  24. Hi,
    A question,
    I tried both Pololu driver, step stick driver.
    I'm using a Sanguinololu and step motor http://www.wantmotor.com/ProductsView.asp?id=155&pid=80 model 42byghw811
    I don't understand why with the Stepstick all work well and with the pololu the motor seem lose step, don't rotate but vibrate.
    Same configuration...
    In both drivere there is a Rosc = 10Kohm.
    Removing it and putting the Rosc to ground also pololu works, but I'd like understand the difference.
    Could be the different value of Rsense?
    Could you help me?

    ReplyDelete
  25. If the Pololus are the later ones with the A4988 then the only difference is the sense resistors are 0.05R. Some stepsticks have them at 0.2R. So for 1A you set a stepstick VREF to 1.6V and you set a Pololu to 0.4V.

    ReplyDelete
  26. Thank you very much.
    I tried and you are right.

    ReplyDelete
  27. I've just tried this mod today.
    3 ohms motors and Pololu A4988 configured to 1.25A.
    Missing steps before, *no* missing steps after: great!!!

    But, I've almost killed the driver trying to solder the darn wire.
    I'll have to do a better job on the remaining 3.
    :-)

    Thanks again.

    ReplyDelete
  28. Thank you mophead!
    Even tho' I'm not a repraper I read all of your articles with great interest because I am trying to develop a telescope drive with microstepping, and I had some troubles with the A4988 (Pololu) at 16X - I need a slow step rate while tracking (10 - 100 /sec), and much quicker rates whilst slewing (10000 steps/sec).
    Sure enough I could see both visibly - Steps 1 - 4 or so with small moves, 5 - 14/15 normal, tehn a large move on step 16, accompanied by an audible difference in the clicks/thunks. After grounding the ROSC pin (easily accessed on the 10k smd resistor) I have noticed a significant improvement.
    Thank You!
    All this has prompted me to study the datasheet more deeply.
    BTW, Pololu has a new driver based on the TI DRV8825 - beefier current capacity and 32X microstepping... Have you tried it?
    Regards,
    Ram

    ReplyDelete
    Replies
    1. No not yet, although I have had the dev kit for it for months but not had the time.

      Delete
    2. The DRV8825 has a similar problem though...

      See my quick hack to fix it.
      http://reprap.harleystudio.co.za/?p=321

      Delete
  29. Let's just buy smaller pulleys.
    -A mechanical engineering (I don't understand electronics :'( )

    ReplyDelete
    Replies
    1. Belts have a minimum pulley radius. For T5 it is 10 teeth and T2.5 14 I think.

      Delete
  30. Hi Nophead,

    In this article you fix the microstepping on the 4988 by shorting R4 and then the motors ran more smoothly but hummed in idle. Did you keep this modification and did the hum turn out to indicate a problem?

    ReplyDelete
    Replies
    1. Yes I had them made this way for Mendel90 kits. The noise when idle doesn't indicate a problem it is just that the lower switching frequency is more likely to generate beat frequencies in the audible range.

      Delete
    2. Thanks! I reckon its time I did the same modification then :)

      Delete
  31. I have 3pcs of A4988 with R4 set to 0 ohms and driving a nema 23 which has a phase resistance of 0.9ohms (model: 23HS22-2804S) with 24 volts Psu makes my prints covered in ripple or moire type effects. What can I do to solve this issue ? Thanks!

    ReplyDelete
    Replies
    1. Does it make sounds like my two videos?

      Perhaps try a 12V PSU because 24V with a very low inductance motor might not allow the lowest current steps to be achieved.

      Delete
    2. where are your videos? btw they sound normal. Will try 12v psu. what inductance should be used with a4988 and 24v psu? thx

      Delete
    3. The youtube videos are embedded in the article above. It is only the sound that is interesting.

      I normally use 1.8R motors at 12V. You have half the resistance at twice the voltage so the duty cycle would need to be roughly four times less. With a fixed off time of 30uS and minimum on time of 1uS I don't think you can achieve a low enough current for x16 microstepping. Certainly not in slow decay mode. I am not sure about mixed decay mode.

      Delete
    4. so using wantai 57BYGH420 which has 1.5 resistance can solve my problem ?

      Delete
    5. At 12V probably because it isn't much different from what I use. I don't run at 24V because of exactly this problem.

      Delete
    6. a step down converter can do the trick or a 12v psu is a must?

      Delete
    7. A step down convertor with sufficient current rating should work but if you want the high speed performance 24V would give then you need better stepper drivers.

      Delete
  32. im measuring the resistance of the coil of the 57BYGH420, by the datasheet it has to be 1.5 ohms but i get 2.5 in all of them, why?

    ReplyDelete
    Replies
    1. I don't know but the datasheet is for unipolar mode, so you should get 1.5R at the centre taps but 3R for bipolar connection.

      I normally get the correct reading once I subtract the meter lead resistance.

      Delete
    2. I have tried with some vexta steppers with a phase resistance of 4 OHms, same 24v PSU and a4988, with this setup the smoothness is incredible!! but the motors are way to expensive at 100usd each..still searching for a better solution to achieve smooth movement.

      Delete
  33. I fitted steppers to telescope mount and made a goto/tracking controller for it.

    It was hopeless moving at very slow speeds (just over one microstep per second) until I made this mod which cured the problem completely.

    I note some stepsticks I received recently have 0R 'resitors' fitted as R4 (and R100 rather than R200 current sense resistors)

    ReplyDelete