Difference between revisions of "Radio Control"

From PaparazziUAV
Jump to navigation Jump to search
Line 55: Line 55:
== Example ==
== Example ==


Below an example of an radio file, in this case openuas_mx22.xml
Below an example of an radio file.
<nowiki>
<?xml version="1.0"?>


<?xml version="1.0"?>
<!--
<!DOCTYPE radio SYSTEM "../radio.dtd">
-- Attributes of root (Radio) tag :
<!-- $Id: openuas_mx22.xml,v 1.1 2010/07/05 21:46:00 mmm Exp $
-- name: name of RC
--
-- min: min width of a pulse to be considered as a data pulse
-- No copyright whatsoever, free to use, 2010 OpenUAS.org
-- max: max width of a pulse to be considered as a data pulse
--
-- sync: min width of a pulse to be considered as a synchro pulse
-- This file can be used in combination with the paparazzi autopilot.
-- min, max and sync are expressed in micro-seconds
-->
-->


<!--
<!--
-- Attributes of root (Radio) tag :
-- Attributes of channel tag :
-- name: name of RC transmitter, e.g. Graupner MX22
-- ctl: name of the command on the transmitter - only for displaying
-- data_min: min width of a pulse to be considered as a data pulse
-- function: logical command
-- data_max: max width of a pulse to be considered as a data pulse
-- average: (boolean) channel filtered through several frames (for discrete commands)
-- sync_min: min width of a pulse to be considered as a synchro pulse
-- min: minimum pulse length (micro-seconds)
-- sync_max: max width of a pulse to be considered as a synchro pulse
-- max: maximum pulse length (micro-seconds)
-- min, max and sync are expressed in micro-seconds
-- neutral: neutral pulse length (micro-seconds)
-->
Note: a command may be reversed by exchanging min and max values
-->


<!--
<radio name="GraupnerMC20" data_min="950" data_max="2150" sync_min="5000" sync_max="15000" pulse_type="NEGATIVE">
-- Attributes of channel tag :
  <channel ctl="A" function="THROTTLE" min="1100" neutral="1100" max="1900" average="0"/> <!-- left stick up/down -->
-- ctl: name of the command on the transmitter - only for displaying
  <channel ctl="B" function="ROLL" min="1100" neutral="1500" max="1900" average="0"/>    <!-- right stick left/right -->
-- no: order in the PPM frame
  <channel ctl="C" function="PITCH" min="1900" neutral="1500" max="1100" average="0"/>    <!-- right stick up/down -->
-- function: logical command
  <channel ctl="D" function="YAW" min="1100" neutral="1500" max="1900" average="0"/>   <!-- left stick left/right-->
-- averaged: channel filtered through several frames (for discrete commands)
  <channel ctl="E" function="MODE" min="1100" neutral="1500" max="1900" average="1"/>    <!-- left middle 3-pos switch -->
-- min: minimum pulse length (micro-seconds)
  <channel ctl="F" function="GAIN1" min="1100" neutral="1500" max="1900" average="0"/>    <!-- left slider prop channel -->
-- max: maximum pulse length (micro-seconds)
  <channel ctl="G" function="GAIN2" min="1100" neutral="1500" max="1900" average="0"/>    <!-- right slider prop channel -->
-- neutral: neutral pulse length (micro-seconds)
  <channel ctl="H" function="SWITCH1" min="1100" neutral="1500" max="1900" average="1"/>  <!-- switch (channel 8) -->
-- Note: a command may be reversed by exchanging min and max values
  <channel ctl="I" function="UNUSED" min="1100" neutral="1500" max="1900" average="1"/>  <!-- channel 9 is transmitted but cannot be controlled -->
-->
</radio>
 
</nowiki>
<!--
  -- Not used at this moment, handy for in air setting nutrals of IR piles
  <x channel xctl="CONTROL5"            xfunction="GAIN1"    xmin="1100" xneutral="1500" xmax="1900" xaverage="0"/>
  <x channel xctl="CONTROL6"            xfunction="CALIB"    xmin="1100" xneutral="1500" xmax="1900" xaverage="0"/>
-->
 
<!--
The order of the list below is of importance if you do not define a "no=" (order in the PPM frame) parameter.
If you do not define this then the order of the PPM is the one of the order of the functon in the list
-->
 
