Sunday, 13 December 2009

Motoring on with the A3977

Previously I have blogged about how to set up the Allegro A3977 driver chip to suit a particular motor: -

hydraraptor.blogspot.com/2009/07/lessons-from-a3977
hydraraptor.blogspot.com/2009/08/motor-math
hydraraptor.blogspot.com/2009/08/mixed-decay-mixed-blessing

Most boards I have seen using the A3977 and similar chips just have a current adjustment, with all the other values fixed. Unless you strike lucky this is not going to allow accurate microstepping because the off time and PFD need to be adjusted to suit the motor and supply voltage.

A while ago Zach sent me samples of the prototype V3 stepper controller kits and the NEMA17 motors used on the MakerBot. I made up the board using my SMT oven (pizza oven controlled by HydraRaptor, more on that later).



It works well, but the initial component values are not optimum for the motor, so I decided to make a test bench from the older prototype board that I have been experimenting with. I RepRapped a chassis for it with a panel to mount some switches to vary the timing components.



The chassis is one of the biggest parts I have made, not in volume, but in overall expanse. It warped a little, despite being PLA, heated bed coming soon!



The switch on the left must be at least 20 years old and the one on the right more than 40 but they both still work fine. I save all this junk and eventually it comes in handy.

I also have potentiometers on V
ref and PFD, so together with a bench PSU and a signal generator I can vary every parameter.

I knocked up a label on a 2D printer, it's so much easier to make this sort of thing than it was when the switches were born!



Zach has updated the board to have four preset potentiometers to make it fully adjustable. There are test points to allow the pots to be set to prescribed values with a multi-meter.

Vref and PFD can be measured as a voltage, but the two RT values have to be set by measuring resistance with the power off. My multimeter seems to give accurate readings of these despite them being in circuit. A good tip is to measure the resistance with both polarities and if it reads the same either way round then it is most likely the chip is not affecting the reading.


So here is a list of motors and optimised settings: -

MakerBot Kysan SKU1123029 NEMA17





This is the motor that MakerBot use for the axis drive on the Cupcake, details here. It is actually a 14V motor, so is not ideally suited to being driven from a 12V chopper drive. You normally want the motor voltage to be substantially lower than the supply.

You can't run it at its full current because the duty cycle would tend to 100%. With a fixed off-time, the on-time tends towards infinity and the frequency drops into the audio range.
In practice I found the maximum current at 12V was 0.3A, any higher and the microstepping waveform was distorted on the leading edge due to the current not being able to rise fast enough.



To maintain the sinusoidal waveform at faster step rates requires the current to be lowered further, 0.25A gives a good compromise. It is not a bad idea to under run steppers anyway, otherwise they can get too hot for contact with plastic.

I used the minimum values for CT and RT, i.e. 470pF and 12K to keep the chopping frequency as high as possible, so that it is outside of the audio range. Not only is this a good idea to keep it quiet when idling, but also you want it much higher than your stepping frequency, otherwise they beat with each other.

The values give a minimum frequency of ~17kHz @ 0.3A and a maximum of ~150kHz on the lowest microstep value.
17kHz is not audible to me, but younger people might be able to hear it. There is still some audible noise at the point in the cycle when both coils have similar currents and so similar high frequencies. The beat frequency, which is the difference of the two, is then in the audio range. It isn't anywhere near as loud as when the chopping is in the audio range though.

I can't see any spec for the maximum switching frequency although a couple of parameters are given at less than 50kHz. I suspect 150kHz is a bit on the high side, which would increase switching losses, but with such a low current compared to the rating of the chip I don't think it is a problem.

One problem I had initially was that the switching waveform was unstable. It had cycles with a shorter on-time than required, which let the current fall until it then did a long cycle to catch up. The long cycle gave a low frequency that was back in the audio range.



I think it was a consequence of the motor needing a very short off-time in order to be able to have the duty cycle nearly 100%. The current hardly falls during the off period, so a little noise due to ringing can trigger it to turn off too early. It is not helped by using the minimum blank time. I fixed it by putting 1uF capacitors across the sense resistors.

The PFD value is best set to 100% fast decay with this motor.

It works better with a 24V supply. The full 0.4A current can be achieved (but it gets much hotter of course) and it maintains microstepping accuracy at higher step rates than it does on 12V.

