Connect with us

Microcontroller and Stepper motor.

Discussion in 'Microcontrollers, Programming and IoT' started by Jessica91, Mar 3, 2015.

Scroll to continue with content
  1. Jessica91

    Jessica91

    10
    0
    Mar 3, 2015
    Dear all,

    I have a microcontroller which I want to connect to a stepper motor and make it turn. I have output pins going from the microcontroller via a breadbord to the stepper motor.

    The Stepper motor I have is:
    http://www.robot-italy.com/en/42byghm810-nema-17-bipolar-48mm-stepper.html

    I read a lot about the motors, but are still a little unsure how they are controlled. My questions is: do I need a driver or can I control the stepper motor directly. As far as I understand it, I only need to send a current to the correct stepper motor input pin, and it should turn?

    Thanks!
     
  2. Gryd3

    Gryd3

    4,098
    875
    Jun 25, 2014
    Directly connecting the stepper to the microcontroller is a bad idea... the motor will draw more current than the microcontroller can handle... Use a driver, or build a basic one out of transistors. (The data sheet says it is rated for 2.4A ! A microcontroller is usually only rated from 10-50mA)
    As far as driving the stepper is concerned... it's not as simple as sending current into a pin... you also need a return path as well. What you have is a bi-polar motor with 4 wires. These are then divided into 2 pairs, and the current through each pair needs to be reversed for each step. This requires the use of a home-made H-Bridge for each pair... or a pre-built stepper driver.
    Please note that a DIY stepper driver is acceptable... but only for lower currents. Running a stepper with higher currents will cause it to heat up and if your home-made driver does not compensate for this you can damage the stepper!
     
  3. Jessica91

    Jessica91

    10
    0
    Mar 3, 2015
    Thanks a lot for your answer Gryd3! Was very clear. :)
     
  4. Gryd3

    Gryd3

    4,098
    875
    Jun 25, 2014
    You're very welcome. any additional questions let us know!
    f I don't get back to you, someone else will.
     
  5. Colin Mitchell

    Colin Mitchell

    1,417
    312
    Aug 31, 2014
    The best is to start with a $5.00 stepper motor and driver from eBay.
    I have a program to drive a uni-polar stepper motor as it does not require "phase-reversal" or a bridge. Once you get an understanding how to drive this type of motor from a microcontroller or set of discrete chips, you can go on to higher-current types. They are almost impossible to damage.
    But none of them have "velocity" as described in the advertisement.
    If they did, I would never be able to catch them.
     
  6. Jessica91

    Jessica91

    10
    0
    Mar 3, 2015
    Hello all, and thanks again for your answers.

    I have been looking more into the topic and have acquired a stepper motor(pololu md20b) and stepper driver. I will power the stepper driver with a 12V battery. The challenge is that the stepper motor has a rated voltage of 2,4V and current of 2,4. I have to do some current regulation, which is an built in function of the driver, so that the motor is not destroyed. While I'm able to understand the concept, I do not yet understand how this is done in practice. By studying the datasheet I've found out there are two reference input called: AVREF and BVREF("Reference voltage for winding current set.") and two inputs called ISENA and ISENB("Connect to current sense resistor for bridge A/B."). As far as I understand it these are used in the following equation to cut the current at a max value.

    upload_2015-3-17_22-12-52.png

    My question is how do I perform this in practice. Do I need to supply the driver with both an reference voltage and current?

    Thanks!
     
  7. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,412
    2,780
    Jan 21, 2010
    You are probably best advised to power the stepper motor from a voltage much closer to its rated voltage. 12v to a 2.4v rated motor will be far too much.
     
  8. BobK

    BobK

    7,682
    1,686
    Jan 5, 2010
    Can you give a link to the entire datasheet that you quoted?

    It sounds to me like the driver is going to use PWM and sense the max current. You supply a reference voltage, which is not the same as the driving voltage, and use a resistor to supply current sensing. The equation tells you how to calculate the resistor for the desired current and reference voltage.

    Stepper motors must be driven from a voltage much higher than that calculate by I / R where R is the winding resistance or they will only run at very low speed. This is due to the inductance of the windings. Drivers will use a higher voltage, like your 12V, and then use PWM to regulate the current at the desired level no matter what speed it is running at.

    Bob
     
  9. Jessica91

    Jessica91

    10
    0
    Mar 3, 2015
  10. Jessica91

    Jessica91

    10
    0
    Mar 3, 2015
    Dear all,

    I have been having a in depth look at the datasheet. I have the general idea, but am struggling to visualize how I will implement it in practice. Following picture is taken from the datasheet, I have also included a picture of the output/inputs of interest below it.
    upload_2015-3-19_13-45-14.png
    upload_2015-3-19_13-47-9.png
    upload_2015-3-19_13-47-38.png
    upload_2015-3-19_13-48-13.png

    My question is how I will implement this circuit in practice, so that I get my desired parameters? My motor has a rated voltage of 2,4V and rated current of 2,4A. I don`t understand how I will supply a reference voltage? How can I make a circuit that takes a portion of the voltage and give it as an input? And are the resistors connect to ISENA and B just connected to the input, and on ground at the other side?

    Thanks a lot :)
     

    Attached Files:

  11. BobK

    BobK

    7,682
    1,686
    Jan 5, 2010
    The ISEN resistors will be connected between the motor and ground and will carry the entire current for the motor, so you need to keep them small. The current is controlled to make the voltage drop across these resistors 1/5 of the VREF

    Let's look at the equation for setting the current:

    I = Vref / (5 x ISEN)

    So with a 200mΩ resistor, 5 x ISEN = 1 and we get:

    I = Vref

    So, using 200mΩ resistors, the current will be limited to exactly the Vref. In other words, to get 2.4A of current, you can use 200mΩ resistors for ISEN and 2.4V for VREF.

    You can use V3P3OUT to provide a 3.3V reference for the VREF pins. You can either use a divider to make this 2.4V, or you can change the ISEN resistors to drop 3.3V / 5 at 2.4A, which would mean the sense resistor would 275mΩ.

    You connect the 12V power to both VMA and VMB.

    Bob
     
    Last edited: Mar 19, 2015
  12. Jessica91

    Jessica91

    10
    0
    Mar 3, 2015
    Thanks a lot BobK for a good answer. I really appreciate the time you put into it. :) I understand it but, there are a few things I would be very happy to have clarified. I drew a picture to try to visualize it better, I am sorry if this seems very silly! Basicly my my questions are these:

    1. How is the interconnection between the stepper motor and the driver. I know AOUT1,2 and BOUT2,1 are connected to it, but how do I connect ISENA,B as you talked about?
    2. Do I need the capacitors between 9V battery and VMA,B and between V3P3OUT and A,BREF? It is described in the column which I named extra info, I was unsure how to interpret it. And is the ground connections for those correct aswell?

    upload_2015-3-19_20-53-53.png
     

    Attached Files:

  13. BobK

    BobK

    7,682
    1,686
    Jan 5, 2010
    Your power connections are wrong. VMA and VMB both connect to the battery +. The battery - connects to ground. The bypass capacitor should be 0.1uF not 0.01uF.

    The sense resistors connect between the ISENA pin and ground and the ISENB pin and ground.

    The motor connects by connecting the two leads one winding to AOUT1 and AOUT2 and the leads of the other winding to BOUT1 and BOUT2.

    The connections for the reference voltage are correct.

    Bob
     
  14. Jessica91

    Jessica91

    10
    0
    Mar 3, 2015
    Thank you very much BobK. You have been great help!
     
  15. Jessica91

    Jessica91

    10
    0
    Mar 3, 2015
    Dear all.

    I'm currently ordering resistor for my circuit when I had a realization. There exists normal resistors and resistors called 'current sensing resistors'. I can't find anything specified in the data sheet, so I have done some reading, but I can't seem to figure out which one I need. Current sensing resistors seems a bit more expensive, so I don't want to spend a lot of money unessesary.

    Regards,
    J91.
     
  16. BobK

    BobK

    7,682
    1,686
    Jan 5, 2010
    Current sensing resistors are really no different than ordinary resistors except that they come in very low resistances and high precision and high power. For your application, I would just get a 1% or better resistor of the value you need.

    For 0.275Ω and 2.4A the power is 2.4^2 * 0.275 = 1.32W. A 2W resistor should be fine, but put it up a little from the PCB for heat dissipation.

    Bob
     
  17. Jessica91

    Jessica91

    10
    0
    Mar 3, 2015
    Ah thanks a lot Bob, I understand it now! :)
    Regarding the VMA and VMB it also says "Connector to motor supply..... .....and connected to appropriate bulk capacitance". Does that mean I need another capacitance in addition to the 0.1uF I have going to ground?

    Regards,
    J91.
     
  18. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,412
    2,780
    Jan 21, 2010
    The bulk capacitor is used for energy storage and thus is a larger value. In section 9 the diagram shows a 100uF capacitor. Note that it is shunted by a 0.1uF capacitor.

    The role of this capacitor is to mitigate the effects of lead resistance and inductance.
     
  19. Jessica91

    Jessica91

    10
    0
    Mar 3, 2015
    Thanks, I sort of get the concept behind a capacitor. It can be used after a power supply, too smoothen out the current. While I understand the circuit diagram now, thanks to you guys, I was wondering if I should go with this one:
    [​IMG]
    Or this one:
    upload_2015-4-10_13-36-24.png

    I was just a bit confused since I was told that one was correct, but you are now quoting the original one. And I can now clearly see that my own diagram is lacking a few components. After this I can hopefully start building the circuit.

    Thanks a lot again.

    Regards,
    J91.
     
  20. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,412
    2,780
    Jan 21, 2010
    I'm not ignoring you :) I tried to look at this yesterday on my phone but the limitations of that platform made it quite difficult.

    Now I can see it better, I'll read the datasheet and get back to you.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-