servo control via pot ?


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    blainecf's Avatar
    blainecf Guest


    Did you find this post helpful? Yes | No

    Thumbs up add a little more code so you only react to changes

    Performing calculations and a series of reads in a row is your major prob. Here's an idea - (pseudo code):

    #1:

    define prev_value vars

    Loop:
    for i = 1 to 4

    read one pot (based on i)

    check to see if it changed (compared to a previously saved value)

    if changed, calc new value

    pulse_out each of your motors
    next i
    goto loop


    This way you're only doing one A/D read per loop, and only doing the math when the value of the pot changes (multiplication and (even more so) division are clock cycle suckers!

    ------------------

    #2: do away with the gosubs in speed-critical situations. In-line code is harder to read, but faster

    Regards,

  2. #2
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Default

    Thanks , I shall give it a try and post the results tomorrow.

    regards

Similar Threads

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