How to program PIC16F877A stepper motor revolution [Full circuit & 3/4 Code]


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    I am most likely missing something, but what about this
    Code:
    ForwardM:
    LCDOUT $FE,1
    LCDOUT $FE,$80,"OPENING BLIND"
    LCDOUT $FE,$C0,"DAYLIGHT"
    FOR i = 1 TO 500 ' ?? will equal 10 revolutions ??
    portb = %1100
    pause speed
    portb = %0110
    pause speed
    portb = %0011
    pause speed
    portb = %1001
    pause speed
    NEXT i
    GOTO Main
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Unless you are counting steps (and have limits preset), I see no way of detecting end of travel of your blind, which means you can drive it beyond it's stop position in either open or close mode.

  3. #3
    Join Date
    Nov 2008
    Posts
    3


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    I am most likely missing something, but what about this
    Code:
    ForwardM:
    LCDOUT $FE,1
    LCDOUT $FE,$80,"OPENING BLIND"
    LCDOUT $FE,$C0,"DAYLIGHT"
    FOR i = 1 TO 500 ' ?? will equal 10 revolutions ??
    portb = %1100
    pause speed
    portb = %0110
    pause speed
    portb = %0011
    pause speed
    portb = %1001
    pause speed
    NEXT i
    GOTO Main
    I tried this code but the motor also seems to rotate without stop.

    Quote Originally Posted by Melanie View Post
    Unless you are counting steps (and have limits preset), I see no way of detecting end of travel of your blind, which means you can drive it beyond it's stop position in either open or close mode.
    I thought it's possible to count the motor step (limit the step). Is there anyway to achieve this?

    I've thinking again, how about use the inside sensor, double the sensor to set the stop position. When the blind is open and the 2nd sensor which is located in the room detect the light, it will stop the motor. This is meant the 1st sensor use to start the motor and 2nd sensor use to stop the motor.

    Same thing goes to close operation. if the outside = 0 and the inside = 0 the blind will close.

    to summary this,

    open operation:

    1st sensor = 1 (motor start) then 2nd sensor = 1 (motor stop)

    close operation:

    1st sensor = 0 (motor start) then 2nd sensor = 0 (motor stop)

    My question is, how can i use any label that prevent the motor spinning like the stop/pause function?

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by slapdash View Post
    I tried this code but the motor also seems to rotate without stop.
    I forgot to say i needs to be a word size variable, as a byte it can never reach 500

    I thought it's possible to count the motor step (limit the step). Is there anyway to achieve this?
    If you do not have a preset limit like Melanie mentioned you can make the stepper stop, but it may not always stop in the exact same place. If there is some drag on the mechanism for example.

    You could use a light sensor, but what if there is enough light to start but not stop. Or attach a couple of micro limit switched that a hit on full open or full close. There are many ways to make some sort of encoder. If the blind are only rotating 90 degrees a pot fixed to a blade may work.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    I forgot to say i needs to be a word size variable
    Really ??? Everyone have it's own project
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    Really ??? Everyone have it's own project
    Every one is a smart _ _ _

    The variable "i" needs to be WORD sized.
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    <b>Open Loop Solution</b>
    How powerful is that stepper motor? You know what happens to a stepper motor when it stalls? At worst it demagnetizes, at best, nothing.
    Stepper motors have no commutator, no brushes, no sparks, no increase in current (to speak of), very unlike a brushed motor which gets very Ticked Off when it stalls. So here is a thought, rig up a counter and count the steps between the ends of travel, and drive your motor that many steps + a few extra.
    Last edited by Archangel; - 5th November 2008 at 05:14.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. PIC 16F877A circuit for stepper motor...
    By kristina in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 27th June 2012, 08:13

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