World's Smallest Stepper Motor with Arduino and EasyDriver

World’s Smallest Stepper Motor with Arduino and EasyDriver


This little wonder of electromechanical engineering came from inside a laser diode sled of an HP CT10L Bluray drive I’ve opened some time ago. The device on the picture consists of several parts, all easily fitting on a dime coin: a bipolar stepper motor with lead screw, a linear stage, a lens, and even an end position sensor (I’ve yet to make use of the sensor though). The entire assembly is only 14mm x 9mm x 4mm. This post is about making this tiny motor move. Keep reading!

There is a tiny bipolar stepper motor inside the HP CT10L sled

There is a tiny bipolar stepper motor inside the HP CT10L sled

The picture on the left shows the location of the stepper inside an HP CT10L laser diode sled, in case you feel like you need one for yourself. I bought a bunch of broken laptop Bluray drives on eBay with only the blue/violet (405nm) laser diode in mind but was quite surprised to find this miniature linear stepper assembly inside and just had to see it move. Besides, I needed a bipolar stepper motor test circuit for another project I’m working on, and proving the test circuit on this little curiosity just made it more fun.

I based the tester on EasyDriver by Brian Schmalz – an open source bipolar stepper motor driver board based on Allegro A3967 driver chip. A3967 makes connecting a stepper motor to an MCU, such as Arduino, very easy by taking care of the stepping sequences and, more importantly, microsteps. The latter would be rather difficult to implement on Arduino – an MCU that does not have a DAC on board. EasyDriver makes the job even easier by providing all outputs of A3967, which is an SMD IC, in an easily breadboarded DIP package.

Arduino EasyDriver Bipolar Stepper Test Circuit

Arduino EasyDriver Bipolar Stepper Test Circuit


Here is the circuit schematics. It contains bare minimum parts, thanks to the EasyDriver board carrying most of what’s needed for the A3967. I have breadboarded the circuit so as to be able to reconfigure it easily for different motors, and the breadboard is pictured in second part of the video. The Arduino sketch that provides the controls and creates the STEP and DIR signals for EasyDriver board is below.

Please note that the sketch is written to only send to the EasyDriver board a particular number of steps upon pressing the STEP button (unless you depress the button earlier than the steps can be completed in which case it stops and step count resets) because for testing of unknown motors I needed to be able to count how many steps does it take for one full revolution. You can easily adjust this line of code: int stepsPassedMax = 160; that presumes 20 steps per revolution. 160 is there because A3967 driver has 1/8th microstep enabled by default, so 20*8=160. Additionally, if you need this for continuous stepper rotation, the step counter can be easily removed from the program.

