Results 1 to 4 of 4

Thread: Controlling stepper motors

  1. #1
    Registered Z.K.'s Avatar
    Join Date
    Nov 2008
    Location
    USA
    Posts
    20
    Downloads
    0
    Uploads
    0

    Question Controlling stepper motors

    I am posting here as I have an interest in cnc and cnc uses stepper motors though quite a bit more powerful than I have. I have a stepper motor question and I am very new to stepper motors. I bought two small stepper motors to experiment with Pololu - Stepper Motor: Bipolar, 200 Steps/Rev, 28x32mm, 3.8V, 670mA and a easy driver stepper controller from SparkFun that are hooked up to an Arduino with an external supply set to 24v. I modified a program I found, but I am disappointed in the results I am getting. The stepper works, but it is jerky and very slow, sometimes slower than others. Is this normal for stepper motors or do I have something wrong.

    Code:
    /*
      Stepper Test - Test a single Stepper Motor 
      http://www.instructables.com/id/How-to-wire-an-arduino-based-3-axis-CNC-machine/?ALLSTEPS
        
     */
    
    // for duemilanove atmega328 arduino board + easydriver stepper controller
    // dan@marginallyclever.com 2010-06-15
    
    #define DIR1_PIN (11)
    #define STEP1_PIN (11)
    //#define DELAY (1600/10)
    #define BAUD (9600)
    
    void setup()
    {
      Serial.begin(BAUD);
      pinMode(DIR1_PIN,OUTPUT);
      pinMode(STEP1_PIN,OUTPUT);
    }
    
    
    void loop()
    {
      int i=0;
    
      digitalWrite(DIR1_PIN, LOW); // Set the direction.
      delayMicroseconds(100);
      Serial.println(">>");
    
      for (i = 0; i<=3400; i++) // Iterate for 4000 microsteps.
      {
        digitalWrite(STEP1_PIN, LOW); // This LOW to HIGH change is what creates the
        digitalWrite(STEP1_PIN, HIGH); // "Rising Edge" so the easydriver knows to when to step.
        delayMicroseconds(700); // This delay time is close to top speed for this
        //j+=1;
      } // particular motor. Any faster the motor stalls.
    
      
    }


  2. #2
    Registered doorknob's Avatar
    Join Date
    Jan 2010
    Location
    USA
    Posts
    1766
    Downloads
    0
    Uploads
    0
    Do you have the easy stepper driver wired for full steps or for microstepping (and if microstepping, is it set for 1/2 or 1/4 or 1/8)?

    Are you running the stepper "unloaded" or is it driving some kind of load?

    Does the jerkiness go away with larger delays?

    According to the datasheet, there is a minimum step low time of 1 microsecond. Your program sets the step signal low and then in the next instruction sets it high. What is the instruction execution speed of your Arduino? Does the step pulse go low for more than 1 microsecond?


  3. #3
    Registered doorknob's Avatar
    Join Date
    Jan 2010
    Location
    USA
    Posts
    1766
    Downloads
    0
    Uploads
    0
    The more that I think about it, the more that I suspect that you are not allowing for 1 microsecond or more of pulse low time.

    The digital write statement probably translates directly into either a single machine instruction or at most just a few machine instructions. My guess is that each port write instruction probably executes in less than 100 nanoseconds. So it is likely that your step pulse is out of spec for the easy stepper driver board.

    Do you have access to an oscilloscope so that you can verify the pulse width?

    Try putting a delay of a few microseconds between setting the output low and bringing it high again. I understand that the minimum delay that you can specify is probably 3 microseconds, so try that or something close such as 5 microseconds between those two digital write instructions and see if that helps smooth things out.


  4. #4
    Registered Z.K.'s Avatar
    Join Date
    Nov 2008
    Location
    USA
    Posts
    20
    Downloads
    0
    Uploads
    0
    Quote Originally Posted by doorknob View Post
    The more that I think about it, the more that I suspect that you are not allowing for 1 microsecond or more of pulse low time.

    The digital write statement probably translates directly into either a single machine instruction or at most just a few machine instructions. My guess is that each port write instruction probably executes in less than 100 nanoseconds. So it is likely that your step pulse is out of spec for the easy stepper driver board.

    Do you have access to an oscilloscope so that you can verify the pulse width?

    Try putting a delay of a few microseconds between setting the output low and bringing it high again. I understand that the minimum delay that you can specify is probably 3 microseconds, so try that or something close such as 5 microseconds between those two digital write instructions and see if that helps smooth things out.
    Thanks for the response. I have not found any other forum where anyone asked such good questions. At the moment I can't answer them as I don't really know the answer. I do have a scope though so I will check. Thanks again.

    I did have a delay between setting it low and high, but that made it worse. The only thing that made it slightly smoother and faster was increasing the delay to around 700 microseconds.

    Last edited by Z.K.; 04-22-2011 at 04:07 AM. Reason: adding content


Similar Threads

  1. Newbie- need help with controlling stepping motors
    By alaskanCNCguy in forum Stepper Motors and Drives
    Replies: 9
    Last Post: 10-20-2010, 05:15 AM
  2. handwheels controlling motors?
    By bbeide in forum General Metal Working Machines
    Replies: 3
    Last Post: 08-18-2009, 12:03 PM
  3. Controlling Stepper motor driver boards
    By scarr in forum General CNC (Mill and Lathe) Control Software (NC)
    Replies: 4
    Last Post: 01-28-2006, 09:17 AM
  4. SDK or Library for controlling Stepper Control Boards
    By tarquingq in forum General CAM Discussion
    Replies: 0
    Last Post: 12-22-2005, 02:01 PM
  5. controlling stepper motor without pc
    By kerimtemel in forum Hobbycnc (Products)
    Replies: 4
    Last Post: 05-18-2005, 02:29 PM

Posting Permissions



About CNCzone.com

    We are the largest and most active discussion forum from DIY CNC Machines to the Cad/Cam software to run them. The site is 100% free to join and use, so join today!

Follow us on

Facebook Dribbble RSS Feed


Search Engine Friendly URLs by vBSEO ©2011, Crawlability, Inc.