<radio name="OpenUAS MX22" data_min="1100" data_max="1900" sync_min="5000" sync_max="15000" pulse_type="NEGATIVE">
  <channel ctl="LeftStickVertical"   function="THROTTLE" min="1100" neutral="1120" max="1900" average="0"/>
  <channel ctl="RightStickHorizontal" function="ROLL"     min="1100" neutral="1500" max="1900" average="0"/>
  <channel ctl="RightStickVertical"   function="PITCH"   min="1100" neutral="1500" max="1900" average="0"/>
  <channel ctl="LeftStickHorizontal" function="YAW"     min="1100" neutral="1500" max="1900" average="0"/>
  <channel ctl="CONTROL8"             function="MODE"     min="1100" neutral="1500" max="1900" average="1"/>
  <channel ctl="CONTROL9"             function="CAMBER"   min="1100" neutral="1500" max="1900" average="0"/>
  <channel ctl="CONTROL10"           function="AIRBRAKE"   min="1100" neutral="1600" max="1900" average="0"/>
  <channel ctl="SW8"                 function="MANUALRELEASE" min="1101" neutral="1900" max="1900" average="4"/>
  <channel ctl="NoneA"               function="NOTUSEDA"   min="1100" neutral="1500" max="1900" average="0"/>
</radio>


== Measuring the PPM time values ==
== Measuring the PPM time values ==

Revision as of 04:36, 20 August 2011

Radio

This XML file, usually located in the conf/radios directory, contains a description of the radio control transmitter PPM signal. It should follow the grammar described in radio.dtd.

The contents are an ordered sequence of elements describing each channel with its name and its range:

<!DOCTYPE radio SYSTEM "radio.dtd">
 <radio name="cockpitMM" data_min="900" data_max="2100" sync_min ="5000" sync_max ="15000" pulse_type="POSITIVE">
 <channel ctl="D" function="ROLL"     min="2000" neutral="1498" max="1000" average="0"/>
 ...
 <channel ctl="E" function="MODE"     min="2000" neutral="1500" max="1000" average="1"/>
 ...
 </radio>

The order of the channels must be the order of the pulses in the PPM signal.

Among the top attributes, we find

  • name: used only in debug traces.
  • data_min (resp. _max): the minimum (resp. max) width (in microseconds) used to code one channel of the PPM signal.
  • sync_min (resp. _max): the minimum (resp. max) width (in microseconds) between two impulses set of the PPM signal.
  • pulse_type: the polarity of the PPM pulse. Can be either POSITIVE (FUTABA, Hitec, Multiplex etc) or NEGATIVE (JR, Graupner etc.).

Each channel is described with its transmitter name (ctl), its function name, its range in microseconds and its neutral value in microseconds. These values are used by the autopilot to compute a normalized input from the PPM signal (this file is preprocessed and the produced code is included in the airborne code). Note that the min and max attributes can be exchanged to reverse the direction of the command.

Wrong attributes of the "radio" element will prevent the decoder to recognize any PPM frame; same for a wrong number or channels.

Note that the number of send servo channels must match exactly. This means if your transmitter sends for example a PPM18 (Graupner/JR) signal you have nine (9) different servo channels. Even if you use a receiver with less channels you must set up all transmitting servos, even if you do not use them then you must use "bogus switches" related to functions. For example a six (6) servo channels out receiver with five (5) functions used in combination with a nine (9) servo channels transmitter would need four (4) bogus entries. (5 + 4 = 9)

...
<channel ctl="NoneA"	              function="NOTUSEDA"    	min="1100" neutral="1500" max="1900" average="0"/>
<channel ctl="NoneB"	              function="NOTUSEDB"    	min="1100" neutral="1500" max="1900" average="0"/>
<channel ctl="NoneC	              function="NOTUSEDC"    	min="1100" neutral="1500" max="1900" average="0"/>
<channel ctl="NoneD"	              function="NOTUSEDD"    	min="1100" neutral="1500" max="1900" average="0"/>
...

Averaging

The average attribute must be set to 1..x for discrete channels for which a trivial averaging filter will be applied. The neutral of a discrete channel need to be halfway through the min and max values. Otherwise it won't be mapped properly by the filter. Note that averaging a channel gives the output an additional small delay.