So, here is what I’ve found out about the nano-sized stepper and the linear stage assembly:

  • It’s a 20 steps per revolution bipolar stepper.
  • The windings are 27.1Ω
  • The windings are most likely energized from the 1.8V source in the Bluray drive. I’ve used Arduino’s 3.3V output for the load supply of A3967 to simplify the setup. The motor gets slightly warm after a few minutes but the load current can also be adjusted on EasyDriver board to alleviate that
  • The linear stage has 2.5mm travel and it gets there in 14 full rotations. So, in theory, you can position this lens (or whatever else you choose to mount on it instead) with pretty darn good precision:
    it’s 0.179 mm lead step (thread step) and A3967 can take 160 steps (winding energizing steps) to complete one rotation, so, it’s a whopping 0.00111 mm or, in other words, 1.1 micron per step. This is millimeters, by the way, not to confuse with thousands of an inch. Sounds like it could be used for positioning of samples under a microscope by someone who does not want to shell out $500 for a professional positioning stage. Just a thought …
  • The end position sensor has three wires coming out of it and is most likely an LED/photodiode pair – I’ve yet to do more research on that. but it’s nothing short of amazing how they managed to put it in the assembly!
  • Closer look at the nano-sized bipolar stepper inside the Bluray drive

    Closer look at the nano-sized bipolar stepper inside the Bluray drive

    The thumbnail picture on the left here appears to be three times the real size of the assembly on my 19″ 1280×1024 monitor – just so you can get a feel of how tiny this thing is. So, there you have it: an interesting source of (almost) free parts that could be used for crazy accurate positioning for your optical or laser tests as well as microscopy. I presume my readers will find dozens of other uses for the world’s smallest bipolar stepper linear actuator.

    Arduino code for the test circuit follows:

    /* 
    EasyDriver stepper test sketch
     
    This example code is in the public domain.
    
    http://elabz.com/
    
     */
    
    // constants won't change. They're used here to 
    // set pin numbers:
    const int stepPin = 1;     // the number of the step pin
    const int directionPin = 0;     // the number of the step pin
    const int stepOut = 2;
    const int directionOut = 3;
    const int ledPin =  13;      // the number of the LED pin
    
    // Variables will change:
    int ledState = LOW;         // the current state of the output pin
    int stepState = HIGH;             // the current reading from the step pin
    int lastStepButtonState = LOW;   // the previous reading from the step pin
    
    int directionState;             // the current reading from the direction pin
    int currentDirectionState; // to keep last direction value
    int lastDirectionButtonState = LOW;   // the previous reading from the step pin
    bool enableDirectionChange = false;
    int stepsPassed = 0; //how many steps?
    int stepsPassedMax = 160; // trying to calculate steps per revolution (remember the microstepping settings 1/8th is default)
    // most small and micro steppers, especially those that came from a CD- or DVD-R/RW drives 
    // have 20 steps per revolution. So 160 mircosteps should make the motor spin 360 degrees once.
    
    long lastStepDebounceTime = 0;  // the last time the output pin was toggled
    long lastDirectionDebounceTime = 0;  // the last time the output pin was toggled
    long debounceDelay = 50;    // the debounce time; increase if the output flickers
    
    long stepDelay = 2; // 500 steps per second
    long lastStepTime = 0; // last time the step signal was sent
    
    void setup() {
      pinMode(stepPin, INPUT);
      pinMode(directionPin, INPUT); 
      pinMode(stepOut, OUTPUT);  
      pinMode(directionOut, OUTPUT);
      pinMode(ledPin, OUTPUT);
    }
    
    void loop() {
      // read the state of the switch into a local variable:
      int readingStep = digitalRead(stepPin);
    
      // check to see if you just pressed the button 
      // (i.e. the input went from LOW to HIGH),  and you've waited 
      // long enough since the last press to ignore any noise:  
    
      // If the switch changed, due to noise or pressing:
      if (readingStep != lastStepButtonState) {
        // reset the debouncing timer
        lastStepDebounceTime = millis();
      } 
      
      if ((millis() - lastStepDebounceTime) > debounceDelay) {
        // whatever the reading is at, it's been there for longer
        // than the debounce delay, so take it as the actual current state:
        stepState = readingStep;
      }
    
    
    
    int readingDirection = digitalRead(directionPin);  
     if (readingDirection != lastDirectionButtonState) {
        // reset the debouncing timer
        lastDirectionDebounceTime = millis();
      } 
      
        if ((millis() - lastDirectionDebounceTime) > debounceDelay) {
        // whatever the reading is at, it's been there for longer
        // than the debounce delay, so take it as the actual current state:
    
        if(readingDirection == HIGH && enableDirectionChange) {
         //change in state
           currentDirectionState = !currentDirectionState ;
           enableDirectionChange = false;
        }else
        {
          if(readingDirection == LOW)
          {
            enableDirectionChange = true;
          }
          
        }
      }
      
      
      
      // set the LED using the state of the button:
      digitalWrite(ledPin, currentDirectionState);
      digitalWrite(directionOut, currentDirectionState);
      
      // save the reading.  Next time through the loop,
      // it'll be the lastButtonState:
      lastStepButtonState = readingStep;
      lastDirectionButtonState = readingDirection;
    
    if(stepState == LOW) // send step signals now
    {
      if((millis() - lastStepTime) > stepDelay) // delay expired, send another step
        {
            if(stepsPassed < stepsPassedMax)
            {
            digitalWrite(stepOut, LOW);
            stepsPassed++;
            }
            lastStepTime = millis();
        }else
        {
          
          digitalWrite(stepOut, HIGH);
        }
    }else{
     stepsPassed = 0; //reset steps count  
    }
    
    
    }
    

