Documentation Center

  • Trials
  • Product Updates

Contents

Arduino Standard Servo Read

Get position of standard servo motor shaft in degrees

Library

Simulink Support Package for Arduino® Hardware/Common

Description

Measure the angle of a standard servo motor shaft in degrees, from 0 to 180.

The data type of the block output is uint8.

During simulations without the hardware, this block emits zeroes. 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.

    Note   The Servo Read block returns the last written value through the Servo Write block. Therefore, while using a Servo Read block in a model, make sure that there is a corresponding Servo Write block to get correct results.

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.

Sample time

Specify how often this block reads a servo motor angle, in seconds. Enter a value greater than zero. This value defaults to a sample time of 1 seconds. The minimum value is 0.000001 second.

Smaller values require the processor to complete the same number of instructions in less time, which can cause task overruns.

See Also

| | |

External Web Sites

Was this topic helpful?