Reprint: Pixhawk Source Note four: Learn RC Input and Output

Source: Internet
Author: User
Tags apm


Turn from: Sina @walkant

Part V Learning RC Input and Output

Reference: http://dev.ardupilot.com/wiki/learning-ardupilot-rc-input-output/

RC input, which is the remote control input, controls the flight direction, changes the flight mode, controls the camera and other peripheral devices. Ardupilot support for centralizing different RC input (depending on the specific hardware flight control Board):

1. ppmsum –on PX4, Pixhawk, Linux and APM2

2. SBUS –on PX4, Pixhawk and Linux

3. SPEKTRUM/DSM –on PX4, Pixhawk and Linux

4. Pwm–on APM1 and APM2

5. RC Override (MAVLink) –all boards

where Sbus and SPEKTRUM/DSM is the serial protocol, Sbus is the 100kbps anti-UART protocol, SPEKTRUM/DSM is the 115200bps UART protocol. For PX4, these protocols are implemented through hardware UARTs, while some Linux systems are implemented through software UARTs. (Original: Some boards implement these using hardware UARTs (such as on PX4) and Some implement them as bit-banged software UARTs (on Linux).)

RC output, refers to the flight control after receiving the RC input, and then processed, output to the servo and motor (ESC). RC output default 50Hz PWM signal. For Arducopter Multi-axis aircraft and helicopters, the output frequency is 400Hz.

1. Rcinput Object (Ap_hal)

Rcinput Object declaration:

ap_hal::rcinput* rcin;

Related routines: Libraries/ap_hal/examples/rcinput/rcinput.pde, try moving the remote control handle to see if the output meets expectations.

2. Rcoutput Object (Ap_hal)

Rcoutput Object declaration:

ap_hal::rcoutput* rcout;

Different flight control, code implementation is different, may include on-chip timer, I²c, through the coprocessor (Px4io) output and other programs.

Related routines: Libraries/ap_hal/examples/rcoutput/rcoutput.pde this program from 1 channels to 14 channels, control the motor from the minimum speed to the maximum speed of the gradual change.

3. Rc_channel Object

Hal.rcin and Hal.rcout objects, for low-level invocation. The most common use of Rc_channel objects in a more advanced package is to implement RC input and output. It allows the user to configure parameters such as Min/max/trim values per channel, support aux channel functions, and scale processing of input output.

Related routines: Libraries/rc_channel/examples/rc_channel/rc_channel.pde routines teach you how to setup, read, copy input to output.

4. Rc_channel Strange input/output settings

When you look at the code, some local programs can make you feel strange, some are due to the imperfections of the program code, and some are not.

For example, many variables work on input and output:

Radio_out = (Pwm_out * _reverse) + Radio_trim;

The Radio_trim in the code above is a trim overlay that corrects the value of the remote control.

For example, for fixed-wing aircraft, roll (rolling) input becomes the steer (steering yaw). For multi-axis aircraft in the Arducopter, when in drift mode (drift mode), we see that the pitch is used for front-flying and roll for steering (rather than conventional yaw for steering). Later, the APM team will correct it and separate the two concepts. Everyone knows it's OK.

5. Rc_channel_aux Object

Another very important class: Rc_channel_aux class, which is a subclass of Rc_channel. It has many features that users can use. This is a bit more difficult to understand, for example:

The user wants to control the lateral stability of the aerial device using channel 6 (channels 6), then he can set the function to 21, the enumeration variable type is "K_rudder" (yaw, deflection, steering meaning). As follows:

Ap_groupinfo ("function", 1, Rc_channel_aux, FUNCTION, +),

Ap_groupend

If this code is called in the program, Rc_channel_aux::set_servo_out (Rc_channel_aux::k_rudder, 4500), then all channels with function set to (K_rudder) (channel ) Will output full offset (4500 is the full offset maximum).

In the corresponding update_aux_servo_function () code,

Case Rc_channel_aux::k_rudder:

_aux_channels[i]->set_angle (4500);//Set the maximum angle.

Break

Note that this is a one-to-many setting. In my understanding, in fact, we often say that the mixed-control output. For example, in auxiliary channel 6, we can set other channels to use function = 21. Then the other uses 21 of the channel, will be the Channel 6 mixed control. (This is complicated, I do not understand, for this has a better understanding, please tell me, learn from each other:[email protected]. Of course, if I can have a better understanding in the future, I will update this blog. )

, Rc_channel a total of 4 channels, rc_channel_aux a total of 10 channels.

First group: 1, 2, 3, 4, 5, 6, 7, 8, 10, 11 (total 10 Channels)

Second group: 9, 12

Group Three: 13, 14



The function parameters are as follows:

FUNCTION is the 1-27,function parameter.

typedef enum

{

K_none = 0,///< disabled

k_manual = 1,///< manual, just pass-thru the RC in signal

K_flap = 2,///< flap

K_flap_auto = 3,///< flap automated

K_aileron = 4,///< aileron

k_unused1 = 5,///< unused function

K_mount_pan = 6,///< Mount Yaw (PAN)

K_mount_tilt = 7,///< mount pitch (tilt)

K_mount_roll = 8,///< mount Roll

K_mount_open = 9,///< mount Open (Deploy)/close (retract)

K_cam_trigger = ten,///< camera trigger

K_egg_drop = one,///< egg drop

K_mount2_pan =///< Mount2 Yaw (PAN)

K_mount2_tilt =///< Mount2 pitch (tilt)

K_mount2_roll =///<, Mount2 roll

K_mount2_open =///< Mount2 Open (Deploy)/close (retract)

K_dspoiler1 =///< differential spoiler 1 (left wing)

K_dspoiler2 =///< Differential spoiler 2 (right wing)

K_aileron_with_input =///< aileron, with RC input

K_elevator =///<, elevator

K_elevator_with_input =///< elevator, with RC input

K_rudder = +,///< secondary rudder channel

K_sprayer_pump =///< Crop Sprayer Pump Channel

K_sprayer_spinner =///< Crop Sprayer Spinner Channel

K_flaperon1 =///< flaperon, left wing

K_flaperon2 =///< flaperon, right wing

k_steering =///< Ground steering, used to separate from rudder

K_parachute_release =///< Parachute Release

K_EPM =///<, EPM Gripper

K_nr_aux_servo_functions///< This must is the last enum value (only add new values _before_ this one)

} aux_servo_function_t;

Ap_int8 function; < see aux_servo_function_t enum

Previous article:
Pixhawk Source Note One: APM code basic structure: http://blog.sina.com.cn/s/blog_402c071e0102v59r.html
Pixhawk Source Note two: APM Thread: http://blog.sina.com.cn/s/blog_402c071e0102v5br.html

Pixhawk Source Note Three: serial interface UART and console:http://blog.sina.com.cn/s/blog_402c071e0102v5e5.html

Reprint: Pixhawk Source Note four: Learn RC Input and Output

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.