MakerBot Lin SKU4118S-62-07 NEMA17





This is the NEMA17 that MakerBot used to supply. It is at the opposite extreme compared to the one above, i.e. it is a very low voltage motor, only 2V @ 2.5A. As mentioned before, this causes a couple of issues: -
  1. The inductance is so low that the ripple current is significant compared to the lowest current microstep, causing positional errors. OK at 2A, but gets worse with lower currents.
  2. It is difficult to get 2.5A from the A3977 without it overheating. The PCB layout has to be very good. The datasheet recommends 2oz copper and four layers. 2A is no problem and that is the maximum with the 0.25Ω sense resistors fitted to the board.
At 2A the motor runs at about 40°C, so just about OK for use with PLA. The chip gets a lot hotter, about 77°C measured on the ground pins.

I used a value of 56K for RT and 2.1V on PFD. To some extent the optimum PFD value depends on how fast you want it to go.

Motion Control FL42STH47-1684A-01 NEMA17





This is the recommended motor for the Mendel extruder, details here. After buying a couple of these a friend pointed out that Zapp Automation do the same motor with dual shafts for about half the price!

This is a high torque motor so it is longer and heavier than the previous two NEMA17s. Electrically it is in the sweet spot for the A3977 with a 12V supply. The A3977 can easily provide the full current and the switching frequency doesn't have wild fluctuations or drop into the audio range.

When microstepped at 1.7A it gets to about 43°C but the chip only gets to 56°C.

I used 39K for RT and 0V on PFD, i.e. 100% fast decay.

I have high hopes for this motor as a replacement for the one above that is in my extruder currently. It should give me almost twice the torque and has the correct sized shaft, i.e. 5mm. The Lin and Kysan motors both have imperial shaft sizes which caught me out as I drilled the worm gear for 5mm thinking NEMA17 specified that, but it must just be the frame dimensions.

MakerBot Keling KL23H251-24-8B NEMA23





This is the motor I used on my Darwin. It has 8 wires so it can be connected in bipolar serial or parallel. Series has the advantage that the full torque can be achieved with 1.7A which is easily within the range of the A3977. Parallel has one quarter of the inductance so torque will fall off with speed four times slower. To get full torque 3.4A is needed but I found 1A was enough for the X and Y axes. I think Z needs more torque but my z-axis uses different motors so I don't know how much.

An RT value of 56K is fine for currents in the range 1-2A. PFD is best at 0v, i.e. 100% fast decay.

Summary

Here is a summary of the motor specifications :-

Motor Resistance Max Current Voltage Max Power Holding Torque Inductance
LIN 4118S-62-07 0.8 Ohm 2.5 A 2.0 V 10.0 W 0.30 Nm
Kysan SKU 1123029 35.0 Ohm 0.4 A 14.0 V 11.2 W 0.26 Nm 44.0 mH
Motion Control FL42STH47-1684A-01 1.7 Ohm 1.7 A 2.8 V 9.5 W 0.43 Nm 2.8 mH
Keling KL23H251-24-8B Series 3.6 Ohm 1.7 A 6.1 V 20.8 W 1.10 Nm 13.2 mH
MakerBot Keling KL23H251-24-8B Parallel 0.9 Ohm 3.4 A 3.1 V 20.8 W 1.10 Nm 3.3 mH

Here are my suggested settings :-

Motor Current Vref CT RT PFD
Kysan SKU 1123029 0.25 – 0.3A 0.5 – 0.6V 470pF 12K 0
LIN 4118S-62-07 1 – 2A 2 – 4V 470pF 56K 2.1V
Motion Control FL42STH47-1684A-01 1 – 1.7A 2 – 3.4V 470pF 39K 0
Keling KL23H251-24-8B Parallel 1 – 2A 2 – 4V 470pF 56K 0

