## Phidget RC Servo.lvlib:RCServoSetTargetPosition.vi

If the RC servo motor is configured and `TargetPosition` is set, the controller will continuously try to reach targeted position.

- The target position is bounded by `MinPosition` and `MaxPosition`.

- Using the default settings this position will correspond to the rotation of the servo arm in degrees, for many standard RC servos.

- If the RC servo motor is not engaged, then the position cannot be read.
- The position can still be set while the RC servo motor is not engaged. Once engaged, the RC servo motor will snap to position, assuming it is not there already.
- The units for `TargetPosition`, `VelocityLimit`, and `Acceleration` are configured by scaling the internal timing (set with `MinPulseWidth` and `MaxPulseWidth`) to a user specified range with `MinPosition` and `MaxPosition`.

### Position and Pulse Width

- An RC servo motor's position is controlled using a type of Pulse Width Modulation, sending voltage pulses of a given time span, or Pulse Width to the servo.
- The servo translates the Pulse Width of the control signal to a corresponding position of the servo arm.
- Knowing this, a servo's range of motion can be thought of in terms of a `MinPulseWidth` and a `MaxPulseWidth` corresponding to range of pulse widths that produce the servo arm's full range of movement.

- In Phidget22, you can adjust the `MinPulseWidth` and `MaxPulseWidth` stored by the library to match the desired range of movement you expect from your servo.

- Since directly setting the timing of RC servo pulse widths is not very intuitive for most purpses, we map these pulse widths to a user-defied Minimum and Maximum Position.This allows you to define the servo's position in terms best suited to your application, such as degrees, fractions of a rotation, or even some measure of speed for a continuous-rotation servo.
- By setting the servo's `TargetPosition` to `MaxPosition`, the controller will send pulses of `MaxPulseWidth` to the servo.
  - Similarly, `MinPosition` will send pulses of `MinPulseWidth` to the servo
  - `MaxPosition` can be set smaller than `MinPosition` to invert movement of the servo, if it helps your application.
- Setting a `TargetPosition` will transate the position between `MinPosition` and `MaxPosition` to a corresponding Pulse Width between `MinPulseWidth` and `MaxPulseWidth`, in turn sending the servo arm to the desired position.
- Setting `VelocityLimit` and `Acceleration` for your servo will limit the rate of change of the servo's position in terms of one UserUnit per second (or /s2). Here, a UserUnit is whatever distance is maked by the change of the `TargetPosition` by 1.0

### Adjusting the Servo's Limits

- To tune your program to a specific servo:

1. First adjust the servo's range of motion by setting the `MaxPulseWidth` and `MinPulseWidth`. You can use the default values for these (or the ones on your servo's datasheet) as a starting point.
2. Send the servo to `MaxPosition` and `MinPosition` to check the results. Repeat steps 1 and 2 as nessesarry.
3. Set the `MaxPosition` and `MinPosition` to match whatever numbers you find best suited to your application.

| Device In Device # Identification

| error in (no error) error in can accept error information wired from VIs previously called.

| status status is TRUE (X) if an error occurred or FALSE (checkmark) to indicate a warning or that no error occurred. Right-click the error in control on the front panel and select Explain Error or Explain Warning from the shortcut menu for more information about the error.

| code code is the error or warning code. Right-click the error in control on the front panel and select Explain Error or Explain Warning from the shortcut menu for more information about the error.

| source source describes the origin of the error or warning. Right-click the error in control on the front panel and select Explain Error or Explain Warning from the shortcut menu for more information about the error.

| Target Position The position value 1000_0 (ver: 200, 201) RC Servo Motor Controller: 1000_0 (ver: 300, 312) RC Servo Motor Controller: 1000_0 (ver: 313) RC Servo Motor Controller: 1001_0 (ver: 200, 201) RC Servo Motor Controller: 1001_0 (ver: 300, 302, 312) RC Servo Motor Controller: 1001_0 (ver: 313) RC Servo Motor Controller: 1061_0 (ver: 100) RC Servo Motor Controller: 1061_0 (ver: 200) RC Servo Motor Controller: 1061_1 (ver: 300, 301, 302, 303, 304) RC Servo Motor Controller: RCC0004_0 (ver: 400) RC Servo Motor Controller: 1066_0 (ver: 100) RC Servo Motor Controller: 1066_1 (ver: 100, 101) RC Servo Motor Controller: RCC1000_0 (ver: 106) RC Servo Motor Controller: RCC1000_0 (ver: 110, 111, 120) RC Servo Motor Controller:

| Device Out Same as Device In

| error out error out passes error or warning information out of a VI to be used by other VIs.

| status status is TRUE (X) if an error occurred or FALSE (checkmark) to indicate a warning or that no error occurred. Right-click the error out control on the front panel and select Explain Error or Explain Warning from the shortcut menu for more information about the error.

| code code is the error or warning code. Right-click the error out control on the front panel and select Explain Error or Explain Warning from the shortcut menu for more information about the error.

| source source describes the origin of the error or warning. Right-click the error out control on the front panel and select Explain Error or Explain Warning from the shortcut menu for more information about the error.