problem with stepper!!


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2007
    Posts
    16

    Default problem with stepper!!

    Hi..

    I am trying to use stepper motor, but i face some problems.

    I need to save the postion of the stepper in the pic16f84a so the stepper must know the start node and the end node.

    The stepper should not continue its moving after end point.If the stepper reverse the direction it should not continue its moving after start point.

    I tryed to use EEPROM,write,read instructions, but there is no result.

    any ideas?

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


    Did you find this post helpful? Yes | No

    Default

    Basically you will need to keep track of how many steps the motor moves. I would guess that the motor will not be allowed to move randomly, so if the "first command" is 20 steps CW " then the second command" of 20 steps CCW would bring it back.

    I the motor can be moved by something else and the "start and end" position needs to be found a simple two position Encoder could be rigged. A switch at each position. When the switch is hit the counting of steps begins.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Apr 2007
    Posts
    16


    Did you find this post helpful? Yes | No

    Default

    I am locking for method that the stepper know where it stands when the power is on or cut-off.

    If the power is cut-off when the stepper -say- at degree 30 cw, if the power turned on , the stepper must know that it stands now at 30 cw degree.

    I sayed that i tryed to save the postion in an variable which is stored at the pic16f84a by using read & write instruction..but the stepper just moves in one direction.

    my code in attchments, it derive the stepper successfully, but the problem in saving position (( forgive me my code is simple because i am beginner in picbasic, i know there is another code which is more simple))...

    any idea??
    Attached Files Attached Files

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


    Did you find this post helpful? Yes | No

    Default

    Here is something to try.

    Add this to the beginning of your program before MAIN and remove lines:
    eeprom 1,[00]
    P VAR BYTE
    read 1,p
    WRITE 1,P
    P=P+1
    P = P-1
    Code:
        cnt var byte        'A VAR for counting the FOR/NEXT
        Pb1	var	byte   'The VAR that is being counted and saved
        P var byte          'The VAR that the saved data is read into to show position
        Plog data 0         'DATA storage area
        
        READ Plog, P        'At program start, reads saved DATA into P
    Now for a SUB routine.
    Code:
        POS_1:              'LABEL
        for cnt = 1 to 1    'Write DATA one time
        Pb1=Pb1+1           'Pb1 is increased by one
        write Plog, Pb1     'Write Pb1 into Plog
        read Plog, P        'Makes P = to Pb1
        pause 100           'Time to write to DATA area
        next                'See if FOR/NEXT is finished
        RETURN              'Return to SENDER
    Put a GOSUB POS_1 inside of all the SUB routines that move the motor. "RIGHT1" for example.
    Last edited by mackrackit; - 7th August 2007 at 16:44.
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. 18f4431; driving a stepper IN HARDWARE mode
    By DDDvvv in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 21st January 2010, 16:49
  2. Replies: 11
    Last Post: - 6th November 2008, 10:27
  3. Controlling stepper motor with PIC
    By The Master in forum Off Topic
    Replies: 3
    Last Post: - 1st July 2008, 10:21
  4. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  5. 1 slave 1 master 1 MAX232 1 problem ?
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 31st July 2005, 22:59

Members who have read this thread : 1

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