Shop OBEX P1 Docs P2 Docs Learn Events
Execution times - Page 2 — Parallax Forums

Execution times

2»

Comments

  • LawsonLawson Posts: 870
    edited 2011-03-04 21:16
    One thing to keep in mind is that most servos don't like getting pulses quicker than 20ms. If the pulses come fast enough, the servo can even go unstable. Spacing servo pulses longer than 20ms will just reduce output torque and add a bit of audible hum.

    In pseudo code I think your code needs to go like this:
    read ping range into RAW
    wait (18ms - RAW)
    do calculations
    pulse the servo.
    repeat

    Executing a quick pulseout on an open pin would be one of the more precise ways to do the wait after the ping.

    Lawson


    *Edit* now that I've actually read Mr. CTWARDELL's code I see that he's already doing what I suggest. You could add a moving average filter to smooth out the servo motion? (i.e. SERVO = NEW * n + (1-n)*SERVO where 'n' is some binary fraction)
Sign In or Register to comment.