27 Responses to “World’s Smallest Stepper Motor with Arduino and EasyDriver”

  • [...] out the super macro video of this Tiny Bi-Polar Stepper Motor being controlled with an Arduino. This great part was scavenged from a blu-ray player.  This cute little motor has only 20 steps [...]

  • neil:

    looking every where for this type of code forward backward start just one more bit of code would have been perfect
    stop i’m making a coil winder i have no clue about writing code how would you add a stop in your code

    • Thanks for stopping by, Neil. Sorry I did not quite understand the question: the stepper stops as soon as you release the “Step” button (one that’s connected to the stepPin input). So no special stopping procedure is required in the software.

      Also, stepper motors are self-holding their position while connected to an energised driver, i.e. it will take considerable force to move it after the driver stopped commutating the windings as it’ll tend to stay where the driver left it, so to speak. Were you looking for some kind of a dynamic brake? I don’t believe it’s possible with the Allegro driver I used (the EasyDriver board). But maybe I just misunderstood what you’re looking for, please clarify.

      • Oops! I looked at the code one more time and I think I understand it now. The code “as is” will NOT stop until all the stepsPassedMax = 160 variable has been reduced to zero, so it will have to send all 160 steps to the motor. I used it to calculate the steps per revolution, that’s why it’s configured so unusually.

        To stop as soon as the button gets released, replace lines 104-108

                if(stepsPassed < stepsPassedMax)
                {
                digitalWrite(stepOut, LOW);
                stepsPassed++;
                }
        

        with just

                digitalWrite(stepOut, LOW);
        

        Sorry, it’s been a couple of months since I wrote this.
        Cheers!

  • Kim:

    I am looking for a smaller one like this one
    http://www.youtube.com/watch?v=M8ywly7rLnc

    I have been opening CD and DVD drives and so far found one that had a tiny stepper for linear motion also some of the laptop floppy drives have these steppers for the head linear motion, none as small as the one in the video.
    Kim

    • The one in your video actually looks just like your “normal” laptop stepper motor except that it does not have the screw for the linear motion. I have spent (er… wasted) enough time a couple of months ago trying to “upgrade”, as it were, the motor and install a screw with smaller pitch. I would say much of what I did would be needed to convert the motor from linear to rotary movement.

      From that experience I can say that unfortunately you cannot just cut the linear screw off to convert the stepper to rotary movement. I am assuming that’s what you need given that the motor in the video had just a short stub of the spindle sticking out on which, I presume, you would want to mount a load of some sort that needs to rotate very slowly and controllably, right?

      Well, anyhow, the laptop CD/DVD/Bluray drives (as well as their desktop counterparts) are missing one very important part that is needed to make that happen – the second bearings in the body where the screw is coming out. It does not look like such a big deal until you realise that the rotor is so loose inside the windings that missing the proper bearings to hold it in the very center of rotation it will just stick (magnetically) to the winding and won’t move at all. The laptop motors with linear screws have this bearing located at the far end of the screw. So, it’s not completely missing, it’s just located in the spot that you would need to cut off in order to convert it into a rotating stepper.

      Sorry for the long winded answer, it just touched upon a frustration I had just recently trying to work with these CD/DVD/Bluray steppers. They are nice little motors but they have to be used just the way they are – linear screw and all – there’s absolutely no room for any modification.

      • Kim:

        Yes that’s exactly the problem all the ones made for linear motion has the second bearing at the end of the linear screw, making it useless for other applications.

        Here is 6mm version I am looking for, the ones from faulhaber would be quite expensive
        http://www.faulhaber-group.com/n126024/n.html

        Also was looking for one that can run under 25mA per phase so you can drive it directly with a microchip. A quartz watch also has a stepper motor but difficult to modify it for any other application.

        There are some 8-10mm motors available from China for cheap, if you google you can find them
        http://www.alibaba.com/product-gs/434688755/TS_0810_8mm_micro_stepper_motor.html?s=p
        I’ll update you if I find any good 6mm stand alone ones at reasonable prices.

        Kim

        • Thanks, Kim, yes, I would appreciate a heads up if you find one without the screw. In fact, even the slightly larger 8mm would be just fine for me, and the 6mm would be just a bonus. Like you, I’m looking for quantities much less than 100 :)

          Anyhow, running them directly from an MCU would be tough on the MCU as well as on any positioning accuracy. These little steppers seem to waste a lot of energy to make any movement, I think it would be hard to eliminate the need for the H-bridge to energise them. The actual power consumption will depend on your application, obviously, but I have that DVD-CNC setup http://elabz.com/dvd-cnc-laser-cutter-diy-concept/ which I’ve yet to finish or even advance enough to post more about it which consumes 1.5A (that’s right, about 60 times more than what you need) when all 3 steppers are running. It’s using 2 slightly larger desktop DVD steppers and one small laptop stepper. It needs to move quite a bit of metal though, so if your load is light, you may be able to bring it down to milliamps but I’m not too sure about 25mA.

          Have you looked into tiny DC motors, such as vibrators from cell phones, controlled with PWM at very low duty cycle? I don’t know anything about your load but if it’s uniform enough, you may be able to create slow rotations by lowering the PWM pulse width to the point where it *just* moves. May have the same effect as a slowly rotating stepper, much simpler to control and much less energy to consume.

        • Just found a picture of the DVD-CNC laser cutter with 3 motors running that has the DC power supply in the background showing 1.53A current going to the device.
          http://elabz.com/forums/post-your-projects/dvd-cnc-diy-laser-cutting-project/
          Well, it should be noted that the laser diode’s circuitry consumes about 160mA and the driver itself consumes about 200mA (drivers for all three motors). There’s a little 5V fan, also running from that DC power supply.

          Still, the three motors are enjoying the rest of the current – approx 1A – and are getting somewhat warm in the process. At the end of the cut that took about 10 minutes to complete the laptop motor (the one that carries the laser diode bracket) got really hot, the larger desktop ones were just warm.

          The supply voltage shows 5.2V – bit too high for the laptop motor and will definitely be too high for an even smaller 6mm one.

  • arie:

    Hi admin, thanks for your post,

    I’m wondering if you have an estimate on the lower bound of the current this motor can operate on ?
    I’m trying to find a itty-bitty motor for a little gadget i have in mind and power delivery is an issue in this one so I wonder – can it run on as low as 10-20 ma ? (or ideally less) ?

    Thanks.
    A.

    • Hi Arrie,

      I think you can make it move without any load at approx. 20-25mA. What kind of useful job should be done by it anyway? The current might go up significantly if there’s a sizeable load.

  • arie:

    thanks, that makes sense.

    I wanted to hook a planetary gearbox to it and make it drive a lead screw..
    Need to get one of those motors and play with it.
    I saw that on ebay they don’t currently have the blueray unit in “broken” condition and i don’t feel like shelling out 40$ for a blueray to take it apart.

    Do you think it is possible to get the motor standalone ?is there a model number or something on it ?

    Thanks again.
    Arie.

    • I’ve seen these motors sold on eBay individually around $10 (not sure whas the shipping was – it would be sent from China, obviosuly). Look for 8mm micro stepper or something to that effect – this is how they are usually called there, and they already have the lead screw. In other words, you would not be able to add a gearbox but, given that this is a stepper motor, you can make it move very slow through controlling the stepping sequence. I hope you understand that this is not a regular brushed DC motor and it needs a controller like the one described in this post.

  • Martin Szymanski:

    Thanks for this project. I used part of the code to make a stepper drive for remote variable control. You can see it on Youtube at. http://youtu.be/5T3lzy-ROZs
    Martin S.

    • Thanks for stopping by and telling about your project, Martin! It’s pretty cool, and I like your two-button multifunction interface! How big is the cap though? Some of those I’ve encountered in the past have been rather difficult to turn and I just wanted to say that if you need an absolutely precise positioning, don’t count on microsteps – if the torque load is high for the motor, it may skip a microstep or several. In fact, if it’s high enough, it might skip a full step as well. But microsteps are especially unreliable if you rely on them for absolute positive positioning.
      Thanks again for stopping by,
      Cheers!

      P.S. I like your nick at Gmail! And you did say the variable cap is for vacuum. Hmm… sounds like a beginning of an interesting story … :)

  • Randy:

    Hi there! This is a great inspirational project. Quick question? What is the value of your pull-down resistors?
    I look forward to updating you on my current project provided I can get it working.

  • Randy:

    I am very sorry for the very noob questions but I am just getting started in Arduino. I am trying to implement your source code into an Arduino Pro-Micro as in the one here https://www.sparkfun.com/products/11098. Your schematic above is a bit confusing for a new guy like me. Would your sketch run fine if I connected the digital out/in pins (0,1,2,3) of my pro-micro as you did in your nano? I looked up the pin outs on the nano and the pin locations on your schematic and its throwing me off. I assume the schematic is just a representation and not really the pin locations on the board. The Easydriver is easy enough to connect but I’m a bit confused on my Arduino connections. Thanks for taking your time to guide me.

    • Hi Randy,

      I should think the sketch will run on Pro-Micro just fine, as long as you are hooking it up to the outputs labeled as digital I/O 0,1,2,3 and 13 (if you use the direction indicator LED). Be sure to select the proper board in the Arduino IDE before you compile/upload the sketch. I could not find Por-Micro in the list of board in the version I’m using ( 1.0.2 ) but I have a feeling just “Micro” is close enough. It’s under Tools -> Board -> Arduino Micro

      When you say it’s throwing you off, what exactly is happening? The Arduino board does very little in this sketch, all the really heavy lifting is done by the Easydriver board, so which part of the sketch does not work?

      I have to hit the road now, will check here when I return tonight. In the meantime, if you wanted to post more about your application and your issues, it’s better to use the forums because they allow for image uploads, videos and advanced formatting – could be useful for troubleshooting. Check here: http://elabz.com/forums/help-and-feedback/

  • [...] stepper-driven linear stage. So, I decided to modify an earlier Arduino sketch I wrote for testing the world’s smallest stepper motor to make it a bit more useful (and clean any bugs in the process). Keep reading to see what came out [...]

  • [...] at the equator and add a couple of tiny set screws. Motor: I need a small, slow, precise motor. Something like this would probably be great. It may even be TOO small. LEDs/Circuit Board: I was trying to decide between etching my own [...]

  • If instead of the EasyDriver we use just two resistors:

    One side of both coils is fed with 2.5V (enable on A0) and we pull and push the other side of the coils using A1 and A2.
    Using analog inputs because these have far more juice than the digital pins.
    The enable goes to the common coil side with a resistor, then that goes to ground with an identical resistor.
    The other sides of the coils will pull on 0V and push on 5V whenever enabled, and have to be 0V whenever disabled.

    • Luis, thanks for the idea! What you are proposing is similar in spirit to another scheme we’ve discussed here on this blog over the last couple of years: Driving a bipolar stepper with ULN2803 but in that case what I’ve found is that at least 1/2 of the available energy is wasted by the resistors and so you actually need twice the juice to make the same work. That and, of course, this tiny stepper is a bipolar stepper which means that you need to be able to both source and sink current on each of the four leads, not just on A1 and A2. Also, there’s not much power available – Atmega328 only sinks/sources 40mA per output.

      How do you know analog I/O can supply more current? That’s not in the datasheet, at least I’ve never seen it.

  • Lego:

    I found that out by burning a led that wasn’t supposed to burn…

    This is from the summary of the atmega family datasheets…

    The PC5…0 output buf- fers have symmetrical drive characteristics with both high sink and source capability.

    I’m trying to get my hands on one…

