Documentation Center

  • Trials
  • Product Updates

Contents

Arduino Continuous Servo Write

Set shaft speed of continuous rotation servo motor

Library

Simulink Support Package for Arduino® Hardware/Common

Description

Set the direction and speed of a continuous rotation servo motor:

  • Sending -90 to the block input produces the maximum rate of rotation in one direction.

  • Sending 90 to the block input produces the maximum rate of rotation in the opposite direction.

  • Sending 0 to the block input stops the servo motor.

  • Sending out-of-range values, such as -95 or 200, to the block input has the same effect as sending the minimum or maximum input values.

The characteristics of some motors cause them to continue rotating when the block input value is 0. In that case, you can experiment to find an offset value that stops the motor.

With Arduino Mega 2560 hardware, you can use External mode to determine the offset while your model is running on the hardware. See Tune and Monitor Model Running on Arduino Mega 2560 Hardware.

The block input inherits the data type of the upstream block, and internally converts it to uint8 with an offset of 90.

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

Some limitations:

  • Do not use Servo blocks with External mode.

  • If you use this block in models with the Serial Receive and Serial Transmit blocks, use longer sample times to avoid overruns.

  • The maximum number of Servo blocks per model is 12 for most Arduino boards except for Arduino Mega 2560 hardware where the maximum is 48.

  • With Arduino Uno hardware, the Arduino PWM block cannot use digital pins 9 or 10 when the model contains Servo blocks.

  • With Arduino Nano hardware, the Arduino PWM block cannot use digital pins 9 or 10 when the model contains Servo blocks.

  • With Arduino Mega 2560 hardware, the Arduino PWM block cannot use digital pins 11 or 12 when the model contains more than 12 Servo blocks.

  • With Arduino Due hardware, the Arduino PWM block cannot use digital pins 9 or 10 when the model contains Servo blocks.

Dialog Box

Pin number

Enter the number of the digital pin.

Do not assign the same pin number to multiple blocks within the model.

If you set the Target hardware parameter to:

  • Arduino Mega 2560, enter a pin number from 0 to 53.

  • Arduino Uno, enter a pin number from 0 to 13.

  • Arduino Nano, enter a pin number from 0 to 13.

  • Arduino Due, enter a pin number from 0 to 53.

    Note:   To change the Target hardware parameter, select Tools > Run on Target Hardware > Options.

See Also

| |

External Web Sites

Was this topic helpful?