Main Content

Verify ArduPilot RC Transmitter Input with RC Receive Block

This example shows how to test your RC transmitter n Simulink® using the RC Receive block in UAV Toolbox Support Package for ArduPilot® Autopilots. You can verify RC functionality on both the host target (simulation environment) and ArduPilot-based flight controller hardware.

This example shows how to:

  • Read raw RC channel data into Simulink from a Pixhawk flight controller.

  • Monitor status information such as flight mode, RSSI, arming status, and emergency stop state.

  • Apply trimming and deadzone settings to RC inputs using ArduPilot’s onboard configuration.

  • Test RC input in both hardware and simulation (host target) environments.

The RC Receive block reads RC channel data transmitted from your RC transmitter. It supports up to 16 RC channels, and provides access to additional vehicle and status information from the flight controller.

For more information on the compatible RC protocols, see Radio Control Systems — Copter documentation .

Prerequisites

Before you begin:

Required Hardware

  • ArduPilot-compatible flight controller. This example uses Pixhawk 6x.

  • USB cable.

  • RC receiver and transmitter supported by ArduPilot protocols. This example uses an FS i6.

Connect Hardware

  1. Connect Pixhawk 6x to your host Computer using a USB cable.

  2. Connect the SBUS pins of the RC Receiver to the RC IN port of Pixhawk 6x, as shown in this image.

Configure RC Receiver Parameters

  1. In the Mission Planner click Connect to establish a connection with the flight controller.

  2. Go to Setup > Radio Calibration and perform the steps mentioned in Radio Control Calibration — Copter documentation .

    Move the sticks and switches on your RC transmitter. The green channel bars in Mission Planner should move in real time.

  3. Complete the calibration process as prompted.

    This process sets the following RC input parameters for each channel (1–16):

    • - RCx_MIN (minimum PWM)

    • - RCx_MAX (maximum PWM)

    • - RCx_TRIM (neutral point)

    (where x is the channel number, 1–16)

Configure and Run Simulink Model

Perform these steps to set up your Simulink model to receive and interpret RC input.

  1. Open MATLAB® and create a new Simulink® model.

  2. Add RC Receive block.

    Double-click anywhere in the model canvas. In the quick insert menu that appears, enter RC Receive. A list of blocks appears. Verify that the RC Receive block from the UAV Toolbox Support Package for ArduPilot Autopilots library is selected. Check the library name listed under the block name and the block description in the pane to the right of the search results.

    Add the RC Receive block to the model by pressing Enter.

  3. Configure the Simulink model to use Pixhawk 6X.

    1. In the Simulink model, go to Modeling> Model Settings.

    2. In the Configuration Parameters dialog box, navigate to Hardware Implementation > Hardware board and select ArduPilot Pixhawk 6X from the drop-down list.

    3. Click Apply and OK.

  4. Set Up RC Channels in the Block.

    • By default, channels 1–4 are included.

    • Add or remove channels using the Add or Delete buttons in the block dialog. The number of RC channels you need depends on your specific application and hardware. For example, quadcopters typically require at least 4 channels (throttle, pitch, roll, yaw).

  5. Choose data type for each channel.

    • Raw Data: The unprocessed PWM value received from the RC transmitter.

    • Using trim & deadzone: The raw values processed according to the trim (RCx_TRIM) and deadzone (RCx_DZ) parameters set in Mission Planner (see Config > Full Parameter List).

    Note

    If you have already set trims on your RC transmitter and do not intend to use the parameters, select Raw Data.

  6. Verify the trim and deadzone output from the RC Receive block by comparing it with the calculated value. For more information, see How Trim and Deadzone Output is Calculated in the RC Receive Block.

  7. In the RC Receive block parameters dialog box, click Advanced and select these additional outputs:

    • Flight Mode

    • Arming Status

    • Emergency Stop Status

Configure Flight Mode Switching

  1. In the Mission Planner, assign the FLTMODE_CH parameter to the desired RC channel for flight mode switching.

  2. Click Write Params to save the change.

  3. Go to Setup > Mandatory Hardware > Flight Modes in Mission Planner to map flight modes to different RC input ranges. This allows you to map specific flight modes to different ranges of values on the assigned RC channel.

    The block outputs the flight mode index, which is a number (starting from 0) that corresponds to the position of the selected flight mode in your Mission Planner configuration. For example, STABILIZE has an index of 2, Loiter has an index of 11, and RTL has an index of 10. The index value indicates which flight mode is currently selected. For more information, see Flight Mode Mapping.

    Note

    If the flight mode change mode change fails, the block retains the previous flight mode value.

Configure Arming and Emergency Stop

  1. In Mission Planner, go to Config> User Params.

  2. Assign the Arm/Disarm (4.2 and higher) and Motor Emergency Stop options to different RC channels.

    For example, assign arming to channel 5 and emergency stop to channel 6.

    These functions activated when the RC channel value reaches maximum, and deactivated when the value is at its minimum.

    • The arm output is 1 when the system is armed, and 0 when disarmed.

    • The emergency stop output is 1 when active, and 0 inactive.

Initiate Monitoring and Tuning

  1. Disconnect Mission Planner.

  2. In the Simulink model, go to the Hardware tab.

  3. Click Monitor & Tune to run the model and connect to your hardware.

Test RC Inputs and Vehicle Status

  1. Vary RC channel inputs on your transmitter and observe the corresponding channel values and vehicle status outputs in real time.

  2. Failsafe Verification:

    By default, the RC Receive block outputs the failsafe status. To test this functionality, turn off the RC transmitter while the model is running; the failsafe output should switch to 1 indicating loss of signal and activation of the failsafe mode.

Test in Simulation Mode (Host Target)

You can test your Simulink model and RC Receive block in simulation mode, without needing physical flight controller hardware. This is known as Host Target mode.

  1. Set the Hardware Board to Host Target.

    • In the Simulink model, click Modeling > Model Settings.

    • In the Configuration Parameters dialog, navigate to Hardware Implementation > Hardware board.

    • Select ArduPilot Host Target from the hardware board drop-down list.

  2. Connect to Mission Planner.

    • Run your Simulink model and open Mission Planner. Mission Planner should automatically detect and connect to your Simulink model via UDP.

    • If Mission Planner does not connect automatically, manually connect Mission Planner to the correct UDP port used by the model.

  3. Read and verify the following RC data.

    • RC channel data.

    • Flight mode

    • Arming status

    • Emergency stop status

    • The workflow for reading and interpreting these signals is the same as when using hardware.

Emulating RC Rx/Tx Behavior in SITL

In Software-in-the-Loop (SITL) simulation, there is no physical RC transmitter or receiver. Instead, you must emulate RC channel inputs to test your Simulink model and vehicle behavior. There are two primary methods:

Option1: Use MAVProxy Terminal

Use the MAVProxy console to directly set RC channel values. For example, enter the following command to set the output of RC channel 3 to 1700 in the Simulink block.

rc 3 1700 

Use this method to manually set or script RC channel values for testing.

Option 2: Use a Joystick via Mission Planner

Connect a joystick or gamepad to your computer and configure Mission Planner to use it as an RC input device for SITL.

For setup instructions, see Joystick/Gamepad — Copter documentation . This method provides a more realistic piloting experience and is ideal for interactive testing.

Other Things to Try

Visualize RC Block Outputs

Visualize RC block outputs by running the same model in Connected I/O mode, which allows real-time interaction with your model while keeping Simulink on the host computer. For more information on Connected I/O mode, see Communicate with Hardware Using Connected I/O.

See Also

RC Receive