Leave a Reply

Or use the Forums ! If your comment is a question, please consider posting it to a matching section of our Electronics Forums. The forums allow for a more natural conversation flow, especially if multiple replies are required. Additionally, you'll be able to style your writing (bold font, italics etc.) and post images which can help with a good answer.

Notify me of followup comments via e-mail. You can also subscribe without commenting.

Tools

Coming soon ...

Recent Comments
  • Mark Needham: Hey mirceboy, I am using a toggle switch, SPDT center off. I will manually start/stop, or a micro...
  • Jeff R: Can you please give me some details about how to reformat the code from milliseconds to microseconds so I can...
  • admin: You would have to reformat the code to start using microseconds instead of milliseconds for the time...
  • Jeff R: Thanks for posting, this was exactly what I was looking for. I’m using the Sparkfun SM-42BYG011-25...
  • mirceboy: Hello, this is perfect and im new with arduino, can you please tell me if its possible to change the code...
  • admin: That sounds great! Sorry I did not have a chance to follow your previous comment. But in general terms this is...
  • Mark: Hi Sir. Just dropped by to report that I have made the unipolar stepper motor rotated clockwise and...
  • Mark: All right sir I got it. Like any other post in some websites, I have found out that pins 5&6 (which are...
  • admin: If we are talking about unipolar (not bipolar, as in the title of this post), then yes, you may have the 5-pin...
  • Mark: Hi Sir it’s me again Mark. Just wanted to ask another one thing sir. Just wanted to ask if there are such...
Meta