With the External Control, the MK can be controlled via serial commands.
see also: en/SerialProtocol
ExternalControl
By sending the External Control frame, you can:
- control the Nick/Roll/Yaw/Gas-Stick inputs by a serial command
get control of these functions: GPS, Altitude, CareFree and Auto-Start/Land
- select if the MK shall ignore the RC-Signals
- select if the MK shall ignore an RC-Lost (MK can be operated without RC-Receiver)
function select
Since Version 2.14 (or 2.13 Beta), it is possible to activate the following functions:
- GPS (PH, CH, Free)
Autostart & Autoland
these functions are only active, if the bit "EC_USE_SWITCH" is set in the ExternalControl .Config
if EC_USE_SWITCH in Config is set, the Transmitter switches are ignored (GPS, Altitude, CareFree and Auto-Start/land) and replaced by the Bits in the "ExternalControl.Switches"
controling camera, gimbal etc
If you want to control the other functions, you must also send the SerialChannel-Frame and assign the channels accordingly. For Example select "Ser CH1" for Poti1.
Timing
We would recommend to send the ExternalControl between 5-20 times per seconds.
The SerialChannel-Frame can be sent slower. The KopterTool for example sends the SerialChannel quite slow if no values were changed (around 2HZ), and sends it more often if any values were changed.
Settings
The ability to control the MK via the ExternalControl depends on the Setting
External Control can be activated by RC
In this case the User on the RC-Transmitter can allow the ExternalControl by a switch on the Transmitter.
In that case it can be used like a Trainer/Student switch.
with this option the pilot on the RC-Transmitter can always get back the control if something goes wrong on the ExternalControl-side
External Control always possible
Here the ExternalControl is always allowed. Use this if you want to fly without RC-Receiver.
Protocol
from uart.h in FC Code:
defines for ExternalControl.Config
1 #define EC_VALID 0x01 // only valid if this is 1
2 #define EC_GAS_ADD 0x02 // if 1 -> use the GAS Value directly and not as MAX
3 #define EC_USE_SWITCH 0x20 // if 1 -> use the Switches for further control -> the according RC transmitter switches are deactivated
4 #define EC_IGNORE_RC_STICK 0x40 // direct control (do not add to RC-Sticks Nick, Roll, Yaw)
5 #define EC_IGNORE_RC_LOST 0x80 // if 1 -> for Flying without RC-Control (Ignore RC-Lost)
6
defines for ExternalControl.Switches
- control GPS Modes etc.
- only active if this bit is set: EC_USE_SWITCH in Config
Structure
1 struct str_ExternControl
2 {
3 signed char Nick;
4 signed char Roll;
5 signed char Gier;
6 signed char Gas;
7 unsigned char Frame; // will return a confirm frame with this value
8 unsigned char Config;
9 unsigned char Switches;
10 unsigned char Free1; // these two don't need capacity in the ASCII data string
11 unsigned char Free2;
12 };
13 extern struct str_ExternControl ExternalControl;
Timeout
There is a timeout of 2 seconds. If the Frame is missing for longer than 2 seconds, the MK would set the External Sticks to zero and switch on Altitude and GPS.
After 15 seconds it goes back to RC-Control (or behave like RC-Lost when operating without RC).
Example code for controlling the MikroKopter without RC
This code part was placed into a second FC as groundstation. There was a Receiver connected and a WI232 as telemetry to the Flying MK.
1 if((CheckDelay(EC_Timer)) && UebertragungAbgeschlossen)
2 {
3 static struct str_ExternControl Test;
4
5 Test.Nick = ChannelNick;
6 Test.Roll = ChannelRoll;
7 Test.Gier = ChannelYaw;
8 Test.Gas = ChannelGas;
9 Test.Frame++;
10
11 Test.Config = 0;
12 if(PPM_in[16] > 64) Test.Config |= EC_GAS_ADD | EC_USE_SWITCH | EC_VALID;
13
14 if(PPM_in[13] > 64) Test.Config |= EC_IGNORE_RC | EC_IGNORE_RC_STICK;
15
16 Test.Switches = 0;
17 if(PPM_in[5] > 64) Test.Switches |= EC2_ALTITUDE;
18
19 if(PPM_in[6] > 64) Test.Switches |= EC2_CH;
20 else if(PPM_in[6] > -64)Test.Switches |= EC2_PH;
21
22 if(PPM_in[8] > 64) Test.Switches |= EC2_CAREFREE;
23 if(PPM_in[10] > 64) Test.Switches |= EC2_AUTOSTART;
24 if(PPM_in[10] < -64) Test.Switches |= EC2_AUTOLAND;
25
26 SendOutData('b', FC_ADDRESS, 1, (unsigned char *) &Test,sizeof(Test));
27 EC_Timer = SetDelay(50);
28 }