Some questions regarding a servo motor's data sheet.


Results 1 to 37 of 37

Threaded View

  1. #14
    Join Date
    Aug 2006
    Location
    In a world of german electrons
    Posts
    102


    Did you find this post helpful? Yes | No

    Default

    On a 16f628a
    Code:
    @ DEVICE MCLR_OFF
    @ DEVICE hs_osc
    @ DEVICE wdt_off
    @ DEVICE lvp_off
    @ DEVICE protect_off
    
    Define OSC 20
    INTCON = 0
    CMCON = 7
    TRISA = 0
    TRISB = 0
    
    StepsRotating CON 93
    RotatingMin CON 267
    RotatingMax CON 1218
    
    
    Position VAR WORD
    PositionBefore VAR WORD
    Counter VAR WORD
    PositionBefore = 0
    LR VAR BYTE
    RotatingPos VAR WORD
    Movement VAR WORD
    
    ServoMotor VAR PORTB.1
    
    GOSUB RoutineStartingPos
    
    ES:
    LR = 1
    RotatingPos = RotatingMin
    ES_HS: 
    ES_HS_Drehung:
    WHILE 1 = 1
        IF LR = 1 THEN
            WHILE RotatingPos < RotatingMax
                GOSUB RoutineRotate
                RotatingPos = RotatingPos + StepsRotating           
            WEND
            LR = 0
        ENDIF
        IF LR = 0 THEN
            WHILE RotatingPos > RotatingMin
                GOSUB RoutineRotate
                RotatingPos = RotatingPos - StepsRotating           
            WEND
            LR = 1
        ENDIF 
    WEND
    END
    
    RoutineRotate:   
        FOR Movement = 0 TO 1000 / 20   
            Low ServoMotor
            Pulsout ServoMotor,RotatingPos
            Pause 20
        NEXT Movement 
        RETURN
    
    RoutineStartingPos:
        FOR Counter = 0 TO 1000 / 20 
            Low ServoMotor
            Pulsout ServoMotor,(RotatingMax+RotatingMin)/2
            Pause 20
        NEXT Counter 
        RETURN
    Last edited by selbstdual; - 5th May 2008 at 13:58.
    Be well - whoever you are.

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 04:47
  2. Read/Write Problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th February 2010, 01:51
  3. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21
  4. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 14:50
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 28th November 2004, 23:56

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