Main Content

Convert PX4 PWM Output Block to PX4 Actuator Write Block

The PX4 PWM Output block will be removed in a future release. It is recommended to use the PX4 Actuator Write block as a replacement. To convert existing PX4 PWM Output blocks in your Simulink model to PX4 Actuator Write blocks, follow the steps listed in this section.

The key difference between these blocks is in the input value range and type. For the PX4 PWM Output, inputs are PWM on-time values with a uint16 type. However, the PX4 Actuator Write block requires inputs to be normalized values of type single, within a range of [0, 1] for motors and [-1, 1] for servos.

To convert the block, perform these steps:

  1. Open your Simulink model that includes the PX4 PWM Output block. Here is an example model with an ARM PWM signal, failsafe, and four MAIN PWM channels connected to PWM Output block.

    Model with PWM Output block

  2. Select the PX4 PWM Output block and press the Delete key on your keyboard to remove it.

  3. Add a PX4 Actuator Write block into your model and establish the necessary connections.

    Model with PWM Output block

    1. Link the ARM PWM signal to the Arm input of the PX4 Actuator Write block.

    2. Remove the failsafe signal, as it is not used by the PX4 Actuator Write block.

    3. Adjust the MAIN PWM signal values. For the minimum and maximum values from 1000 to 2000, the corresponding actuator values will range from 0 to 1. So for the value 1500, actuator value will be 0.5.

  4. Map the PWM Output block channels to the Motors inputs on the Actuator Write block. Since the Motors inputs only accept Single scalar values, insert a Data Type Conversion block to modify the channel values accordingly.

    Model with PWM Output block and data type conversion block

  5. Open the Data Type Conversion block settings by double-clicking it. In the Block Parameters dialog, set the Output data type to single, then click Apply and OK.

    Model with PWM Output block

Your model should now reflect the changes, with the PX4 PWM Output block successfully converted to a PX4 Actuator Write block.

See Also