21 comments:

  1. Mostexcellent, Solid work and very detailed/informative.

    Cheers Nophead you are a star.

    ReplyDelete
  2. >> I save all this junk and eventually it comes in handy.<<<< Yes, but your reuse is done so professionaly others might differ...heheh.

    Your info helped me move up the learning curve again.

    ReplyDelete
  3. Gear work nophead!

    I'm going to test the KL23H251-24-8B and Kysan 1123029 too, once they're cleared from Dutch customs (which is taking forever). I'm using them with an SMC-11 from Nanotec. I also want to try them with the BitsFromBytes all-in-one controller. Both boards use microstepping, but only have potentionmeters for the chopper drive as a configurable setting.

    ReplyDelete
  4. Yes very intresting and detailed yet again..

    I agree with you regarding driving the steppers at 1A; as the Bertha CNC can run/move smothly with a 1A drive on the original Bits from Bytes Nema 23's
    The friction on the Bertha CNC compared to any of the RepRap machines must be 2 or 3 times that found on Darwin maybe 6 or 7 times that of Mendel with its roller bearings. Where as the X and Y axies on Bertha have 4 Slide bars per axis and 8 nylon sliding bearings per axis made Nylon corner blocks.

    I found that much more support or stiffness was needed for a milling machine.

    So it was a pleasant supprise to find it could run happily with 1A drive. That said it can be run much faster with microstepping controllers and a 2A drive current.

    After two years following your adventures with HydraRaptor ~ realizing the size of HydraRaptors print bed was my biggest supprize from this post its only seeing its size in relation to the chasis.

    Before this picture it just looked a lot bigger.

    Having now messed with ABS in my extruder I now also know the sweet smell of ABS extruding.
    Its much stronger smell than I expected.

    ReplyDelete
  5. Hi BodgeIt,
    Yes the bed is 8" by 8" and the build volume only about 6" cube.

    When I first used ABS I noticed the smell but somehow I got used to it and don't really smell it at all now. Quite worrying that I have damaged my sense of smell!

    ReplyDelete
  6. Is that 40 year old switch salvaged from an AN/GRA-39 (C-2328)? It looks almost exactly like it, and that's the only place i have exer seen a switch of that type.

    ReplyDelete
  7. No I don't think so as I have never seen one of those but I can't remember what it did come from. It was probably in something my dad made but he may have salvaged it from something else.

    You can see 3 pole 3 way on the side facing the camera but I think it has the same on the other side as well, so it would be 6 pole 3 way which is unusually wide.

    ReplyDelete
  8. Can i ask, why are the rc1 and rc2 - e.g. why are in a separate manner, would be the point of that. I only see extra parts usage but cant figure out the motivation of that. Even that in the end having different pots for both lines would result in slight inevitable different settings, not significant unless some1 gets confused. So why are different, on chip (for different applications?) and also on the 4 pot board, because obviously i am missing something. Sorry for my lack of both experience and imagination. What am i missing please and thank you very much.

    ReplyDelete
  9. There are two time constants that need to be identical because the chip has two separate chopper circuits, one for each coil. Later chips have only one time constant. I suspect rather than having an analogue monostable circuit they use a digital one with a time constant set by a clock oscillator that is common to both halves of the circuit.

    The motivation for having a pot for each value is to allow the board to drive different types of motor, use different supply voltages and optimise for different speeds. For a particular application you can use fixed values.

    ReplyDelete
  10. I understand the pfd and vref parts, just no ideea why 2 x rc to be honest. Like, why would one ever want to set rc1 different than rc2. That brings the question of isnt possible to have only 3 pots instead of 4, only one rc line by simply cumulating rc1 with rc2.
    I had to change the original eagle files to make them compatible with mb 1.2, e.g. 10 pin header, reset line out, and 2 headers for endstops, and also changed smd to 1206 which i had. That gave me too much time with the board so i had to take a closer look.
    I am also thinking to put 8 diodes on the output and have a jumper on sr line. Do you think its worth it? Does it affect the calculations you made on the a3977 math and tuning - and if it does, how?
    I did a small research and found a file for a3986 (different ofc) attached to another design, i think primarily made to compute its driven fets values. But does some of the pfd/vref/offtime tuning maths also. The link is here http://www.c-n-c.cz/viewtopic.php?t=3162&postdays=0&postorder=asc&start=0 its the XLS file, google translation works. I am linking in the hope that you can make something the same for a 3977 4 pots driver for reprap ppls. I intend to put my version on thingverse for double sided toner transfer diy, and would be nice to be able to point peoples to a file like that, instead of "no clue how to use it".
    Another design of a3977 which seems nicely done with some over voltage and reverse polarity http://www.students.tut.fi/~kontkant/a3977.php.html Could be worth adding features like that for a pcb that holds all drivers in one place, instead of just one. What do you think about it.
    Thank you very much - HoobMan

    ReplyDelete
  11. No you would never set them differently but there are two separate chopper circuits, oscillating independently, that both need an off time monostable, so you need two pairs of components.

    You can squeeze a bit more current out if you use external diodes and it will change the maths. I haven't spent time analysing that mode so I can't tell you the formula and I don't have time to work on this at the moment as I have moved on to the more modern chips with only one RC and fixed PFD.

    ReplyDelete
  12. Ok one last question please.
    Using the external diodes would change the math only in a "good way" e.g. no bad side effects. Meaning one could use the external diodes and use the math values you provided, and be even more in the safe zone.
    In comparison, diodes will lower energy on chip (i dont know how to calculate that e.g. for byv27), and in the end min off time would be even less. Pfd and vref could be the same, although vref can be a bit higher, closer to 4v max if microsteping.

    Bottom line, in principle, the math compiled without diodes should be no problem on a board with diodes. The wave should be same nice. The reprap host - deceleration part should be glad. Is that correct please?
    Sorry for the trouble and thank you very much.

    ReplyDelete
  13. I think the overall efficiency is less with the diode, certainly at low currents. With synchronous rectification the voltage drop across the FET is the current times its on resistance. For a diode it is logarithmic function of current, so up to a certain current SR is best and above that Schottky diodes are better, depending on the diode.

    ReplyDelete
  14. in the a3977 application note
    http://www.allegromicro.com/en/Products/Design/stp/stp01-2.pdf
    on page 3 it uses "tBLANK = 1900 CT" (526->470), any reason the math above used 1400? also at some point they note rDS 0.22.

    Also i made some comments on the wiki on a page i was working on here
    http://www.reprap.org/wiki/DIY_PCBs_double_sided_toner_transfer#StMoDrv_3.3v_Mendel_.22pins_compatible.22
    Please help and review / edit it if i wrote something wrong.
    Tyvm, NoobMan

    ReplyDelete
  15. sry tried to speed things and made the above post on the wrong page, should of been on motor math page (sry again, thats typical for me :D)

    ReplyDelete
  16. I used the values in the datasheet. I don't know why the app note is different.

    ReplyDelete
  17. The V3.0 boards I used on my Mendel have 78L05 regulators on them. I think by changing to 7805 it makes the board more likely to fry with a loose motor connection or ESD strike.

    ReplyDelete
  18. I added the tip about 78L05 in diy comments area, ty.

    ReplyDelete
  19. I looked more on allegro site and in faqs of the other chips seem to point to the same a3977 application note, so i think the values there might of been intended to point to more than the a3977 chip itself, so maybe that could explain the differences. Probably the datasheet is for proper particular a3977 values and the app notes are somekind of averages for a "chip family" or group or something like that. The 3.3v board has ct 470pf so i think was more oriented (perhaps wrong) on the application note than on the datasheet. I dont have the iq to think this properly.

    I like that i had room to overkill and with 3-4 cm heatsinks the chip doesnt heat at all, and i mean after hours of runtime cant even feel the slightest temp increase from powering on. The motors however kinda heat up like ~70C or more and still have some audible range noise more than i'm accustom to. I can get 3 different motors types all nema 17 to run more or less acceptable (1.2-1,5-1,8A and 2-4-9 ohm), but still not happy with my blinded tested settings (for example with an 3984 they seem to run better).

    Still cant find the way out of the mess that is in my head so i made a forum thread here http://forums.reprap.org/read.php?13,67513

    ReplyDelete
  20. Nophead,
    Did you come to a conclusion for the MakerBot stepper and controller settings for the PFD, REF, RC1&RC2? I'm reading specs but, saw with your articles that a scope is helpful. I just do not have the skills for the scope and the circuitry. Thanks for your articles. I am learning quite a bit. Brian.

    ReplyDelete
  21. Yes see the section for Kysan SKU 1123029 and the summary table at the end, assuming that is still motor that Makerbot use.

    ReplyDelete