Servo control woes


Results 1 to 25 of 25

Threaded View

  1. #22
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Cool

    Try this code.
    Schematic and code are also attached.
    ------------------------------------------------------------------------


    @ DEVICE intrc_osc, MCLR_OFF,WDT_OFF,PROTECT_OFF

    DEFINE LCD_EREG PORTA
    ' Set LCD Enable port

    DEFINE LCD_EBIT 7
    ' Set LCD Enable bit

    TRISA=%00100000
    ' RA5=Input, Rest= Output

    TRISB=%01100001
    ' RB6, RB5, RB0 = Input, Rest=Output

    '--------Assign name to ports---------------
    potvar var portb.0
    'Pot is connected to RB0.

    servo var portb.3
    'Servo is connected to RB3.

    Button1 var portb.5
    'Button1 is connected to Portb.5 and increases the frequency.

    Button2 var portb.6
    'Button2 is connected to Portb.6 and decreases the frequency.


    '---------Variables-------------------------
    pulse var byte
    'Variable to hold Pot value for servo Position

    freq var byte
    'Variable to hold Button1 and Button2 adjustments for Frequency

    '--------Initial Setup----------------------
    Freq=18
    'Initial Frequency

    '--------Main Loop-------------------------

    loop:

    IF button1=0 then freq=freq+1
    'Incr freq

    IF button2=0 then freq=freq-1
    'Decr freq

    IF freq>30 then freq=30
    'Max. Low freq

    IF freq<5 then freq=5
    'Max. High Freq

    pot potvar,255,pulse
    'Read pot and store the value in pulse variable

    If pulse>240 then pulse=240
    'Max. Pulse 240mS

    IF pulse<60 then pulse=60
    'Min. Pulse 60mS.

    pulsout servo,pulse
    'pulsout the stored pot value (pulse) to servo pin.

    pause freq

    lcdout $fe,1,"Pulse:",#pulse
    LCDOUT $fe,$c0,"Freq:",#freq


    goto loop

    --------------------------------------------------------------------------
    Attached Images Attached Images  
    Attached Files Attached Files
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

Similar Threads

  1. More Servo Woes
    By chrisshortys in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 13th May 2009, 08:40
  2. Replies: 10
    Last Post: - 26th May 2008, 07:00
  3. Help with Servo Control Please!
    By wireman22 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 7th June 2007, 18:15
  4. Control RC servo via Parallax Servo Control
    By cibotsan in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 17th September 2005, 08:18
  5. Servo control with 12F629
    By achilles03 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd June 2005, 23:34

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