Servo - quasics/quasics-frc-sw-2015 GitHub Wiki

Servos

Servos are their own class of actuators, separate from motors and pneumatic devices.

Rotational Servos

servo

They come in two flavors, Continuous, and angled (stuck between 0 and 180 degrees (generally speaking). Continuous servos are essentially low-powered, directly PWM controlled motors, good for fast response, reasonable torque, and speed (accessory cam gears?).

Standard servos are stuck between 0 and 180 degrees. Give them an angle between those, and it will quickly match and hold that angle.

Linear Servos

linear Actuator

In the second photo is shown a linear servo, which offers linear motion through the same interface as its rotational cousins. It may not recognize full 0-180, so be prepared to set maxes and mins inside of the normal range.

Smart/Programmable Servos

Smart Servo With Remote

These servos can interface with an outside controller to set maximums and minimums, as well as change from continuous to angled servos.

Coding

From a coding perspective, different types of hardware are controlled as a Servo object, but may need to be handled differently.

WPILib provides the capability to control servos that match what they describe as "the common hobby input specification (Pulse Width Modulation (PWM) signal, 0.6 ms - 2.4 ms pulse width)". If you've got a servo that meets those constraints, then you can follow the examples in the Control System docs:

  1. Plug it into a PWM port (e.g., port 2).
  2. Create a Servo object for it in code (e.g., frc::Servo m_servo(2);).
  3. Control its position from code by either:
  • Calling the Set() method to use a scaled value (ranging from 0 to +1.0) to set its position (e.g., m_servo.Set(0.5);)
  • Calling the SetAngle() method, specifying a value in degrees from 0 to 180, though "This method will [only] work for servos with the same range as the Hitec HS-322HD servo".

However, this doesn't work "out of the box" with all hardware.

For example, consider the AndyMark L16 linear actuator:

  • This is controlled at the digital level by sending a PWM-encoded signal that indicates the degree to which the actuator should be extended.
  • The specs for the L16 indicate that:
    • The minimum pulse width (corresponding to full retraction) should have a period of 1 msec.
    • The maximum pulse width (corresponding to full extension) should have a period of 2 msec.
    • The center pulse width (corresponding to 50% extension) should have a period of 1.5 msec.
  • To use a Servo object to control the L16, you would therefore need to configure the "bounds" for the servo (which can be different from the defaults for a Servo, as in this case):
    m_servo.SetBounds(   // C++ method; in Java, it's "setBoundsMicroseconds"
        2.0_ms, // max (would be 2000 for Java; similar changes for the others)
        1.8_ms, // deadbandMax (per docs)
        1.5_ms, // center
        1.2_ms, // deadbandMin (per docs)
        1.0_ms  // min
    );
  • You would then set the desired position of the L16 by calling the SetSpeed() method (as though it were a motor, rather than a simple "WPI-standard" linear servo), and passing in a value from -1.0 (fully retracted) to +1.0 (fully extended):
    m_servo.SetSpeed(+1.0);

External Links