Electronic – Servo position with no pulse

picpwmservo

I am using a PIC 16F884 to run 2 motors and 2 servos. The motors are using the onboard PWM module, and I am bit banging PWM for the servos on Timer 2.

With only one servo being controlled, it works perfectly, but when I add a second servo control, the timing becomes off because of the number of commands that are being issued during the interrupt period (at least this is what I've seen when I've hooked it up to an oscilloscope).

My question is: Can I issue a command to a servo, wait until its reached to proper position, then turn off the pulse and expect it to maintain position? If this is the case, then I should be able to control both servos with 1 timer.

I saw a similar question here: Will a servo hold its position without a signal? with no definitive answer.

Best Answer

A specific type of servo motor, a latching servo, is required for holding position after the control signal is removed.


Depending on the specific servo in use (see caveats below), an alternative "poor man's latching servo" can be implemented thus:

  • Control the power supply line for the servo with a high side switch, either a P-MOSFET or for high power servos, an SSR.
    • Low side switching is not suggested, as disconnecting the ground path may cause unpredictable behavior due to the control signal losing ground reference.
  • After allowing the servo time to achieve desired position, disable the servo power before removing the control signal.
  • For changing position, start the control signal, then enable power to the servo.

Caveats:

  • The servo needs to be of a high reduction ratio / high torque type, so that small forces applied to the arm while it is unpowered, do not cause the arm to rotate.
  • Not all servos can tolerate a control signal arriving while supply power is absent. While some will suffer damage to the internal electronics (not too likely), I have at least one servo that tries powering its motor from the control signal, ergo microcontroller pin damage.

Side Note:

Servo control signals are not actually PWM but a variant, pulse duration modulation: Servo position is not defined by the PWM duty cycle (i.e., ON vs OFF time) but only by the duration of the pulse. As long as it is anywhere in a range of (typically) 40 Hz to 200 Hz, the exact value of the frame rate is irrelevant. The servo expects to see a pulse every so many ms, this can vary within a wide range that differs from servo to servo.

This is relevant because the OP's requirement can be meet by generating consecutive pulses of desired durations for each driven servo, with a lot of flexibility in the time taken between a pulse for Servo A, and a pulse for Servo B, for example. The servos would thus be fed their control pulses in round Robin fashion.

As pointed out by Dave Tweed in comments, using the acronym PDM can be confusing, as that is also applied to Pulse Density Modulation, yet another special case variant of PWM.

Related Topic