Motor Stepper Example


Closed Thread
Results 1 to 40 of 135

Hybrid View

  1. #1
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

    Default Re: Motor Stepper Example

    Hi Henrik,

    thanks a lot for the advice.

    in order to send for example 200 pulses for one revolution, do i need to give for i = 200 to do the revolution label so many times as the i ?

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Motor Stepper Example

    Yes, exactly!
    By the way, you seem to have your TRIS settings backwards, a set bit makes the pin an input, a cleared bit makes it an output.

    I haven't actually tested the following so please see it as an overall idea and not verified/working code:
    Code:
    DEFINE OSC 4
    
    StepCount VAR WORD   ' Distance to move
    Delay VAR WORD          ' Time, in us, between each step-pulse
    i VAR WORD                 ' General purpose index/counter variable
    
    But VAR PortB.2
    Dir_Pin VAR PortB.4
    Step_Pin VAR PortB.5
    
    CW CON 0
    CCW CON 1
    
    CMCON = 7
    ANSEL = 0
    TRISB = %11001111   ' PortB4-5 outputs, rest are inputs.
    
    Main:
      If But = 0 THEN
         StepCount = 200   ' Distance to move motor
         Delay = 2000        ' 2000us between each step
         Dir_Pin = CCW    
         Gosub MoveMotor
      ENDIF
    Goto Main
    
    END
    
    MoveMotor:
      For i = 0 to (StepCount - 1)
        Gosub StepIt
        PauseUs Delay
      NEXT
    RETURN
    
    StepIt:
        Step_Pin = 1     ' Generate a 10us wide pulse on the step pin.
        PauseUs 10
        Step_Pin = 0
    RETURN
    /Henrik.

  3. #3
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

    Default Re: Motor Stepper Example

    ops my bad, you are right, TRISB must be otherway round.

    1 is inpupt and 0 is output.

    Apart from than i will compile the code and try to run it and test it tomorrow.

    will keep you updated. Let me print first the jig and fixture models so i can test the steps easier.

    thanks a lot.

  4. #4
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

    Default Re: Motor Stepper Example

    today i will try to build the models but will be ready for testing tomorrow. So please give me some time. thanks a lot.

  5. #5
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

    Default Re: Motor Stepper Example

    I have promised you to show you the jig and fixture Mode for the stepper Motor with 1.8* degree and 200 steps per revolution. I have ONLY built 2 parts from the assembly.

    For your reference checking the design on the Page 2.

    Please find attached pictures. The other 2 parts which is the Base and the columns will be ready tomorrow.
    Attached Images Attached Images    
    Last edited by astanapane; - 4th March 2013 at 19:56.

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Motor Stepper Example

    Wow! I don't know much about 3d-printing but those pieces looks very profesional, nice work!
    What's the end application, is it only for experimenting/learning about step-motors or are these pieces going to be used for some specific application?
    Again, nice work indeed!

    /Henrik

  7. #7
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

    Default Re: Motor Stepper Example

    hi Henrik,

    thanks a lot. the models are from a Fortus 400mc system designed in a 3D CAD.

    The specific model is only a jig and fixture part. I designed it for helping me to learn how to move step by step the motor.

    But the end application will be based on the following.

    a small gear is attached on the small gear and will drive the big gear.
    Attached Images Attached Images     

Members who have read this thread : 4

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