Results 1 to 12 of 12

Thread: how to control stepper motor

  1. #1
    Registered
    Join Date
    May 2007
    Location
    egypt
    Posts
    6
    Downloads
    0
    Uploads
    0

    how to control stepper motor

    Hi all
    I am new here and i need some help to build my first machine,what i need now (how to control stepper motor).
    i have three stepper motors taken from hp deskjet printer,and after searching i found that they are unipoler 6wire 2phase.
    so i need to know what to do after this.
    Thanks


  2. #2
    Registered
    Join Date
    Feb 2006
    Location
    USA
    Posts
    102
    Downloads
    0
    Uploads
    0
    Hmedich,

    A good thing for you to do would be to study the information at
    http://www.cs.uiowa.edu/~jones/step/ to get a better understanding
    of stepper motors, and controlling them.

    What you do next depends on a number of things. First what
    specific printer did those motors come from? Are they all identical?
    A six wire motor could be used as UNIPOLAR or BIPOLAR.
    Few motors from laser printers are powerful enough to do any real
    work without a lot of extra gearing. One exception are motors from
    HP Laserjet IID & IIID printers, these are around 100 Oz. Inch motors.
    They make a decent entry level motor.
    (http://www.cnczone.com/forums/attach...achmentid=5238)

    What is the size of the machine you wish to eventually build and what types
    of material do you plan to use it with?

    What is your experience with electronics? Have you ever worked with designing
    your own circuits for anything? Can you Identify electronics components?
    Are you comfortable with soldering electronics components into a printed circuit board?

    Depending on these factors and a few others, you could purchase pre built controllers,
    kits to build controllers from, or you could build your own from plans and schematics
    linked from postings on the CNCZone.
    http://www.cnczone.com/forums/open_source_controller_boards/
    Mike_L

    When I was younger I thought I knew EVERYTHING,
    NOW, the older I get the more I find out I don’t know!


  3. #3
    Registered
    Join Date
    May 2007
    Location
    egypt
    Posts
    6
    Downloads
    0
    Uploads
    0

    scratch_6057

    thanks for ur reply
    i doesn't know to mush about electronic but I am working in the computer field and i am fast learner.
    all i need now,just to make the motors move after this i take the next step.
    the motors i have is PM55l.
    i guess at first i will purchase the board, but i need to know how to choose the controller and driver,and which one work with which one.
    thank those links


  4. #4
    Registered pminmo's Avatar
    Join Date
    Jun 2003
    Location
    St. Peters, Mo USA
    Posts
    3325
    Downloads
    0
    Uploads
    0
    Might be some info on my website that would be helpfull to you.
    Phil, Still too many interests, too many projects, and not enough time!!!!!!!!
    Vist my websites - http://pminmo.com & http://millpcbs.com


  • #5
    Registered
    Join Date
    Jun 2007
    Location
    india
    Posts
    44
    Downloads
    0
    Uploads
    0
    great links scratch!!
    i dont know sqat!!! will be asking dumb questions


  • #6
    Registered
    Join Date
    Jun 2007
    Location
    india
    Posts
    44
    Downloads
    0
    Uploads
    0
    i just read on one of these threads of someone using a wind shield wiper motor.
    ??
    i dont know sqat!!! will be asking dumb questions


  • #7
    Registered
    Join Date
    Dec 2006
    Location
    Clw, FL
    Posts
    526
    Downloads
    0
    Uploads
    0
    Quote Originally Posted by shashank ayyar View Post
    i just read on one of these threads of someone using a wind shield wiper motor.
    ??
    probably for spindle, not as replacement for steeper i would think...


  • #8
    Registered
    Join Date
    Jun 2007
    Location
    india
    Posts
    44
    Downloads
    0
    Uploads
    0
    currently ease of use,simplicity,cost concerns etc push me towards steppers.plus i wont require much accuracy.even if i use somethig totell me about missed steps,what do i do about them??
    i dont know sqat!!! will be asking dumb questions


  • #9
    Registered
    Join Date
    Jan 2005
    Location
    Toronto, Canada
    Posts
    1464
    Downloads
    0
    Uploads
    0
    A properly designed stepper system will have no missing steps.


  • #10
    Gold Member dertsap's Avatar
    Join Date
    Oct 2005
    Location
    canada
    Posts
    3886
    Downloads
    0
    Uploads
    0
    http://www.hobbycnc.com/4aupc.php

    hobbycnc has their old control boards on for a pretty cheap price
    i don t think youll be able to find anything cheaper of the same quality


  • #11
    imo
    imo is offline
    Registered
    Join Date
    May 2007
    Location
    england
    Posts
    1
    Downloads
    0
    Uploads
    0

    A little help

    New herenot sure if i am in the right pace
    Can anyone tell me how to use two stepper motors on the x axis as regards to wireing,i am useing mach 3.
    Thanks


  • #12
    Registered
    Join Date
    Dec 2008
    Location
    USA
    Posts
    1
    Downloads
    0
    Uploads
    0

    Linux Univelop 4\5 Axis Stepper Driver

    I just got my Univelop 4\5 Axis controller today. I wanted to write C++ user mode code to control the steppers. The interface is parallel.

    ~~~~~~~~~~~~~~~~~~ univelop.h start ~~~~~~~~~~~~~~

    /*******************************************************************************
    *
    * Name: Univelop.h
    * Purpose: Allow for easy control of Univelop CNC 4\5 Axis board in user mode
    * Tested On: Ubuntu 8.10
    * Programmer: Ludvik Jerabek
    * Date: 12\1\2008
    * Version: 1.0.0
    * License: GPL - This is provided as is with no warranty.
    * Realease Notes:
    *
    * Initial Release 1.0.0 - 12\1\2008 - Ludvik Jerabek
    *
    *
    *******************************************************************************/

    #ifndef __UNIVELOP_H__
    #define __UNIVELOP_H__

    #include <stdlib.h>
    #include <unistd.h>
    #include <sys/io.h>
    #include <sys/perm.h>

    class Univelop5Axis
    {
    public:
    enum ROTATION { CW , CCW };

    // Constructor
    Univelop5Axis( unsigned int port , bool implement_stop = true ) :
    _baseport(port) , _implement_stop(implement_stop) , x(0) , y(0) , z(0) , a(0) , c(0) ,
    x_delay(1200) , y_delay(1200) , z_delay(1200) , a_delay(1200) , c_delay(1200)
    {
    ioperm(_baseport,3,1);
    outb( 0 , _baseport );
    // Cut set C axis to nothing...
    outb( 0x08 , _baseport + 2 );
    usleep( 1500 );
    }

    // Destructor
    ~Univelop5Axis()
    {
    ioperm(_baseport,3,0);
    }

    // The following function return true if Aux,XLimit,YLimit,ALimit,ZLimit,Stop terminals on the
    // driver bored are closed. In the event of a normally closed switch logic must be reversed.
    bool IsSetAux() { return ((inb( _baseport + 2 ) & 0x01) != 0) ; }
    bool IsSetXLimit() { return ((inb( _baseport + 1 ) & 0x08 ) == 0); }
    bool IsSetALimit() { return (( inb( _baseport + 1 ) & 0x10 ) == 0); }
    bool IsSetZLimit() { return ( ( inb( _baseport + 1 ) & 0x20 ) == 0); }
    bool IsSetStop() { return ((inb( _baseport + 1 ) & 0x40 ) == 0); }
    bool IsSetYLimit() { return (( inb( _baseport + 1 ) & 0x80 ) != 0); }

    // Function Set[XYZAC]Pos allows for a forcible setting of the virtual axis value.
    // Most likely this would be used if calibrating using a limiter the stepper
    // start position.
    int64_t SetXPos( int64_t pos ) { int64_t old = x; x = pos; return old; }
    int64_t SetYPos( int64_t pos ) { int64_t old = y; y = pos; return old; }
    int64_t SetZPos( int64_t pos ) { int64_t old = z; z = pos; return old; }
    int64_t SetAPos( int64_t pos ) { int64_t old = a; a = pos; return old; }
    int64_t SetCPos( int64_t pos ) { int64_t old = y; c = pos; return old; }

    // Functions will retrieve the virtual positon of the axis.
    int64_t GetXPos() { return x; }
    int64_t GetYPos() { return y; }
    int64_t GetZPos() { return z; }
    int64_t GetAPos() { return a; }
    int64_t GetCPos() { return c; }

    // Funtions are used to Set\Get delay values of the axii. Delay tuning is nessessary to tweek
    // performance of the steppers. In some cases delays can be too low preventing axii from
    // stepping.
    useconds_t SetXDelay( useconds_t delay ) { useconds_t old = x_delay; x_delay = delay ; return old; }
    useconds_t GetXDelay( ) { return x_delay; }
    useconds_t SetYDelay( useconds_t delay ) { useconds_t old = y_delay; y_delay = delay ; return old; }
    useconds_t GetYDelay( ) { return y_delay; }
    useconds_t SetZDelay( useconds_t delay ) { useconds_t old = z_delay; z_delay = delay ; return old; }
    useconds_t GetZDelay( ) { return z_delay; }
    useconds_t SetADelay( useconds_t delay ) { useconds_t old = a_delay; a_delay = delay ; return old; }
    useconds_t GetADelay( ) { return a_delay; }
    useconds_t SetCDelay( useconds_t delay ) { useconds_t old = c_delay; c_delay = delay ; return old; }
    useconds_t GetCDelay( ) { return c_delay; }

    // Function will move an Axis to a virtal postion relative to it's current position
    // Function arguments are virtual position , time between steps
    // Function returns the virtual position prior to moving
    int64_t MoveXTo( int64_t pos , useconds_t usec_delay )
    {
    int64_t last = x;
    if( last == pos )
    return last;
    if( last > pos )
    StepX( last - pos , CCW , usec_delay );
    if( last < pos )
    StepX( pos - last , CW , usec_delay );
    return last;
    }

    // Function will move an Axis to a virtal postion relative to it's current position
    // Function arguments are virtual position , time between steps
    // Function returns the virtual position prior to moving
    int64_t MoveYTo( int64_t pos , useconds_t usec_delay )
    {
    int64_t last = y;
    if( last == pos )
    return last;
    if( last > pos )
    StepY( last - pos , CCW , usec_delay );
    if( last < pos )
    StepY( pos - last , CW , usec_delay );
    return last;
    }

    // Function will move an Axis to a virtal postion relative to it's current position
    // Function arguments are virtual position , time between steps
    // Function returns the virtual position prior to moving
    int64_t MoveZTo( int64_t pos , useconds_t usec_delay )
    {
    int64_t last = z;
    if( last == pos )
    return last;
    if( last > pos )
    StepZ( last - pos , CCW , usec_delay );
    if( last < pos )
    StepZ( pos - last , CW , usec_delay );
    return last;
    }

    // Function will move an Axis to a virtal postion relative to it's current position
    // Function arguments are virtual position , time between steps
    // Function returns the virtual position prior to moving
    int64_t MoveATo( int64_t pos , useconds_t usec_delay )
    {
    int64_t last = a;
    if( last == pos )
    return last;
    if( last > pos )
    StepA( last - pos , CCW , usec_delay );
    if( last < pos )
    StepA( pos - last , CW , usec_delay );
    return last;
    }

    // Function will move an Axis to a virtal postion relative to it's current position
    // Function arguments are virtual position , time between steps
    // Function returns the virtual position prior to moving
    int64_t MoveCTo( int64_t pos , useconds_t usec_delay )
    {
    int64_t last = c;
    if( last == pos )
    return last;
    if( last > pos )
    StepC( last - pos , CCW , usec_delay );
    if( last < pos )
    StepC( pos - last , CW , usec_delay );
    return last;
    }

    // Will step the stepper steps number of times in ROTATION direction with a delay between each step.
    // Function argument is number of steps , ROTATION direction, time between steps
    // Function returns the new virtual axis position
    int64_t StepX( const unsigned int steps , const ROTATION rotation = CW , useconds_t usec_delay = 0)
    {
    for( unsigned int i = 0; !( _implement_stop && IsSetStop() ) && i < steps ; i++ ) { StepX( rotation ) ; usleep(usec_delay); }
    return x;
    }

    // Will step the stepper steps number of times in ROTATION direction with a delay between each step.
    // Function argument is number of steps , ROTATION direction, time between steps
    // Function returns the new virtual axis position
    int64_t StepY( const unsigned int steps , const ROTATION rotation = CW , useconds_t usec_delay = 0)
    {
    for( unsigned int i = 0; !( _implement_stop && IsSetStop() ) && i < steps ; i++ ) { StepY( rotation ); usleep(usec_delay); }
    return y;
    }

    // Will step the stepper steps number of times in ROTATION direction with a delay between each step.
    // Function argument is number of steps , ROTATION direction, time between steps
    // Function returns the new virtual axis position
    int64_t StepZ( const unsigned int steps , const ROTATION rotation = CW , useconds_t usec_delay = 0)
    {
    for( unsigned int i = 0; !( _implement_stop && IsSetStop() ) && i < steps ; i++ ) { StepZ( rotation ); usleep(usec_delay); }
    return z;
    }

    // Will step the stepper steps number of times in ROTATION direction with a delay between each step.
    // Function argument is number of steps , ROTATION direction, time between steps
    // Function returns the new virtual axis position
    int64_t StepA( const unsigned int steps , const ROTATION rotation = CW , useconds_t usec_delay = 0)
    {
    for( unsigned int i = 0; !( _implement_stop && IsSetStop() ) && i < steps ; i++ ) { StepA( rotation ); usleep(usec_delay); }
    return a;
    }

    // Will step the stepper steps number of times in ROTATION direction with a delay between each step.
    // Function argument is number of steps , ROTATION direction, time between steps
    // Function returns the new virtual axis position
    int64_t StepC( const unsigned int steps , const ROTATION rotation = CW , useconds_t usec_delay = 0)
    {
    for( unsigned int i = 0; !( _implement_stop && IsSetStop() ) && i < steps ; i++ ) { StepC( rotation ); usleep(usec_delay); }
    return c;
    }

    // Will step the stepper one time in the direction of CW or CCW
    // Function argument is the ROTATION direction
    // Function returns the new virtual axis position
    int64_t StepX( const ROTATION rotation = CW )
    {
    if( _implement_stop && IsSetStop() ) return x;
    int state = inb( _baseport ) & 0xFC;
    if( rotation == CW ) { outb( state | 0x02, _baseport ); x++; } else x--;
    usleep( x_delay );
    outb( state | 0x01, _baseport );
    usleep( x_delay );
    outb( state , _baseport );
    usleep( x_delay );
    return x;
    }

    // Will step the stepper one time in the direction of CW or CCW
    // Function argument is the ROTATION direction
    // Function returns the new virtual axis position
    int64_t StepY( const ROTATION rotation = CW )
    {
    if( _implement_stop && IsSetStop() ) return y;
    int state = inb( _baseport ) & 0xF3;
    if( rotation == CW ) { outb( state | 0x08, _baseport ); y++; } else y--;
    usleep( y_delay );
    outb( state | 0x04 , _baseport );
    usleep( y_delay );
    outb( state , _baseport );
    usleep( y_delay );
    return y;
    }

    // Will step the stepper one time in the direction of CW or CCW
    // Function argument is the ROTATION direction
    // Function returns the new virtual axis position
    int64_t StepZ( const ROTATION rotation = CW )
    {
    if( _implement_stop && IsSetStop() ) return z;
    int state = inb( _baseport ) & 0xCF;
    if( rotation == CW ) { outb( state | 0x20 , _baseport ); z++; } else z--;
    usleep( z_delay );
    outb( state | 0x10 , _baseport );
    usleep( z_delay );
    outb( state , _baseport );
    usleep( z_delay );
    return z;
    }

    // Will step the stepper one time in the direction of CW or CCW
    // Function argument is the ROTATION direction
    // Function returns the new virtual axis position
    int64_t StepA( const ROTATION rotation = CW )
    {
    if( _implement_stop && IsSetStop() ) return a;
    int state = inb( _baseport ) & 0x3F;
    if( rotation == CW ) { outb( state | 0x80 , _baseport ); a++; } else a--;
    usleep( a_delay );
    outb( state | 0x40 , _baseport );
    usleep( a_delay );
    outb( state , _baseport );
    usleep( a_delay );
    return a;
    }

    // Will step the stepper one time in the direction of CW or CCW
    // Function argument is the ROTATION direction
    // Function returns the new virtual axis position
    int64_t StepC( const ROTATION rotation = CW )
    {
    if( _implement_stop && IsSetStop() ) return c;
    int state = (inb( _baseport + 2 ) & 0xF3) | 0x08;
    if( rotation == CW ) { outb( state | 0x04 , _baseport + 2 ); c++; } else c--;
    usleep( c_delay );
    outb( state & 0xF7 , _baseport + 2 );
    usleep( c_delay );
    outb( state , _baseport + 2 ); // Original off state..
    usleep( c_delay );
    return c;
    }

    operator unsigned int() { return _baseport; }
    private:
    unsigned int _baseport; // Port to be used to communicat with the stepper driver
    bool _implement_stop; // Used to do internal checking of the stop pin
    // This is used to keep track of a virtual axis position + or -
    int64_t x;
    int64_t y;
    int64_t z;
    int64_t a;
    int64_t c;
    // Delays are used when setting parallel port pins.
    // Too short a delay will cause motor not to step (1200) default for each axis
    useconds_t x_delay;
    useconds_t y_delay;
    useconds_t z_delay;
    useconds_t a_delay;
    useconds_t c_delay;
    };

    #endif


    ~~~~~~~~~~~~~~~~~~ univelop.h end ~~~~~~~~~~~~~~

    ~~~~~~~~~~~~~~~~main.cpp~~~~~~~~~~~~~~~~~
    #include <stdio.h>
    #include "univelop.h"

    void PrintState( Univelop5Axis& r )
    {
    printf( "AuxState: %d\n" , r.IsSetAux() );
    printf( "StopState: %d\n" ,r.IsSetStop() );
    printf( "XlimState: %d\n" ,r.IsSetXLimit() );
    printf( "YlimState: %d\n" ,r.IsSetYLimit() );
    printf( "ZlimState: %d\n" ,r.IsSetZLimit() );
    printf( "AlimState: %d\n" ,r.IsSetALimit() );
    printf( "Base + 0: %d\n" , inb( r ));
    printf( "Base + 1: %d\n" , inb( r + 1 ));
    printf( "Base + 2: %d\n" , inb( r + 2 ));
    printf( "Testing stepper X movement\n");
    r.StepX( 500 , Univelop5Axis::CW);
    r.StepX( 500 , Univelop5Axis::CCW);
    printf( "Testing stepper Y movement\n");
    r.StepY( 500 , Univelop5Axis::CW);
    r.StepY( 500 , Univelop5Axis::CCW);
    printf( "Testing stepper Z movement\n");
    r.StepZ( 500 , Univelop5Axis::CW);
    r.StepZ( 500 , Univelop5Axis::CCW);
    printf( "Testing stepper A movement\n");
    r.StepA( 500 , Univelop5Axis::CW);
    r.StepA( 500 , Univelop5Axis::CCW);
    printf( "Testing stepper C movement\n");
    r.StepC( 500 , Univelop5Axis::CW);
    r.StepC( 500 , Univelop5Axis::CCW);
    usleep( 1000000 );
    }

    #define BASEPORT 0x378

    int main( int argc , char* argv[] )
    {
    Univelop5Axis u5a(BASEPORT);
    PrintState(u5a);
    printf("LastPos: %qi\n",u5a.MoveXTo( 24 , 5000 ));
    printf("CurrPos: %qi\n",u5a.GetXPos());
    printf("LastPos: %qi\n",u5a.MoveXTo( -24 , 5000 ));
    printf("CurrPos: %qi\n",u5a.GetXPos());
    printf("LastPos: %qi\n",u5a.MoveXTo( 0 , 5000 ));
    printf("CurrPos: %qi\n",u5a.GetXPos());
    }


    ~~~~~~~~~~~~~~~~~main.cpp end ~~~~~~~~~~~~~~~~~~~~~~
    Attached Files Attached Files
    Last edited by Ludio; 12-01-2008 at 02:21 AM. Reason: Adding comments to the code...


  • Similar Threads

    1. Stepper Motor Control Upon Startup
      By tonofsteel in forum General Electronics Discussion
      Replies: 1
      Last Post: 07-24-2006, 07:56 PM
    2. Standalone Stepper Control
      By WeCheat in forum General Electronics Discussion
      Replies: 53
      Last Post: 01-18-2006, 05:42 PM
    3. Stepper Motor Control Basics
      By Halfnutz in forum Stepper Motors and Drives
      Replies: 12
      Last Post: 05-24-2005, 02:40 PM
    4. servos motor controled by stepper motor driver?
      By mike10 in forum Servo Motors and Drives
      Replies: 1
      Last Post: 01-03-2005, 06:05 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.