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

    How do you think you loaded?
    I tried to test it and no-load, but it is the same.
    problem is that when running the operation is complete, not return to the same starting point, but perhaps the real fault of a few steps, and I really should be the precise.

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


    Did you find this post helpful? Yes | No

    Default Re: Step motor control

    Going by your code it seems that you have a unipolar motor (6 wires) and 4 switches (transistors or whatever). If so, using pulsout is not the best way since there will be a short delay between each pulsout statement where no current is flowing in any of the coils. When no current is flowing the torque drops and the rotor can "jump" to the closest natural step (magnetic pole).
    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
    Now, there are other ways to "produce" the step sequence than this rather crude one but try this and see if it helps.

  3. #3
    Join Date
    May 2010
    Posts
    43


    Did you find this post helpful? Yes | No

    Default Re: Step motor control

    Thks for help HenrikOlsson,
    is work but is not precision,make mistake every 5-6 circle working.
    I use this step motor,ST-28 have 5 wire uni polar step motor,
    this is specification:

    Rated voltage: 12VDC
    Current: 32mA
    Resistance/phase: 280
    Fases: 4
    Angle/step: 5.625 deg
    Gear ratio: 1:64
    detent torque: 350gfcm (0.034Nm)
    pull-in torque: 6360g (0.059Nm)
    max. starting pulse rate:700pps
    max. slewing pulse rate:1400pps
    max. speed: 20.5 rpm
    steps/rev: 2048 (tested!!)
    connector order:

    B2: Blue
    B1: Pink
    A2: Yellow
    A1: Orange
    GND: Red

    And one more question in your code I will see you dont use this like in my 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 here dont have i whay

    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
    and tell is when I change speed of motor maybe I must change some number of steps,of some else... I dont now!!!
    Last edited by dragan77; - 5th September 2011 at 19:02.

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


    Did you find this post helpful? Yes | No

    Default Re: Step motor control

    Can you post the wiring diagram?

    Al.
    All progress began with an idea

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


    Did you find this post helpful? Yes | No

    Default Re: Step motor control

    Hi,
    It's not easy to say what the problem is. It might be that you need to start even slower than ~100Hz and then ramp up the step frequency, in order to see if that is the case increase the pause time between each step to something like 25ms.

    The above is also the answer to how you change the speed. There's the DELAY variable which, in my example gets assigned the value of 10. Between each step there's a delay of 10ms, change that and the motor speed changes.

    A schematic of how you have it wired would help too. Usually you run step motors at much higher voltage than what they are rated for and then limit the current. For unipolar drive this was usually done by big series resistors. In todays bipolar drives it's done thru chopping/PWM.

    With PBP you don't need to specify anything with the NEXT statement. It automatically belongs to the FOR that is "closest to it". You CAN definitely add a variable to the NEXT for added clarity but it's not needed.

    Finally, you say the motor has a step angle of 5.625 degrees, that's 360/5.625=64 steps/rev. Then you have a gearbox with a ratio of 1:64, so 64*64 is 4096 and not 2048 as you've stated....something isn't correct there but it's not related to your problem so it doesn't really matter right now.

    /Henrik.

  6. #6
    Join Date
    May 2010
    Posts
    43


    Did you find this post helpful? Yes | No

    Default Re: Step motor control

    HI,
    do you now what is hapend,
    when I write this code:

    Delay VAR BYTE
    i VAR WORD

    TRISB = 0 ' All outputs.

    Delay = 10 ' ~100steps / second

    For i = 1 to 512
    PORTB = %00000001
    Pause Delay
    PORTB = %00000010
    Pause Delay
    PORTB = %00000100
    Pause Delay
    PORTB = %00001000
    Pause Delay

    NEXT

    Pause 1500

    For i = 1 to 512
    PORTB = %00001000
    Pause Delay
    PORTB = %00000100
    Pause Delay
    PORTB = %00000010
    Pause Delay
    PORTB = %00000001
    Pause Delay
    NEXT
    My motor turn round 360 degrees, and back - 360 degrees ,1 time!!!

    and when I write this code:

    Delay VAR BYTE
    i VAR WORD

    TRISB = 0 ' All outputs.

    Delay = 10 ' ~100steps / second

    For i = 1 to 4096
    PORTB = %00000001
    Pause Delay
    PORTB = %00000010
    Pause Delay
    PORTB = %00000100
    Pause Delay
    PORTB = %00001000
    Pause Delay

    NEXT

    Pause 1500

    For i = 1 to 4096
    PORTB = %00001000
    Pause Delay
    PORTB = %00000100
    Pause Delay
    PORTB = %00000010
    Pause Delay
    PORTB = %00000001
    Pause Delay
    NEXT
    my motor turn round 360 degrees,and back - 360 degrees, 4 time is correct?
    Last edited by dragan77; - 5th September 2011 at 19:32.

  7. #7
    Join Date
    May 2010
    Posts
    43


    Did you find this post helpful? Yes | No

    Default Re: Step motor control

    this is schema:
    Attached Images Attached Images  

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


    Did you find this post helpful? Yes | No

    Default Re: Step motor control

    Hi,
    Yes, if the motor/gearbox requires 4096 steps to turn one revolution the first piece of code will move 360 degrees forward and then 360 degrees back. There are 4 "steps" each time thru the FOR-NEXT loop so 512*4=4096.

    In the second piece of code it'll move 1440 degrees forward and then 1440 degrees back.

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