Main Content

RC Servo

Radio control servomotor with PWM-based angular position tracking and fault modeling

  • RC Servo block

Libraries:
Simscape / Electrical / Electromechanical / Brushed Motors

Description

The RC Servo block represents a small DC motor with a gearbox and control circuitry, commonly used in quadcopters, radio-controlled planes and helicopters, and other mechatronic devices. RC servos provide angular position control of the output shaft over a limited angle range. The angle demand is set by the pulse width of a PWM signal applied to port s.

The RC Servo block models the following effects:

  • Torque-speed behavior based on DC motor equations

  • Position tracking based on the input PWM signal pulse width

  • Internal gear reduction ratio, including associated friction losses

  • Mechanical end stops, to prevent the output shaft being driven out of range by the load

  • Position measurement error

  • Fault modeling

The motor equations are the same as those used by the DC Motor block, except that the inductance is not modeled. The RC Servo block determines the equation parameters using the stall torque and no-load speeds, and makes a correction to take account of the backdrive torque.

Faults

The RC Servo block allows you to model several types of fault:

  • Fail off — No electrical torque.

  • Fail forward — Rotates in a positive direction to hit the upper end stop.

  • Fail reverse — Rotates in a negative direction to hit the lower end stop.

  • Failed winding — Torque is applied only if the motor rotor lines up with one of the two remaining functioning windings.

The block can trigger fault events:

  • At a specific time.

  • When a current limit is exceeded for longer than a specific time interval.

If you want to trigger a fault at a specific time, set the Fault trigger parameter to Temporal. If you want to determine whether a system fails and, if so, when it fails, set the Fault Trigger parameter to Behavioral.

You can choose whether to issue an assertion when a fault occurs, by using the Reporting when a fault occurs parameter. The assertion can take the form of a warning or an error. By default, the block does not issue an assertion.

Variables

To set the priority and initial target values for the block variables prior to simulation, use the Initial Targets section in the block dialog box or Property Inspector. For more information, see Set Priority and Initial Target for Block Variables.

Nominal values provide a way to specify the expected magnitude of a variable in a model. Using system scaling based on nominal values increases the simulation robustness. Nominal values can come from different sources, one of which is the Nominal Values section in the block dialog box or Property Inspector. For more information, see System Scaling by Nominal Values.

Assumptions and Limitations

  • This block has no optional thermal port.

  • If you simulate the model with a fixed-step solver, for example, using a local solver, the step size must be small enough to get the required resolution of the input pulse width. For fast desktop simulation, use this block with variable step solvers.

Ports

Conserving

expand all

Electrical conserving port associated with the PWM control signal. The output shaft angle demand is set by the pulse width of the voltage applied to this port.

Electrical conserving port associated with the motor positive terminal.

Electrical conserving port associated with the motor negative terminal.

Mechanical rotational conserving port associated with the rotor.

Mechanical rotational conserving port associated with the stator (casing).

Parameters

expand all

Electrical Torque

Maximum load torque that the RC servo can move without stalling (stopping).

Time for the output shaft to turn 60 degrees when the motor is driving no load.

DC supply voltage used when measuring stall torque and time to travel 60 degrees.

Output shaft angular range of the RC servo.

Input pulse widths corresponding to the minimum and maximum output angles, as defined by the Rotational range parameter. Pulse widths outside of this range are clipped by the block to stay within this range.

Control

Threshold voltage for pulse control. The input pulse is detected as high when the voltage between the s and - ports is above this level.

Electrical impedance measured between the s and - ports.

Minimum error allowed between the demanded and measured output shaft angle. When the error between the demanded output shaft angle and measured output shaft angle drops below the angle resolution, the motor is powered off. This parameter models the hysteresis usually incorporated into an RC servo controller to prevent chatter around a set point.

Model error in angle measurement. This parameter allows you to model an angle measurement error, such as can happen due to a failing potentiometer angle sensor. For example, if you want to model the motor being powered against one of the hard stops, you can set a suitable angle measurement error to achieve this.

Mechanical

Load torque required to backdrive the motor when it is unpowered. The block uses this value to determine the gear friction parameters.

Reduction ratio from the DC motor shaft to the RC servo output shaft. This parameter affects only the impact of rotor inertia on equivalent inertia value at the output shaft. It has no impact on no-load speed. Therefore, the value does not have to be precise.

Inertia of the DC motor, plus inertia of the gearing reflected to the rotor (typically small if the gears are plastic).

Mechanical end stops prevent rotation of the output shaft beyond the specified range. The range specified by the end stop angles must be larger than that specified by the Rotational range parameter.

Stiffness of mechanical end stops.

Damping of mechanical end stops.

Faults

Select Yes to enable faults modeling. The associated parameters in the Faults section become visible to let you select the reporting method and specify the trigger mechanism (temporal or behavioral).

Choose whether to issue an assertion when a fault occurs:

  • None — The block does not issue an assertion.

  • Warn — The block issues a warning.

  • Error — Simulation stops with an error.

Dependencies

To enable this parameter, set Enable faults to Yes.

Select the type of fault:

  • Fail off — No electrical torque.

  • Fail forward — Rotates in a positive direction to hit the upper end stop.

  • Fail reverse — Rotates in a negative direction to hit the lower end stop.

  • Failed winding — Torque is applied only if the motor rotor lines up with one of the two remaining functioning windings.

Dependencies

To enable this parameter, set Enable faults to Yes.

Since R2023a

Set this parameter to Temporal to enable time-based fault triggering.

Set this parameter to Behavioral to enable behavioral fault triggering.

Dependencies

To enable this parameter, set Enable faults to Yes.

Simulation time at which the block enters the faulted state.

Dependencies

To enable this parameter, set Fault trigger to Temporal.

Current threshold to a fault transition. If the current exceeds this value for longer than the Time to fail when exceeding maximum permissible current parameter value, then the block enters the faulted state.

Dependencies

To enable this parameter, set Fault trigger to Behavioral.

Maximum length of time that the current can exceed the maximum permissible value without triggering the fault.

Dependencies

To enable this parameter, set Fault trigger to Behavioral.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2017b

expand all

See Also