Main Content

Standard Servo Write

Drive servo motor to specified angle

Description

Use this block to control the shaft angle of a servo motor attached to a pulse width modulation (PWM) output pin on the hardware board.

The block input takes a double value:

  • An input value of 0 positions the shaft at 0 degrees

  • An input value of 180 positions the shaft at 180 degrees

  • Any input value between the [0, 180] range, for example 50, positions the shaft at 50 degrees

  • Any input value out of the [0, 180] range, for example -2 or 188, positions the shaft at 0 and 180, respectively

By default, the minimum and maximum pulse durations are chosen to match the expected input for standard hobby servos to produce full range of servo motion. The pulse durations can be modified to customize the range of servo motion.

During simulations without the hardware, this block does nothing. See Block Produces Zeros or Does Nothing in Simulation.

Parameters

Board

Select the specific board you are using. You can find this information on the target hardware, product packaging, or product documentation.

Changing Board updates the Pin choices.

Pin

Select the servo signal pin.

Click View pin map to locate the pin.

Do not specify the same pin more than once within a given model.

Minimum pulse duration

Set the minimum pulse duration of the servo signal in seconds.

By default, this value is 1000e-6 seconds.

Maximum pulse duration

Set the maximum pulse duration of the servo signal in seconds.

By default, this value is 2000e-6 seconds.

Introduced in R2016b