Direction

The following signs have been used in the radio configuration files distributed in conf/radios:

  • ROLL: The min attribute value stands for the right position of the stick (turning right)
  • PITCH: The min attribute value stands for the down position of the stick (pitching down)

Practical test

In the RC message:

  • when the ROLL stick is pulled to the right (aircraft banks right), you should see a value close to -MAX_PPRZ (-9600) in the ROLL channel
  • When the PITCH stick is pushed (aircraft pitch down), you should see a value close to MAX_PPRZ (9600) in the PITCH channel

This works with all kind of radios (PPM, USB, 2.4GHz)

Example

Below an example of an radio file.

<?xml version="1.0"?>

<!--
-- Attributes of root (Radio) tag :
-- name: name of RC
-- min: min width of a pulse to be considered as a data pulse
-- max: max width of a pulse to be considered as a data pulse
-- sync: min width of a pulse to be considered as a synchro pulse
-- min, max and sync are expressed in micro-seconds
-->

<!--
-- Attributes of channel tag :
-- ctl: name of the command on the transmitter - only for displaying
-- function: logical command
-- average: (boolean) channel filtered through several frames (for discrete commands)
-- min: minimum pulse length (micro-seconds)
-- max: maximum pulse length (micro-seconds)
-- neutral: neutral pulse length (micro-seconds)
Note: a command may be reversed by exchanging min and max values
-->

<radio name="GraupnerMC20" data_min="950" data_max="2150" sync_min="5000" sync_max="15000" pulse_type="NEGATIVE">
  <channel ctl="A" function="THROTTLE" min="1100" neutral="1100" max="1900" average="0"/> <!-- left stick up/down -->
  <channel ctl="B" function="ROLL" min="1100" neutral="1500" max="1900" average="0"/>     <!-- right stick left/right -->
  <channel ctl="C" function="PITCH" min="1900" neutral="1500" max="1100" average="0"/>    <!-- right stick up/down -->
  <channel ctl="D" function="YAW" min="1100" neutral="1500" max="1900" average="0"/>	   <!-- left stick left/right-->
  <channel ctl="E" function="MODE" min="1100" neutral="1500" max="1900" average="1"/>     <!-- left middle 3-pos switch -->
  <channel ctl="F" function="GAIN1" min="1100" neutral="1500" max="1900" average="0"/>    <!-- left slider prop channel -->
  <channel ctl="G" function="GAIN2" min="1100" neutral="1500" max="1900" average="0"/>    <!-- right slider prop channel -->
  <channel ctl="H" function="SWITCH1" min="1100" neutral="1500" max="1900" average="1"/>  <!-- switch (channel 8) -->
  <channel ctl="I" function="UNUSED" min="1100" neutral="1500" max="1900" average="1"/>   <!-- channel 9 is transmitted but cannot be controlled -->
</radio>

Measuring the PPM time values

R/C receiver timing diagram

There are two common ways to measure the time characteristics of the PPM signal:

  1. Using an oscilloscope: easy to achieve with a high level digital scope with capture and measure facilities.
  2. Using the telemetry of the autopilot: the PPM message (defined in conf/messages.xml) contains the sequence of a (recently) received PPM signal.

There are two ways to enable this message:

  • With the default telemetry configuration file (conf/telemetry/default.xml), this message is not sent in the default mode (numbered 0). This mode can be changed to debug (numbered 1) in the airframe file by setting the TELEMETRY_MODE_FBW constant in your firmware section:
 <define name="TELEMETRY_MODE_FBW" value="1"/>.
  • Use the settings mechanism to change the FBW telemetry mode while the autopilot is already running:
    In the GCS: Settings -> mode -> tele_FBW -> set to 1

The time unit used in this PPM message is hardware dependent:

  • On the obsolete AVR hardware, 1 microsecond = 16 units (because the crystal is running at 16MHz)
  • on the LPC hardware, 1 microsecond = 15 units (because the cristal is running at 12MHz)
    (conf/autopilot/tiny.h), the CPU clock is 5 times more, the peripheral bus is 4 times less, and the timer is not prescaled (sw/airborne/arm7/sys_time_hw.h) !!!)

Tips

If one has a good servo tester the output values at the receiver side can be measured