584,802 active members*
4,926 visitors online*
Register for free
Login
IndustryArena Forum > OpenSource CNC Design Center > Open Source Controller Boards > Microcontroller based bipolar stepper driver
Page 1 of 3 123
Results 1 to 20 of 50
  1. #1
    Join Date
    Feb 2005
    Posts
    122

    Microcontroller based bipolar stepper driver

    Hi,

    I would like to discuss the posibility to build a microcontroller based stepper motor driver able to drive bipolar motors in microstepping mode.

    Specs of driver :
    - cost effective solution composed by a microcontroller and 2 Fet based H-Bridges
    - PWM driving (not current chopping)
    - start point schematic is Mariss's schematic from thread http://www.cnczone.com/forums/showth...=24699&page=54


    Questions :
    - How to set up the fill factor of of PWM ? Would be suitable a PID function in this case ? Usually PID function thakes as input the error (defined as difference between desired value and measured value ) and sets the drive value. In this case when desired coil current it is evaluated trough a simple comparator I think that it is not applicable. Would be necessary a very fast ADC.
    - It is mandatory PID on PWM ?
    - What microcontroller would be suitable for this job ? (only cost effective solution that comes to my mind is at90PWM2/3 has integrated PowerStageController - pwm with programable deadtime )


    Regards,
    Daniel

  2. #2
    Join Date
    Jul 2008
    Posts
    411
    Daniel

    A lot of the top end Microchip PICs have integrated ADC and PWM hardware for this sort of job...

  3. #3
    Join Date
    Feb 2005
    Posts
    122
    Irvin, thank you for pointing me to that direction (I don't know why I'm staked on Atmel products).
    Looking trough their list of motor control dedicated products (http://www.microchip.com/ParamChartS...g=en&pageId=75) I tooked as example : dsPIC33FJ32MC202 .

    From datasheet results that ADC can do :
    10-bit, 1.1 Msps or 12-bit, 500 ksps conversion:
    - Two and four simultaneous samples (10-bit ADC)
    I wonder if 1Msps ADC on coil current would be enough to drive a stepper motor.
    If 2000 steps per second would be an acceptable performance then the ADC would have 500 samples per each step + time needed for calling PID function and changing fill factor of PWM.

  4. #4
    Join Date
    Aug 2006
    Posts
    2758
    Quote Originally Posted by dandumit View Post
    Irvin, thank you for pointing me to that direction (I don't know why I'm staked on Atmel products).
    Looking trough their list of motor control dedicated products (http://www.microchip.com/ParamChartS...g=en&pageId=75) I tooked as example : dsPIC33FJ32MC202 .

    From datasheet results that ADC can do :

    I wonder if 1Msps ADC on coil current would be enough to drive a stepper motor.
    If 2000 steps per second would be an acceptable performance then the ADC would have 500 samples per each step + time needed for calling PID function and changing fill factor of PWM.

    The dsPIC33FJ32MC202 is an overkill for this task.

    Mariss does not use PI or PID to control phase current, for the simple reason that there is no A/D conversion and the CPLD he uses does not have the resources to implement PID or PI control. He uses a fixed frequency chopper, although he does not want to call it a chopper, all choppers are PWM (even when some of them have variable frequency).

    How are you planning to deal with current decay?, Mosfet turn on and reverse recovery switching transients affecting the results of A/d current measurements?

    It would be a good learning experience.

    IR2104 does not have separated high and Low side input signals, and has fixed dead-time. Using the Atmel At90PWM2/3 controller is going to be a waste of resources unless you change the Mosfet half bridge driver.

    I think that controller will be very busy doing only 20Khz PI control of current, what kind of math are you planning to implement? fixed point, floating point, integer only?.

    Kreutz.

  5. #5
    Join Date
    Jul 2008
    Posts
    411
    I would probably use IR2110 for this as has seperate hi and lo inputs and a common shutdown gate.

  6. #6
    Join Date
    Feb 2005
    Posts
    122
    1. Microchip says that dsPIC33FJ32MC202 is $2.59 for volume - so it's god for our purpose

    2. Chopper's freq is depending also on supply voltage ... Chopper=PWM ? debatable . I think that Mariss want's to have fixed frequency on both windings and variable fill factor. Also he already explained that because of chopper's different freq in windings, motor starts to "sing".

    3. BEMF ! - good quetion ! in this moment I don't know what to answer to this. Anyway if it can be found a way to analyze the BEMF we can find out some informations about the load of motor and the point where it is about to stall or to enter on resonance.

    4. Procesor load : processor load it is big when the error (diference between desired and measured value) it is big. I intend to implement the following procedure : at the very first time after board power, when it is made a first complete cycle of microsteps i intend to have an array where to store values found by PID function for each coil + each microstep. At the next steps those values will be send from begining to pwm - this way the error will be smaller and load of cpu also smaller.
    I would be tempted to try integer only math (thinking that we need as much speed as possible).
    I still need advices if it is feasible to implement pid over adc from coil's current. 1Msps ADC would be enough ?

    Beautiful part here is that if such a board would be made, would be possible to drive stepper motor or servomtor.

    I think that we need Mariss advice on this ideea.

    Regards,
    Daniel

  7. #7
    Join Date
    Feb 2005
    Posts
    122
    I have started to read the Application Note AN532 . Until now it confuses me : says that contol loop can go up to 2khz and the time needed for pid calculation it's 200ms. that's huge and it cannot be used to make pid pwm stepper driver

  8. #8
    Join Date
    Aug 2006
    Posts
    2758
    Quote Originally Posted by dandumit View Post
    ..................- What microcontroller would be suitable for this job ? (only cost effective solution that comes to my mind is at90PWM2/3 has integrated PowerStageController - pwm with programable deadtime )..............
    Daniel;

    I implemented a complete translator with multiple micro-step modes on a 2K of Flash, 128 bits of RAM, $1.00 Attiny2313-20. It is used on a 48V 5Amps bipolar Micro-stepper drive, as well as on an 80V 8Amps unipolar micro-stepper drive with ZERO Noise, both work at 100K steps/sec. Both designs are discussed on the respective threads and blogs, even provided the source code, PCB designs and schematics.

    I don't intend you to follow on the same path, but maybe my implementation could give you some ideas. The PIC DSC is more than enough to do what you intend to do, a DC motor controller is something completely different from a stepper controller, so that AN will not help much.

    About the chopper versus PWM debate. If you don't understand what they are and what the similitude (or difference) is, it is difficult to use any of them on your design. PWM is a pulse modulation technique, it does not have anything to do with PID, except that some PID controllers employ PWM as control output, the same way other PID controllers could give you +/-10v output.

    About PID controller load, it does not depend at all on the error size. The error is only one variable on the chosen PID algorithm. It does depend on the math employed (fixed point, floating point, integer) and the number bits assigned to the variables and coefficients (precision), as well as the capabilities and speed of the processor itself. The DSPIC is fast enough for a fixed point (Q15) PI loop running at 20 Khz.

    Kreutz.

  9. #9
    Join Date
    Sep 2006
    Posts
    218

    Quote Originally Posted by dandumit View Post
    From datasheet results that ADC can do :
    - 10-bit, 1.1 Msps or 12-bit, 500 ksps conversion:
    - Two and four simultaneous samples (10-bit ADC)
    I wonder if 1Msps ADC on coil current would be enough to drive a stepper motor.
    If 2000 steps per second would be an acceptable performance then the ADC would have 500 samples per each step + time needed for calling PID function and changing fill factor of PWM.
    hm..
    I've played with a dsPic some time ago, but I was verry dissapointed by the ADC module. Allthrough can be configured to 1Msps, I couldn't use-it for signals faster than 10kHz (ADC values were wrong...)
    Fast and accurate ADC with Microchip is not for beginners. You must learn wery well how pic is working, and what can you disable while reading analog values.
    But if you want to try, will give a help, if we can

  10. #10
    Join Date
    Sep 2006
    Posts
    218
    Quote Originally Posted by dandumit View Post
    I have started to read the Application Note AN532 . Until now it confuses me : says that contol loop can go up to 2khz and the time needed for pid calculation it's 200ms. that's huge and it cannot be used to make pid pwm stepper driver
    there are other law for current controlling than PID. PID is slow. A sliding mode will be much faster and intuitive

  11. #11
    Join Date
    Feb 2005
    Posts
    122
    Kreutz, first of all thank you for giving feedback on this idea, I look on your 2313 design immediately. (comparing myself with you or Mariss I'm weak in stepper driving so, I have a lot of things to learn).

    Also I have to comment a little / or better said to add some more details :
    DC motor controller is something completely different from a stepper controller, so that AN will not help much
    .

    Very basically a stepper driver consist in 2 synchronized regulators who take care to have an amount of current trough windings.

    When I say regulator I mean :
    1. one device to measure the resulted output value, value which will be used as feedback
    2. decision mechanism which: a) take in account desired value and measured result from point 1 ; b) decides about action that should be made and send this decision to no 3
    3. Power Stage

    Everywhere where is a regulator should be a PID function in no 2 - Decision Mechanism.

    All designs that I have seen for driving stepper motors are based on a simple comparator. I consider this as the point where improvement has to be made.

    PWM is a pulse modulation technique, it does not have anything to do with PID
    Indeed PWM it's the working mode of power stage.

    About PID controller load, it does not depend at all on the error size.
    That's correct. What I was willing to say is :
    1. in the first on pwm cycles error will be big and PID procedure will be called.
    2. after few iterations will be found the correct fill factor of PWM. when all pwm values coresponding to desired winding current are known , error will be small enough to avoid calling PID function.


    Daniel

  12. #12
    Join Date
    Aug 2006
    Posts
    2758
    Quote Originally Posted by dandumit View Post
    ..........All designs that I have seen for driving stepper motors are based on a simple comparator. I consider this as the point where improvement has to be made..............

    Daniel
    Yes, and No.

    Yes, the majority of the stepper drives use "bang-bang" or chopper control, which is the term applied to a Proportional controller with infinite gain. The system works fine because of the L/R time constant of the Motor coil. The coil current could not have sudden changes due to the inductive nature of the winding.

    In this way the stepper coil regulator is equivalent to a DC/DC Buck regulator, and the same general techniques are applied for current control. There are nevertheless some differences when taking into account current decay modes.

    The currently employed current regulation technique does a wonderful job and is simple (and fast) enough, main factor here is: You setup a reference value for the current, it does not matter which motor or power supply dc voltage. The proportional control (chopper) will try to regulate the current and will do a great job modulating the duty cycle value in order to regulate the coil current while the drive acts as a current source (below 100% duty cycle). The problems start when the drive begins to act as a voltage source after certain speed due to the L/R time constant and BEMF (with constant DC voltage).

    If you were to design a PI type of control, it will behave about the same, because you are not acting against the limiting factor, that is the L/R and the effect of the BEMF. PID is not required because the controlled variable changes relatively slow vs time (due to the inductive nature of the motor winding). Now you have a big problem: PI loop tuning for different motors and different power supply voltages, hence the competitive dis-advantage. Here goes the No, regarding to "improvements could be made".

    If what you are trying to accomplish is only to eliminate the sub-harmonic instability, there are other simpler ways employed in the DC/DC controller's industry for quite some time: The use of a "Blanking time" and Slope-compensation, which by the way was not invented by Mariss or Me, it has been there for a long time, just not used on stepper drives.

    A well calculated or adjustable Slope-compensation will take care of another disadvantage of the chopper technique, it will compensate against the change of average current value vs duty cycle, which is inherent to the Peak limit current regulation mechanism, so the regulator circuit becomes an effective average current regulator when properly employed (adjusted for 50% duty cycle).

    If you want to go deeper into solving the problems of the L/R and BEMF effects at high speed, then there are also other techniques that have been developed, between others: Dual voltage drives and Field Oriented Control (flux vector) drives (including field weakening), that is what Mariss working on now.

  13. #13
    Join Date
    Feb 2005
    Posts
    122
    Indeed I have a lot of things to learn and I have received very knowledgeable answers.
    I wonder if it worth the effort to push a stepper driver so much. Stepper motor would become an option over servomotor ? What would be the final achievement ?


    Looking trough internet for Field Oriented Control I have found 2 interesting papers :
    http://www.he-arc.ch/hearc/fr/imi/pu...dia_dsp_06.pdf
    http://www.csuohio.edu/engineering/e...004/Bhavin.pdf
    http://academic.csuohio.edu/embedded...ayu_thesis.pdf
    (Latest one it's an master thesis and I think that it could be "compressed" in a singe dsPic.)

    It seems that Field Oriented Control in this moment it's too much for me.

    However, I won't give up.
    Bottom line doesn't seems to be such a wrong direction to do ADC over winding coil current. I don't know yet what kind of regulator would be needed.

    I have received also many interesting ideea's from another great guy from this forum MaX-MoD.
    He pointed me to http://papsi.origo.ethz.ch/ project . It's a dsPic based stepper driver.
    I will try to move further from this project.

    Regards,
    Daniel

  14. #14
    Join Date
    Aug 2006
    Posts
    2758
    Quote Originally Posted by dandumit View Post
    Indeed I have a lot of things to learn and I have received very knowledgeable answers.
    I wonder if it worth the effort to push a stepper driver so much. Stepper motor would become an option over servomotor ? What would be the final achievement ?


    Looking trough internet for Field Oriented Control I have found 2 interesting papers :
    http://www.he-arc.ch/hearc/fr/imi/pu...dia_dsp_06.pdf
    http://www.csuohio.edu/engineering/e...004/Bhavin.pdf
    (Latest one it's an master thesis and I think that it could be "compressed" in a singe dsPic.)

    It seems that Field Oriented Control in this moment it's too much for me.

    However, I won't give up.
    Bottom line doesn't seems to be such a wrong direction to do ADC over winding coil current. I don't know yet what kind of regulator would be needed.

    I have received also many interesting ideea's from another great guy from this forum MaX-MoD.
    He pointed me to http://papsi.origo.ethz.ch/ project . It's a dsPic based stepper driver.
    I will try to move further from this project.

    Regards,
    Daniel
    Daniel;

    Don't give up or get discouraged, just start walking before trying to run. Start with a simple design and begin to improve it, that way you will be cashing on a lot of build up experience and integrating the acquired knowledge for more complex approaches.

    The ADC conversion is not a big issue, you just have to sample on a small window during each PWM active portion of the duty cycle (center) and you are done, it will also take care of the blanking, since at that time you are not supposed to have any ringing or switching noise interference. Any ADC with > 250Ksps will be good. You will need a good sample and hold, triggered by the PWM timer, because the PID /PI algorithm requires a precise timing of the samples. The minimum PWM duty must be limited to avoid sampling on the transient switching noise region.

    About your questions, it does not matter what the future of the stepper drives is going to be, it is knowledge what you gain from this endeavor.

    Best regards,

    Kreutz

  15. #15
    Join Date
    Nov 2008
    Posts
    522
    Yeah help me out here:
    Say we're holding a particular current level, say 1A, with microstepping. The ideal driver switch the bridge in that direction (say Side A high/Side B low) until current reaches say 1.1A, then turn off both high transistors and turn on both lows to short the coil, putting it in recirculation mode. In that state the current decays slowly, only with the resistance of the motor + 2 * rds-on of the low transistors. The driver waits until current equals 0.9A then switches Side A high again to increase the current again.

    But say the current is 1A and the next microstep commanded requires the current to be 0.75A, though in the same direction. Switching on Side A will increase current. Putting it in recirculation, switching on both lowsides, will not make current decay anytime soon.

    Are we supposed to switch on Side B high/Side A low, the opposite of the needed current direction, to lower the current? That would certainly need to be done briefly since we only want to reduce the winding current not reverse it. Or, well, we can just turn off the Side B low and that'll forward-bias the intrinsic diode (or external rectifier diode) in Side B high even if we don't turn on Side B high's gate.

  16. #16
    Join Date
    Jul 2003
    Posts
    246
    PI controller not good choice for AC systems. Because PI controller and stepper motor are like this low pass filter. PI controller not problem for low frequency. PI controllers are usable if you dont need to high rpm.

    Field oriented control eliminate this problem. Because PI section of FOC use DC type input signals.

    At the past I used PID control for stepper motors. Derivative section more critic. Because derivative action noise sensitive and pwm section produce more noise. (Sample point very importand if you work by pwm)

    My first models (FLZ03) use PID type stepper controller http://www.cnczone.com/gallery/showp.../3/ppuser/1242 This PID regulator has 50 usec servo loop.

    My last dsp based stepper motor controller (MCR1207) use second order type filter for current servo. (Pole placement)

    MCR1207 controller use 25usec servo loop. http://www.cnczone.com/gallery/showp.../3/ppuser/1242

  17. #17
    Join Date
    Feb 2005
    Posts
    122
    MechanoMan - Thanks for input. I think that this procedure is described as fast / slow decay in (for example) Allegro's documentation.

    Your explanation for this functionality it's more appropriate to chopper driver.

    Mariss consider that PWM driving mode it's more effective .
    Anyway, reading your post and thinking to schematic posted by MAriss I am not convinced that he is using mixed decay in his driver (fet are driven by ir2104 wich doesn't allow to command selectively high side and low side fet).

    bunalmis - are you willing to give us some more details about your drivers ?

  18. #18
    dandumit,

    The only switching options are "fast decay" and "slow decay". For "fast decay" the polarity on the winding is reversed and current decays at di/dt = (V supply) / (motor L). For "slow decay" the winding is shorted and current decays at di/dt = (V motor) / (motor L). Because (V supply) can be 20 times (V motor), "fast decay" can be up to 20 times faster than "slow decay".

    We use "fast decay" because winding currents track the sine-cosine reference far more quickly than "slow decay".

    "Mixed-Mode" means different things to different people. For Allegro, "mixed-mode" means "slow decay" from sine 0 to sine 90 and "fast decay" from sine 90 to sine 180. This introduces an unacceptable distortion in the motor current. Let's say at sine 89.9 (fast decay) current ripples between 0.8A and 1.0A making the average current 0.9A. At sine 90 the mode is changed to "slow decay" and ripple becomes 20 times less, 0.99A to 1.0A for an average current of 0.995A. The motor "sees" a near 0.1A squarewave offset current which introduces a terrible harmonic distortion (and vibration)!

    For us, "mixed-mode" means using both continuously. This introduces no distortion and the motor is significantly cooler while stopped or turning very slowly. It is also a significantly more complex circuit (4 comparators instead of 2), so it must deliver a significantly greater advantage to justify the complexity. Sadly it doesn't when looking at the bigger picture. See the attached pdf.

    Mariss
    Attached Files Attached Files

  19. #19
    Join Date
    Feb 2005
    Posts
    122
    Impressive work.
    You should be consultant for Allegro , ST etc. Every company that want's to make a chip to drive stepper motor should "buy" knowledge from you (unfortunately from my experience: deadlines, business cases and budgets are biggest enemy of quality products).


    My first mistake/misunderstunding it was that I was thinking that fast decay it is achieved by leaving all transistors from h bridge in "high state" and BEMF will flow back trough "anti parallel"/protective fet's diodes - big mistake since power supply is much bigger than tension over coil.


    You have said that for Your mixed decay are needed 4 comparators.
    Why are needed the second('s) ? On the fast decay stage it's needed to lower the current under the value of phase's direct drive ? Wouldn't be a cheap and dirty solution to use the same comparator + eventually a resistor to ground to divide the reference ?


    Daniel

    PS. few minutes after posting this message I have read the thread http://www.cnczone.com/forums/showthread.php?t=71275 - I truly agree with everything there even I have the impression that I'm a hammer ...

  20. #20
    Join Date
    Aug 2006
    Posts
    2758
    Quote Originally Posted by dandumit View Post
    ................My first mistake/misunderstunding it was that I was thinking that fast decay it is achieved by leaving all transistors from h bridge in "high state" and BEMF will flow back trough "anti parallel"/protective fet's diodes -.............

    Daniel

    ...
    No mistake, that is how it works. The other option is what is called "Synchronous rectifier mode or Synchronous rectification", that is: reverse the bridge until the current reaches zero (or the PWM cycle ends), but it requires a zero current detector.

    Syncronous rectification is a more efficient Fast Decay mode, since the voltage drop is reduced to 2x Rdson x I instead of I x 2xVf, so de power dissipated on the Mosfets decreases. It seems that Mariss applies this method on both: Fast decay portion of the "mixed mode" and Fast decay in "non recirculation mode".

Page 1 of 3 123

Similar Threads

  1. New Allegro Bipolar Stepper Driver A3986
    By BCwanderer in forum Open Source Controller Boards
    Replies: 825
    Last Post: 09-05-2014, 06:46 AM
  2. Unipolar Stepper run with Bipolar Driver
    By bcromwell in forum CNC Machine Related Electronics
    Replies: 45
    Last Post: 06-21-2013, 03:20 PM
  3. need help to connect microcontroller to stepper driver
    By xinzc28 in forum CNC Machine Related Electronics
    Replies: 0
    Last Post: 11-07-2008, 09:59 AM
  4. MicroController/DSP based Motion interface
    By Haz in forum CNC Machine Related Electronics
    Replies: 3
    Last Post: 03-22-2007, 09:54 PM
  5. RQ: Bipolar stepper motor driver circuit
    By elektronchika in forum Stepper Motors / Drives
    Replies: 2
    Last Post: 12-22-2005, 12:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •