Step motor control


Closed Thread
Results 1 to 23 of 23

Hybrid View

  1. #1
    Join Date
    May 2010
    Posts
    43


    Did you find this post helpful? Yes | No

    Default Re: Step motor control

    thks,but sorry I don't understood,is not problem to write code to I tested,pls.

  2. #2
    Join Date
    May 2010
    Posts
    43


    Did you find this post helpful? Yes | No

    Default Re: Step motor control

    Can you looking this page,
    my motor is ST-28.MAYBE YOU FIND ANSWER!
    http://www.khwelling.nl/cnc/hardware/motor_test.html

  3. #3
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: Step motor control

    You can improve your motor performance in two ways:

    1) Use half step sequence ( here a sample code)

    Code:
    HStep           var byte    [8]     ' Half step sequence array
    B0              var byte
    C0              var byte
    P0              var byte
    W0              var word
    
    TRISB = 0
    
    
    P0 = 50   ' incrementing the delay will reduce the motor speed  (max 255)
    C0 = 0
    B0 = 0
    
    HalfMode:                      
    If C0 = 0 then gosub CW
    C0 = C0 + 1
    if C0 = 2 then C0 = 0
    If C0 = 0 then gosub CW
    If C0 = 1 then gosub CCW
    
    for W0 = 0 to 8192   ' one turn of the gear shaft ( 64 motor turns)
    PortB = HStep[B0]
    B0 = B0+1   
    if B0 = 8 then B0=0
    pause P0
    next W0
    
    Goto HalfMode
    
    CW:        ' half step sequence (clockwise)
    HStep[0] = 1
    HStep[1] = 3
    HStep[2] = 2
    HStep[3] = 6
    HStep[4] = 4
    HStep[5] = 12
    HStep[6] = 8
    HStep[7] = 9
    return
    
    CCW:       ' half step sequence (counter clockwise)
    HStep[0] = 9
    HStep[1] = 8
    HStep[2] = 12
    HStep[3] = 4
    HStep[4] = 6
    HStep[5] = 2
    HStep[6] = 3
    HStep[7] = 1
    return
    
    end
    2) Use a constant current setup to your motor. The simple way is to use a LM317 configured as costant current supply. See the attached schematic (Resistor 33 Ohms 1 watt. Use 24 V dc as an input to the LM317)

    cheers

    Al.
    Attached Images Attached Images  
    Last edited by aratti; - 5th September 2011 at 21:31.
    All progress began with an idea

  4. #4
    Join Date
    May 2010
    Posts
    43


    Did you find this post helpful? Yes | No

    Default Re: Step motor control

    Thks,all for help!!!
    I tired testing all code,I hope I do something!
    Just one question,
    Is possible make some code in picbasic,

    When I start step motor,to start every time to one position,
    example:

    If step motor work some,go to left,go to right,.......
    and I stop power,and turn again,is possible,motor back in some start position,and continue work some function!

    Last edited by dragan77; - 6th September 2011 at 02:20.

  5. #5
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: Step motor control

    Check this thread http://www.picbasic.co.uk/forum/showthread.php?t=12248 perhaps you will Find what you need!

    Cheers

    Al.
    All progress began with an idea

  6. #6
    Join Date
    May 2010
    Posts
    43


    Did you find this post helpful? Yes | No

    Default Re: Step motor control

    This code work very nice!
    Is very precision!
    I testing yes-today!

    Code:
    Delay VAR BYTE
    i VAR WORD
    
    TRISB = 0  ' All outputs.
    
    Delay = 10   ' ~100steps / second
    
    For i = 1 to 1000    '1000 steps forward.
      PORTB = %00000001
      Pause Delay
      PORTB = %00000010
      Pause Delay
      PORTB = %00000100
      Pause Delay
      PORTB = %00001000
      Pause Delay
    NEXT
    
    Pause 2500
    
    For i = 1 to 1000    '1000 steps reverse.
      PORTB = %00001000
      Pause Delay
      PORTB = %00000100
      Pause Delay
      PORTB = %00000010
      Pause Delay
      PORTB = %00000001
      Pause Delay
    NEXT
    But I don't now what is happens,
    work well 5-6 min,and in the moment stop,like some reset happened,I don't now ,
    and start over again,I don't why!

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,617


    Did you find this post helpful? Yes | No

    Default Re: Step motor control

    Hi,
    If it looks like a reset it probably is. There's no bypass capacitor in the schematic, if you don't have that in your circuit make sure you add one. 0.1uf right across the Vdd/Vss pins.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

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